/* ---------- Tokens ---------- */
:root {
  --bg: #F2F4F0;
  --surface: #FFFFFF;
  --surface-2: #E7EBE4;
  --ink: #15181D;
  --muted: #555D6B;
  --rule: #D3D8CF;
  --accent: #2944C4;
  --accent-soft: #E3E8FB;
  --accent-ink: #FFFFFF;
  --mark: #F6DB6A;
  --mark-ink: #15181D;
  --good: #1D7247;
  --good-soft: #DDF0E4;
  --warn: #92560A;
  --warn-soft: #F7EAD2;
  --bad: #A13A2A;
  --bad-soft: #F6DFDA;

  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.125rem;
  --step-4: clamp(2.125rem, 5vw, 3.25rem);

  --radius: 6px;
  --topbar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1215;
    --surface: #171B20;
    --surface-2: #1F242B;
    --ink: #E5E8EC;
    --muted: #9BA3AF;
    --rule: #2B313A;
    --accent: #8A9FFF;
    --accent-soft: #1F2744;
    --accent-ink: #0F1215;
    --mark: #54461A;
    --mark-ink: #F7E9AE;
    --good: #6BCB96;
    --good-soft: #17301F;
    --warn: #E3AB5A;
    --warn-soft: #33261A;
    --bad: #EE8C7A;
    --bad-soft: #3A1E19;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1215;
  --surface: #171B20;
  --surface-2: #1F242B;
  --ink: #E5E8EC;
  --muted: #9BA3AF;
  --rule: #2B313A;
  --accent: #8A9FFF;
  --accent-soft: #1F2744;
  --accent-ink: #0F1215;
  --mark: #54461A;
  --mark-ink: #F7E9AE;
  --good: #6BCB96;
  --good-soft: #17301F;
  --warn: #E3AB5A;
  --warn-soft: #33261A;
  --bad: #EE8C7A;
  --bad-soft: #3A1E19;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3, h4 {
  font-family: var(--f-display);
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--step-4); font-weight: 800; letter-spacing: -0.025em; }
h2 { font-size: var(--step-3); font-weight: 800; }
h3 { font-size: var(--step-1); font-weight: 700; margin-top: 0.75rem; }
h4 { font-size: var(--step-0); font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

mark {
  background: linear-gradient(transparent 12%, var(--mark) 12%, var(--mark) 88%, transparent 88%);
  color: var(--mark-ink);
  padding-inline: 0.15em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
small { font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); font-weight: 400; }
.mono { font-family: var(--f-mono); font-size: var(--step--1); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-inline: max(16px, calc((100vw - 1200px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1rem;
  min-width: 0;
}
.brand-mark {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--ink);
  color: var(--bg);
  padding: 0.25rem 0.4rem;
  border-radius: 3px;
  letter-spacing: 0.04em;
}
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-toggle {
  display: none;
  font-family: var(--f-mono);
  font-size: var(--step--1);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

/* ---------- Page switcher ---------- */
.pages {
  display: flex;
  gap: 2px;
  margin-left: auto;
  padding: 3px;
  background: var(--surface-2);
  border-radius: calc(var(--radius) + 2px);
  font-family: var(--f-mono);
  font-size: var(--step--1);
}
.pages a {
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.pages a:hover { color: var(--ink); }
.pages a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.toc-list a.out { color: var(--accent); }
.toc-list a.out .n { color: var(--accent); }
.crosslink {
  padding: 0.85rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 0.97rem;
}

/* ---------- Shell ---------- */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 16px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 3.5rem;
}

/* ---------- TOC ---------- */
.toc {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding-block: 2rem;
}
.toc-part {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-block: 0.5rem;
}
.toc-list { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; gap: 1px; }
.toc-list a {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--f-display);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.3;
}
.toc-list a .n { font-family: var(--f-mono); font-size: 0.7rem; min-width: 1.4rem; color: var(--muted); }
.toc-list a:hover { color: var(--ink); background: var(--surface-2); }
.toc-list a.active { color: var(--ink); background: var(--surface); box-shadow: inset 2px 0 0 var(--accent); }
.toc-list a.active .n { color: var(--accent); }

/* ---------- Content ---------- */
.content { min-width: 0; max-width: 780px; padding-block: 2.5rem 4rem; }
.content > section { display: grid; gap: 1.1rem; }
.chapter { padding-top: 3.5rem; margin-top: 3.5rem; border-top: 1px solid var(--rule); }
.chapter > p, .chapter > ul, .chapter > h3 { max-width: 68ch; }
.chapter-num {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

/* ---------- Hero ---------- */
.hero { padding-top: 1rem; }
.eyebrow {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.hero h1 { max-width: 18ch; }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--muted); max-width: 60ch; }

.ratecard {
  margin: 0.75rem 0 0;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--f-mono);
  font-size: var(--step--1);
  box-shadow: 0 1px 0 var(--rule), 0 12px 32px -18px rgb(0 0 0 / 0.25);
}
.ratecard-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}
.ratecard-rows { margin: 0; padding: 0.5rem 1rem; }
.ratecard-rows div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding-block: 0.45rem;
  border-bottom: 1px dashed var(--rule);
}
.ratecard-rows div:last-child { border-bottom: 0; }
.ratecard-rows dt { color: var(--ink); }
.ratecard-rows dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ratecard figcaption {
  padding: 0.6rem 1rem 0.8rem;
  color: var(--muted);
  font-size: 0.7rem;
  border-top: 1px solid var(--rule);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
th {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
td strong { font-family: var(--f-display); font-weight: 700; }
.num { text-align: right; font-family: var(--f-mono); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
table.services td:first-child, table td:first-child { min-width: 9rem; }

.pill {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Lists ---------- */
.points { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.6rem; }
.points li::marker { color: var(--accent); }
.points.tight { gap: 0.35rem; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chips li {
  font-family: var(--f-mono);
  font-size: var(--step--1);
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
}

/* ---------- Grids & cards ---------- */
.grid-2, .grid-3 { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  display: grid;
  gap: 0.5rem;
  align-content: start;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.card .eg { font-style: italic; color: var(--muted); font-size: 0.95rem; }

.formula {
  font-family: var(--f-display);
  font-size: var(--step-1);
  line-height: 1.7;
  font-weight: 500;
}
.slot {
  font-family: var(--f-mono);
  font-size: 0.85em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
}

.note {
  font-size: 0.95rem;
  color: var(--muted);
  padding: 0.75rem 1rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}

/* ---------- Steps (real sequences) ---------- */
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 0; }
.steps li {
  counter-increment: step;
  position: relative;
  display: grid;
  gap: 0.25rem;
  padding: 0 0 1.25rem 3rem;
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--f-mono);
  font-size: 0.75rem;
  font-weight: 600;
  width: 2rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--surface);
}
.steps li::after {
  content: "";
  position: absolute;
  left: 1rem;
  top: 1.6rem;
  bottom: 0;
  border-left: 1px solid var(--rule);
}
.steps li:last-child { padding-bottom: 0; }
.steps li:last-child::after { display: none; }
.steps p { color: var(--muted); max-width: 62ch; }

/* ---------- SOW document ---------- */
.doc {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1rem;
  box-shadow: 0 12px 32px -20px rgb(0 0 0 / 0.3);
}
.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--ink);
}
.doc-title { font-family: var(--f-display); font-weight: 800; font-size: var(--step-1); }
.doc-meta { font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); }
.doc-sections { margin: 0; padding: 0; list-style: none; counter-reset: sec; }
.doc-sections li {
  counter-increment: sec;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 12rem) minmax(0, 1fr);
  gap: 0.25rem 1rem;
  padding-block: 0.7rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
}
.doc-sections li:last-child { border-bottom: 0; }
.doc-sections li::before {
  content: counter(sec) ".";
  font-family: var(--f-mono);
  font-size: 0.8rem;
  color: var(--muted);
  padding-top: 0.1rem;
}
.doc-sections strong { font-family: var(--f-display); }
.doc-sections span { color: var(--muted); }

/* ---------- Contract clauses ---------- */
.clauses { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 1rem; }
.clause {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.clause-ref { font-family: var(--f-mono); font-size: 0.7rem; color: var(--accent); letter-spacing: 0.04em; }
.clause p:last-child { font-size: 0.93rem; color: var(--muted); line-height: 1.5; }

/* ---------- Delivery phases ---------- */
.phases { list-style: none; margin: 0; padding: 0; counter-reset: ph; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.phases li {
  counter-increment: ph;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 13rem) minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: baseline;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.phases li:last-child { border-bottom: 0; }
.phases li::before { content: counter(ph, decimal-leading-zero); font-family: var(--f-mono); font-size: 0.75rem; color: var(--accent); font-weight: 600; }
.phase-name { font-family: var(--f-display); font-weight: 700; }
.phase-out { color: var(--muted); font-size: 0.95rem; }
.phase-time { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); white-space: nowrap; text-align: right; }

/* ---------- Stack ---------- */
.stack { border-top: 1px solid var(--rule); }
.stack-row {
  display: grid;
  grid-template-columns: minmax(0, 12rem) minmax(0, 1fr);
  gap: 0.25rem 1.5rem;
  padding-block: 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.stack-row h4 { font-size: 0.95rem; }
.stack-row p { color: var(--muted); font-size: 0.97rem; }

/* ---------- Layer map (engineering page) ---------- */
.layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.layers li {
  display: grid;
  grid-template-columns: minmax(0, 17rem) minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: baseline;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
/* Each layer down sits a little further in, like a cross-section toward the hardware. */
.layers li:nth-child(2) { margin-inline: 0.5rem; }
.layers li:nth-child(3) { margin-inline: 1rem; }
.layers li:nth-child(4) { margin-inline: 1.5rem; }
.layers li:nth-child(5) { margin-inline: 2rem; }
.layers li:nth-child(6) { margin-inline: 2.5rem; }
.layers li:nth-child(7) { margin-inline: 3rem; background: var(--surface-2); }
.layers li.here { border-color: var(--accent); background: var(--accent-soft); }
.layer-name { font-family: var(--f-display); font-weight: 700; }
.layer-eg { color: var(--muted); font-size: 0.95rem; }
.layer-tag { font-family: var(--f-mono); font-size: 0.7rem; color: var(--accent); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Depth meter ---------- */
.depth { display: inline-flex; gap: 3px; vertical-align: middle; }
.depth i { width: 10px; height: 10px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--rule); }
.depth[data-level="1"] i:nth-child(-n+1),
.depth[data-level="2"] i:nth-child(-n+2),
.depth[data-level="3"] i:nth-child(-n+3),
.depth[data-level="4"] i:nth-child(-n+4),
.depth[data-level="5"] i:nth-child(-n+5) { background: var(--accent); border-color: var(--accent); }
table.disciplines td:nth-child(3) { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }

/* ---------- Complexity axes ---------- */
.axes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.axis {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.axis p { font-size: 0.95rem; }
.axis .axis-eg { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); padding-top: 0.4rem; border-top: 1px dashed var(--rule); }
.levels .phase-time { color: var(--accent); }
.books dt { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.books dd a { overflow-wrap: anywhere; }

/* ---------- Sources & table notes ---------- */
.sources { font-family: var(--f-mono); font-size: 0.72rem; line-height: 1.8; color: var(--muted); }
.sources a { color: var(--muted); }
.sources a:hover { color: var(--accent); }
.table-note { font-size: 0.85rem; color: var(--muted); }
table.opportunity td:nth-child(2) { font-size: 0.9rem; }
table.opportunity .pill { white-space: normal; }

/* ---------- Roadmap page ---------- */
.stage-note { font-size: 0.95rem; color: var(--muted); }
.ratecard-rows dd a { color: var(--accent); text-decoration: none; }
.ratecard-rows dd a:hover { text-decoration: underline; }

/* ---------- Money split ---------- */
.split { margin: 0.25rem 0 0; display: grid; gap: 0; font-family: var(--f-mono); font-size: var(--step--1); }
.split div { display: flex; justify-content: space-between; padding-block: 0.4rem; border-bottom: 1px dashed var(--rule); }
.split div:last-child { border-bottom: 0; }
.split dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Pitfalls ---------- */
.pitfalls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.pitfall { padding: 1rem 1.2rem; display: grid; gap: 0.3rem; align-content: start; border-bottom: 1px solid var(--rule); }
.pitfall:nth-child(odd) { border-right: 1px solid var(--rule); }
.pitfall:nth-last-child(-n+2) { border-bottom: 0; }
.pitfall h4::before { content: "✕ "; color: var(--bad); font-family: var(--f-mono); font-size: 0.85em; }
.pitfall p { color: var(--muted); font-size: 0.95rem; }

/* ---------- Calculator ---------- */
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.calc-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
  padding: 1.25rem;
}
.calc label {
  display: grid;
  gap: 0.3rem;
  align-content: start;
  font-family: var(--f-display);
  font-size: 0.85rem;
  font-weight: 700;
}
.calc input, .calc select, .search input {
  font-family: var(--f-mono);
  font-size: 0.95rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.calc input:focus, .calc select:focus, .search input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.calc-out {
  display: grid;
  align-content: start;
  gap: 0;
  padding: 1.25rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--f-mono);
}
.out-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-block: 0.55rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--bg) 25%, transparent);
  font-size: 0.8rem;
}
.out-row strong { font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.out-main { flex-direction: column; align-items: flex-start; gap: 0.2rem; padding-top: 0; }
.out-main strong { font-family: var(--f-display); font-size: 2.75rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.out-quote { margin-top: 0.75rem; border-bottom: 0; border-top: 2px solid var(--mark); padding-top: 0.8rem; }
.out-quote strong { color: var(--mark); font-size: 1.15rem; }
:root[data-theme="dark"] .out-quote strong { color: var(--mark-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .out-quote strong { color: var(--mark-ink); } }
.out-note { margin-top: 0.75rem; font-size: 0.7rem; line-height: 1.5; opacity: 0.75; }

/* ---------- Practice ---------- */
.progress { display: grid; gap: 0.4rem; }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
@media (prefers-reduced-motion: reduce) { .progress-bar span { transition: none; } }
#progress-text { font-family: var(--f-mono); font-size: var(--step--1); color: var(--muted); }
.phase-group { display: grid; gap: 0.6rem; }
.phase-group h3 { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.wk { font-family: var(--f-mono); font-size: 0.72rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.checklist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.checklist li { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--rule); }
.checklist li:last-child { border-bottom: 0; }
.checklist input { width: 1.1rem; height: 1.1rem; margin-top: 0.25rem; accent-color: var(--accent); flex: none; cursor: pointer; }
.checklist label { cursor: pointer; }
.checklist input:checked + label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--rule); }
.btn-ghost {
  justify-self: start;
  font-family: var(--f-mono);
  font-size: var(--step--1);
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- Glossary ---------- */
.search { display: grid; gap: 0.35rem; max-width: 360px; font-family: var(--f-display); font-weight: 700; font-size: 0.85rem; }
.search input { background: var(--surface); }
.glossary { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2rem; }
.glossary div { padding-block: 0.7rem; border-bottom: 1px solid var(--rule); display: grid; gap: 0.15rem; align-content: start; }
.glossary dt { font-family: var(--f-display); font-weight: 700; }
.glossary dd { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.empty { color: var(--muted); font-style: italic; }

/* ---------- Footer ---------- */
.footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc-toggle { display: inline-block; }
  .toc {
    position: fixed;
    z-index: 15;
    top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    max-height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top, 0px));
    padding: 1rem 16px 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 20px 40px -20px rgb(0 0 0 / 0.35);
    display: none;
  }
  .toc.open { display: block; }
  .calc { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .brand-name { display: none; }
}
@media (max-width: 480px) {
  .brand { display: none; }
  .pages { margin-left: 0; }
  .pages a { padding: 0.3rem 0.5rem; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .glossary, .pitfalls, .axes { grid-template-columns: minmax(0, 1fr); }
  .layers li { grid-template-columns: minmax(0, 1fr); }
  .layers li:nth-child(n) { margin-inline: 0; }
  .pitfall:nth-child(odd) { border-right: 0; }
  .pitfall:nth-last-child(2) { border-bottom: 1px solid var(--rule); }
  .calc-inputs { grid-template-columns: minmax(0, 1fr); }
  .doc { padding: 1rem; }
  .doc-sections li { grid-template-columns: 1.75rem minmax(0, 1fr); }
  .doc-sections span { grid-column: 2; }
  .phases li { grid-template-columns: 2rem minmax(0, 1fr); }
  .phase-out, .phase-time { grid-column: 2; text-align: left; }
  .stack-row { grid-template-columns: minmax(0, 1fr); }
  .chapter { padding-top: 2.5rem; margin-top: 2.5rem; }
  .out-main strong { font-size: 2.25rem; }
}
