/* COMPENG 2DI4 midterm study — styles
   palette: near-black ground, one accent per module (set inline as --a) */

:root {
  --bg: #0f1116;
  --bg-2: #14171e;
  --panel: #171b23;
  --panel-2: #1c212b;
  --line: #262c38;
  --line-2: #333b4a;
  --ink: #e3e7ef;
  --ink-2: #b3bacb;
  --muted: #949eaf;
  --faint: #808a9c;
  --accent: #7aa2f7;
  --good: #5fbf8a;
  --bad: #e0716f;
  --warn: #d8b26a;
  --r: 8px;
  --r-lg: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1360px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 620; letter-spacing: -.012em; line-height: 1.22; }
h1 { font-size: clamp(1.5rem, 2.2vw, 2rem); }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
code, pre, kbd, samp { font-family: var(--mono); }
code { font-size: .92em; color: var(--ink); background: #0b0d12; border: 1px solid var(--line); border-radius: 4px; padding: .05em .32em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -40px; z-index: 100;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 8px 12px; text-decoration: none;
}
.skip-link:focus { top: 10px; }

/* ---------- shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; min-height: 54px;
  background: rgba(15, 17, 22, .93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; flex-direction: column; gap: 1px; text-decoration: none; flex: 0 0 auto; }
.brand-code { font-size: 13px; font-weight: 680; letter-spacing: .1em; }
.brand-sub { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }

/* Every route label is a real, whole word at every width: the bar wraps instead
   of scrolling, because a horizontally clipped label reads as broken chrome.
   Below 900px the nav takes its own full-width row so the `?` control can never
   sit on top of the last label. */
.nav {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  flex: 1 1 auto; min-width: 0;
}
.nav a {
  flex: 0 0 auto;
  padding: 6px 9px; border-radius: 6px;
  font-size: 12.5px; letter-spacing: .02em; color: var(--muted);
  text-decoration: none; white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }

.topright { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.topmastery { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.topmastery-num { font: 12px var(--mono); color: var(--ink-2); min-width: 3ch; text-align: right; }
.topmastery-bar { display: block; width: 54px; height: 4px; background: var(--line); border-radius: 3px; overflow: hidden; }
.topmastery-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; }

.iconbtn {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: var(--panel); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 6px; font: 600 13px/1 var(--mono); cursor: pointer;
}
.iconbtn:hover { color: var(--ink); border-color: var(--line-2); }

.banner {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 20px; font-size: 12.5px;
  color: #f0dcb4; background: #241f14; border-bottom: 1px solid #3a311d;
}
.banner::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

#main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 20px 40px;
  outline: none;
}

.foot {
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px 28px;
  color: var(--faint); font-size: 12px;
  display: flex; flex-wrap: wrap; gap: 6px 16px;
}
.foot a { color: var(--muted); }

/* ---------- shared atoms ---------- */

.eyebrow {
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
}
.page-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.page-head .lede { color: var(--ink-2); max-width: 74ch; font-size: 14px; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.head-side { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.section { margin-top: 34px; }
.section > h2 {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
.section-note { font-size: 12.5px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line-2);
  font: 500 13px/1.2 var(--sans); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #232936; border-color: #414b5e; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0d1016; font-weight: 620; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
/* a quiet button is a secondary control, not body text: it keeps the standard
   control border (--line-2) and only drops the fill, so `fit`, `to the quiz →` and
   `own cheat sheet` read as controls beside their filled siblings */
.btn-quiet { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-quiet:hover { color: var(--ink); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
/* .45 of --ink on --panel-2 measured 3.75:1, so a disabled control was the least
   legible text on the page; .55 lands at 4.90:1 and still reads as off */
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; white-space: normal; max-width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel);
  font-size: 11.5px; color: var(--ink-2); text-decoration: none;
  cursor: pointer;
}
button.chip { font-family: var(--sans); }
.chip:hover { color: var(--ink); border-color: #4b566b; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); background: #1b2130; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.chip-code { font: 600 10.5px var(--mono); letter-spacing: .06em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 10px/1 var(--sans); letter-spacing: .09em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 4px;
  border: 1px solid var(--line-2); color: var(--muted); background: #101319;
}
.badge-full { color: #9fd7b6; border-color: #2c4636; background: #131d17; }
.badge-partial { color: #e0c489; border-color: #40361f; background: #1c1810; }
.badge-out { color: #b98d90; border-color: #42292b; background: #1d1414; }
.badge-fault { color: #e8a1a1; border-color: #4a2b2b; background: #201314; }
.badge-high { color: #e8b9a0; border-color: #453026; background: #1e1512; }
.badge-med { color: #d7cf9f; border-color: #3d3a24; background: #1a1a12; }
.badge-low { color: var(--faint); }

.count-line { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.dot-high { background: #e08d6d; }
.dot-med { background: #cbb96a; }
.dot-low { background: #4d586a; }

.bar { display: block; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--a, var(--accent)); border-radius: 3px; }

.empty {
  border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  padding: 28px; color: var(--ink-2); background: var(--bg-2);
}
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 13.5px; max-width: 70ch; }
.empty ul { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.empty li { margin: 3px 0; }
.empty code { color: var(--ink-2); }

/* ---------- map: shared head ---------- */

.maphead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.maphead-lede { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; max-width: 66ch; }
.maphead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mastery-inline { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.mastery-inline .bar { width: 120px; }
.lastdiag { font: 11.5px var(--mono); color: var(--muted); }

/* One line, rendered only when something is stored: what was left open and the
   click back into it. No stored route means no line at all, not an empty state. */
.resume-line {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  max-width: 100%; margin: 0 0 6px; padding: 6px 11px;
  border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--panel); color: var(--ink);
  font: 12px var(--mono); text-decoration: none;
}
.resume-line:hover { border-color: var(--accent); background: #232936; }
.resume-tag { color: var(--faint); letter-spacing: .04em; }
.resume-what { color: var(--ink); }
.resume-go { color: var(--accent); }

/* ---------- map: ordered stages ---------- */

.ring { flex: 0 0 auto; }
.ring circle { fill: none; stroke-width: 4; }
.ring .ring-bg { stroke: var(--line); }
.ring .ring-fg { stroke: var(--a, var(--accent)); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring text { fill: var(--ink-2); font: 600 11px var(--mono); text-anchor: middle; dominant-baseline: central; }

.stages { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.stage-row, .rail-unit {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 11px 16px 11px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--a, var(--accent));
  border-radius: var(--r-lg);
}

.stage-num { display: flex; flex-direction: column; align-items: center; gap: 6px; align-self: stretch; }
.stage-num-n { font: 600 22px/1 var(--mono); color: var(--a, var(--accent)); letter-spacing: -.02em; }
/* the rule is the whole connector: no arrowhead, because direction inside a
   pair of units is mixed and an arrow would claim one that the data denies */
.stage-num-rule { flex: 1 1 auto; width: 1px; min-height: 18px; background: linear-gradient(var(--a, var(--accent)), transparent); opacity: .5; }
.stage-row:last-child .stage-num-rule { display: none; }

.stage-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stage-hop { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font: 11px var(--mono); }
.stage-hop-label { color: var(--muted); letter-spacing: .04em; }
.stage-hop-weight { color: var(--a, var(--accent)); }
.stage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 10px; }
.stage-name { display: inline-flex; align-items: baseline; gap: 8px; font-size: 16px; font-weight: 620; letter-spacing: -.012em; color: var(--ink); text-decoration: none; }
.stage-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.stage-code { font: 600 10.5px var(--mono); letter-spacing: .1em; color: var(--a, var(--accent)); }
.stage-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.stage-counts { font: 11.5px var(--mono); color: var(--faint); }
.stage-side { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.stage-ring-label { font: 10px var(--mono); color: var(--faint); text-align: center; white-space: nowrap; }

/* the action sits against the mastery ring, not floating in the middle of a
   1,123px body: 736px of dead air between the link and the ring read as a gap */
.stage-next {
  display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 7px;
  margin-top: 4px; padding: 6px 11px; align-self: flex-end;
  border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--panel-2); color: var(--ink); text-decoration: none;
  font-size: 13px; font-weight: 560;
}
.stage-next:hover { border-color: var(--a, var(--accent)); background: #232936; }
.stage-next-tag { font: 600 9.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--a, var(--accent)); }
.stage-next-text { min-width: 0; }
.stage-next-arrow { color: var(--muted); flex: 0 0 auto; }

/* the lab sits beside the chain, not in it */
.rail-section { border-left: 1px solid var(--line-2); padding-left: 16px; margin-left: 2px; }
.rail-unit { grid-template-columns: minmax(0, 1fr) auto; padding-left: 18px; border-left-style: dashed; background: var(--bg-2); }

.badge-note { color: var(--warn); border-color: #40361f; background: #1c1810; }
.badge-weak { color: #e8a1a1; border-color: #4a2b2b; background: #201314; }

/* ---------- map: pair ledger ---------- */

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 12px 0 14px; }
.legend-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.swatch { width: 14px; height: 3px; border-radius: 2px; flex: 0 0 auto; }

.ledger-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 4px; }
.searchbox { position: relative; flex: 1 1 260px; max-width: 380px; }
.searchbox svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; stroke: var(--faint); fill: none; stroke-width: 1.8;
}
.ledger-count { font: 11.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ledger-search {
  width: 100%; padding: 7px 10px 7px 28px; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font: 13px var(--sans);
}
.ledger-search::placeholder { color: var(--faint); }
.ledger-sub {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  margin: 22px 0 8px; font: 600 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
}
.ledger-sub .count-line { letter-spacing: 0; text-transform: none; font-weight: 400; }
.ledger-list { display: flex; flex-direction: column; gap: 6px; }
.ledger-empty { margin-top: 10px; }

.lpair { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); }
.lpair > summary {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px;
  padding: 9px 12px; cursor: pointer; list-style: none;
}
.lpair > summary::-webkit-details-marker { display: none; }
.lpair > summary::after { content: "+"; color: var(--faint); font: 600 13px var(--mono); margin-left: 4px; }
.lpair[open] > summary::after { content: "\2013"; }
.lpair[open] > summary { border-bottom: 1px solid var(--line); }
.lpair-keys { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; }
.lpair-codes { font: 600 11px var(--mono); letter-spacing: .08em; color: var(--ink); white-space: nowrap; }
.lpair-titles { font-size: 12px; color: var(--muted); }
.lpair-weight { font: 11px var(--mono); color: var(--a, var(--accent)); color: var(--ink-2); white-space: nowrap; }
.lpair-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 14px; }

.lgroup-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  font: 600 9.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 6px;
}
.ledge-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.ledge {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  font-size: 12.5px; line-height: 1.5;
}
.ledge .lp-arrow { color: var(--faint); }
.ledge .lp-node { display: inline-flex; align-items: baseline; gap: 5px; }
.lp-code { font: 600 9.5px var(--mono); letter-spacing: .06em; color: var(--faint); }
.lp-name { overflow-wrap: break-word; }
.lpair.is-inner > summary { background: linear-gradient(90deg, #181c24, var(--bg-2)); }
.lp-node.is-subject { color: var(--ink); border-bottom-color: var(--accent); }
.lp-why { color: var(--faint); font-size: 12px; }
.lp-type { font: 600 10px var(--mono); letter-spacing: .05em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; background: #101319; border: 1px solid var(--line); }

/* ---------- concept destination, graph entry and neighbourhood ---------- */

.chead { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.chead-lede { font-size: 13.5px; color: var(--ink-2); max-width: 74ch; }
.concept-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cbody { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; max-width: 82ch; }
.cf h3 { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 5px; }
.cf p { font-size: 13.5px; color: var(--ink-2); }
.cf ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
.cf li { margin: 4px 0; }
.field-note { font-family: var(--mono); font-size: 12.5px; background: #0b0d12; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; color: var(--ink); overflow-wrap: break-word; }
.drill-row { margin-top: 4px; }
.drill-btn { font-weight: 600; }

.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 4px; }
.filter-chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 4px 9px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--accent); background: #1b2130; color: var(--ink); font-size: 12.5px;
}
.filter-chip:hover { background: #232936; }
.filter-chip-tag { font: 600 9.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.filter-chip-x { color: var(--muted); font-size: 13px; }

.gsearch-results { margin-top: 12px; }
.concept-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.concept-link-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 7px 10px; border: 1px solid var(--line); border-left: 2px solid var(--a, var(--accent)); border-radius: 6px; background: var(--panel); }
.concept-link { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 560; }
.concept-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.concept-link-name { overflow-wrap: break-word; }
.concept-link-one { font-size: 12px; color: var(--muted); }
.rel-group > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.rel-group .ledge-list { margin-top: 8px; }


/* ---------- module detail ---------- */

.mhead { display: flex; flex-direction: column; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.mhead-scope { font-size: 13px; color: var(--ink-2); max-width: 76ch; }
.mhead-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.mhead-meta .bar { width: 200px; }
.mhead-decks { display: flex; flex-wrap: wrap; gap: 6px; }
.mhead-badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* In-page section nav. Sticky in its own row — `top` clears the 54px topbar, and
   because the bar comes before the sections in the flow, becoming sticky moves
   nothing under the reader's eye. Worked examples start 5–6 k px down, which is
   six screens of blind scroll from the closest thing to an exam question. */
.sectnav {
  position: sticky; top: var(--topbar-h, 54px); z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 16px 0 0; padding: 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.sectnav-chip { font-size: 12px; padding: 5px 10px; }
.sectnav-chip .chip-code { color: var(--faint); }
.section[id] { scroll-margin-top: calc(var(--topbar-h, 54px) + 56px); }

.concept-list { display: flex; flex-direction: column; gap: 6px; }
.tier-head {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 4px;
  font: 600 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
  scroll-margin-top: 68px;
}
.tier-head::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }
.tier-jumps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.tier-jumps .chip-code { color: var(--faint); }

.crow {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2);
  border-left: 2px solid var(--a, var(--accent));
}
.crow[open] { background: var(--panel); }
.crow.is-focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); animation: crow-focus 2.4s ease-out 1; }
@keyframes crow-focus {
  0% { background: #1b2130; }
  100% { background: var(--panel); }
}
.crow > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px;
  padding: 9px 12px; cursor: pointer; list-style: none;
}
.crow > summary::-webkit-details-marker { display: none; }
.crow > summary .crow-name { grid-row: 1; grid-column: 1; }
.crow > summary .count-line { grid-row: 1; grid-column: 2; }
.crow > summary .crow-tools { grid-row: 1; grid-column: 3; }
.crow-name { font-size: 13.5px; font-weight: 560; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.crow-one { grid-row: 2; grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
/* The row keeps its controls at rest: the slide is one click away without opening
   the row, and the chevron reports the open state the summary already owns. */
.crow-tools { display: flex; align-items: center; gap: 4px; }
.crow-tool {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  background: var(--panel); color: var(--ink-2); border: 1px solid var(--line-2);
  border-radius: 6px; cursor: pointer;
}
.crow-tool:hover { color: var(--ink); background: var(--panel-2); border-color: #4b566b; }
.crow-chev { display: grid; place-items: center; width: 18px; height: 28px; color: var(--muted); cursor: pointer; }
.crow-chev svg { transition: transform .16s ease; }
.crow[open] .crow-chev { color: var(--ink-2); }
.crow[open] .crow-chev svg { transform: rotate(180deg); }
.crow[open] > summary .crow-name { color: var(--ink); }
.crow-body { padding: 0 12px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.crow-field h4 { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.crow-field p { font-size: 13px; color: var(--ink-2); }
.crow-field ul { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--ink-2); }
.crow-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.trap { border: 1px solid var(--line); border-left: 2px solid #7a4b4b; border-radius: var(--r); background: var(--bg-2); padding: 11px 13px; }
.trap + .trap { margin-top: 8px; }
.trap-claim { font-size: 13.5px; font-weight: 560; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.trap-why { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }
.trap-foot { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.ex { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); padding: 12px 14px; }
.ex + .ex { margin-top: 8px; }
.ex-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ex-title { font-size: 13.5px; font-weight: 600; }
.ex-problem { font-size: 13px; color: var(--ink-2); margin-top: 6px; white-space: pre-wrap; }
.ex-reveal { margin-top: 10px; }
.ex-body { display: flex; flex-direction: column; gap: 8px; }
.ex-field h4 { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.ex-field p { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }
.ex-answer { font: 600 13px var(--mono); color: var(--ink); }
.ex-pitfall p { color: #d7ad9b; }

/* ---------- flashcards ---------- */

.cards-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.scope-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.scope-chip {
  display: flex; flex-direction: column; gap: 1px; align-items: flex-start;
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-2);
  font: 12.5px var(--sans); text-align: left;
}
.scope-chip:hover { border-color: var(--line-2); color: var(--ink); }
.scope-chip[aria-pressed="true"] { border-color: var(--a, var(--accent)); background: var(--panel-2); color: var(--ink); }
.scope-chip .sc-code { font: 600 9.5px var(--mono); letter-spacing: .1em; color: var(--a, var(--accent)); }
.scope-chip .sc-title { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fc-stage { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.fc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); }
.counter { display: inline; font: 12.5px var(--mono); color: var(--ink-2); white-space: nowrap; }
.counter .c-pos { color: var(--ink); }
.counter .c-total { color: var(--muted); }
.counter .c-label { color: var(--muted); font-family: var(--sans); }

.fc {
  position: relative; width: 100%; min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 34px 30px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--a, var(--accent));
  border-radius: var(--r-lg); color: var(--ink);
  font: inherit; cursor: pointer;
}
.fc:hover { background: var(--panel-2); }
.fc-face { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.fc-text { font-size: clamp(1.05rem, 1.9vw, 1.42rem); font-weight: 560; line-height: 1.35; max-width: 54ch; overflow-wrap: break-word; }
.fc-back .fc-text { font-weight: 480; color: var(--ink); }
.fc-hint { font-size: 11.5px; color: var(--faint); font-family: var(--mono); }
.fc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fc-src { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.fc-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- quiz / diagnostic ---------- */

.run-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.run-progress { display: flex; align-items: center; gap: 12px; font: 12px var(--mono); color: var(--muted); }
.run-progress .bar { width: 220px; }
/* 1 of 32 is 7px of track: without a floor a just-started run is a grey bar and
   the position has to be read off the counter instead */
.run-progress .bar > i { min-width: 8px; }
.run-score { font: 12px var(--mono); color: var(--muted); }
.qcard {
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 16px;
}
.qtext { font-size: clamp(1rem, 1.5vw, 1.18rem); font-weight: 560; line-height: 1.4; white-space: pre-wrap; }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  padding: 11px 13px; border-radius: var(--r);
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  font: 13.5px/1.45 var(--sans); cursor: pointer;
}
.opt:hover:not([disabled]) { border-color: var(--line-2); background: var(--panel-2); }
.opt-key {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 19px; height: 19px; border-radius: 4px; margin-top: 1px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  font: 600 10.5px var(--mono); color: var(--muted);
}
.opt-text { flex: 1 1 auto; }
.opt[disabled] { cursor: default; }
.opt.is-correct { border-color: #376b50; background: #14211a; }
.opt.is-correct .opt-key { background: #376b50; border-color: #376b50; color: #dff6e7; }
.opt.is-wrong { border-color: #6b3738; background: #211414; }
.opt.is-wrong .opt-key { background: #6b3738; border-color: #6b3738; color: #fbe4e4; }
.opt.is-dim { opacity: .58; }
/* at .58 the muted key glyph landed at 2.96:1, the last text on the page under
   4.5; the option's own text clears it, and the key has to stay readable beside it */
.opt.is-dim .opt-key { color: var(--ink); }
.opt-mark { font: 600 11px var(--mono); color: var(--muted); margin-left: auto; }
.feedback { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.fb-verdict { font: 600 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.fb-verdict.good { color: var(--good); }
.fb-verdict.bad { color: var(--bad); }
.fb-explain { font-size: 13.5px; color: var(--ink-2); white-space: pre-wrap; }
.fb-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.results { display: flex; flex-direction: column; gap: 22px; }
.report-note { max-width: 74ch; }

/* The diagnostic's pre-run card: the only added click in the plan, and it buys
   back a destroyed eight-minute run. */
.diag-card {
  display: flex; flex-direction: column; gap: 10px; max-width: 640px;
  margin: 18px 0 8px; padding: 18px 20px;
  border: 1px solid var(--line-2); border-left: 2px solid var(--accent);
  border-radius: var(--r-lg); background: var(--panel);
}
.diag-big { font: 600 1.05rem/1.3 var(--sans); color: var(--ink); }
.diag-card .count-line { max-width: 62ch; }
.diag-card .btn-row { margin-top: 4px; }
.diag-runbar { margin-top: 18px; }
.verdict { font-size: clamp(1rem, 1.6vw, 1.16rem); line-height: 1.45; max-width: 74ch; }
.verdict strong { color: var(--ink); }
.scoreline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; }
.scoreline .big { font: 600 clamp(1.8rem, 3.4vw, 2.5rem)/1 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.scoreline .pct { font: 13px var(--mono); color: var(--muted); }
.scoreline .of { font: 15px var(--mono); color: var(--muted); }

.brk { display: flex; flex-direction: column; gap: 8px; }
/* the row key is the whole point of the breakdown, so the module name wraps
   instead of ellipsising: 497px of title does not fit a 220px column at any width */
.brk-row { display: grid; grid-template-columns: minmax(0, 480px) minmax(120px, 1fr) auto; align-items: center; gap: 4px 14px; font-size: 12.5px; }
.brk-name { color: var(--ink-2); display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
.brk-code { font: 600 10px var(--mono); letter-spacing: .1em; color: var(--a, var(--accent)); }
.brk-title { overflow-wrap: break-word; }
.brk-val { font: 11.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.ranks { display: flex; flex-direction: column; gap: 6px; }
.rank {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2);
  border-left: 2px solid var(--a, var(--accent));
}
.rank-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; }
.rank-name { font-size: 13.5px; font-weight: 560; color: var(--ink); text-decoration: none; overflow-wrap: break-word; }
.rank-name:hover { text-decoration: underline; }
.rank-mod { font: 10.5px var(--mono); color: var(--muted); }
.rank-side { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rank-count { font: 600 12px var(--mono); color: var(--bad); font-variant-numeric: tabular-nums; }
.rank-good .rank-count { color: var(--good); }
.rank-why { grid-column: 1 / -1; font-size: 12px; color: var(--faint); }

/* ---------- deck browser + slide ---------- */

.deckhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.deckhead h1 { font-size: clamp(1.1rem, 1.7vw, 1.35rem); overflow-wrap: break-word; }
.deckhead-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.pagenum { font: 600 12px var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.goinput { width: 62px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; color: var(--ink); font: 600 12px var(--mono); }

.deck { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 16px; align-items: start; }
.strip { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 190px); overflow-y: auto; padding-right: 4px; }
.strip-item {
  display: block; width: 100%; padding: 0; cursor: pointer; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 5px; overflow: hidden; position: relative;
}
.strip-item { aspect-ratio: 4 / 3; flex: 0 0 auto; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .72; }
.strip-item .strip-num {
  position: absolute; left: 3px; top: 2px;
  font: 600 9.5px var(--mono); color: #cfd6e4;
  background: rgba(10, 12, 16, .78); border-radius: 3px; padding: 0 3px;
}
.strip-item:hover { border-color: var(--line-2); }
.strip-item:hover img { opacity: 1; }
.strip-item[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.strip-item[aria-current="true"] img { opacity: 1; }

.stage-wrap { min-width: 0; }
.stage-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.stage {
  position: relative; overflow: hidden;
  background: #0b0d12; border: 1px solid var(--line); border-radius: var(--r);
  min-height: 240px; display: block;
}
.stage-inner { width: 100%; transition: transform .12s ease; transform-origin: top left; will-change: transform; }
.slide-view .stage { border-radius: var(--r-lg); }
.stage.grabbing .stage-inner { cursor: grabbing; }
.stage img { width: 100%; height: auto; display: block; }
.stage-empty { padding: 40px 20px; text-align: center; color: var(--faint); font-size: 12.5px; }
.stage-empty code { color: var(--muted); }

.decktext { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.decktext h2 { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 6px; }
.decktext pre {
  margin: 0; padding: 0 12px 12px; overflow: auto; max-height: calc(100vh - 220px);
  font: 11.5px/1.5 var(--mono); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: break-word;
}
.decktext .dt-empty { padding: 0 12px 14px; font-size: 12.5px; color: var(--faint); }

.slide-view { display: flex; flex-direction: column; gap: 12px; }
.slide-full { border: 1px solid var(--line); border-radius: var(--r); background: #0b0d12; overflow: hidden; }
.slide-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* dialog: slide overlay */
.dlg { border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--panel); color: var(--ink); padding: 0; }
.dlg::backdrop { background: rgba(6, 8, 12, .78); }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 13px; font-weight: 600; }
.dlg-head .dlg-sub { font: 11.5px var(--mono); color: var(--muted); margin-top: 2px; }
.dlg-close { margin-left: auto; }
.dlg-slide { width: min(1080px, 94vw); max-height: 92vh; }
.slide-dlg-body { position: relative; padding: 10px 14px 14px; max-height: calc(92vh - 128px); }
.slide-dlg-scroll {
  overflow: auto; overscroll-behavior: contain;
  max-height: calc(92vh - 152px);
  border: 1px solid var(--line); border-radius: 6px; background: #0b0d12;
}
.stage-overlay { border: 0; border-radius: 6px; min-height: 120px; overflow: visible; }
/* portrait solution pages run ~1,382 px in a ~708 px body; without a cue the cut
   reads as the end of the document */
.scrollcue {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: rgba(23, 27, 35, .94); border: 1px solid var(--line-2); color: var(--ink-2);
  font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}
.scrollcue:hover { color: var(--ink); border-color: var(--accent); }
.scrollcue-arrow { font-size: 13px; line-height: 1; color: var(--accent); }
.slide-dlg-body.is-more::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 14px; height: 44px;
  border-radius: 0 0 6px 6px; pointer-events: none;
  background: linear-gradient(rgba(11, 13, 18, 0), rgba(11, 13, 18, .92));
}
.dlg-zoom { display: inline-flex; align-items: center; gap: 4px; }
.dlg-tools .pagenum { min-width: 6ch; text-align: center; }
.dlg-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.dlg-help { width: min(560px, 94vw); }
.keys { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; padding: 14px 16px; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; font-size: 13px; color: var(--ink-2); }
kbd {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-bottom-width: 2px;
  font: 600 11px var(--mono); color: var(--ink-2);
}
.keys-note { margin: 0; padding: 0 16px 16px; font-size: 12px; color: var(--faint); }

/* ---------- cheat sheet ---------- */

.sheet-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
/* the exam-room strip: the point of `#/sheet` is density, so the printed help sheet
   is one line and a route to the tables instead of a 550px panel above the fold */
.examroom {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 7px 12px; margin-bottom: 20px;
  border: 1px solid var(--line); border-left: 2px solid var(--accent);
  border-radius: var(--r); background: var(--bg-2);
  font-size: 12.5px; color: var(--ink-2);
}
.examroom-tag { font: 600 9.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.examroom-line { flex: 1 1 auto; min-width: 0; }
.examroom .btn { flex: 0 0 auto; }
.sheet { columns: 2; column-gap: 28px; }
@media (max-width: 900px) { .sheet { columns: 1; } }
.sheet-block { break-inside: avoid; page-break-inside: avoid; margin-bottom: 16px; }
.sheet-block h3 {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--a, var(--accent));
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 7px;
}
.sheet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.sheet-item { font-size: 12.5px; }
.sheet-item .si-name { font-weight: 600; }
.sheet-item .si-one { color: var(--muted); }
.sheet-note { font: 12px/1.5 var(--mono); background: #0b0d12; border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; margin-top: 3px; overflow-wrap: break-word; display: block; white-space: pre-wrap; }
/* 168 high-relevance concepts: notation sits on the name's line so the sheet
   prints on two pages instead of nine. */
.sheet-line { line-height: 1.5; }
.sheet-note-inline {
  display: inline; margin: 0 0 0 5px; padding: 0 4px;
  font-size: 11px; line-height: 1.35; white-space: normal; vertical-align: baseline;
}
.sheet-line .sheet-gotcha { display: inline; margin-left: 5px; }
.sheet-gotcha { font-size: 11.5px; color: #cfa193; margin-top: 2px; }
.sheet-prose { font-size: 12.5px; color: var(--ink-2); }
.sheet-prose ul { margin: 4px 0 0; padding-left: 16px; }
.sheet-prose li { margin: 2px 0; }
table.ref { width: 100%; border-collapse: collapse; font: 11.5px var(--mono); }
table.ref caption { text-align: left; font: 600 10px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-bottom: 5px; }
table.ref th, table.ref td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; vertical-align: top; }
table.ref th { background: var(--panel-2); color: var(--ink-2); font-weight: 600; }
table.ref td { color: var(--ink-2); }

/* what the exam gives you: the printed help sheet, verbatim */

.helpsheet {
  border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--bg-2);
  padding: 14px 16px 16px; margin-bottom: 26px;
}
.helpsheet-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  padding-bottom: 9px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}
.helpsheet-head h2 { font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
.helpsheet-head .eyebrow { color: var(--accent); }
.helpsheet-lede { flex: 1 0 100%; font-size: 12.5px; color: var(--muted); }
.hs-groups {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px 18px; align-items: start;
}
/* the postulate table is the widest thing on the page and wraps badly in a
   single column, so it takes two of the four */
.hs-algebra { grid-column: span 2; }
.hs-group { min-width: 0; }
.hs-group h3 {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 8px;
}
.hs-sub + .hs-sub { margin-top: 9px; }
.hs-sub h4 { font: 600 10.5px var(--mono); letter-spacing: .06em; color: var(--ink-2); margin-bottom: 4px; }
.hs-table td { overflow-wrap: break-word; }
.hs-eqgroup { grid-column: span 4; }
.hs-eqs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.hs-eqs code { font: 12px var(--mono); white-space: pre; border-radius: 4px; padding: 3px 7px; }
.hs-eqs .hs-sep { color: var(--faint); }
/* the point of the section: what the sheet leaves out */
.hs-note {
  margin-top: 16px; padding: 10px 14px;
  border-left: 3px solid var(--warn); border-radius: 0 var(--r) var(--r) 0;
  background: var(--panel); color: var(--ink-2); font-size: 13px; line-height: 1.5;
}
.hs-note strong { color: var(--ink); font-weight: 650; }

@media (max-width: 1200px) {
  .hs-groups { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hs-algebra, .hs-eqgroup { grid-column: span 2; }
}

@media (max-width: 760px) {
  .hs-groups { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .hs-algebra, .hs-eqgroup { grid-column: auto; }
  .helpsheet { padding: 12px 12px 14px; }
}

/* ---------- exams ---------- */

.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.exam-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-2); padding: 14px 16px; }
.exam-card h3 { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 9px; }
.exam-big { font: 600 1.4rem/1.2 var(--sans); }
.exam-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.exam-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.exam-list li { display: flex; gap: 8px; align-items: baseline; }
.exam-list .k { color: var(--muted); font: 11px var(--mono); flex: 0 0 auto; }
.prose { font-size: 13.5px; color: var(--ink-2); max-width: 76ch; }
.prose + .prose { margin-top: 10px; }
.hs-pointer {
  margin-top: 14px; padding: 8px 0 8px 12px; border-left: 2px solid var(--line-2);
  font-size: 12.5px; line-height: 1.55; color: var(--muted); max-width: 86ch;
}
.hs-pointer strong { color: var(--ink-2); font-weight: 620; }
.hs-pointer a { color: var(--accent); }

/* ---------- progress ---------- */

.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.pcard { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-2); padding: 14px 16px; }
.pcard h3 { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.prow { display: grid; grid-template-columns: minmax(90px, 1fr) 90px auto; gap: 10px; align-items: center; font-size: 12.5px; }
.prow + .prow { margin-top: 8px; }
.prow .bar { height: 4px; }
.prow-val { font: 11.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
a.prow { text-decoration: none; color: var(--ink-2); }
a.prow:hover { color: var(--ink); }
a.prow:hover .prow-val { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.hist-link { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; width: 100%; text-decoration: none; color: inherit; }
.hist-link:hover .h-score { text-decoration: underline; text-underline-offset: 3px; }
.hist-link.is-flat { cursor: default; }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.hist li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; padding-bottom: 0; }
.hist .h-when { font: 11px var(--mono); color: var(--faint); }
.hist .h-score { font: 600 12px var(--mono); color: var(--ink); }
.hist .h-scope { color: var(--muted); }
.spark { display: block; width: 100%; height: 56px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark circle { fill: var(--accent); }
.spark line { stroke: var(--line); stroke-width: 1; }
.danger { border-color: #4a2b2b; color: #e8a1a1; }
.danger:hover { background: #211414; border-color: #6b3738; }

/* ---------- lesson ---------- */

.stagerail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px; }
.stagerail .stage-chip {
  font: 600 10px var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--faint);
}
.stagerail .stage-chip[data-active="true"] { color: var(--ink); border-color: var(--accent); background: #1b2130; }

/* ---------- 404 ---------- */

.notfound { display: flex; flex-direction: column; gap: 14px; }
.route-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.route-list li { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); padding: 10px 12px; font-size: 12.5px; }
.route-list code { display: inline-block; margin-bottom: 3px; color: var(--accent); background: none; border: 0; padding: 0; }
.route-list span { color: var(--muted); display: block; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  /* the header grows instead of clipping: brand and the mastery/help cluster keep
     row one, the route labels get a full-width row of their own and wrap there */
  .topbar { flex-wrap: wrap; row-gap: 6px; padding-top: 7px; padding-bottom: 7px; }
  .brand { order: 1; }
  .topright { order: 2; margin-left: auto; }
  .nav { order: 3; flex: 1 1 100%; }
  .crow > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .crow > summary .crow-name { grid-row: 1; grid-column: 1; }
  .crow > summary .count-line { grid-row: 2; grid-column: 1; }
  .crow > summary .crow-tools { grid-row: 1 / span 2; grid-column: 2; }
  .crow-one { grid-row: 3; grid-column: 1 / -1; }
  .stage-row, .rail-unit { grid-template-columns: 42px minmax(0, 1fr); }
  .stage-side { grid-column: 2; flex-direction: row; align-items: center; gap: 10px; }
}

@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .topbar { gap: 10px; padding-left: 12px; padding-right: 12px; min-height: 50px; }
  .brand-sub { display: none; }
  .topmastery { display: none; }
  #main { padding: 18px 14px 60px; }
  .deck { grid-template-columns: minmax(0, 1fr); }
  .strip { flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; }
  .strip-item { width: 86px; flex: 0 0 auto; }
  .decktext pre { max-height: none; }
  .stage-row, .rail-unit { padding-right: 12px; gap: 10px; }
  .stage-name { font-size: 15px; }
  /* the arrow stays on the label's last line instead of orphaning below it */
  .stage-next { flex-wrap: nowrap; align-items: baseline; align-self: flex-start; }
  .stage-next-text { flex: 1 1 auto; }
  .rail-section { padding-left: 10px; }
  .sheet { columns: 1; }
  .work-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Seven route labels need ~431px and a 420px bar offers 396px, so the flex wrap
   broke 6+1 and left `progress` alone on row two (it does so anywhere from 441 to
   454px as well). Four fixed columns split the bar 4+3 across that whole range and
   never clip a label: the widest is 62px in an 82px cell at 360px. Above 470px the
   seven labels fit one row with room to spare, so the grid stops there. */
@media (max-width: 470px) {
  .nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  .nav a { padding: 6px; font-size: 12px; text-align: center; }
}

@media (min-width: 1200px) {
  .deck-3 { grid-template-columns: 132px minmax(0, 1fr) 340px; }
}

@media (max-width: 560px) {
  /* the module name owns the whole row here: a 497px title in a 142px column
     was cut to `module 1 · Introduction, Number…` at every phone width */
  .brk-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .brk-name { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .qcard { padding: 15px 14px; }
  .fc { padding: 24px 18px; min-height: 220px; }
  .opt { padding: 9px 10px; font-size: 13px; }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
  .ring .ring-fg { transition: none; }
}

/* ---------- print ---------- */

@media print {
  :root { --bg: #fff; --bg-2: #fff; --panel: #fff; --panel-2: #fff; --ink: #111; --ink-2: #222; --muted: #444; --faint: #555; --line: #bbb; --line-2: #999; }
  body { background: #fff; color: #111; font-size: 10.5pt; }
  /* nothing interactive reaches paper: no topbar, no nav, no footer, no buttons,
     no section chips, no resume strip */
  .topbar, .banner, .foot, .nav, .sheet-tools, .skip-link, .iconbtn, .dlg,
  .btn, .btn-row, .sectnav, .resume-line, .no-print, .examroom, .crow-tools { display: none !important; }
  /* the one artefact worth carrying to a table with a pencil: no row splits */
  .rank, .brk-row, .sheet-item, .sheet-block, .prow, .hist li, .hs-sub { break-inside: avoid; page-break-inside: avoid; }
  .results.report .section { margin-top: 6mm; }
  .results.report h1 { font-size: 12.5pt; line-height: 1.35; }
  .results.report .scoreline .big { font-size: 20pt; }
  .rank-name { color: #111 !important; }
  .rank-count { color: #111 !important; }
  .rank-why, .rank-mod, .brk-name, .brk-val, .report-note { color: #333 !important; }
  .rank, .brk-row .bar { border-color: #bbb !important; }
  #main { max-width: none; padding: 0; }
  /* a page is a column set of its own: at 168 high-relevance concepts, two
     columns spill to five pages and three settle at six (Chromium printToPDF,
     A4, default margins). The h1 no longer claims a page count. */
  .sheet { columns: 3; column-gap: 7mm; }
  .sheet-block { break-inside: avoid; page-break-inside: avoid; margin-bottom: 9px; }
  .sheet-block h3 { font-size: 8pt; margin-bottom: 4px; }
  .sheet-list { gap: 3px; }
  .sheet-note, code, table.ref th { background: #f4f4f4 !important; border-color: #bbb !important; color: #111 !important; }
  table.ref { font-size: 7.5pt; }
  table.ref th, table.ref td { border-color: #999; padding: 2px 4px; }
  a { color: #111; text-decoration: none; }
  .sheet-item { break-inside: avoid; font-size: 8pt; line-height: 1.34; }
  .sheet-line .si-name { font-size: 8pt; }
  .sheet-note-inline { font-size: 7.4pt; border: 0 !important; background: transparent !important; padding: 0; }
  .sheet-gotcha { font-size: 7.4pt; }
  .sheet-prose { font-size: 8pt; }
  .helpsheet { break-inside: auto; page-break-inside: auto; border-color: #bbb !important; background: #fff !important; padding: 0 0 3mm; margin-bottom: 4mm; }
  .helpsheet-head { border-bottom-color: #999; }
  .helpsheet-head h2 { font-size: 11pt; }
  .helpsheet-head .eyebrow, .helpsheet-lede { color: #444 !important; font-size: 8pt; }
  .hs-groups { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4mm; }
  .hs-algebra, .hs-eqgroup { grid-column: span 2; }
  .hs-group h3 { color: #111 !important; font-size: 7.6pt; border-bottom-color: #999; }
  .hs-sub h4 { color: #111 !important; font-size: 7.6pt; }
  .hs-table { font-size: 7.5pt; }
  .hs-algebra .hs-table { width: auto; }
  .hs-eqs code { background: #f4f4f4 !important; border-color: #bbb !important; color: #111 !important; font-size: 8pt; }
  .hs-note { background: #fff !important; border-left-color: #111 !important; color: #111 !important; font-size: 8pt; }
  .hs-note strong { color: #000 !important; }
  .hs-pointer { color: #333 !important; border-left-color: #999; }
}
