:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-2: #eaf0ee;
  --ink: #14232c;
  --ink-2: #56666f;
  --line: #dbe3e0;
  --glyco: #a96b00;  --glyco-soft: #fbf0d9;
  --link: #08766f;   --link-soft: #dcf1ee;
  --krebs: #a3256b;  --krebs-soft: #f9e5f0;
  --etc: #2a50bf;    --etc-soft: #e5ebfb;
  --proton: #c0362b; --proton-soft: #fbe6e3;
  --good: #1f7a45;   --good-soft: #e0f3e7;
  --bad: #b3261e;    --bad-soft: #fbe5e2;
  --accent: var(--etc); --accent-soft: var(--etc-soft);
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Literata", Georgia, serif;
  --r: 10px;
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1820; --surface: #16222d; --surface-2: #1c2a37; --ink: #e3e9ee; --ink-2: #9aaab6; --line: #253543;
    --glyco: #f2b24a; --glyco-soft: #33280f; --link: #4fcfc3; --link-soft: #0f312e;
    --krebs: #ee76ae; --krebs-soft: #381a2a; --etc: #8aa6ff; --etc-soft: #1a274d;
    --proton: #ff8476; --proton-soft: #3d1b18; --good: #5fd08f; --good-soft: #13301f; --bad: #ff8a80; --bad-soft: #3d1a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1820; --surface: #16222d; --surface-2: #1c2a37; --ink: #e3e9ee; --ink-2: #9aaab6; --line: #253543;
  --glyco: #f2b24a; --glyco-soft: #33280f; --link: #4fcfc3; --link-soft: #0f312e;
  --krebs: #ee76ae; --krebs-soft: #381a2a; --etc: #8aa6ff; --etc-soft: #1a274d;
  --proton: #ff8476; --proton-soft: #3d1b18; --good: #5fd08f; --good-soft: #13301f; --bad: #ff8a80; --bad-soft: #3d1a17;
  color-scheme: dark;
}

[data-stage="intro"] { --accent: var(--ink-2); --accent-soft: var(--surface-2); }
[data-stage="glyco"] { --accent: var(--glyco); --accent-soft: var(--glyco-soft); }
[data-stage="link"]  { --accent: var(--link);  --accent-soft: var(--link-soft); }
[data-stage="krebs"] { --accent: var(--krebs); --accent-soft: var(--krebs-soft); }
[data-stage="etc"]   { --accent: var(--etc);   --accent-soft: var(--etc-soft); }
[data-stage="reg"]   { --accent: var(--proton); --accent-soft: var(--proton-soft); }
[data-stage="cat"]   { --accent: var(--link);  --accent-soft: var(--link-soft); }
[data-stage="ferm"]  { --accent: var(--glyco); --accent-soft: var(--glyco-soft); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.7; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--etc); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.topbar { display: none; }
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 32px 16px 20px;
  border-right: 1px solid var(--line); background: var(--bg); font-family: var(--display);
  display: flex; flex-direction: column; gap: 22px;
}
.brand { text-decoration: none; color: var(--ink); display: block; padding: 0 10px; }
.brand-course { display: block; font-size: 13px; color: var(--ink-2); }
.brand-title { display: block; font-size: 21px; font-weight: 750; line-height: 1.15; letter-spacing: -.02em; margin-top: 2px; }
.nav, .nav ul { list-style: none; margin: 0; padding: 0; }
.nav a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-size: 15px; line-height: 1.3; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 650; background: var(--surface-2); }
.nav-group { margin: 8px 0; }
.nav-label { display: block; padding: 6px 10px 4px; font-size: 12.5px; color: var(--ink-2); opacity: .8; }
#navLessons a { display: flex; gap: 10px; align-items: baseline; font-size: 14.5px; }
#navLessons .num { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 12.5px; font-weight: 700; min-width: 28px; }
#navLessons .dot { display: none; }
.sidebar-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 8px; }
.theme-btn { border: 0; background: none; padding: 4px 0; cursor: pointer; font-family: var(--display); font-size: 13.5px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.theme-btn:hover { color: var(--ink); }
.back-hub { font-size: 13.5px; color: var(--ink-2); }

main { min-width: 0; padding: 48px clamp(24px, 4vw, 64px) 96px; outline: none; }
#view { max-width: 1040px; }
main.has-rail { display: grid; grid-template-columns: minmax(0, 1040px) 236px; justify-content: center; gap: 0 clamp(32px, 4vw, 64px); }
main.has-rail #view { width: 100%; }

/* ---------- type ---------- */
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.15; letter-spacing: -.015em; }
h1 { font-size: clamp(34px, 5vw, 52px); font-weight: 800; margin: 0 0 14px; letter-spacing: -.03em; }
h2 { font-size: clamp(24px, 3.2vw, 30px); font-weight: 750; margin: 56px 0 12px; }
h3 { font-size: 23px; font-weight: 700; margin: 2.4em 0 .5em; }
h4 { font-size: 18px; font-weight: 650; margin: 1.6em 0 .3em; }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }
li { margin-bottom: .3em; }
li > ul, li > ol { margin-top: .3em; }
.lede { font-size: 19px; color: var(--ink-2); max-width: 60ch; }
.muted { color: var(--ink-2); }
sub, sup { line-height: 0; }
.term { font-weight: 650; color: var(--ink); }
strong { font-weight: 650; }

/* ---------- lesson components ---------- */
.callout { padding: 12px 18px 8px; margin: 1.5em 0; border-radius: var(--r); background: var(--surface-2); }
.callout > :last-child { margin-bottom: .3em; }
.callout-title { font-family: var(--display); font-weight: 700; font-size: 14px; margin: 0 0 2px; color: var(--c, var(--ink-2)); }
.callout.teacher { --c: var(--krebs); background: var(--krebs-soft); }
.callout.key { --c: var(--etc); background: var(--etc-soft); }
.callout.tip { --c: var(--link); }
.callout.warn { --c: var(--proton); }
.eq { font-family: var(--display); font-size: 18px; text-align: center; padding: 12px 16px; margin: 1.3em 0; border-radius: var(--r); background: var(--surface-2); overflow-x: auto; line-height: 1.6; }
.table-wrap { overflow-x: auto; margin: 1.2em 0 1.5em; }
table.data { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.5; }
table.data th, table.data td { padding: 9px 12px 9px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.data thead th { font-family: var(--display); font-weight: 600; color: var(--ink-2); font-size: 13.5px; border-bottom-color: var(--ink-2); }
table.data tbody th { font-family: var(--display); font-weight: 650; }
ol.steps { list-style: none; padding: 0; counter-reset: step; margin: 1.2em 0; }
ol.steps > li { counter-increment: step; position: relative; padding: 0 0 4px 44px; margin-bottom: 14px; }
ol.steps > li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 750; font-size: 14px; background: var(--accent-soft); color: var(--accent); }
.step-head { font-family: var(--display); font-weight: 700; margin: 2px 0 2px; font-size: 17px; }
.tally { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 1em 0; }
.chip { font-family: var(--display); font-size: 14.5px; font-weight: 700; }
.chip.atp { color: var(--glyco); } .chip.nadh { color: var(--etc); } .chip.fadh { color: var(--krebs); } .chip.co2 { color: var(--ink-2); }
figure.diagram { margin: 1.8em 0; padding: 0; }
figure.diagram.narrow svg { max-width: 520px; margin: 0 auto; }
figure.diagram svg { display: block; width: 100%; height: auto; font-family: var(--display); }
figure.diagram figcaption { font-size: 14.5px; color: var(--ink-2); margin-top: 10px; line-height: 1.5; text-align: center; max-width: 62ch; margin-left: auto; margin-right: auto; }
details.check { margin: 1em 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
details.check + details.check { margin-top: -1px; }
details.check > summary { cursor: pointer; padding: 12px 0 12px 30px; font-family: var(--display); font-weight: 600; font-size: 16px; position: relative; list-style: none; line-height: 1.4; }
details.check > summary::-webkit-details-marker { display: none; }
details.check > summary::before { content: "+"; position: absolute; left: 4px; top: 10px; font-size: 20px; line-height: 1; color: var(--accent); font-weight: 500; }
details.check[open] > summary::before { content: "–"; }
details.check .ans { padding: 0 0 6px 30px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin: 1.2em 0; }
.compare h4 { margin-top: .4em; }

/* ---------- overview ---------- */
.hero { margin-bottom: 8px; }
.hero-course { font-family: var(--display); color: var(--ink-2); font-size: 15px; margin-bottom: 8px; }
.journey { margin: 32px 0 0; }
figure.map { margin: 0 0 8px; }
figure.map svg { display: block; width: 100%; height: auto; font-family: var(--display); }
.mapstage { transition: opacity .25s ease; }
.mapstage.dim { opacity: .22; }
.journey-track { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.stage-btn { cursor: pointer; border: 1px solid var(--line); background: none; padding: 6px 14px; border-radius: 999px; font-family: var(--display); font-size: 14.5px; display: inline-flex; gap: 8px; align-items: center; }
.stage-btn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sc); }
.stage-btn .s-where, .stage-btn .s-carbon { display: none; }
.stage-btn .s-name { font-weight: 600; }
.stage-btn:hover { border-color: var(--sc); }
.stage-btn[aria-pressed="true"] { background: var(--sc-soft); border-color: var(--sc); }
.st-glyco { --sc: var(--glyco); --sc-soft: var(--glyco-soft); }
.st-link { --sc: var(--link); --sc-soft: var(--link-soft); }
.st-krebs { --sc: var(--krebs); --sc-soft: var(--krebs-soft); }
.st-etc { --sc: var(--etc); --sc-soft: var(--etc-soft); }
.ledger { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 22px 0 6px; }
.ledger div { font-family: var(--display); }
.ledger b { font-size: 30px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; margin-right: 6px; }
.ledger span { font-size: 13.5px; color: var(--ink-2); }
.ledger .l-atp b { color: var(--glyco); } .ledger .l-nadh b { color: var(--etc); } .ledger .l-fadh b { color: var(--krebs); } .ledger .l-co2 b { color: var(--ink-2); }
.journey-detail { margin-top: 12px; min-height: 120px; }
.journey-detail h3 { margin: 10px 0 4px; font-size: 19px; }
.ledger-note { font-size: 15px; color: var(--ink-2); }
.rows { border-top: 1px solid var(--line); margin: 8px 0 0; }
.row-link, .rows.tools a { display: flex; gap: 16px; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.row-link:hover b, .rows.tools a:hover b { color: var(--accent); }
.rl-num { font-family: var(--display); font-weight: 700; color: var(--accent); min-width: 34px; font-variant-numeric: tabular-nums; padding-top: 2px; font-size: 14.5px; }
.rl-body b, .rows.tools b { display: block; font-family: var(--display); font-size: 17.5px; font-weight: 700; line-height: 1.3; }
.rl-body span, .rows.tools span { display: block; font-size: 15px; color: var(--ink-2); line-height: 1.5; margin-top: 2px; }
.rows.tools a { display: block; }
.tier-explain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 14px 0 6px; }
.tier-explain p { font-size: 15px; line-height: 1.5; margin: 8px 0 0; color: var(--ink-2); }

/* ---------- lesson page ---------- */
.lesson-head { margin-bottom: 20px; }
.lesson-kicker { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-family: var(--display); font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 650; font-family: var(--display); font-size: 13px; }
.objectives { margin: 22px 0; }
.objectives p { font-family: var(--display); font-weight: 700; margin: 0 0 4px; font-size: 15px; }
.objectives ul { margin-bottom: 0; }
.toc { font-family: var(--display); font-size: 14.5px; margin: 0 0 10px; }
.toc summary { cursor: pointer; color: var(--ink-2); }
.toc ol { margin: 8px 0 0; columns: 2; column-gap: 24px; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--accent); }
.lesson-body > .tier-sec:first-child > h3:first-child, .lesson-body > h3:first-child { margin-top: 1.2em; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; }
.pager a { display: block; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 650; }
.pager a:hover { color: var(--accent); }
.pager small { display: block; color: var(--ink-2); font-size: 13px; font-weight: 400; }
.pager .next { text-align: right; grid-column: 2; }
.practice-cta { margin-top: 48px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.practice-cta p { margin: 0; font-family: var(--display); font-weight: 650; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); padding: 8px 16px; font-family: var(--display); font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { opacity: .88; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink-2); opacity: 1; }
.btn:disabled { opacity: .4; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.fchip { border: 1px solid var(--line); background: none; padding: 4px 12px; border-radius: 999px; cursor: pointer; font-family: var(--display); font-size: 14px; color: var(--ink-2); }
.fchip:hover { color: var(--ink); border-color: var(--ink-2); }
.fchip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.field-label { font-family: var(--display); font-weight: 700; font-size: 14.5px; margin: 20px 0 4px; display: block; }
input[type="search"], textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
textarea { min-height: 100px; resize: vertical; font-family: var(--body); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 20px; }

/* ---------- Q&A ---------- */
.qa-group { margin: 40px 0; }
.qa-group h3 { margin: 0 0 4px; }
.qa-source { font-family: var(--display); font-size: 14px; color: var(--ink-2); margin: 0 0 12px; }
.qa-item { border-bottom: 1px solid var(--line); }
.qa-group h3 + .qa-source + .qa-item, .qa-group h3 + .qa-item { border-top: 1px solid var(--line); }
.qa-item > summary { list-style: none; cursor: pointer; padding: 13px 0 13px 36px; position: relative; font-family: var(--display); font-weight: 600; font-size: 16.5px; line-height: 1.4; }
.qa-item > summary::-webkit-details-marker { display: none; }
.qa-item .qn { position: absolute; left: 0; top: 14px; font-size: 13.5px; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.qa-item .qa-a { padding: 0 0 8px 36px; }
.qa-note { font-size: 14.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.qa-item[open] > summary { color: var(--accent); }

/* ---------- quiz ---------- */
.quiz-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px clamp(16px, 3vw, 30px); }
.quiz-top { display: flex; justify-content: space-between; gap: 10px; font-family: var(--display); font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.progress { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 22px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s ease; }
.q-text { font-family: var(--display); font-size: 21px; font-weight: 650; line-height: 1.35; margin: 0 0 18px; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r); padding: 12px 16px 12px 48px; cursor: pointer; position: relative; font-size: 16.5px; line-height: 1.45; }
.opt:hover:not(:disabled) { border-color: var(--ink-2); }
.opt .k { position: absolute; left: 16px; top: 12px; font-family: var(--display); font-size: 14px; font-weight: 700; color: var(--ink-2); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .k { color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { color: var(--bad); }
.tf-row { grid-template-columns: 1fr 1fr; }
.feedback { margin-top: 18px; padding: 12px 16px 4px; border-radius: var(--r); background: var(--surface-2); }
.feedback .verdict { font-family: var(--display); font-weight: 750; margin: 0 0 2px; }
.feedback.ok { background: var(--good-soft); } .feedback.no { background: var(--bad-soft); }
.feedback.ok .verdict { color: var(--good); } .feedback.no .verdict { color: var(--bad); }
.quiz-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.score-big { font-family: var(--display); font-size: 64px; font-weight: 800; line-height: 1; margin: 6px 0; letter-spacing: -.03em; }
.bars { display: grid; gap: 8px; margin: 16px 0; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 48px; gap: 12px; align-items: center; font-family: var(--display); font-size: 14px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.review-item { border-top: 1px solid var(--line); padding: 16px 0 4px; }
.review-item .q-text { font-size: 17px; margin-bottom: 6px; }
.review-item .your { color: var(--bad); font-size: 15px; margin: 0 0 2px; }
.review-item .correct { color: var(--good); font-size: 15px; margin: 0 0 8px; }
.kbd-hint { font-family: var(--display); font-size: 13px; color: var(--ink-2); margin: 14px 0 0; }

/* ---------- apply ---------- */
.x-card { border-top: 1px solid var(--line); padding: 26px 0 10px; }
.x-meta { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--display); font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; align-items: center; }
.x-card h3 { margin: 0 0 10px; font-size: 21px; }
.x-hint { background: var(--surface-2); border-radius: 8px; padding: 8px 14px; margin: 10px 0; font-size: 15.5px; }
.x-answer { margin-top: 10px; padding: 14px 18px 6px; background: var(--good-soft); border-radius: var(--r); }
.x-answer > p.x-label { font-family: var(--display); font-weight: 750; color: var(--good); margin-bottom: 4px; }

/* ---------- beyond / glossary ---------- */
.beyond-list { border-top: 1px solid var(--line); margin: 8px 0 30px; }
.beyond-list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-decoration: none; color: var(--ink); padding: 13px 4px; border-bottom: 1px solid var(--line); }
.beyond-list a:hover b { color: var(--accent); }
.beyond-list b { font-family: var(--display); font-size: 17px; line-height: 1.3; }
.beyond-list span.why { grid-column: 1 / -1; font-size: 15px; color: var(--ink-2); line-height: 1.5; }
.gloss { margin-top: 10px; border-top: 1px solid var(--line); }
.gloss-row { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gloss-row dt { font-family: var(--display); font-weight: 700; }
.gloss-row dt small { display: block; font-weight: 500; font-size: 12.5px; }
.gloss-row dt small a { color: var(--ink-2); }
.gloss-row dd { margin: 0; font-size: 16px; line-height: 1.6; }
.empty { padding: 20px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--r); font-family: var(--display); }
.noscript { padding: 24px; }

/* ---------- knowledge tiers ---------- */
:root[data-depth="essential"] [data-tier="likely"],
:root[data-depth="essential"] [data-tier="extra"],
:root[data-depth="likely"] [data-tier="extra"] { display: none !important; }
.tier-badge { display: inline-block; vertical-align: middle; font-family: var(--display); font-size: 11.5px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 999px; white-space: nowrap; transform: translateY(-2px); letter-spacing: .01em; }
.tier-badge.t-essential { background: var(--ink); color: var(--bg); }
.tier-badge.t-likely { background: var(--etc-soft); color: var(--etc); }
.tier-badge.t-extra { background: var(--krebs-soft); color: var(--krebs); }
h3 .tier-badge { margin-left: 6px; }
.tier-flag { margin: 1.4em 0 -.8em; }
.depth-box { padding: 0 2px; }
.depth { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; margin: 4px 0 6px; }
.depth button { border: 0; background: none; padding: 6px 2px; border-radius: 6px; font-family: var(--display); font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.depth button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.depth-hint { font-family: var(--display); font-size: 12.5px; color: var(--ink-2); line-height: 1.4; margin: 0 4px; }
.cram h3 { font-size: 21px; }
.cram table.data { font-size: 14.5px; }
.cram tbody th { white-space: nowrap; width: 1%; padding-right: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 16px; font-family: var(--display); }
  .topbar-title { font-weight: 750; color: var(--ink); text-decoration: none; flex: 1; font-size: 16.5px; }
  .menu-btn { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 5px 12px; font-family: var(--display); font-size: 14px; cursor: pointer; }
  .topbar .theme-btn { font-size: 14px; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); height: auto; z-index: 40; transform: translateX(-102%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.18); background: var(--bg); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(5, 12, 20, .45); z-index: 35; }
  main { padding: 28px 16px 80px; }
  .toc ol { columns: 1; }
  .tier-explain { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .compare { grid-template-columns: 1fr; gap: 0; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; text-align: left; }
  .gloss-row { grid-template-columns: 1fr; gap: 2px; }
  .bar-row { grid-template-columns: 110px 1fr 40px; }
  .tf-row { grid-template-columns: 1fr; }
  .q-text { font-size: 19px; }
  .cram tbody th { white-space: normal; width: 34%; }
  .ledger b { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .pager, .practice-cta, .toc, .toolbar { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  details.check, details.qa-item { break-inside: avoid; }
}

/* ---------- right rail ---------- */
.rail nav { position: sticky; top: 40px; max-height: calc(100vh - 80px); overflow-y: auto; scrollbar-width: thin; font-family: var(--display); padding-top: 6px; }
.rail summary { list-style: none; pointer-events: none; font-size: 13px; color: var(--ink-2); padding: 0 10px 8px; }
.rail summary::-webkit-details-marker { display: none; }
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail li { margin: 0; }
.rail a { display: block; padding: 5px 10px; border-radius: 6px; font-size: 14px; line-height: 1.35; color: var(--ink-2); text-decoration: none; }
.rail a:hover { color: var(--ink); }
.rail a[aria-current="true"] { color: var(--ink); font-weight: 650; background: var(--surface-2); }
.lesson-body > .tier-sec { scroll-margin-top: 24px; }
.lesson-body > .tier-sec + .tier-sec { border-top: 1px solid var(--line); margin-top: 2.4em; }
.lesson-body > .tier-sec > h3:first-child { margin-top: 1.1em; }
@media (max-width: 1100px) {
  main.has-rail { display: flex; flex-direction: column; }
  main.has-rail #view, .rail { width: 100%; max-width: 1040px; margin: 0 auto; }
  .rail { order: -1; margin-bottom: 18px; }
  .rail nav { position: static; max-height: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; }
  .rail summary { pointer-events: auto; cursor: pointer; padding-bottom: 0; list-style: revert; }
  .rail summary::-webkit-details-marker { display: revert; }
  .rail details[open] summary { padding-bottom: 8px; }
  .rail ol { columns: 2; column-gap: 12px; }
}
@media (max-width: 820px) { html { scroll-padding-top: 56px; } .rail ol { columns: 1; } }

/* ---------- diagram fitting ---------- */
#view { margin-left: auto; margin-right: auto; }
.fig-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.fig-scroll > svg { margin: 0 auto; height: auto; }
.fig-scroll.scrolls { border-radius: 8px; background: linear-gradient(to right, transparent 92%, var(--surface-2)); }
.fig-scroll.scrolls + figcaption::before { content: "Swipe sideways to see the whole diagram. "; font-weight: 650; color: var(--ink); }
@media (max-width: 560px) {
  figure.diagram, figure.map { margin-left: -16px; margin-right: -16px; }
  figure.diagram figcaption { padding: 0 16px; }
  .fig-scroll { padding: 0 16px; }
}

/* ---------- shared colour aliases + generic stages (Unit 1) ---------- */
:root { --blue: var(--etc); --blue-soft: var(--etc-soft); --teal: var(--link); --teal-soft: var(--link-soft); --amber: var(--glyco); --amber-soft: var(--glyco-soft); --magenta: var(--krebs); --magenta-soft: var(--krebs-soft); --red: var(--proton); --red-soft: var(--proton-soft); }
[data-stage="c1"] { --accent: var(--etc); --accent-soft: var(--etc-soft); }
[data-stage="c2"] { --accent: var(--link); --accent-soft: var(--link-soft); }
[data-stage="c3"] { --accent: var(--glyco); --accent-soft: var(--glyco-soft); }
[data-stage="c4"] { --accent: var(--krebs); --accent-soft: var(--krebs-soft); }
[data-stage="c5"] { --accent: var(--proton); --accent-soft: var(--proton-soft); }
[data-stage="c6"] { --accent: var(--ink-2); --accent-soft: var(--surface-2); }

/* ---------- quiz extras ---------- */
.chip-group { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-family: var(--display); font-weight: 650; font-size: 14.5px; margin: 14px 0 0; }
.linkish { border: 0; background: none; padding: 0; color: var(--etc); font-family: var(--display); font-size: 13.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.opt.chosen { border-color: var(--ink); background: var(--surface-2); }
.opt.chosen .k { color: var(--ink); }

@media print {
  .rail { display: none !important; }
  main.has-rail { display: block; }
}
