/* Drill, review, and mock exams.
   Colour is only --ok and --bad, and only on a verdict.
   Everything else is the shell's monochrome tokens. */

.pq {
  box-sizing: border-box;
  width: min(100%, var(--measure));
  max-width: 100%;
  min-width: 0;
  margin-inline: auto;
  padding: var(--space-5) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom));
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--step-1);
  line-height: 1.55;
}

.pq *,
.pq *::before,
.pq *::after { box-sizing: border-box; }

.pq-top { margin: 0 0 var(--space-5); }

.pq-top.has-lesson {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.pq-top-main { flex: 1 1 auto; min-width: 0; }

.pq-lesson-btn { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 560px) {
  .pq-top.has-lesson { flex-direction: column; gap: var(--space-3); }
}

.pq-eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pq-lesson-link {
  margin: var(--space-2) 0 0;
  font-family: var(--font-ui);
  font-size: var(--step--1);
}

/* "Beyond Exam 2" on a set the student opened directly. Monochrome, quiet, and
   above the title's baseline: it is a fact about the set, not a warning. */
.pq-beyond,
.exam-scope-note {
  margin: 0 0 var(--space-3);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
}

/* WHY THIS SET, under the title on a practice header and in the same voice as the
   "Beyond" note: one sentence, muted, never a badge. The question it answers —
   "why am I doing this one?" — is the one a learner asks when the item lands, so
   it sits above the question rather than below the answer. */
.pq-why,
.next-why {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.45;
  max-width: 46ch;
  overflow-wrap: anywhere;
}

/* WHAT THE LEARNER CAN NOW DO. One sentence under the score on a finished set, and
   under the state word on a skill page. It is the one line on either surface about
   what the sitting BOUGHT rather than what it cost, so it is set in the body face
   at body size — not a chip, not a badge, and never coloured. */
.pq-can,
.skill-can {
  margin: var(--space-3) 0 0;
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.45;
  max-width: 46ch;
}

.pq-title {
  margin: 0;
  font-family: var(--font-text);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.25;
}

.pq-lead,
.pq-state {
  margin: 0 0 var(--space-4);
  color: var(--fg);
}

.pq-note {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.45;
}

/* THE ONE-TIME "FIND YOUR LEVEL" CARD (founder, 23 Nov 2026 00:16).
 *
 * It sits on the done screen as a bordered block, ABOVE the miss list and BELOW the
 * score, so the sitting's own result stays the first thing read. It is deliberately
 * not a coloured banner: this product is monochrome except where colour carries
 * meaning (AGENTS.md §2), and "you may take a test" carries none.
 *
 * Its two controls are the same size on purpose — "Find your level" is an offer, not
 * a demand, and an offer whose refusal is a small grey word beside a big button is
 * not really optional. `.pq-btn-quiet` is the existing quiet button, so nothing here
 * invents a control the product does not already have. */
.pq-offer {
  margin: var(--space-5) 0 0;
  padding: var(--space-4);
  border: 1px solid var(--faint);
}

.pq-offer h2 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-text);
  font-size: var(--step-0);
  font-weight: 600;
}

.pq-offer p {
  margin: 0 0 var(--space-3);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.5;
  max-width: 52ch;
}

.pq-offer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.pq-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}

.pq-concept {
  margin: 0 0 var(--space-3);
  color: var(--fg);
  font-size: var(--step-0);
}

.pq-meter {
  display: flex;
  gap: var(--space-1);
  height: 4px;
  margin: 0 0 var(--space-3);
}

.pq-meter i {
  flex: 1;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.pq-meter i.is-done { background: var(--fg); }
.pq-meter i.is-now { background: var(--muted); }

.pq-prompt,
.pq-ex-b,
.pq-solve {
  font-size: var(--step-1);
  line-height: 1.6;
}

.pq-prompt > :first-child,
.pq-ex-b > :first-child,
.pq-solve > :first-child { margin-top: 0; }

.pq-prompt > :last-child,
.pq-ex-b > :last-child,
.pq-solve > :last-child { margin-bottom: 0; }

.pq-ex {
  margin: 0 0 var(--space-4);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: var(--surface);
}

.pq-ex summary {
  min-height: var(--tap);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--step-0);
}

.pq-ex-b { padding: 0 var(--space-4) var(--space-4); }

.pq-answer { margin: var(--space-4) 0; }

.pq-opts,
.pq .fmt-opts { display: grid; gap: var(--space-2); }

.pq button,
.pq .fmt-chip {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
}

.pq-opt,
.pq .fmt-opt {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: var(--tap);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  cursor: pointer;
}

.pq-opt.is-on,
.pq .fmt-opt.on,
.pq .fmt-pair.is-active,
.pq .fmt-chip.is-on {
  border-color: var(--fg);
  background: var(--surface-2);
}

.pq-opt.is-good,
.pq .fmt-opt.good,
.pq .fmt-step.good,
.pq .fmt-pair.good {
  border-color: var(--ok);
}

.pq-opt.is-bad,
.pq .fmt-opt.bad,
.pq .fmt-step.bad,
.pq .fmt-pair.bad {
  border-color: var(--bad);
}

.pq-opt.is-good .pq-key,
.pq .fmt-mark.ok { color: var(--ok); }

.pq-opt.is-bad .pq-key,
.pq .fmt-mark.no { color: var(--bad); }

.pq .fmt-opt.missed { border-style: dashed; border-color: var(--ok); }
.pq .fmt-mark.miss { color: var(--ok); }

.pq-key,
.pq .fmt-opt .k,
.pq .fmt-n {
  flex: 0 0 auto;
  min-width: 1.6em;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.pq-ov,
.pq .fmt-opt .ov,
.pq .fmt-txt { flex: 1; min-width: 0; max-width: 100%; }

.pq-ov .katex,
.pq .fmt-opt .ov .katex,
.pq .fmt-txt .katex { font-size: 1.12em; }

/* Fractions inside a matrix answer option.
 *
 * The view sets those fractions as `\dfrac` (`optionMath` in quiz/question.js).
 * That is the whole fix: KaTeX gives a `\dfrac` its full size, so the digits come
 * out the same height as the integers in the same matrix (20.16px against
 * 20.16px, measured at 390px — `\frac` gave 14.1px against 20.16px and was the
 * "tiny" the student reported). The row pitch already has a 1.6 strut from
 * core.js, and the measured gap between two stacked fractions is 17px, so
 * nothing collides and the option grows by 8px rather than needing a new rule. */

.pq .yuz-math-field,
.pq math-field { max-width: 100%; min-width: 0; }

.pq-opt:disabled,
.pq .fmt-opt:disabled { cursor: default; opacity: 1; }

.pq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-4);
}

/* The Check / Next bar stays reachable on a laptop.
 *
 * On a 1440×900 or 1280×800 screen the card's action sat below the fold: the
 * student had to scroll to find Check on every question, which is two decisions
 * per answer instead of one. The bar is sticky to the bottom of the viewport
 * while the question is on screen. Monochrome, one hairline, the same button.
 *
 * Three things it must not do:
 *   - cover the phone tab bar: `body` already reserves --tap for it, and the bar
 *     adds that reservation below 720px;
 *   - sit under MathLive's keyboard: math-keyboard.css raises --yuz-vk-height and
 *     hides the tab bar while it is up, so the bar rides above the plate;
 *   - float over the summary screen: on that page the same class is the plain
 *     row of trailing buttons, so `pq-actions-end` opts out. */
.pq-q > .pq-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: var(--space-4) calc(var(--space-4) * -1) 0;
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--faint);
}

.pq-q > .pq-actions .pq-hint { flex: 1 1 12rem; }

/* The summary's trailing buttons are a plain row, not the question's bar. */
.pq-actions-end {
  position: static;
  bottom: auto;
  margin: var(--space-4) 0 0;
  padding: 0;
  background: none;
  border-top: 0;
}

/* The phone tab bar is 44px at the bottom and the sticky bar rides above it. */
@media (max-width: 719px) {
  .pq-q > .pq-actions { bottom: calc(var(--tap) + env(safe-area-inset-bottom)); }
  html.yuz-vk-open .pq-q > .pq-actions { bottom: var(--yuz-vk-height, 0px); }
}

.pq-btn,
a.pq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  text-decoration: none;
  cursor: pointer;
}

.pq-btn-quiet,
a.pq-btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.pq button.pq-btn-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.pq button:disabled { cursor: default; opacity: 0.45; }
.pq button:disabled.pq-opt,
.pq button:disabled.fmt-opt { opacity: 1; }

.pq :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.pq-hint { margin: 0; color: var(--muted); font-family: var(--font-ui); font-size: var(--step--1); }
.pq-hint.ok { color: var(--ok); }
.pq-hint.no { color: var(--bad); }

/* A key hint on a device with no keys.
 *
 * The footer told a phone "1–4 or A–D selects. Enter checks, then moves on." —
 * three instructions about a keyboard that is not attached, in the space where
 * the student expects the verdict. `data-keys` is set on the instruction only and
 * removed when the line becomes Correct / Incorrect, so a phone still sees the
 * verdict. No script: the rule is in effect at first paint, so nothing flashes. */
@media (hover: none) and (pointer: coarse) {
  .pq-hint[data-keys] { display: none; }
}

.pq-live {
  min-height: 6.5rem;
  margin-top: var(--space-4);
}

.pq-live[tabindex="-1"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.pq-verdict {
  margin: 0 0 var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--step-1);
  font-weight: 600;
}

.pq-verdict.ok { color: var(--ok); }
.pq-verdict.no { color: var(--bad); }

/* THE OFFLINE NOTICE (CRITIC-11, Sev-2). One calm sentence in the space the verdict
 * would have used, in the muted text colour rather than the failure red: nothing was
 * refused and nothing was lost, so colouring it like a wrong answer would tell the
 * learner the opposite of what happened. It sits in `.pq-live`, which is the polite
 * live region, so a screen-reader user hears it once without it interrupting what
 * they were doing. */
.pq-offline {
  margin: 0 0 var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  color: var(--muted);
  border-left: 3px solid var(--line);
  padding-left: var(--space-3);
}

.pq-diag,
.pq-trick,
.pq-solve {
  margin: 0 0 var(--space-3);
}

.pq-diag b,
.pq-trick b {
  display: block;
  margin-bottom: var(--space-1);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: 600;
}

.pq-expected,
.pq-solve { overflow-x: auto; }

.pq code {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

.pq-typed textarea,
.pq-typed input.typed-in,
.pq textarea.typed-in,
.pq math-field {
  display: block;
  width: 100%;
  min-height: var(--tap);
  margin-top: var(--space-2);
  padding: var(--space-3);
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step-0);
  line-height: 1.45;
}

/* "Your answer · one number".
 *
 * The label used to be the bare hint: a lowercase fragment ("one number", "one
 * row per line") sitting above the box with nothing saying it described the
 * answer rather than the question. The two parts are named so the shape reads as
 * a property of the field, and the separator is decorative only. */
.pq-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-ui);
  font-size: var(--step-0);
}

.pq-label-what { font-weight: 600; }
.pq-label-sep { color: var(--muted); }
.pq-label-kind { color: var(--muted); }

.pq-score {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: var(--step-3);
  line-height: 1;
}

.pq-score span {
  color: var(--muted);
  font-size: var(--step-1);
}

.pq-block { margin-top: var(--space-6); }
.pq-block h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--step-1);
  font-weight: 600;
}

.pq-miss,
.pq-ladder,
.pq-queue,
.pq-choose,
.pq-lens {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pq-miss li,
.pq-ladder li,
.pq-queue li,
.pq-lens li,
.pq-card {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--faint);
}

.pq-card h2,
.pq-card h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--step-1);
}

.pq-choose a {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  min-height: var(--tap);
  padding: var(--space-3) 0;
  color: inherit;
  text-decoration: none;
  border-top: 1px solid var(--faint);
}

.pq-choose-id {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.pq-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.pq-link {
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--step-0);
}

.pq-missing { color: var(--muted); }

/* Format widgets, restyled. The markup comes from /js/formats.js. */

.pq .fmt { margin: 0; }
.pq .fmt-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.pq .fmt-kind,
.pq .fmt-prog {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.pq .fmt-hint { margin: 0 0 var(--space-3); color: var(--muted); font-size: var(--step-0); }
/* The tick-all count, beside the boxes it counts. Monochrome, one step down, and
   always present — a blank where a count should be reads as "the click did
   nothing". */
.pq .fmt-count {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.pq .fmt-count[data-count] { min-height: 1.4em; }

/* The one-line explanation of a skill that slipped from Solid back to Learning.
 * It sits directly under the state word it explains, one step down and muted, so
 * it reads as a note on the state rather than as a second paragraph of the card.
 * Monochrome: it describes a state, and colour belongs only to right and wrong. */
.ladder-drop {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.45;
}

/* Why a right answer did not count. Sits with the score, above the demotion
 * note: it explains the number the student is looking at ("4/4") rather than a
 * state change, and the two can appear on the same set. Monochrome and muted —
 * it is a fact about the ladder's rules, not a verdict on the answer, and colour
 * here belongs only to right and wrong. A left rule marks it as an aside without
 * adding a second typeface or a colour. */
.pq .assisted {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-3);
  border-left: 2px solid color-mix(in srgb, var(--fg) 22%, transparent);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.45;
}
.pq .fmt-stage { margin-bottom: var(--space-4); }
.pq .fmt-stage-h {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.pq .fmt-stage.is-locked { opacity: 0.55; }
.pq .fmt-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.pq .fmt-step {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: none;
}
.pq .fmt-step.is-dragging { border-color: var(--fg); background: var(--surface-2); }
.pq .fmt-mv { display: flex; flex-direction: column; gap: var(--space-1); margin-left: auto; }
.pq .fmt-mv button {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: var(--surface-2);
}
.pq .fmt-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.pq .fmt-chip {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}
.pq .fmt-pairs { display: grid; gap: var(--space-2); }
.pq .fmt-pair {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
}
.pq .fmt-left { display: flex; gap: var(--space-2); align-items: flex-start; flex: 1 1 12rem; }
.pq .fmt-sel {
  min-height: var(--tap);
  min-width: 5rem;
  padding: var(--space-2);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  font: inherit;
}
.pq .fmt-fb { margin-top: var(--space-3); }
.pq .fmt-fb-h {
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.pq .fmt-part {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--faint);
}
.pq .fmt-part.ok .fmt-part-h { color: var(--ok); }
.pq .fmt-part.no .fmt-part-h { color: var(--bad); }
.pq .fmt-actions { display: none; }

/* Exam chrome */

.pq-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: baseline;
  margin: 0 calc(var(--space-4) * -1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--faint);
}

.pq-bar-title { margin: 0; font-family: var(--font-ui); font-size: var(--step-0); }
.pq-clock { margin: 0; font-variant-numeric: tabular-nums; }
.pq-clock b { font-family: var(--font-mono); font-weight: 600; }

.pq-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.pq-jump {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: transparent;
}

.pq-jump.is-now { border-color: var(--fg); background: var(--surface-2); }
.pq-jump.is-done { background: var(--surface); }
.pq-jump.is-flagged { border-style: dashed; }

.pq-time { min-height: 0; margin: 0; }
.pq-time:empty { display: none; }

.pq-result { border-top: 1px solid var(--faint); padding: var(--space-3) 0; }
.pq-result summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: baseline;
  min-height: var(--tap);
  cursor: pointer;
}
.pq-result-b { padding-top: var(--space-3); --flow: var(--space-3); }
/* A SCROLLING LIST MUST STOP ABOVE THE PHONE TAB BAR.
 *
 * `40vh` measures the WINDOW, not the space the fixed 44px bar takes, so a long
 * list's last inch sat under the tab bar and its final row was covered until
 * something else scrolled. The offset lives HERE, beside the base rule, rather
 * than in the phone block earlier in the file: a later declaration at the same
 * specificity wins, so the media-query version was silently overridden and changed
 * nothing (measured twice before this note). */
.pq-lens { max-height: 40vh; overflow: auto; }
@media (max-width: 719px) {
  .pq-lens { max-height: calc(40vh - var(--tap) - env(safe-area-inset-bottom)); }
}

/* The working slot's failure state: a visible message and a retry, because a
   slot that fails silently keeps saying "Loading the working…" forever and
   toggling the details made no request at all. Monochrome; the button reuses
   the quiet style so nothing new is introduced. */

.pq-work-err {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--faint);
}
.pq-work-err .pq-note { margin: 0 0 var(--space-2); }

/* Submitting a paper with blanks asks first, in the page. */

.pq-confirm {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--fg);
  background: var(--bg);
}
.pq-confirm-t {
  margin: 0 0 var(--space-2);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  font-weight: 600;
}
.pq-confirm .pq-note { margin: 0; }
.pq-confirm .pq-actions { margin-top: var(--space-3); }

@media (max-width: 640px) {
  .pq { padding-inline: var(--space-3); }
  .pq .fmt-pair { align-items: stretch; }
  .pq-bar { margin-inline: calc(var(--space-3) * -1); }
}

/* Exam readiness. Greys only: mastered is solid, then ready, in progress, not started. */

.ex-ready { margin-bottom: var(--space-6); }

.ex-ready h2,
.ex-papers h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--step-1);
  font-weight: 600;
}

.ex-card {
  margin: 0 0 var(--space-5);
  padding: var(--space-4) 0 0;
  border-top: 1px solid var(--faint);
  border-top-color: color-mix(in srgb, var(--fg) 16%, transparent);
}

.ex-head h3 {
  margin: 0;
  font-family: var(--font-text);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.25;
}

.ex-when,
.ex-days,
.ex-count {
  margin: var(--space-2) 0 0;
}

.ex-days,
.ex-count {
  font-variant-numeric: tabular-nums;
}

.ex-count { font-weight: 600; }

.ex-bar {
  display: flex;
  height: 8px;
  margin: var(--space-3) 0 var(--space-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}

.ex-bar > span { display: block; height: 100%; min-width: 0; }
.ex-bar .is-mastered { background: var(--fg); }
.ex-bar .is-ready { background: color-mix(in srgb, var(--fg) 62%, var(--bg)); }
.ex-bar .is-progress { background: color-mix(in srgb, var(--fg) 36%, var(--bg)); }
.ex-bar .is-none { background: color-mix(in srgb, var(--fg) 14%, var(--bg)); }

.ex-legend,
.ex-shown,
.ex-mod-count,
.ex-past-n,
.ex-skill-state {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.ex-legend,
.ex-shown,
.ex-empty { margin: var(--space-2) 0 0; }

.ex-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

/* On a phone the paper and the gap are each their own full-width row: two
   primary buttons sharing a 390px line put "Sit Mock Exam 2" and "Practise what
   is not ready" edge to edge with nothing between them. */
.ex-actions .ex-go { width: 100%; }

.ex-sit { order: -1; }

@media (min-width: 720px) {
  .ex-actions .ex-go { width: auto; }
  /* The paper and the gap are both primary, so they sit side by side with the
     paper first; wrapping is left to the phone. */
  .ex-actions { justify-content: flex-start; }
}

.ex-tools {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-3);
}

.ex-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--faint);
  border-color: color-mix(in srgb, var(--fg) 18%, transparent);
  border-radius: var(--radius);
}

.ex-filters button {
  appearance: none;
  min-height: var(--tap);
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: calc(var(--radius) - 1px);
  cursor: pointer;
  padding: 0 var(--space-2);
}

.ex-filters button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

.ex-search {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ex-search span {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}

.ex-search input {
  font-size: 1rem;
  line-height: 1.4;
  min-height: var(--tap);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--faint);
  border-color: color-mix(in srgb, var(--fg) 28%, transparent);
  border-radius: var(--radius);
}

.ex-past { margin: var(--space-4) 0 var(--space-5); }

.ex-mod,
.ex-past { border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent); }

.ex-mod > summary,
.ex-past > summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  cursor: pointer;
  list-style: none;
}

.ex-mod > summary::-webkit-details-marker,
.ex-past > summary::-webkit-details-marker { display: none; }

.ex-mod > summary::before,
.ex-past > summary::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 1.5px solid var(--fg);
  border-bottom: 1.5px solid var(--fg);
  transform: rotate(-45deg);
  flex: none;
}

.ex-mod[open] > summary::before,
.ex-past[open] > summary::before { transform: rotate(45deg); }

.ex-mod-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--step-0);
  line-height: 1.35;
}

.ex-mod-count { white-space: nowrap; }

.ex-past > summary { font-weight: 600; }
.ex-past-n { font-weight: 400; }

.ex-skills {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-3);
}

.ex-skill {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-top: 1px solid color-mix(in srgb, var(--fg) 10%, transparent);
}

.ex-skill-title {
  margin: 0;
  font-size: var(--step-0);
  line-height: 1.4;
}

.ex-skill-state { margin: var(--space-1) 0 0; }

/* The two links are a two-column grid, always.
 *
 * They used to be a wrapping flex row, so a narrow row stacked them and a wide
 * one put them side by side: the same two buttons sat at different heights down
 * one list, which reads as an unfinished layout rather than as emphasis. A grid
 * gives every row the same shape at every width, and the labels keep their own
 * line. The `.sr` text inside each link (which names the skill) does not take
 * width, so it cannot be what decides the wrap. */
.ex-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  width: 100%;
}

.ex-links a {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  color: var(--fg);
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--fg) 28%, transparent);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  white-space: nowrap;
}

@media (min-width: 720px) {
  .ex-skill {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }
  .ex-skill-main { min-width: 0; flex: 1 1 auto; }
  .ex-links { flex: 0 0 auto; width: 21rem; }
}

.ex-mod[hidden],
.ex-skill[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .pq, .pq * { scroll-behavior: auto; transition: none; animation: none; }
}
