/* Rene's Study Room. Dark first: a top bar, a wide study column, a phone tab bar.
   The standalone site pins data-theme="dark" on <html>; with no attribute the page follows the system. */
:root {
  --text: #e9efef;
  --text-2: #afc1cc;
  --dim: #93aab8;
  --ground: #0b1116;
  --panel: #111b23;
  --panel-2: #182832;
  --line: #293b46;
  --rose: #e69b92;
  --teal: #75ded0;
  --gold: #e8c36b;
  --iris: #a7baf5;
  --hue: var(--teal);
  --frost: #0d151bf5;
  --font: Arial, Helvetica, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --round-l: 12px;
  --round-m: 10px;
  --round-s: 7px;
  --gutter: 32px;
  --lift: 0 10px 30px #0002;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --text: #142a35; --text-2: #405c69; --dim: #56717d;
    --ground: #f2f6f8; --panel: #fff; --panel-2: #e7f0f2; --line: #c8d9df;
    --rose: #a34236; --teal: #166e62; --gold: #896307; --iris: #555eaa;
    --frost: #f8fbfdf5;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --text: #142a35; --text-2: #405c69; --dim: #56717d;
  --ground: #f2f6f8; --panel: #fff; --panel-2: #e7f0f2; --line: #c8d9df;
  --rose: #a34236; --teal: #166e62; --gold: #896307; --iris: #555eaa;
  --frost: #f8fbfdf5;
  color-scheme: light;
}
[data-topic="endocrine"] { --hue: var(--teal); }
[data-topic="sensory"] { --hue: var(--iris); }
[data-topic="substance"] { --hue: var(--rose); }
[data-topic="musculo"] { --hue: var(--gold); }

*, *::before, *::after { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 110px; background: var(--ground); }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 61;
  background: var(--ground);
}
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.2; letter-spacing: -.035em; text-wrap: balance; }
.meta-n, .run-count, .clock, .stat-tiles b, .bd-row span:last-child, .topic-card .stats b { font-variant-numeric: tabular-nums; }
p { margin: 0; }
a { color: var(--hue); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 4px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }
::selection { background: color-mix(in srgb, var(--teal) 35%, transparent); }
svg { flex: none; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; top: 8px; left: 16px; z-index: 300;
  padding: 10px 16px; border-radius: 6px;
  background: var(--teal); color: var(--ground); text-decoration: none;
  transform: translateY(-180%);
}
.skip:focus { transform: none; }

.mono, .overline {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .12em;
  line-height: 1.6;
  text-transform: uppercase;
  color: var(--dim);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 60;
  display: flex; align-items: center; gap: 20px;
  min-height: 86px;
  padding-block: 16px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  background: var(--frost);
  -webkit-backdrop-filter: saturate(1.8) blur(18px);
  backdrop-filter: saturate(1.8) blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 245px; text-align: left; }
.brand-mark {
  width: 41px; height: 43px; padding: 8px;
  border: 1px solid color-mix(in srgb, var(--teal) 32%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--teal) 8%, var(--panel));
  fill: none; stroke: var(--teal); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round;
}
.brand-text { display: flex; flex-direction: column; gap: 4px; }
.brand-text b { font-size: 16px; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; line-height: 1.2; }
.brand-text span { font-size: 12px; letter-spacing: .035em; color: var(--dim); line-height: 1.3; }
.navlinks { display: flex; gap: 3px; margin-left: auto; align-items: center; }
.navlinks button {
  min-height: 44px; padding: 10px 12px; border-radius: 6px;
  font-size: 14px; color: var(--dim); white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.navlinks button:hover { background: var(--panel-2); color: var(--text); }
.navlinks button[aria-current="page"] {
  background: color-mix(in srgb, var(--teal) 12%, var(--panel));
  color: var(--teal);
  box-shadow: inset 0 -2px var(--teal);
}
.navlinks .sm { display: none; }
.theme-btn {
  width: 44px; height: 44px; border-radius: 8px;
  display: grid; place-items: center;
  border: 1px solid var(--line); color: var(--text);
}
.theme-btn:hover { background: var(--panel-2); }
.theme-btn svg { width: 18px; height: 18px; }

/* ---------- layout ---------- */
.main-col {
  max-width: 1540px; margin: 0 auto; outline: none;
  padding-top: 0; padding-bottom: 80px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.main-col > *, .column, .topic-head, .lesson, .ch-head { min-width: 0; }
.screen { display: none; }
.screen.is-on { display: block; animation: rise .3s var(--ease) both; }
@keyframes rise { from { opacity: .55; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.column { max-width: 830px; margin: 0 auto; padding-top: 34px; }
.column-wide { max-width: 1200px; }
.column > h2, .page-title { font-size: 36px; }
.lead-in { margin: 12px 0 26px; max-width: 62ch; font-size: 16px; line-height: 1.75; color: var(--dim); }

/* ---------- home ---------- */
.home-top {
  display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 50px; align-items: center;
  padding: 36px 0 26px;
}
.intro { max-width: 760px; }
.intro .overline { display: block; margin-bottom: 12px; color: var(--teal); }
.intro h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.14; letter-spacing: -.045em; }
.intro p { margin-top: 14px; max-width: 61ch; color: var(--dim); line-height: 1.75; }
.intro p b { color: var(--text); font-weight: 500; }
.note-card {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 19px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.note-card svg { width: 24px; height: 24px; margin-top: 2px; fill: none; stroke: var(--teal); stroke-width: 1.5; stroke-linejoin: round; }
.note-card .overline { color: var(--teal); }
.note-card .line { margin: 4px 0; font-size: 15px; line-height: 1.65; color: var(--text-2); }
.note-card .sig { margin-top: 7px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

.home-row { display: flex; gap: 16px; align-items: stretch; margin-bottom: 30px; }
.searchbox {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
  padding: 6px 8px 6px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
}
.searchbox svg { width: 20px; height: 20px; fill: none; stroke: var(--dim); stroke-width: 1.7; stroke-linecap: round; }
.searchbox input {
  flex: 1; min-width: 0; min-height: 44px;
  font-size: 16px; background: transparent; border: 0; color: var(--text);
}
.searchbox input:focus { outline: none; }
.searchbox:focus-within { border-color: color-mix(in srgb, var(--teal) 55%, var(--line)); }
.searchbox input::placeholder { color: var(--dim); opacity: 1; }
.searchbox button {
  min-height: 44px; padding: 8px 18px; border-radius: 6px;
  font-size: 14px; background: var(--panel-2); color: var(--teal);
}
.resume {
  display: grid; grid-template-columns: 1fr auto; gap: 1px 20px; align-items: center;
  min-width: 240px; max-width: 360px; padding: 9px 17px; text-align: left;
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line)); border-radius: 9px;
  background: color-mix(in srgb, var(--teal) 7%, var(--panel));
}
.resume .k { font-size: 12px; color: var(--teal); }
.resume b { grid-column: 1; font-size: 14px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume .arrow { grid-column: 2; grid-row: 1 / 3; color: var(--teal); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 26px 0 15px; }
.section-head h2 { font-size: 22px; }
.section-head > span { font-size: 13px; color: var(--dim); text-align: right; }

.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.topic-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; min-height: 215px;
  padding: 26px 26px 22px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  transition: transform .22s var(--ease), border-color .22s var(--ease);
}
.topic-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--hue); opacity: .7;
}
.topic-card .overline { color: var(--hue); }
.topic-card h2 { margin-top: 10px; font-size: 29px; }
.topic-card .blurb { margin-top: 8px; font-size: 15px; line-height: 1.65; color: var(--text-2); }
.topic-card .stats { display: flex; gap: 32px; margin-top: auto; padding-top: 24px; }
.topic-card .stats div { font-size: 12px; color: var(--dim); }
.topic-card .stats b { display: block; margin-top: 3px; font-size: 25px; font-weight: 400; color: var(--hue); letter-spacing: -.03em; }
.topic-card .gauge { margin-top: 16px; }

.helpers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.helper {
  display: flex; flex-direction: column; min-height: 154px; padding: 22px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  transition: transform .22s var(--ease), border-color .22s var(--ease);
}
.helper b { margin-bottom: 9px; font-size: 20px; font-weight: 500; line-height: 1.3; letter-spacing: -.02em; }
.helper span { font-size: 14px; line-height: 1.7; color: var(--dim); }
.helper.feature {
  grid-column: span 2;
  background: linear-gradient(115deg, color-mix(in srgb, var(--teal) 10%, var(--panel)), var(--panel));
  border-color: color-mix(in srgb, var(--teal) 30%, var(--line));
}
.helper .kicker { display: block; margin-bottom: 8px; font: 12px var(--font-mono); letter-spacing: .1em; color: var(--teal); text-transform: uppercase; }
.helper.feature b { font-size: 25px; }
.helper .tool-go { display: flex; gap: 12px; align-items: center; margin-top: auto; padding-top: 16px; font-size: 14px; color: var(--teal); }
.topic-card:hover, .helper:hover, .ch-card:hover { transform: translateY(-2px); border-color: var(--hue); }
.topic-card:active, .helper:active, .ch-card:active, .button:active, .choice:active:not([disabled]) { transform: scale(.985); }

.how { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.how ol { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); }
.how li { margin: 6px 0; line-height: 1.7; }
.about { margin-top: 36px; }
.about p { margin-top: 10px; max-width: 105ch; font-size: 13px; line-height: 1.8; color: var(--dim); }
.stamp { margin-top: 18px; font: 9px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); opacity: .65; }

/* ---------- controls ---------- */
.switcher {
  display: flex; flex-wrap: wrap; width: max-content; max-width: 100%;
  padding: 3px; margin-bottom: 20px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--round-m);
}
.switcher button {
  flex: 1 1 auto; min-height: 44px; padding: 9px 16px; border-radius: var(--round-s);
  font-size: 14px; line-height: 1.4; color: var(--dim); white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.switcher button:hover { color: var(--text); }
.switcher button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--hue) 14%, var(--panel));
  color: var(--hue);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hue) 35%, var(--line));
}
.field { display: block; margin-bottom: 20px; }
.field > span { display: block; margin-bottom: 7px; font-size: 13px; color: var(--dim); }
.dropdown {
  width: 100%; min-height: 48px; padding: 11px 44px 11px 14px;
  font-size: 16px; line-height: 1.5;
  background-color: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--round-m);
  -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  font-size: 14px; line-height: 1.4;
  border: 1px solid var(--line); border-radius: var(--round-s);
  background: transparent; color: var(--text);
  transition: transform .16s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.button:hover { background: var(--panel-2); }
.button.primary { background: var(--teal); border-color: var(--teal); color: var(--ground); }
.button.primary:hover { filter: brightness(1.08); background: var(--teal); }
.button.ghost { border-color: transparent; color: var(--dim); }
.button.danger { border-color: color-mix(in srgb, var(--rose) 50%, var(--line)); color: var(--rose); }
.button[disabled] { opacity: .35; pointer-events: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.row .meta-n { font: 12px var(--font-mono); letter-spacing: .1em; color: var(--dim); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.gauge { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.gauge i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--hue); transition: width .5s var(--ease); }

/* ---------- topic pages ---------- */
.topic-head { padding-top: 34px; }
.topic-head .overline { color: var(--hue); }
.topic-head h2 { margin-top: 8px; font-size: 38px; }
.topic-head .lead-in { margin-bottom: 22px; }
.ch-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ch-card {
  display: flex; flex-direction: column; gap: 8px; min-height: 172px; padding: 18px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-m);
  transition: transform .22s var(--ease), border-color .22s var(--ease);
}
.ch-card .overline { font-size: 11px; }
.ch-card b { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; }
.ch-card p { font-size: 14px; line-height: 1.6; color: var(--dim); }
.ch-card .mono { margin-top: auto; font-size: 11px; color: var(--hue); }
.topic-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.topic-tools .meta-n { font: 12px var(--font-mono); letter-spacing: .08em; color: var(--dim); }
.callout-card {
  display: flex; gap: 16px; align-items: flex-start; margin-top: 20px; padding: 18px 20px;
  border: 1px solid color-mix(in srgb, var(--hue) 45%, var(--line)); border-radius: var(--round-m);
  background: color-mix(in srgb, var(--hue) 5%, var(--panel));
}
.callout-card b { display: block; font-size: 17px; font-weight: 600; }
.callout-card p { margin-top: 4px; font-size: 14px; color: var(--dim); }

.ch-head { padding: 8px 0 22px; border-bottom: 1px solid var(--line); }
.ch-head .overline { color: var(--hue); }
.ch-head h3 { margin-top: 8px; font-size: 30px; }
.ch-head .ch-meta { margin-top: 8px; font-size: 13px; color: var(--dim); }
.ch-head .button-row { margin-top: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 4px; }
.chip-row button {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; line-height: 1.4; color: var(--text-2);
}
.chip-row button:hover { border-color: var(--hue); color: var(--text); }
.block-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 14px; }
.block-title h4 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--hue); font-family: var(--font-mono); font-weight: 500; }
.lesson { padding: 22px 0; border-bottom: 1px solid var(--line); }
.lesson:last-child { border-bottom: 0; }
.lesson-top { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.lesson h5 { margin: 0; font-size: 21px; font-weight: 500; letter-spacing: -.02em; line-height: 1.3; }
.lesson .slide-ref { font: 11px var(--font-mono); letter-spacing: .1em; color: var(--dim); white-space: nowrap; text-transform: uppercase; }
.points { margin: 12px 0 0; padding: 0; list-style: none; }
.points li { position: relative; padding: 4px 0 4px 22px; font-size: 16px; line-height: 1.75; color: var(--text-2); max-width: 78ch; }
.points li::before {
  content: ""; position: absolute; left: 3px; top: 15px; width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid var(--hue);
}
.said, .heads {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--round-m); max-width: 82ch;
}
.said { background: color-mix(in srgb, var(--hue) 7%, var(--panel)); border: 1px solid color-mix(in srgb, var(--hue) 25%, var(--line)); }
.heads { background: color-mix(in srgb, var(--gold) 8%, var(--panel)); border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--line)); }
.said .overline { color: var(--hue); font-size: 11px; }
.heads .overline { color: var(--gold); font-size: 11px; }
.said ul, .heads ul { margin: 6px 0 0; padding-left: 18px; }
.said li, .heads li { margin: 4px 0; font-size: 15px; line-height: 1.7; color: var(--text-2); }
.tbl-wrap { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--round-m); }
.tbl-wrap table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.tbl-wrap caption { caption-side: top; text-align: left; padding: 12px 14px 8px; font: 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--hue); }
.tbl-wrap th { padding: 10px 14px; text-align: left; vertical-align: bottom; font-weight: 600; color: var(--text); background: var(--panel-2); border-bottom: 1px solid var(--line); }
.tbl-wrap td { padding: 10px 14px; vertical-align: top; color: var(--text-2); border-bottom: 1px solid var(--line); }
.tbl-wrap tr:last-child td { border-bottom: 0; }
.tbl-wrap td:first-child { color: var(--text); font-weight: 500; }

.guide-tools { display: flex; align-items: center; gap: 12px; }
.guide-tools .meta-n { font: 12px var(--font-mono); letter-spacing: .08em; color: var(--dim); }
.qa { margin: 0 0 8px; border: 1px solid var(--line); border-radius: var(--round-m); background: var(--panel); }
.qa summary {
  display: flex; gap: 12px; align-items: flex-start; min-height: 48px; padding: 14px 16px;
  font-size: 17px; line-height: 1.6; cursor: pointer; list-style: none;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before { content: "+"; flex: none; width: 18px; font: 16px var(--font-mono); color: var(--hue); }
.qa[open] summary::before { content: "\2212"; }
.qa[open] { border-color: color-mix(in srgb, var(--hue) 40%, var(--line)); }
.qa .ans { padding: 0 16px 15px 46px; font-size: 16px; line-height: 1.8; color: var(--text-2); }
.trap-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.trap-list li {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--round-m); background: var(--panel);
  font-size: 15px; line-height: 1.7; color: var(--text-2);
}
.trap-list li::before {
  content: "!"; flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 2px;
  border-radius: 50%; font: 700 12px var(--font-mono); color: var(--rose);
  background: color-mix(in srgb, var(--rose) 16%, transparent);
}
.aid-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.aid-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--round-m); background: var(--panel); }
.aid-card b { display: block; font-size: 16px; font-weight: 600; color: var(--hue); }
.aid-card p { margin-top: 4px; font-size: 15px; line-height: 1.7; color: var(--text-2); }
.note-area textarea {
  width: 100%; min-height: 130px; padding: 14px; resize: vertical;
  font-size: 16px; line-height: 1.6; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-m);
}
.note-area .mono { margin-top: 6px; font-size: 11px; }
.ch-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 38px; padding-top: 20px; border-top: 1px solid var(--line); }
.ch-layout { display: block; }
.ch-main { min-width: 0; }
.ch-aside { display: none; }
.ch-aside ol { display: grid; gap: 2px; margin: 10px 0 0; padding: 0; list-style: none; }
.ch-aside li.sep { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.ch-aside button {
  display: block; width: 100%; min-height: 36px; padding: 7px 10px; border-radius: var(--round-s);
  text-align: left; font-size: 13.5px; line-height: 1.45; color: var(--dim);
}
.ch-aside button:hover { background: var(--panel-2); color: var(--text); }
.ch-aside button[aria-current="true"] { color: var(--hue); background: color-mix(in srgb, var(--hue) 12%, var(--panel)); }
@media (min-width: 1181px) {
  .ch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 44px; align-items: start; }
  .ch-aside {
    display: block; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 104px);
    max-height: calc(100vh - 130px); overflow: auto; padding: 22px 0 20px;
  }
  .ch-head .chip-row { display: none; }
}

/* ---------- flashcards ---------- */
.flash {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  width: 100%; min-height: 360px; padding: 50px 34px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-l);
  transition: border-color .2s var(--ease);
}
.flash:hover { border-color: color-mix(in srgb, var(--hue) 45%, var(--line)); }
.flash .side-name, .flash .flash-ref, .flash .flash-hint { position: absolute; font: 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }
.flash .side-name { top: 14px; left: 16px; color: var(--dim); }
.flash .flash-ref { top: 14px; right: 16px; color: var(--hue); }
.flash .flash-hint { left: 0; right: 0; bottom: 14px; color: var(--dim); }
.flash .card-face { animation: rise .28s var(--ease) both; }
.flash .term-side { font-size: 28px; line-height: 1.4; letter-spacing: -.02em; }
.flash .def-side { font-size: 20px; line-height: 1.75; color: var(--text-2); }
.flash .def-side small { display: block; margin-top: 14px; font: 11px var(--font-mono); letter-spacing: .1em; color: var(--dim); text-transform: uppercase; }
.flash.is-empty { cursor: default; color: var(--dim); }
.rate-wrap { margin-top: 14px; }
.rate-wrap > .overline { display: block; text-align: center; font-size: 11px; margin-bottom: 8px; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.grade {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; padding: 6px; border-radius: var(--round-s);
  border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 6%, var(--panel));
}
.grade b { font: 600 13px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--c); }
.grade small { font-size: 12px; color: var(--dim); }
.grade[data-g="0"] { --c: var(--rose); }
.grade[data-g="1"] { --c: var(--gold); }
.grade[data-g="2"] { --c: var(--teal); }
.grade[data-g="3"] { --c: var(--iris); }
.deck-extra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 14px; }
.deck-extra .meta-n { font: 12px var(--font-mono); letter-spacing: .08em; color: var(--dim); }
.keys-hint { margin-top: 18px; font: 11px var(--font-mono); letter-spacing: .08em; color: var(--dim); text-align: center; }

/* ---------- quiz ---------- */
.len-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 4px; }
.len-row .meta-n { font-size: 14px; color: var(--dim); }
.exam-box {
  margin-top: 22px; padding: 20px 22px; border-radius: var(--round-m);
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  background: linear-gradient(115deg, color-mix(in srgb, var(--teal) 9%, var(--panel)), var(--panel));
}
.exam-box b { display: block; font-size: 20px; font-weight: 500; letter-spacing: -.02em; }
.exam-box p { margin: 6px 0 14px; font-size: 14px; line-height: 1.7; color: var(--dim); }
.meter { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.meter .gauge { flex: 1; }
.meter .run-count { font: 12px var(--font-mono); letter-spacing: .08em; color: var(--dim); white-space: nowrap; }
.meter .clock { font: 600 13px var(--font-mono); letter-spacing: .06em; color: var(--text); white-space: nowrap; }
.meter .clock.is-low { color: var(--rose); }
.q-kind { display: block; margin-bottom: 10px; color: var(--hue); }
.stem { font-size: 24px; line-height: 1.5; letter-spacing: -.015em; }
.q-src { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 22px; font: 11px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.tag { padding: 2px 7px; border-radius: 4px; font: 600 10px var(--font-mono); letter-spacing: .1em; color: var(--ground); background: var(--hue); }
.tag.alt { background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line); }
.choices { display: grid; gap: 10px; margin-bottom: 20px; }
.choice {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: start;
  width: 100%; min-height: 52px; padding: 15px 18px; text-align: left;
  font-size: 16px; line-height: 1.55;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-m);
  transition: transform .16s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.choice:hover:not([disabled]) { border-color: color-mix(in srgb, var(--hue) 55%, var(--line)); }
.choice .letter {
  display: grid; place-items: center; width: 24px; height: 24px; margin-top: 0;
  font: 13px var(--font-mono); color: var(--dim);
  border: 1px solid var(--line); border-radius: 50%;
}
.choice.box .letter { border-radius: 5px; }
.choice[aria-checked="true"], .choice[aria-pressed="true"] {
  border-color: var(--hue);
  background: color-mix(in srgb, var(--hue) 9%, var(--panel));
}
.choice[aria-checked="true"] .letter, .choice[aria-pressed="true"] .letter { background: var(--hue); border-color: var(--hue); color: var(--ground); }
.choice[disabled] { cursor: default; }
.choice[data-mark="right"] { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 13%, var(--panel)); }
.choice[data-mark="right"] .letter { background: var(--teal); border-color: var(--teal); color: var(--ground); }
.choice[data-mark="wrong"] { border-color: var(--rose); background: color-mix(in srgb, var(--rose) 11%, var(--panel)); }
.choice[data-mark="wrong"] .letter { background: var(--rose); border-color: var(--rose); color: var(--ground); }
.choice[data-mark="missed"] { border-color: var(--teal); border-style: dashed; }
.choice[data-mark="missed"] .letter { color: var(--teal); border-color: var(--teal); }
.choice[data-mark="plain"] { opacity: .78; }
.choice .reason { grid-column: 2; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.choice .reason em { font-style: normal; font-weight: 600; }
.choice[data-mark="right"] .reason em, .choice[data-mark="missed"] .reason em { color: var(--teal); }
.choice[data-mark="wrong"] .reason em { color: var(--rose); }
.order-zone { display: grid; gap: 14px; margin-bottom: 20px; }
.order-zone .overline { font-size: 11px; }
.order-list { display: grid; gap: 8px; min-height: 52px; padding: 0; margin: 6px 0 0; list-style: none; }
.order-list.placed:empty::before {
  content: "Tap the steps below in order."; display: block; padding: 15px 18px;
  border: 1px dashed var(--line); border-radius: var(--round-m); color: var(--dim); font-size: 15px;
}
.order-list .choice .letter { border-radius: 6px; }
.order-result { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.order-result ol { margin: 6px 0 0; padding-left: 22px; }
.order-result li { margin: 5px 0; font-size: 15px; line-height: 1.6; color: var(--text-2); }
.order-result li.is-ok { color: var(--teal); }
.order-result li.no { color: var(--rose); }
.feedback {
  margin-bottom: 20px; padding: 14px 16px 14px 18px;
  background: var(--panel); border-left: 3px solid var(--c, var(--hue)); border-radius: 0 var(--round-s) var(--round-s) 0;
  font-size: 15.5px; line-height: 1.7; color: var(--text-2);
}
.feedback[data-v="right"] { --c: var(--teal); }
.feedback[data-v="wrong"] { --c: var(--rose); }
.feedback[data-v="part"] { --c: var(--gold); }
.feedback > b { display: block; margin-bottom: 6px; font: 600 12px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--c, var(--text)); }
.feedback p + p { margin-top: 8px; }
.feedback .tip { color: var(--text); }
.feedback .cite { font: 11px var(--font-mono); letter-spacing: .08em; color: var(--dim); }
.q-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.q-foot .meta-n { font: 11px var(--font-mono); letter-spacing: .08em; color: var(--dim); }
.result { padding: 26px 0 8px; text-align: center; }
.result .pct-big { font-size: clamp(64px, 14vw, 128px); line-height: .9; letter-spacing: -.06em; color: var(--hue); }
.result .result-of { margin-top: 14px; font: 12px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.result .result-msg { max-width: 46ch; margin: 18px auto 0; color: var(--text-2); }
.breakdown { display: grid; gap: 10px; margin-top: 26px; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 64px; gap: 14px; align-items: center; font-size: 14px; }
.bd-row .gauge i { background: var(--c, var(--hue)); }
.bd-row span:last-child { text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--dim); }
.review { margin-top: 26px; }
.review details { margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--round-m); background: var(--panel); }
.review summary { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; cursor: pointer; list-style: none; font-size: 15px; line-height: 1.6; }
.review summary::-webkit-details-marker { display: none; }
.review .verdict-dot { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; font: 700 12px var(--font-mono); color: var(--ground); background: var(--rose); }
.review .verdict-dot.is-ok { background: var(--teal); }
.review .q-detail { padding: 0 16px 16px; }
.review .q-detail .choices { margin-bottom: 12px; }
.review .q-detail .choice { font-size: 15px; padding: 12px 14px; min-height: 0; }

/* ---------- stats ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 6px 0 26px; }
.stat-tiles div { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-m); }
.stat-tiles b { display: block; font-size: 38px; font-weight: 400; line-height: 1.1; letter-spacing: -.04em; color: var(--teal); }
.stat-tiles span { font-size: 14px; color: var(--dim); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-m); }
.panel h3 { font-size: 18px; margin-bottom: 14px; }
.panel .bd-row { grid-template-columns: minmax(0, 1fr) 120px 60px; }
.panel p.quiet, .quiet { color: var(--dim); font-size: 14px; line-height: 1.7; }
.drill-list { margin: 0; padding: 0; list-style: none; }
.drill-list li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.6; color: var(--text-2); }
.drill-list li:last-child { border-bottom: 0; }
.drill-list li b { color: var(--text); font-weight: 500; }
.spark { width: 100%; height: 70px; }
.spark path { fill: none; stroke: var(--teal); stroke-width: 2; }
.spark circle { fill: var(--teal); }
.spark line { stroke: var(--line); stroke-dasharray: 3 4; }
.backup textarea {
  width: 100%; min-height: 110px; margin-top: 10px; padding: 12px;
  font: 12px/1.5 var(--font-mono); color: var(--text);
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--round-s);
}
.status-line { margin-top: 8px; font-size: 14px; color: var(--teal); min-height: 1.6em; }
.status-line.err { color: var(--rose); }

/* ---------- search ---------- */
.find-box input {
  width: 100%; min-height: 52px; padding: 12px 16px;
  font-size: 17px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--round-m);
}
.find-meta { margin: 14px 0 6px; font: 12px var(--font-mono); letter-spacing: .08em; color: var(--dim); }
.hits { margin: 0; padding: 0; list-style: none; }
.hit { padding: 15px 0; border-bottom: 1px solid var(--line); }
.hit .overline { font-size: 11px; color: var(--hue); }
.hit b { display: block; margin-top: 3px; font-size: 17px; font-weight: 500; }
.hit p { margin-top: 4px; font-size: 15px; line-height: 1.7; color: var(--text-2); }
.hit button { margin-top: 6px; font-size: 13px; color: var(--hue); }
mark { padding: 0 2px; border-radius: 3px; background: color-mix(in srgb, var(--gold) 40%, transparent); color: inherit; }

/* ---------- phone tab bar ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: none; justify-content: space-around; gap: 0;
  padding: 8px max(6px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
  background: var(--frost);
  -webkit-backdrop-filter: saturate(1.8) blur(18px);
  backdrop-filter: saturate(1.8) blur(18px);
  border-top: 1px solid var(--line);
}
.dock button {
  flex: 1; min-width: 0; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 5px 0; border-radius: var(--round-s); color: var(--dim);
}
.dock svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dock span { font-size: 11px; line-height: 1.1; white-space: nowrap; }
@media (max-width: 370px) { .dock span { font-size: 10px; letter-spacing: -.01em; } }
.dock button[aria-current="page"] { color: var(--teal); background: color-mix(in srgb, var(--teal) 10%, var(--panel)); }

/* ---------- responsive ---------- */
@media (min-width: 641px) and (max-width: 1180px) {
  .topbar { display: grid; grid-template-columns: 1fr 44px; gap: 10px 18px; padding-top: 14px; padding-bottom: 8px; }
  .brand { grid-column: 1; }
  .theme-btn { grid-column: 2; grid-row: 1; }
  .navlinks { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin: 0; }
  .navlinks button { padding: 8px 4px; }
  .navlinks .lg { display: none; }
  .navlinks .sm { display: inline; }
  html { scroll-padding-top: 155px; }
}
@media (max-width: 1024px) {
  :root { --gutter: 24px; }
  .home-top { grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; }
  .intro h1 { font-size: 36px; }
  .helpers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-row { flex-wrap: wrap; }
  .searchbox { min-width: 100%; }
  .resume { max-width: none; flex: 1; }
  .topic-card h2 { font-size: 26px; }
  .ch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .column > h2, .page-title, .topic-head h2 { font-size: 34px; }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .home-top { grid-template-columns: 1fr; gap: 20px; padding-top: 28px; }
  .intro h1 { font-size: 34px; }
  .topics { grid-template-columns: 1fr; gap: 14px; }
  .topic-card { padding: 21px; min-height: 195px; }
  .topic-card .stats { gap: 24px; }
  .section-head { align-items: center; }
  .section-head > span { max-width: 44%; }
  .stat-grid { grid-template-columns: 1fr; }
  .aid-grid { grid-template-columns: 1fr; }
  .order-result { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .topbar { min-height: 76px; padding-block: 12px; gap: 10px; }
  .brand { min-width: 0; }
  .brand-text b { font-size: 14px; letter-spacing: .04em; }
  .brand-mark { width: 36px; height: 39px; padding: 7px; }
  .navlinks { display: none; }
  .theme-btn { margin-left: auto; }
  .dock { display: flex; }
  .main-col { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .intro h1 { font-size: 32px; }
  .searchbox { padding-left: 12px; gap: 8px; }
  .searchbox button { padding: 8px 12px; }
  .searchbox input::placeholder { font-size: 14px; }
  .helpers { gap: 10px; }
  .helper { padding: 18px; min-height: 150px; }
  .helper b { font-size: 19px; }
  .section-head h2 { font-size: 21px; }
  .section-head > span { font-size: 12px; }
  .column > h2, .page-title, .topic-head h2 { font-size: 31px; }
  .ch-head h3 { font-size: 25px; }
  .ch-grid { grid-template-columns: 1fr; }
  .ch-card { min-height: 0; }
  .lesson h5 { font-size: 19px; }
  .lesson-top { flex-direction: column; gap: 2px; }
  .flash { min-height: 320px; padding: 46px 22px; }
  .flash .term-side { font-size: 25px; }
  .flash .def-side { font-size: 18px; }
  .grade b { font-size: 12px; }
  .stem { font-size: 20px; }
  .choice { padding: 13px 14px; gap: 4px 12px; }
  .row .button-row, .q-foot .button-row { flex: 1; justify-content: flex-end; }
  .bd-row { grid-template-columns: minmax(0, 1fr) 90px 54px; gap: 10px; }
  .panel .bd-row { grid-template-columns: minmax(0, 1fr) 80px 50px; }
  .stat-tiles b { font-size: 30px; }
  .switcher { width: 100%; }
  .switcher button { padding: 9px 10px; }
  .topic-tools .button-row { width: 100%; }
  .topic-tools .button-row .button { flex: 1; }
  .q-foot .meta-n { display: none; }
  .keys-hint { display: none; }
}
@media (pointer: coarse) {
  button, input, select { min-height: 44px; }
  .topic-card:hover, .helper:hover, .ch-card:hover { transform: none; }
  .chip-row button { padding: 10px 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .dock, .button-row, .button, .note-area, .chip-row { display: none !important; }
  .qa .ans { display: block; }
  body { background: #fff; color: #000; }
}
