@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/source-sans-3-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #FAF7F1;
  --ink: #23231F;
  --muted: #5A5B54;
  --sage: #E7EAE0;
  --grow: #1F7A4D;
  --coral: #F05A28;
  --plus-orange: #E8A13D;
  --on-coral: #23231F;
  --focus-ring: #1F7A4D;
  --band: #DDEFE3;
  --amber: #E8A13D;
  --line: #C9C9BD;
  --shadow: 0 18px 42px rgba(35, 35, 31, 0.08);
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Source Sans 3", Seravek, Verdana, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1E211F;
    --ink: #ECEAE4;
    --muted: #BFC2B7;
    --sage: #2A2E2A;
    --grow: #74C89A;
    --coral: #FF8B61;
    --plus-orange: #F0B65C;
    --on-coral: #23231F;
    --focus-ring: #74C89A;
    --band: #24382C;
    --amber: #F0B65C;
    --line: #4A5148;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1E211F;
  --ink: #ECEAE4;
  --muted: #BFC2B7;
  --sage: #2A2E2A;
  --grow: #74C89A;
  --coral: #FF8B61;
  --plus-orange: #F0B65C;
  --on-coral: #23231F;
  --focus-ring: #74C89A;
  --band: #24382C;
  --amber: #F0B65C;
  --line: #4A5148;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-align: left;
}
img, svg { max-width: 100%; height: auto; }
a {
  color: var(--ink);
  text-decoration-color: var(--coral);
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.16em;
}
a:hover {
  color: var(--ink);
  text-decoration-color: var(--grow);
}
p, li { max-width: 70ch; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.35rem; }
li + li { margin-top: 0.45rem; }
h1, h2, h3 {
  line-height: 1.08;
  letter-spacing: 0;
  margin: 0 0 1rem;
}
h1 { font-family: var(--display); }
h2, h3 { font-family: var(--body); font-weight: 800; }
h1 { font-size: clamp(2.3rem, 6vw, 5.4rem); max-width: 10ch; }
h2 { font-size: clamp(1.65rem, 3vw, 2.75rem); }
h3 { font-size: 1.35rem; }
button, input, summary { font: inherit; }
button, .button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
button[aria-pressed="true"], .button.primary {
  background: var(--coral);
  border-color: var(--coral);
  color: var(--on-coral);
  font-weight: 700;
}
.button.secondary { background: var(--sage); }
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 4px;
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  z-index: 40;
}
.skip-link:focus { transform: translateY(0); }
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
}
.header-inner {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-grid;
  line-height: 1;
  min-width: max-content;
}
.brand-word {
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: 0;
}
.brand-word span { color: var(--coral); }
.brand-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.18rem; }
.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem 0.7rem;
}
.top-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
}
.top-nav a[aria-current="page"] {
  background: var(--sage);
  box-shadow: inset 0 -3px 0 var(--coral);
}
.toolbar-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0.35rem auto 0;
  position: sticky;
  top: 0.5rem;
  z-index: 20;
  pointer-events: none;
}
.toolbar-toggle {
  display: none;
  pointer-events: auto;
  margin-left: auto;
}
.toolbar {
  pointer-events: auto;
  margin-left: auto;
  width: fit-content;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  box-shadow: var(--shadow);
}
.toolbar button {
  min-height: 2.4rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.95rem;
}
.page-shell, .home-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.6rem 0 5rem;
}
.measure { max-width: 68ch; }
.page-intro, .lesson-hero {
  margin: 1rem 0 2.2rem;
}
.eyebrow {
  color: var(--grow);
  font-weight: 700;
  margin-bottom: 0.55rem;
}
.lead {
  font-size: 1.25rem;
  line-height: 1.55;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 1.05fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  padding: 1.6rem 0 2rem;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0 4rem;
}
.choice-card, .rung, .chunk, .progress-panel, .glossary-item, .quiz {
  position: relative;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--sage), var(--sage)) padding-box,
    linear-gradient(120deg,
      color-mix(in srgb, var(--coral) 22%, var(--line)),
      color-mix(in srgb, var(--plus-orange) 18%, var(--line))) border-box;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.choice-card {
  padding: 1.2rem;
  color: var(--ink);
  text-decoration: none;
}
.choice-card h2 { max-width: 14ch; margin-top: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 0.16rem 0.6rem;
  font-size: 0.92rem;
  font-weight: 600;
}
.need-card {
  display: inline-block;
  max-width: 48rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 0.5rem 0.7rem;
  font-size: 0.96rem;
}
.chunk {
  margin: 2.4rem 0;
  padding: clamp(1rem, 3vw, 2rem);
}
.chunk-head {
  display: block;
  margin-bottom: 0.8rem;
}
.chunk-head h2 {
  display: inline-flex;
  align-items: center;
  margin-right: 0.35rem;
}
.copy { max-width: 70ch; }
.simpler-copy { display: none; }
.simple-on .base-copy { display: none; }
.simple-on .simpler-copy { display: block; }
.notice {
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  margin: 3rem 0 0;
  padding: 1rem 1.2rem;
  background:
    linear-gradient(color-mix(in srgb, var(--coral) 10%, var(--paper)), color-mix(in srgb, var(--coral) 10%, var(--paper))) padding-box,
    linear-gradient(120deg,
      color-mix(in srgb, var(--coral) 22%, var(--line)),
      color-mix(in srgb, var(--plus-orange) 18%, var(--line))) border-box;
  box-shadow: var(--shadow);
}
.fee-table,
.comparison-table {
  width: min(100%, 46rem);
  border-collapse: collapse;
  margin: 1rem 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.98rem;
}
.fee-table caption,
.comparison-table caption {
  text-align: left;
  font-weight: 800;
  margin-bottom: 0.4rem;
}
.fee-table th,
.fee-table td,
.comparison-table th,
.comparison-table td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
.fee-table thead th,
.comparison-table thead th {
  background: color-mix(in srgb, var(--grow) 10%, var(--paper));
}
.comparison-table td strong {
  display: block;
  margin-bottom: 0.2rem;
}
.source-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  vertical-align: text-bottom;
}
.source-button {
  min-height: 2rem;
  min-width: 2rem;
  width: 2rem;
  padding: 0;
  border-color: var(--line);
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1;
  background: var(--paper);
}
.source-popover {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  width: min(18rem, 80vw);
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  z-index: 30;
}
.source-wrap.open .source-popover,
.source-wrap:focus-within .source-popover {
  display: block;
}
.glossary-trigger {
  min-height: 1.5rem;
  min-width: 1.5rem;
  border: 0;
  border-bottom: 2px dotted var(--coral);
  border-radius: 0;
  background: transparent;
  color: inherit;
  display: inline;
  padding: 0 0.04rem;
  text-align: inherit;
  text-decoration: none;
  cursor: help;
}
.glossary-trigger[aria-expanded="true"] {
  color: var(--ink);
  background: color-mix(in srgb, var(--coral) 16%, transparent);
}
.glossary-dialog {
  position: fixed;
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(20rem, calc(100vh - 2rem));
  overflow: auto;
  z-index: 60;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.glossary-dialog[hidden] { display: none; }
.glossary-dialog h2 {
  font-size: 1.2rem;
  margin-bottom: 0.45rem;
}
.glossary-dialog p { margin-bottom: 0.8rem; }
.glossary-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.glossary-close {
  min-height: 2.25rem;
  min-width: 2.25rem;
  padding: 0.3rem 0.6rem;
}
.diagram {
  margin: 1.5rem 0;
  max-width: 760px;
}
.diagram svg {
  display: block;
  width: 100%;
  border-radius: 8px;
}
.diagram figcaption {
  margin-top: 0.65rem;
  color: var(--muted);
  max-width: 68ch;
}
.svg-paper { fill: var(--paper); stroke: var(--line); }
.axis { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.band-fill { fill: var(--band); stroke: var(--grow); stroke-width: 4; }
.sell-line { stroke: var(--coral); stroke-width: 5; }
.buy-line { stroke: var(--grow); stroke-width: 5; }
.price-path { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.svg-label, .svg-token { fill: var(--ink); font: 700 20px var(--body); }
.svg-chip-bg { fill: var(--paper); stroke: var(--line); stroke-width: 1; }
.sell-text { fill: var(--coral); }
.buy-text { fill: var(--grow); }
.coral-dot { fill: var(--coral); }
.arrow { fill: none; stroke: var(--grow); stroke-width: 4; stroke-linecap: round; marker-end: url(#arrowhead); }
.arrow-head { fill: var(--grow); }
.ratio-row { fill: var(--paper); stroke: var(--line); stroke-width: 2; }
.ratio-fund { fill: color-mix(in srgb, var(--grow) 28%, var(--paper)); stroke: var(--grow); stroke-width: 2; }
.ratio-anchor { fill: color-mix(in srgb, var(--plus-orange) 38%, var(--paper)); stroke: var(--plus-orange); stroke-width: 2; }
.ratio-marker { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.ratio-caret { fill: none; stroke: var(--coral); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.band-explorer {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--sage), var(--sage)) padding-box,
    linear-gradient(120deg,
      color-mix(in srgb, var(--coral) 22%, var(--line)),
      color-mix(in srgb, var(--plus-orange) 18%, var(--line))) border-box;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.4rem);
  max-width: 820px;
}
.band-explorer-copy h2 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}
.band-widget {
  margin: 1rem 0;
}
.band-window {
  transition: transform 220ms ease;
}
.band-explorer.ratchet-high .band-window { transform: translateY(-38px); }
.band-explorer.ratchet-low .band-window { transform: translateY(38px); }
.band-range {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  accent-color: var(--coral);
}
.range-label {
  display: block;
  font-weight: 800;
  margin-bottom: 0.25rem;
}
.band-status {
  font-weight: 800;
  margin-top: 0.5rem;
}
.simulation-note {
  border-left: 4px solid var(--grow);
  padding-left: 0.75rem;
  margin: 0.4rem 0 0.6rem;
}
.band-state-list {
  margin-bottom: 0;
}
.ladder-active { fill: color-mix(in srgb, var(--coral) 28%, var(--paper)); stroke: var(--coral); stroke-width: 4; }
.ladder-box { fill: var(--band); stroke: var(--grow); stroke-width: 2; }
.ladder-line { stroke: var(--grow); stroke-width: 7; }
.progress-panel {
  padding: 1rem;
  max-width: 760px;
  margin: 0 0 2rem;
}
.progress-text { font-weight: 700; margin-bottom: 0.6rem; }
.progress-bar {
  height: 1rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper);
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grow);
}
.ladder-list {
  display: grid;
  gap: 1rem;
  max-width: 840px;
}
.rung {
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}
.rung.complete {
  background: color-mix(in srgb, var(--grow) 20%, var(--sage));
}
.rung h2 { margin-top: 0.5rem; }
.rung h2 a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
.rung h2 a:hover,
.rung h2 a:focus-visible {
  text-decoration-color: var(--coral);
}
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.breadcrumb span::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--muted);
}
.lesson-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 2rem 0;
}
.lesson-rail {
  display: none;
}
.quiz {
  padding: clamp(1rem, 3vw, 2rem);
  margin: 2.4rem 0;
}
.quiz-question {
  border: 0;
  padding: 0;
  margin: 0;
}
.quiz-question legend {
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.8rem;
}
.answer-option {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 0.75rem;
  margin: 0.55rem 0;
  max-width: 40rem;
}
.quiz-next { display: none; }
.quiz-feedback { font-weight: 700; min-height: 1.6rem; }
.quiz-feedback.is-correct { color: var(--grow); }
.quiz-feedback.is-wrong { color: var(--ink); }
.glossary-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 2rem 0 3rem;
}
.glossary-item {
  padding: 0.85rem 1rem;
}
.glossary-item summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 2rem;
}
.qa-list > h2 { margin-top: 3rem; }
.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 1rem;
  color: var(--muted);
}
.site-footer p {
  width: min(1180px, 100%);
  margin: 0 auto;
}
.spacing-on {
  letter-spacing: 0.12em;
  word-spacing: 0.16em;
  line-height: 1.8;
}
.spacing-on p { margin-bottom: 2em; }
.spacing-on .glossary-trigger {
  padding-inline: 1.5em;
}
.calm-motion *, .calm-motion *::before, .calm-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
.focus-controls {
  display: none;
  position: sticky;
  bottom: 1rem;
  max-width: 720px;
  margin: 1rem 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  z-index: 15;
}
.focus-controls-inner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.focus-active .site-header,
.focus-active .site-footer,
.focus-active .breadcrumb,
.focus-active .lesson-rail {
  display: none;
}
.focus-active main > :not([data-focus-step]):not(.focus-controls) { display: none; }
.focus-active [data-focus-step].focus-hidden { display: none; }
.focus-active .focus-controls { display: block; }
[id] { scroll-margin-top: 7rem; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .band-window { transition: none !important; }
}
@media (min-width: 900px) {
  .lesson-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 13rem;
    gap: 2rem;
    align-items: start;
  }
  .lesson-shell > :not(.lesson-rail) {
    grid-column: 1;
  }
  .lesson-rail {
    display: block;
    position: sticky;
    top: 6rem;
    grid-column: 2;
    grid-row: 1 / span 8;
    border-left: 3px solid var(--line);
    padding-left: 0.9rem;
  }
  .lesson-rail p {
    font-weight: 800;
    margin-bottom: 0.5rem;
  }
  .lesson-rail nav {
    display: grid;
    gap: 0.45rem;
  }
  .lesson-rail a {
    text-decoration: none;
    border-radius: 8px;
    padding: 0.35rem 0.45rem;
    color: var(--ink);
  }
  .lesson-rail a[aria-current="true"] {
    background: var(--sage);
    box-shadow: inset 3px 0 0 var(--coral);
    font-weight: 800;
  }
}
@media (max-width: 820px) {
  .header-inner { align-items: flex-start; flex-direction: column; }
  .top-nav { justify-content: flex-start; }
  .hero { grid-template-columns: 1fr; padding-top: 1.5rem; }
  .choice-grid, .glossary-list { grid-template-columns: 1fr; }
  h1 { max-width: 12ch; }
}
@media (max-width: 640px) {
  .toolbar-shell {
    position: static;
    top: auto;
    pointer-events: auto;
    margin: 0.5rem auto 0;
  }
  .toolbar-toggle {
    display: inline-flex;
    width: 100%;
    justify-content: space-between;
  }
  .toolbar-toggle::after { content: "+"; font-weight: 800; }
  .toolbar-shell.open .toolbar-toggle::after { content: "-"; }
  .toolbar {
    display: none;
    width: 100%;
    margin-top: 0.5rem;
    box-shadow: none;
    background: var(--sage);
  }
  .toolbar-shell.open .toolbar {
    display: flex;
    justify-content: flex-start;
  }
  .toolbar button { flex: 1 1 11rem; }
  .lesson-meta { align-items: stretch; }
  .need-card { width: 100%; }
  .source-popover {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 1rem;
    top: auto;
    width: auto;
  }
  body[data-page^="lesson"] .lesson-shell { min-height: 50vh; }
  body.focus-active[data-page^="lesson"] main > [data-focus-step]:not(.focus-hidden) { min-height: 50vh; }
  .comparison-table,
  .comparison-table thead,
  .comparison-table tbody,
  .comparison-table tr,
  .comparison-table th,
  .comparison-table td {
    display: block;
    width: 100%;
  }
  .comparison-table thead tr {
    display: grid;
    grid-template-columns: 1fr;
  }
  .comparison-table th,
  .comparison-table td {
    border-bottom: 0;
  }
  .comparison-table tbody tr:last-child td:last-child {
    border-bottom: 1px solid var(--line);
  }
}
@media (max-width: 520px) {
  body { font-size: 1rem; }
  .page-shell, .home-shell, .header-inner, .toolbar-shell { width: min(100% - 1rem, 1180px); }
  .rung { grid-template-columns: 1fr; }
  .source-popover { left: 0; right: auto; }
  h1 { font-size: clamp(2.1rem, 14vw, 3.5rem); }
  .svg-label, .svg-token { font-size: 18px; }
}
