:root {
  --navy: #134E4A;
  --accent: #0F766E;
  --accent-strong: #115E59;
  --accent-soft: #CCFBF1;
}

:is(#rooted-growth-heading-specificity, html[data-theme] body) h1,
:is(#rooted-growth-heading-specificity, html[data-theme] body) h2,
:is(#rooted-growth-heading-specificity, html[data-theme] body) h3,
:is(#rooted-growth-heading-specificity, html[data-theme] body) h4,
:is(#rooted-growth-heading-specificity, body:is([data-theme], [data-rooted-growth-index])) h1,
:is(#rooted-growth-heading-specificity, body:is([data-theme], [data-rooted-growth-index])) h2,
:is(#rooted-growth-heading-specificity, body:is([data-theme], [data-rooted-growth-index])) h3,
:is(#rooted-growth-heading-specificity, body:is([data-theme], [data-rooted-growth-index])) h4,
.brand > div:not(.brand-mark) > div:first-child,
.brand > span:not(.brand-mark),
.brand-title {
  font-family: 'Fraunces', ui-serif, Georgia, serif;
  font-optical-sizing: auto;
}

.brand-mark[data-rooted-growth='sapling'] {
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.rooted-growth-sapling {
  display: block;
  width: 100%;
  height: 100%;
}

.ba-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ba-grid > * {
  min-width: 0;
}

.layout > * {
  min-width: 0;
}

@media (max-width: 820px) {
  .ba-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  .prim-table,
  .fit-matrix {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mtx-2x2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .mtx-2x2 .corner {
    display: none;
  }

  .fact-row .fact-selects {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  .place-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

:focus-visible {
  outline: 2px solid #0F766E;
  outline-offset: 2px;
}

.sidebar-media-fallback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .75rem .75rem;
  color: inherit;
  font-size: .75rem;
  line-height: 1.4;
  opacity: .82;
}

.sidebar-media-fallback a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

[data-theme='dark'] {
  --navy: #99F6E4;
  --accent: #5EEAD4;
  --accent-strong: #99F6E4;
  --accent-soft: rgba(45, 212, 191, 0.16);
}

[data-theme='dark'] .hero,
[data-theme='dark'] .flashcard,
[data-theme='dark'] .progress-strip-fill {
  background: linear-gradient(135deg, #134E4A 0%, #0F766E 100%);
}

[data-theme='dark'] .btn-primary,
[data-theme='dark'] .lock-btn,
[data-theme='dark'] .draw-btn,
[data-theme='dark'] .notes-fab,
[data-theme='dark'] .sign-btn,
[data-theme='dark'] .studio-toolbar .tb-pill.active {
  border-color: #0F766E;
  background: #0F766E;
  color: #fff;
}

[data-theme='dark'] :focus-visible {
  outline-color: #5EEAD4;
}

@media (prefers-color-scheme: dark) {
  body[data-rooted-growth-index] {
    --navy: #99F6E4;
    --accent: #5EEAD4;
    --accent-strong: #99F6E4;
    --accent-soft: rgba(45, 212, 191, 0.16);
  }
}

/* Keep standalone lesson controls and diagrams readable on narrow phones. */
@media (max-width: 540px) {
  .topbar-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding-inline: 16px;
  }
  .progress-wrap { flex-wrap: wrap; }
  .verif-head { flex-wrap: wrap; }
  .verif-title { min-width: 0; }
  .verif-summary { flex-wrap: wrap; }
  .verif-chevron { flex-shrink: 0; }
  .balance-card { grid-template-columns: minmax(0, 1fr); }
  .balance-diagnosis { min-width: 0; }
  .balance-bar { grid-template-columns: minmax(0, 100px) minmax(0, 1fr) 24px; gap: 8px; }
  .stepper-track,
  .lifecycle-track { grid-template-columns: minmax(0, 1fr); }
  .stepper-line,
  .lifecycle-line { display: none; }
  .rung { grid-template-columns: 40px minmax(0, 1fr); }
  .rung > :last-child { grid-column: 2; }
  .sorter-grid,
  .connections { grid-template-columns: minmax(0, 1fr); }
  .repo-browser > *,
  .conn-card { min-width: 0; }
  .repo-tree .tree-line { white-space: normal; overflow-wrap: anywhere; }
  .conn-title { overflow-wrap: anywhere; }
  .pop-engagement { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 540px) {
  .sorter-cards { grid-template-columns: minmax(0, 1fr); }
  .conn-card > * { min-width: 0; }
}

@media (max-width: 540px) {
  .conn-card { overflow-wrap: anywhere; }
}
