/* ==========================================================================
   ZAKADEMY — main stylesheet
   Structure: reset · type · layout · header · footer · components · pages
   Rule: --muted is never used for text. Meta text uses --slate (AA on both
   grounds). --cyan / --gold / --light-blue appear on dark grounds only.
   ========================================================================== */

/* ---------- 1. Reset ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

img, picture, svg, video { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }

/* ---------- 2. Typography ------------------------------------------------- */
h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: var(--navy);
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); font-weight: 600; }
h3 { font-size: var(--t-h3); font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: 1.0625rem; font-weight: 600; letter-spacing: 0; }

p { text-wrap: pretty; }
.lead { font-size: var(--t-lead); color: var(--slate); max-width: 62ch; }
.small { font-size: var(--t-small); }
.meta { font-size: var(--t-small); color: var(--slate); }

/* Small headings inside a card or a form. Sentence case: capitals are kept for
   the pills, the stat tiles and the Watch out box, which is how the Zakademy
   PDFs use them. */
.label, .field-title, .filter-title, .aside-title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--navy);
}
.field-title, .filter-title, .aside-title { display: block; }
.watchout .label, .answerbox .label {
  font-size: var(--t-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

a { color: var(--royal); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

strong, b { font-weight: 600; }
code, kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--panel);
  padding: 0.1em 0.38em;
  border-radius: var(--r-sm);
}

/* ---------- 3. Focus & skip link ------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.on-dark :focus-visible, .band :focus-visible, .hero :focus-visible {
  outline-color: var(--cyan);
}

.skip-link {
  position: absolute;
  left: var(--s4); top: -100px;
  z-index: 200;
  background: var(--navy);
  color: #fff;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--t-state) var(--ease-out);
}
:root[data-theme="dark"] .skip-link { background: var(--royal); color: #04142F; }
.skip-link:focus { top: var(--s4); }

/* ---------- 4. Layout ----------------------------------------------------- */
.container {
  width: min(100% - (var(--gutter) * 2), var(--container));
  margin-inline: auto;
}
.container-narrow { width: min(100% - (var(--gutter) * 2), 760px); margin-inline: auto; }

.section { padding-block: clamp(3rem, 1.6rem + 5vw, 5.5rem); }
.section-sm { padding-block: clamp(2rem, 1.2rem + 3vw, 3.5rem); }

.section-head { margin-bottom: var(--s8); max-width: 64ch; }
.section-head p { color: var(--slate); margin-top: var(--s3); }
.section-head h1 + p { font-size: var(--t-lead); }
.tint { background: var(--card); }

.grid { display: grid; gap: var(--s6); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 262px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }

.stack > * + * { margin-top: var(--s4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }

/* ---------- 5. Dark bands + orbit-ring motif ------------------------------ */
/* The signature decoration from the Zakademy banner artwork: faint concentric
   rings with gold ticks, used behind every dark band. */
.band {
  position: relative;
  isolation: isolate;
  background-color: var(--deep-navy);
  background-image:
    radial-gradient(120% 140% at 78% 10%, var(--mid-navy) 0%, var(--deep-navy) 46%, var(--deeper-navy) 100%);
  color: var(--on-dark);
  overflow: clip;
}
.band h1, .band h2, .band h3 { color: var(--on-dark); }
.band p { color: var(--on-dark-soft); }
/* written with :where() so that a button or a chip on a dark band keeps its own text colour */
.band :where(a) { color: var(--cyan); }

.band::before,
.band::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}
.band::before {
  width: 46rem; height: 46rem;
  right: -14rem; top: -16rem;
  background: radial-gradient(circle, rgb(0 94 252 / 0.16) 0%, transparent 62%);
}
.band::after {
  width: 34rem; height: 34rem;
  left: -12rem; bottom: -14rem;
  background: radial-gradient(circle, rgb(1 220 253 / 0.09) 0%, transparent 65%);
}

.orbit {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  color: var(--cyan);
}
.orbit svg { width: 100%; height: 100%; }

/* ---------- 6. Header ----------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--page) 90%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border-soft);
  transition: box-shadow var(--t-state) var(--ease-out);
}
.site-header[data-scrolled="true"] { box-shadow: var(--shadow-rest); }

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--s4);
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.brand img { width: 34px; height: 34px; }
.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: 0.08em;
  color: var(--navy);
}

/* the main menu: five entries, four of which open a panel */
.nav { margin-left: var(--s4); margin-right: auto; }
.nav-list { display: flex; align-items: center; gap: 2px; }
.nav-list > li { position: relative; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
  transition: background var(--t-state) var(--ease-out), color var(--t-state) var(--ease-out);
}
.nav-link:hover, .nav-item[open] > .nav-link { background: var(--panel); color: var(--navy); }
.nav-link.is-here, .nav-item.is-here > .nav-link { color: var(--royal); font-weight: 600; }
.nav-caret { width: 14px; height: 14px; opacity: 0.7; transition: transform var(--t-state) var(--ease-out); }
.nav-item[open] .nav-caret { transform: rotate(180deg); }

.nav-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 110;
  min-width: 290px;
  padding: var(--s2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 44px rgb(1 33 111 / 0.16);
}
.nav-menu-right { left: auto; right: 0; }
.nav-menu-wide { min-width: min(720px, 92vw); padding: var(--s4); }
.nav-menu ul { display: grid; gap: 2px; }
.nav-menu li a {
  display: grid;
  gap: 1px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}
.nav-menu li a small { font-size: 0.8125rem; font-weight: 400; color: var(--slate); }
.nav-menu li a:hover { background: var(--panel); color: var(--navy); }
.nav-menu a[aria-current="page"] { background: var(--panel); color: var(--royal); }
.nav-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.nav-col-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  border-radius: var(--r-sm);
}
.nav-col-head:hover { background: var(--panel); }
.nav-code {
  font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.45rem;
  border-radius: var(--r-pill); background: var(--panel); color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.nav-menu-foot {
  display: block;
  margin-top: var(--s2);
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
.nav-menu-foot:hover { text-decoration: underline; }

.header-actions { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }

.countdown {
  display: inline-flex; align-items: center;
  height: 32px; padding: 0 0.7rem;
  border-radius: var(--r-pill);
  background: var(--cream);
  color: var(--amber);
  font-size: 0.8125rem; font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.countdown:hover { text-decoration: underline; }
/* when the countdown is showing, the search button drops its keyboard hint to make room */
.countdown:not([hidden]) ~ .search-trigger kbd { display: none; }
/* just after the row of links appears there is the least room: first the
   countdown waits, then the search button shows only its icon beside it */
@media (min-width: 1081px) and (max-width: 1179px) {
  .countdown { display: none; }
}
@media (min-width: 1180px) and (max-width: 1239px) {
  .countdown:not([hidden]) ~ .search-trigger { position: relative; width: 38px; justify-content: center; padding: 0; }
  .countdown:not([hidden]) ~ .search-trigger .search-trigger-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}

.yt-link {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  color: #D60000;
}
.yt-link:hover { background: var(--panel); }
.yt-link svg { width: 22px; height: 22px; }
:root[data-theme="dark"] .yt-link { color: #FF5A5A; }

.theme-toggle {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--slate);
  transition: background var(--t-state) var(--ease-out), color var(--t-state) var(--ease-out);
}
.theme-toggle:hover { background: var(--panel); color: var(--navy); }
.theme-toggle svg { width: 19px; height: 19px; }
:root[data-theme="dark"] .icon-sun,
:root:not([data-theme="light"]) .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon { display: block; }
.icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
  :root:not([data-theme="light"]) .yt-link { color: #FF5A5A; }
}
:root[data-theme="light"] .icon-sun  { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* Show sidebar: on screen whenever the sidebar is not (see section 69) */
.sb-show {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--navy);
}
.sb-show:hover { border-color: var(--royal); color: var(--royal); }
.sb-show svg { width: 22px; height: 22px; flex: 0 0 22px; }

/* Below this width the row of links steps aside: everything in it is in the
   sidebar, and on phones in the bar at the bottom of the screen too. */
@media (max-width: 1080px) {
  .nav { display: none; }
}
@media (max-width: 560px) {
  .countdown { display: none; }
  .yt-link { display: none; }
}

/* ---------- 7. Buttons ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform var(--t-state) var(--ease-out),
              background var(--t-state) var(--ease-out),
              border-color var(--t-state) var(--ease-out),
              color var(--t-state) var(--ease-out),
              box-shadow var(--t-state) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-primary { background: var(--royal); color: #fff; box-shadow: var(--shadow-rest); }
.btn-primary:hover { background: #0050DC; box-shadow: var(--shadow-raise); }
:root[data-theme="dark"] .btn-primary { background: #0F5FE8; color: #fff; }
:root[data-theme="dark"] .btn-primary:hover { background: #0B4FC4; }

.btn-secondary { background: var(--card-solid); color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--royal); color: var(--royal); }

.btn-ghost { color: var(--navy); }
.btn-ghost:hover { background: var(--panel); }

/* on dark grounds */
.band .btn-secondary, .hero .btn-secondary {
  background: rgb(255 255 255 / 0.07);
  border-color: rgb(255 255 255 / 0.28);
  color: #fff;
  backdrop-filter: blur(6px);
}
.band .btn-secondary:hover, .hero .btn-secondary:hover {
  background: rgb(255 255 255 / 0.14);
  border-color: var(--cyan);
  color: #fff;
}

.btn-yt { background: #E00000; color: #fff; }
.btn-yt:hover { background: #C50000; }

.btn-sm { min-height: 38px; padding: 0.4rem 0.85rem; font-size: 0.875rem; }
.btn-lg { min-height: 52px; padding: 0.85rem 1.75rem; font-size: 1rem; }

/* ---------- 8. Pills, chips, tags ----------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-navy  { background: var(--navy); color: #fff; }
.pill-panel { background: var(--panel); color: var(--navy); }
.pill-code  { background: var(--panel); color: var(--navy); letter-spacing: 0.02em; text-transform: none; font-variant-numeric: tabular-nums; }
.pill-gold  { background: rgb(245 180 0 / 0.16); color: #8A6400; }
.pill-green { background: var(--mint); color: var(--green-text); }
.pill-outline { border: 1px solid var(--border); color: var(--slate); }
:root[data-theme="dark"] .pill-navy { background: var(--royal); color: #04142F; }
:root[data-theme="dark"] .pill-gold { background: rgb(245 180 0 / 0.2); color: var(--gold); }

.band .pill-panel, .hero .pill-panel {
  background: rgb(255 255 255 / 0.1);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 0.18);
}

.marks-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--r-sm);
  background: var(--navy);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .marks-pill { background: var(--royal); color: #04142F; }

/* ---------- 9. Stat tiles -------------------------------------------------- */
.stats { display: flex; flex-wrap: wrap; gap: var(--s6) var(--s8); }
.stat { min-width: 0; }
.stat-n {
  display: block;
  font-family: var(--font-display);
  font-size: var(--t-stat);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}
.stat-l {
  display: block;
  margin-top: 0.45rem;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--slate);
}
.band .stat-n, .hero .stat-n { color: #fff; }
.band .stat-l, .hero .stat-l { color: var(--light-blue); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s4);
}
.stat-tile {
  padding: var(--s4) var(--s4) var(--s4) var(--s4);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.stat-tile .stat-n { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }

/* ---------- 10. Cards ------------------------------------------------------ */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s6);
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-rest);
  transition: border-color var(--t-state) var(--ease-out);
}
.card:has(> .card-link):hover, .card:has(h3 > .card-link):hover { border-color: var(--royal); }

/* whole-card link via overlay — keeps nested actions clickable */
.card-link { text-decoration: none; color: inherit; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card h3 a { text-decoration: none; color: inherit; }
.card-top { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.card-foot {
  margin-top: auto;
  padding-top: var(--s3);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  font-size: var(--t-small);
  color: var(--slate);
}
.card-stats { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: var(--t-small); color: var(--slate); }
.card-stats b { color: var(--navy); font-weight: 600; font-variant-numeric: tabular-nums; }
/* The default look for a paragraph in a card. It is written with :where() so
   that it never outranks a component's own class: the focus timer's clock, a
   quiz score or a form's error message keep the size and colour their own rule
   gives them when they sit inside a card. */
.card :where(p) { font-size: 0.9375rem; color: var(--slate); }
/* a card on a dark band keeps the card's text colour, not the band's */
.band .card :where(p) { color: var(--slate); }
.band .card h2, .band .card h3, .band .card h4 { color: var(--navy); }

/* subject card with a coloured spine */
.subject-card { padding-left: calc(var(--s6) + 4px); overflow: hidden; }
.subject-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent, var(--royal));
}
.subject-card .code {
  font-family: var(--font-display);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--ls-label);
  color: var(--accent, var(--royal));
}

/* YouTube on the home page: one icon to tap, and one line beside it once the
   channel has an address. The icon is
   drawn in the channel's red, so the play triangle shows the page behind it. */
.yt-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s4) var(--s8); }
.yt-badge {
  display: grid; place-items: center;
  flex: 0 0 auto;
  width: 96px; height: 76px;
  border-radius: var(--r-lg);
  color: #D60000;
  transition: transform var(--t-state) var(--ease-out);
}
.yt-badge svg { width: 84px; height: 84px; }
.yt-badge:hover { transform: scale(1.06); }
.yt-line {
  max-width: 26ch;
  font-family: var(--font-display);
  font-size: var(--t-h3);
  font-weight: 600;
  line-height: var(--lh-snug);
  color: var(--navy);
}
:root[data-theme="dark"] .yt-badge { color: #FF5A5A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .yt-badge { color: #FF5A5A; }
}
@media (max-width: 560px) {
  .yt-strip { flex-direction: column; text-align: center; }
}

/* ---------- 11. Watch out / answer boxes ---------------------------------- */
.watchout {
  position: relative;
  padding: var(--s4) var(--s6);
  padding-left: calc(var(--s6) + 4px);
  background: var(--cream);
  border-radius: var(--r-md);
  font-size: 0.9375rem;
}
.watchout::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--gold); border-radius: var(--r-md) 0 0 var(--r-md); }
.watchout .label { color: var(--amber); display: block; margin-bottom: var(--s2); }

.answerbox { padding: var(--s4) var(--s6); background: var(--mint); border-radius: var(--r-md); font-size: 0.9375rem; }
.answerbox .label { color: var(--green-text); display: block; margin-bottom: var(--s2); }

/* ---------- 12. Breadcrumbs ------------------------------------------------ */
.breadcrumb { padding-block: var(--s4); font-size: var(--t-small); }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.breadcrumb li { display: flex; align-items: center; gap: 0.5rem; color: var(--slate); }
.breadcrumb li + li::before { content: "·"; color: var(--slate); }
.breadcrumb a { color: var(--slate); text-decoration: none; }
.breadcrumb a:hover { color: var(--royal); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--navy); font-weight: 500; }
/* on a dark band the breadcrumb and the chips use the light text colours */
.band .breadcrumb li, .band .breadcrumb a, .band .breadcrumb li + li::before { color: var(--on-dark-soft); }
.band .breadcrumb a:hover { color: #fff; }
.band .breadcrumb [aria-current="page"] { color: var(--on-dark); }

/* ---------- 13. Tables ----------------------------------------------------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.data-table { font-size: 0.9375rem; min-width: 620px; }
.table { font-size: 0.9375rem; }
.data-table thead th, .table thead th {
  background: var(--navy);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  padding: 0.7rem var(--s4);
  white-space: nowrap;
}
:root[data-theme="dark"] .data-table thead th, :root[data-theme="dark"] .table thead th { background: var(--panel); color: var(--ink); }
.data-table td, .data-table tbody th, .table td, .table tbody th {
  padding: 0.75rem var(--s4); border-top: 1px solid var(--border-soft); vertical-align: middle;
}
.table tbody th { font-weight: 500; color: var(--navy); }
.table td small { color: var(--slate); white-space: nowrap; }
.data-table tbody tr:hover, .table tbody tr:hover { background: var(--card); }
.data-table .num, .table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .topic-no {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent, var(--royal));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.data-table a, .table a { font-weight: 500; text-decoration: none; }
.data-table a:hover, .table a:hover { text-decoration: underline; }
.table-actions { display: flex; gap: var(--s2); justify-content: flex-end; }

/* ---------- 14. Forms ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label { font-size: 0.9375rem; font-weight: 500; color: var(--ink); }
.field .hint { font-size: var(--t-small); color: var(--slate); }
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: border-color var(--t-state) var(--ease-out), box-shadow var(--t-state) var(--ease-out);
}
.textarea { min-height: 140px; resize: vertical; line-height: var(--lh-body); }
.input:hover, .select:hover, .textarea:hover { border-color: #AFC4EC; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 3px rgb(0 94 252 / 0.15);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: #C0392B; }
.error-msg { font-size: var(--t-small); color: #C0392B; font-weight: 500; display: none; }
.error-msg[data-show="true"] { display: block; }
:root[data-theme="dark"] .error-msg { color: #FF8A7A; }
:root[data-theme="dark"] .input[aria-invalid="true"] { border-color: #FF8A7A; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6785' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 18px;
  padding-right: 2.4rem;
}
.form-status { padding: var(--s4); border-radius: var(--r-md); font-size: 0.9375rem; }
.form-status[data-state="success"] { background: var(--mint); color: var(--green-text); }
.form-status[data-state="error"] { background: #FDECEA; color: #A5281B; }
:root[data-theme="dark"] .form-status[data-state="error"] { background: #3A1512; color: #FFB4A8; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- 15. Accordion (FAQ) -------------------------------------------- */
.accordion { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.accordion details + details { border-top: 1px solid var(--border-soft); }
.accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s6);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--navy);
  list-style: none;
  transition: background var(--t-state) var(--ease-out);
}
.accordion summary:hover { background: var(--card); }
.accordion summary::after {
  content: "";
  flex-shrink: 0;
  width: 10px; height: 10px;
  border-right: 2px solid var(--slate);
  border-bottom: 2px solid var(--slate);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--t-layout) var(--ease-out);
}
.accordion details[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.accordion .acc-body { padding: 0 var(--s6) var(--s6); color: var(--slate); font-size: 0.9375rem; }
.accordion .acc-body > * + * { margin-top: var(--s3); }

/* ---------- 16. Catalogue -------------------------------------------------- */
.catalogue { display: grid; grid-template-columns: 260px 1fr; gap: var(--s8); align-items: start; }
@media (max-width: 900px) { .catalogue { grid-template-columns: 1fr; gap: var(--s6); } }

.filters { position: sticky; top: calc(var(--header-h) + var(--s4)); }
@media (max-width: 900px) { .filters { position: static; } }
.filter-group + .filter-group { margin-top: var(--s6); }
.filter-group > .label { display: block; color: var(--slate); margin-bottom: var(--s3); }
.filter-opt { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; font-size: 0.9375rem; cursor: pointer; min-height: 32px; }
.filter-opt input { width: 17px; height: 17px; accent-color: var(--royal); flex-shrink: 0; cursor: pointer; }
.filter-opt .n { margin-left: auto; font-size: var(--t-small); color: var(--slate); font-variant-numeric: tabular-nums; }
.filter-opt:hover { color: var(--royal); }

.search-row { display: flex; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.search-box { position: relative; flex: 1 1 280px; }
.search-box svg { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--slate); pointer-events: none; }
.search-box .input { padding-left: 2.6rem; }

.result-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s6); font-size: 0.9375rem; color: var(--slate); }
.result-bar b { color: var(--navy); font-variant-numeric: tabular-nums; }

.empty-state { padding: var(--s16) var(--s6); text-align: center; border: 1px dashed var(--border); border-radius: var(--r-md); }
.empty-state h3 { margin-bottom: var(--s3); }
.empty-state p { color: var(--slate); margin-bottom: var(--s6); }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--card-solid);
  font-size: var(--t-small);
  color: var(--slate);
  cursor: pointer;
  min-height: 32px;
}
.chip:hover { border-color: var(--royal); color: var(--royal); }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.band .chip { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.3); color: var(--on-dark); }
.band .chip:hover { border-color: var(--cyan); color: var(--cyan); }
:root[data-theme="dark"] .chip[aria-pressed="true"] { background: var(--royal); border-color: var(--royal); color: #04142F; }

/* ---------- 17. Hero + intro ----------------------------------------------- */
.hero {
  position: relative;
  isolation: isolate;
  background-color: var(--deep-navy);
  background-image:
    radial-gradient(110% 130% at 72% 8%, var(--mid-navy) 0%, var(--deep-navy) 44%, var(--deeper-navy) 100%);
  color: var(--on-dark);
  overflow: clip;
  padding-top: clamp(2.5rem, 1.5rem + 4vw, 4.5rem);
}
.hero h1, .hero h2 { color: #fff; }
.hero p { color: var(--on-dark-soft); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; z-index: -1; }
.hero::before { width: 52rem; height: 52rem; right: -16rem; top: -18rem; background: radial-gradient(circle, rgb(0 94 252 / 0.2) 0%, transparent 62%); }
.hero::after  { width: 38rem; height: 38rem; left: -14rem; bottom: -16rem; background: radial-gradient(circle, rgb(1 220 253 / 0.1) 0%, transparent 65%); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: var(--s8);
  align-items: end;
}
@media (max-width: 920px) {
  .hero-grid { grid-template-columns: 1fr; gap: var(--s6); }
}

.hero-copy { padding-bottom: clamp(2.5rem, 1.5rem + 4vw, 4.5rem); }
.hero h1 {
  font-size: var(--t-display);
  letter-spacing: -0.025em;
  margin-bottom: var(--s4);
}
.hero-sub { font-size: var(--t-lead); max-width: 48ch; margin-bottom: var(--s6); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s8); }
@media (max-width: 560px) {
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; }
}
.hero-rule { height: 1px; background: rgb(255 255 255 / 0.16); margin-bottom: var(--s6); max-width: 34rem; }

/* the sticker */
.hero-figure { position: relative; display: flex; justify-content: center; align-items: flex-end; min-height: 300px; }
.hero-figure img {
  width: min(100%, 430px);
  position: relative;
  z-index: 1;
}
@media (max-width: 920px) {
  .hero-figure img { width: min(74%, 330px); }
  .hero-copy { padding-bottom: var(--s4); }
}
.hero-figure .halo {
  position: absolute;
  bottom: 4%;
  left: 50%;
  translate: -50% 0;
  width: min(108%, 500px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(0 94 252 / 0.36) 0%, rgb(1 220 253 / 0.1) 42%, transparent 68%);
  z-index: 0;
}


/* ---------- 18. Intro curtain ---------------------------------------------- */
#intro {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background-color: var(--deep-navy);
  background-image: radial-gradient(120% 130% at 50% 40%, var(--mid-navy) 0%, var(--deep-navy) 45%, var(--deeper-navy) 100%);
  overflow: hidden;
}
#intro[hidden] { display: none; }
.intro-inner { display: grid; justify-items: center; text-align: center; padding: var(--gutter); }
.intro-logo { width: clamp(96px, 18vw, 140px); opacity: 0; transform: scale(0.72); }
.intro-word {
  margin-top: var(--s6);
  display: flex;
  gap: clamp(0.18em, 0.6vw, 0.3em);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 0.9rem + 2.6vw, 2.5rem);
  color: #fff;
  letter-spacing: 0.06em;
}
.intro-word span { opacity: 0; transform: translateY(14px); display: inline-block; }
.intro-tag {
  margin-top: var(--s4);
  font-family: var(--font-display);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0;
}
.intro-skip {
  position: absolute;
  top: var(--s6); right: var(--s6);
  z-index: 2;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: var(--r-pill);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0;
  animation: fadeIn 400ms 900ms var(--ease-out) forwards;
}
.intro-skip:hover { background: rgb(255 255 255 / 0.12); border-color: var(--cyan); }

/* curtain choreography */
.intro-ring { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.intro-ring div {
  position: absolute;
  border: 1px solid rgb(1 220 253 / 0.22);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
}
.intro-ring div:nth-child(1) { width: 300px; height: 300px; }
.intro-ring div:nth-child(2) { width: 520px; height: 520px; border-color: rgb(1 220 253 / 0.14); }
.intro-ring div:nth-child(3) { width: 760px; height: 760px; border-color: rgb(1 220 253 / 0.08); }

@keyframes fadeIn    { to { opacity: 1; } }
@keyframes logoIn    { to { opacity: 1; transform: scale(1); } }
@keyframes letterIn  { to { opacity: 1; transform: none; } }
@keyframes ringIn    { to { opacity: 1; transform: scale(1); } }
@keyframes curtainUp { to { opacity: 0; transform: translateY(-14%); visibility: hidden; } }

html[data-intro="running"] { overflow: hidden; }
html[data-intro="running"] body { overflow: hidden; }

#intro[data-play="true"] .intro-logo   { animation: logoIn 760ms 80ms var(--ease-spring) forwards; }
#intro[data-play="true"] .intro-word span { animation: letterIn 460ms var(--ease-out) forwards; animation-delay: calc(460ms + var(--i) * 52ms); }
#intro[data-play="true"] .intro-tag    { animation: fadeIn 600ms 1080ms var(--ease-out) forwards; }
#intro[data-play="true"] .intro-ring div:nth-child(1) { animation: ringIn 900ms 120ms var(--ease-out) forwards; }
#intro[data-play="true"] .intro-ring div:nth-child(2) { animation: ringIn 1000ms 220ms var(--ease-out) forwards; }
#intro[data-play="true"] .intro-ring div:nth-child(3) { animation: ringIn 1100ms 320ms var(--ease-out) forwards; }
#intro[data-dismiss="true"] { animation: curtainUp 620ms var(--ease-out) forwards; }

/* the hero reveal that follows the curtain */
@keyframes slideFromRight { from { opacity: 0; transform: translateX(42%) scale(0.94) rotate(2.5deg); } to { opacity: 1; transform: none; } }
@keyframes riseIn         { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes haloIn         { from { opacity: 0; transform: translate(-50%, 0) scale(0.6); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }


body[data-reveal="go"] .hero-figure img { animation: slideFromRight 1100ms 60ms var(--ease-spring) backwards; }
body[data-reveal="go"] .hero-figure .halo { animation: haloIn 1000ms 220ms var(--ease-out) forwards; }
body[data-reveal="go"] .reveal { animation: riseIn 640ms var(--ease-out) forwards; animation-delay: calc(var(--d, 0) * 1ms); }

.intro-replay {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: var(--t-small);
  color: var(--on-dark-fine);
  background: none;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.intro-replay:hover { color: var(--cyan); }

/* ---------- 19. Resource detail -------------------------------------------- */
.resource-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s8); align-items: start; }
@media (max-width: 860px) { .resource-head { grid-template-columns: 1fr; } }
.resource-actions { display: flex; flex-direction: column; gap: var(--s3); min-width: 260px; }
.resource-actions .btn { width: 100%; }
.dl-meta { font-size: var(--t-small); color: var(--slate); text-align: center; }

.terms-note {
  padding: var(--s4) var(--s6);
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-md);
  font-size: 0.9375rem;
  color: var(--slate);
}
.terms-note .label { color: var(--navy); display: block; margin-bottom: var(--s2); }

.contents-list { display: grid; gap: var(--s2); }
.contents-list li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s3);
  padding: 0.6rem var(--s4);
  background: var(--card);
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
}
.contents-list .k { font-weight: 600; color: var(--navy); font-family: var(--font-display); }
.contents-list .v { margin-left: auto; color: var(--slate); font-size: var(--t-small); font-variant-numeric: tabular-nums; }

.pdf-frame { width: 100%; aspect-ratio: 1 / 1.35; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--card); }
@media (min-width: 760px) { .pdf-frame { aspect-ratio: 16 / 11; } }

/* ---------- 20. Prose (legal + long form) ---------------------------------- */
.prose { max-width: 70ch; }
.prose > * + * { margin-top: var(--s4); }
.prose h2 { margin-top: var(--s12); font-size: 1.375rem; }
.prose h3 { margin-top: var(--s8); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose ul li { list-style: disc; margin-top: 0.4rem; }
.prose ol li { list-style: decimal; margin-top: 0.4rem; }
.prose li::marker { color: var(--royal); }
.prose p, .prose li { color: var(--slate); }
.prose strong { color: var(--ink); }

.clause { scroll-margin-top: calc(var(--header-h) + 2rem); }
.clause h2 {
  display: flex; align-items: baseline; gap: var(--s3);
  font-size: 1.1875rem;
  padding-top: var(--s8);
  border-top: 1px solid var(--border-soft);
}
.clause h2 .n { font-size: 0.875rem; color: var(--gold-text); font-weight: 700; }
.clause-summary { font-size: 0.9375rem; color: var(--ink); background: var(--card); border-radius: var(--r-md); padding: var(--s3) var(--s4); }
.toc { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s6); }
.toc ol { display: grid; gap: 0.35rem; counter-reset: c; }
.toc li { counter-increment: c; font-size: 0.9375rem; }
.toc li::before { content: counter(c) ". "; color: var(--gold-text); font-weight: 700; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--royal); text-decoration: underline; }

/* ---------- 21. Footer ------------------------------------------------------ */
.site-footer { background: var(--deep-navy); color: var(--on-dark-soft); padding-top: var(--s16); margin-top: var(--s16); }
.footer-grid { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: var(--s8) var(--s6); padding-bottom: var(--s12); }
@media (max-width: 1000px) {
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}
/* beside the sidebar (section 69) the footer is 248 px narrower than the window */
@media (min-width: 1169px) and (max-width: 1248px) and (hover: hover) and (pointer: fine) {
  :root:not([data-sidebar="hidden"]) .footer-grid { grid-template-columns: repeat(4, 1fr); }
  :root:not([data-sidebar="hidden"]) .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 620px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.site-footer h2 { font-size: 0.9375rem; font-weight: 600; color: #fff; margin-bottom: var(--s4); }
.site-footer ul { display: grid; gap: 0.55rem; }
.site-footer a { color: var(--on-dark-soft); text-decoration: none; font-size: 0.9375rem; }
.site-footer a:hover { color: var(--cyan); text-decoration: underline; }
.footer-brand img { width: 46px; height: 46px; margin-bottom: var(--s4); }
.footer-brand .word { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; letter-spacing: 0.1em; color: #fff; }
.footer-brand .tag { font-family: var(--font-display); font-size: var(--t-small); color: var(--cyan); margin-top: 0.3rem; }
.footer-legal { border-top: 1px solid rgb(255 255 255 / 0.12); padding-block: var(--s6); display: grid; gap: var(--s3); font-size: var(--t-small); color: var(--on-dark-fine); }
.footer-legal .row { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between; }
.footer-legal a { font-size: var(--t-small); color: var(--on-dark-fine); }
/* keep the small print clear of the back-to-top button, which sits in the corner */
@media (max-width: 1339px) { .footer-legal { padding-right: 3.5rem; } }
@media (min-width: 1169px) and (max-width: 1587px) and (hover: hover) and (pointer: fine) {    /* the same, beside the sidebar */
  :root:not([data-sidebar="hidden"]) .footer-legal { padding-right: 3.5rem; }
}
.social-row { display: flex; gap: var(--s3); }
.social-row a { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgb(255 255 255 / 0.2); border-radius: var(--r-sm); color: #fff; }
.social-row a:hover { border-color: var(--cyan); color: var(--cyan); }
.social-row svg { width: 19px; height: 19px; }

/* ---------- 22. Utilities ---------------------------------------------------- */
/* The hidden attribute must beat every component display rule, or filtered
   cards stay on screen. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.text-center { text-align: center; }
.mx-auto { margin-inline: auto; }
.mt-6 { margin-top: var(--s6); }
.mt-8 { margin-top: var(--s8); }
.mt-12 { margin-top: var(--s12); }
.mb-6 { margin-bottom: var(--s6); }
.divider { height: 1px; background: var(--border-soft); border: 0; }
.nowrap { white-space: nowrap; }

/* ---------- 23. Reduced motion ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 24. Print ---------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .filters, #intro, .hero-figure { display: none; }
  body { color: #000; background: #fff; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* ==========================================================================
   25. HERO FIGURE — composition
   Zak's cut-out is drawn exactly as he made it, white outline included. There
   is no mask, filter or transform on the picture: each of those has a browser
   redraw it softer, and the mask also cut the glow into a visible box.
   The picture has a few fixed sizes, and for each one there is a file with
   exactly the pixels a 1x, 2x or 3x screen needs (tools/make_pictures.py), so
   the browser copies the file to the screen and never rescales it. Change a
   size here and the files and the <picture> on the home page change with it.
   From 1169 px a laptop or desktop has the sidebar beside the page (section
   69) and the hero has 248 px less room, so the sizes step down there and
   come back further up. Each step is where the picture keeps at least 18.9 px
   clear of the hero text (the closest it comes without the sidebar, at
   921 px). These sizes go by the window's width alone, on every device: a
   hidden sidebar, or a tablet that never has one beside the page, keeps the
   size the picture has beside the sidebar, with more room round it, and the
   <source> and the box still match pixel for pixel.
   ========================================================================== */
.hero-grid { align-items: end; }

.hero-figure {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  align-self: end;
  justify-self: end;                      /* as wide as the picture, with its right edge on the page's right margin */
  min-height: 0;
  margin-bottom: calc(var(--s6) * -1);    /* the flat cut at the bottom of the picture sits just below the band's edge */
  z-index: 1;
}

.hero-figure picture { display: block; position: relative; z-index: 1; }

.hero-figure img {
  width: 553px; height: 710px;      /* the 2x file is 1106 x 1420, which is Zak's own file */
  max-width: none;
}

/* pool of light he is standing in */
.hero-figure .halo {
  position: absolute;
  left: 50%; bottom: -2%;
  translate: -50% 0;
  width: min(128%, 660px);
  aspect-ratio: 1 / 0.82;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, rgb(0 94 252 / 0.40) 0%, rgb(1 220 253 / 0.12) 48%, transparent 72%);
  filter: blur(6px);
  z-index: 0;
}


@media (max-width: 1418px) {
  .hero-figure img { width: 440px; height: 565px; }    /* beside the sidebar, 1246 to 1418 px */
}
@media (max-width: 1245px) {
  .hero-figure img { width: 400px; height: 514px; }    /* beside the sidebar, 1169 to 1245 px */
}
@media (max-width: 1168px) {
  .hero-figure img { width: 440px; height: 565px; }    /* no sidebar beside the page: as before */
}
@media (max-width: 1039px) {
  .hero-figure img { width: 400px; height: 514px; }    /* still two columns down to 921 px: the smaller size keeps clear of the search box */
}
@media (max-width: 920px) {
  .hero-figure { margin-bottom: calc(var(--s8) * -1); margin-top: var(--s6); justify-self: center; }
  .hero-figure img { width: 400px; height: 514px; }
  .hero-figure .halo { width: min(100%, 420px); }
}
/* 3x screens in the two 400 px ranges get Zak's file itself again: 1104 x 1419 is 368 x 473 at three pixels per point */
@media (min-width: 479.1px) and (max-width: 1039px) and (-webkit-min-device-pixel-ratio: 2.5),
       (min-width: 479.1px) and (max-width: 1039px) and (min-resolution: 2.5dppx),
       (min-width: 1168.1px) and (max-width: 1245px) and (-webkit-min-device-pixel-ratio: 2.5),
       (min-width: 1168.1px) and (max-width: 1245px) and (min-resolution: 2.5dppx) {
  .hero-figure img { width: 368px; height: 473px; }
}
@media (max-width: 479px) {
  .hero-figure img { width: 300px; height: 385px; }
}
@media (max-width: 345px) {
  .hero-figure img { width: 260px; height: 334px; }    /* the narrowest phones */
}


/* ==========================================================================
   26. READER (on-site PDF viewer)
   ========================================================================== */
body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: clamp(0px, 2vw, 28px);
}
.viewer[hidden] { display: none; }

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(3 9 26 / 0.74);
  backdrop-filter: blur(6px);
  animation: fadeIn 200ms var(--ease-out);
}

.viewer-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(94vh, 100%);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: clamp(0px, 1.2vw, var(--r-lg));
  box-shadow: 0 32px 90px rgb(2 8 28 / 0.55);
  overflow: hidden;
  animation: viewerIn 280ms var(--ease-spring);
}
@keyframes viewerIn { from { opacity: 0; transform: translateY(16px) scale(0.985); } to { opacity: 1; transform: none; } }

.viewer-bar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.viewer-meta { display: flex; align-items: center; gap: var(--s3); min-width: 0; flex: 1 1 240px; }
.viewer-meta h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
}
.viewer-tools { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.viewer-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.viewer-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 5px;
  color: var(--slate);
  transition: background var(--t-state) var(--ease-out), color var(--t-state) var(--ease-out);
}
.viewer-btn:hover { background: var(--panel); color: var(--navy); }
.viewer-btn svg { width: 17px; height: 17px; }
.viewer-close { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.viewer-pageinput {
  width: 46px;
  height: 30px;
  text-align: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
}
.viewer-pageinput:focus { outline: 2px solid var(--royal); outline-offset: -1px; }
.viewer-count { font-size: 0.8125rem; color: var(--slate); padding-right: 0.45rem; font-variant-numeric: tabular-nums; }
.viewer-zoom {
  min-width: 52px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--slate);
  font-variant-numeric: tabular-nums;
}

.viewer-stage {
  flex: 1;
  overflow: auto;            /* both axes: a zoomed page is wider than the pane */
  overscroll-behavior: contain;
  background: #6B7280;
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  /* Not align-items:center. A flex item wider than its container overflows
     equally on both sides, and the left half becomes unreachable by scrolling.
     Centring with auto inline margins keeps every edge reachable when zoomed. */
  align-items: flex-start;
  gap: var(--s4);
  -webkit-user-select: none;
  user-select: none;
}
:root[data-theme="dark"] .viewer-stage { background: #0A1028; }
.viewer-stage:focus-visible { outline: 2px solid var(--royal); outline-offset: -2px; }

.viewer-page {
  position: relative;
  flex: 0 0 auto;            /* column flex items shrink by default — that
                                collapsed every page to a thin strip */
  width: min(100%, 980px);   /* a starting value; the zoom sets it in px */
  margin-inline: auto;
  background: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.3);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.viewer-page canvas { display: block; }
.viewer-pagelabel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: #C7CEDC;
}
.viewer-page.is-rendered .viewer-pagelabel { display: none; }

/* a quiet ownership mark over each page */
.viewer-page.is-rendered::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='200'%3E%3Ctext x='150' y='110' font-family='Helvetica,Arial,sans-serif' font-size='15' font-weight='600' fill='%2301216F' fill-opacity='0.055' text-anchor='middle' transform='rotate(-28 150 100)'%3EZAKADEMY · VIEW ONLY%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
}

.viewer-loading, .viewer-error {
  margin: auto;
  text-align: center;
  color: #F2F5FC;
  padding: var(--s8);
  max-width: 44ch;
}
.viewer-error h3 { color: #fff; margin-bottom: var(--s3); }
.viewer-error p { color: #D6DEF0; font-size: 0.9375rem; }
.viewer-error .small { margin-top: var(--s3); opacity: 0.7; font-size: 0.8125rem; }
.viewer-loading { display: flex; align-items: center; gap: 0.6rem; justify-content: center; }
.viewer-spinner {
  width: 17px; height: 17px;
  border: 2px solid rgb(255 255 255 / 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
  padding: 0.6rem var(--s4);
  background: var(--card);
  border-top: 1px solid var(--border);
  font-size: var(--t-small);
  color: var(--slate);
}
.viewer-kbd { display: flex; align-items: center; gap: 0.3rem; }
.viewer-kbd kbd {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--page);
  color: var(--slate);
}
@media (max-width: 760px) {
  .viewer-kbd { display: none; }
  .viewer-meta h2 { font-size: 0.875rem; }
  .viewer-panel { height: 100%; border-radius: 0; }
}
@media print { .viewer { display: none !important; } }

/* ==========================================================================
   27. COMMAND PALETTE  (Cmd/Ctrl + K)
   ========================================================================== */
.palette { position: fixed; inset: 0; z-index: 380; display: grid; place-items: start center; padding: clamp(12px, 8vh, 110px) var(--gutter) var(--gutter); }
.palette[hidden] { display: none; }
.palette-backdrop { position: absolute; inset: 0; background: rgb(3 9 26 / 0.6); backdrop-filter: blur(4px); }
.palette-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 28px 70px rgb(2 8 28 / 0.4);
  overflow: hidden;
  animation: viewerIn 220ms var(--ease-spring);
}
.palette-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.palette-head svg { width: 18px; height: 18px; color: var(--slate); flex-shrink: 0; }
.palette-input { flex: 1; border: 0; background: none; font-size: 1rem; color: var(--ink); min-height: 40px; }
.palette-input:focus { outline: none; }
.palette-results { overflow-y: auto; padding: var(--s2); }
.palette-item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%;
  padding: 0.55rem var(--s3);
  border-radius: var(--r-sm);
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9375rem;
}
.palette-item:hover, .palette-item[aria-selected="true"] { background: var(--panel); }
.palette-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .k { font-size: 0.8125rem; font-weight: 600; color: var(--slate); flex-shrink: 0; }
.palette-empty { padding: var(--s8) var(--s4); text-align: center; color: var(--slate); font-size: 0.9375rem; }
.palette-foot { padding: 0.5rem var(--s4); border-top: 1px solid var(--border); font-size: var(--t-small); color: var(--slate); display: flex; gap: var(--s4); }

.search-trigger {
  display: inline-flex; align-items: center; gap: 0.5rem;
  height: 38px; padding: 0 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--card-solid);
  color: var(--slate);
  font-size: 0.875rem;
}
.search-trigger:hover { border-color: var(--royal); color: var(--royal); }
.search-trigger svg { width: 16px; height: 16px; }
.search-trigger kbd {
  font-family: var(--font-body); font-size: 0.6875rem;
  padding: 0.1rem 0.3rem; border: 1px solid var(--border); border-radius: 4px; color: var(--slate);
  white-space: nowrap;
}
@media (max-width: 1139px) {
  /* keep the label in the accessibility tree when the button collapses to an
     icon, so its accessible name still matches what it does */
  .search-trigger .search-trigger-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .search-trigger kbd { display: none; }
  .search-trigger { position: relative; width: 38px; justify-content: center; padding: 0; }
}

/* ==========================================================================
   28. REVISION PROGRESS
   ========================================================================== */
.progress-head { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.progress-bar { flex: 1 1 200px; height: 7px; background: var(--panel); border-radius: var(--r-pill); overflow: hidden; min-width: 140px; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--accent, var(--royal)); border-radius: inherit; transition: width 400ms var(--ease-out); }
.progress-count { font-size: var(--t-small); color: var(--slate); font-variant-numeric: tabular-nums; white-space: nowrap; }

.topic-state { width: 1%; }
.state-select {
  appearance: none;
  min-height: 30px; padding: 0.15rem 1.5rem 0.15rem 0.55rem;
  font-size: 0.75rem; font-weight: 600; font-family: var(--font-display);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--card-solid); color: var(--slate); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6785' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.4rem center; background-size: 13px;
}
.state-select:hover { border-color: var(--royal); }
tr[data-state="1"] .state-select { border-color: #D9A441; color: #8A5A00; background-color: var(--cream); }
tr[data-state="2"] .state-select { border-color: var(--green); color: var(--green-text); background-color: var(--mint); }
:root[data-theme="dark"] tr[data-state="1"] .state-select { color: var(--amber); }
/* A done row reads as done by colour, never by dimming: opacity blends the
   link into the page and drops it under 4.5:1. The row's state select
   carries the same information in text, so colour is not the only cue. */
.data-table tr[data-state="2"] .topic-title a { color: var(--slate); font-weight: 400; }

/* ==========================================================================
   29. READING PROGRESS BAR + RECENTLY VIEWED
   ========================================================================== */
.scrollbar-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--royal), var(--cyan));
  z-index: 150;
  transition: width 80ms linear;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { .scrollbar-progress { display: none; } }

.recent-row { display: flex; gap: var(--s3); flex-wrap: wrap; }
.recent-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--card-solid);
  font-size: var(--t-small);
  color: var(--ink);
  text-decoration: none;
  /* never wider than the row: on a 320 px phone a long name made the page
     24 px wider than the screen */
  min-width: 0;
  max-width: min(320px, 100%);
}
.recent-chip:hover { border-color: var(--royal); color: var(--royal); }
.recent-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   30. PREV / NEXT
   ========================================================================== */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-top: var(--s12); }
@media (max-width: 620px) { .pager { grid-template-columns: 1fr; } }
.pager a {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: var(--s4) var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  background: var(--card-solid);
  transition: border-color var(--t-state) var(--ease-out);
}
.pager a:hover { border-color: var(--royal); }
.pager .dir { font-family: var(--font-display); font-size: 0.8125rem; font-weight: 600; color: var(--slate); }
.pager .ttl { font-weight: 500; color: var(--navy); font-size: 0.9375rem; }
.pager .next { text-align: right; }

/* ==========================================================================
   31. Narrow header
   ========================================================================== */
@media (max-width: 480px) {
  .header-inner { gap: var(--s2); }
  .brand-word { font-size: 1rem; letter-spacing: 0.06em; }
}
/* the narrowest phones: the logo and the sidebar, search and theme buttons still fit on one row */
@media (max-width: 345px) {
  .header-inner { gap: 6px; }
  .header-actions { gap: 4px; }
  .brand { gap: 0.45rem; }
  .brand img { width: 30px; height: 30px; }
  .brand-word { font-size: 0.9375rem; letter-spacing: 0.04em; }
}

/* ==========================================================================
   32. Hero subject links — replaces the old statistics row
   ========================================================================== */
.hero-subjects { display: flex; flex-wrap: wrap; gap: var(--s3); }
.hero-subjects a {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 0.6rem 1rem;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / 0.06);
  backdrop-filter: blur(6px);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--t-state) var(--ease-out),
              background var(--t-state) var(--ease-out),
              transform var(--t-state) var(--ease-out);
}
.hero-subjects a:hover {
  border-color: var(--cyan);
  background: rgb(255 255 255 / 0.12);
}
.hero-subjects .c {
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.hero-copy { padding-bottom: clamp(3rem, 2rem + 4vw, 5rem); }
@media (max-width: 920px) { .hero-copy { padding-bottom: var(--s6); } }

/* ==========================================================================
   33. STUDY PLANNER
   ========================================================================== */
.plan-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--s8); align-items: start; }
@media (max-width: 900px) { .plan-grid { grid-template-columns: 1fr; } }
.plan-setup { position: sticky; top: calc(var(--header-h) + var(--s4)); gap: var(--s6); }
@media (max-width: 900px) { .plan-setup { position: static; } }
.plan-setup .field + .field { margin-top: var(--s2); }
.plan-setup .hint { margin-top: var(--s2); }

.plan-stats { margin-bottom: var(--s8); }

.plan-today-card { border-color: var(--royal); box-shadow: 0 10px 34px rgb(0 94 252 / 0.14); }
.plan-today-head .label { color: var(--royal); display: block; margin-bottom: var(--s1); }
.plan-today-head h2 { font-size: var(--t-h3); }
.plan-done h2 { font-size: var(--t-h3); margin-bottom: var(--s3); }

.plan-list { display: grid; gap: var(--s2); margin-top: var(--s4); }
.plan-item {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: 0.65rem var(--s4);
  background: var(--card);
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
}
.plan-item-title { font-weight: 500; color: var(--navy); text-decoration: none; flex: 1 1 200px; min-width: 0; }
.plan-item-title:hover { text-decoration: underline; }
.plan-item-meta { font-size: var(--t-small); color: var(--slate); white-space: nowrap; }

.plan-day {
  display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--s4);
  padding: var(--s4) 0; border-top: 1px solid var(--border-soft); align-items: start;
}
@media (max-width: 620px) { .plan-day { grid-template-columns: 1fr; gap: var(--s2); } }
.plan-day-date {
  font-family: var(--font-display); font-size: var(--t-small); font-weight: 600;
  color: var(--slate); padding-top: 0.7rem;
}
.plan-day.is-past { opacity: 0.55; }
.plan-day.is-past .plan-day-date { color: #A1262B; }
.plan-day .plan-list { margin-top: 0; }

/* ==========================================================================
   34. OFFLINE NOTICE
   ========================================================================== */
.offline-bar {
  position: fixed; left: 50%; bottom: var(--s6); translate: -50% 0;
  z-index: 160;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: var(--navy); color: #fff;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-raise);
  font-size: var(--t-small);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-layout) var(--ease-out), translate var(--t-layout) var(--ease-out);
}
.offline-bar[data-show="true"] { opacity: 1; translate: -50% -4px; pointer-events: auto; }
.offline-bar::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); flex-shrink: 0;
}
:root[data-theme="dark"] .offline-bar { background: var(--panel); color: var(--ink); }

/* ==========================================================================
   35. TOPIC PAGES — the unit a student studies
   ========================================================================== */
.topic-head { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: var(--s8); align-items: start; }
@media (max-width: 900px) { .topic-head { grid-template-columns: 1fr; } }
.topic-head h1 { font-size: var(--t-h1); }
.topic-quick { margin-top: var(--s6); }
.band h1 + .lead { margin-top: var(--s2); }
.topic-aside { position: sticky; top: calc(var(--header-h) + var(--s4)); gap: 0; }
@media (max-width: 900px) { .topic-aside { position: static; } }
.topic-aside .label { color: var(--navy); }
.topic-aside[data-state="1"] { border-color: #D9A441; }
.topic-aside[data-state="2"] { border-color: var(--green); }

.steps { display: grid; gap: var(--s4); counter-reset: s; }
.step {
  display: grid; grid-template-columns: 44px minmax(0,1fr); gap: var(--s4);
  padding: var(--s6);
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  align-items: start;
}
.step.is-empty { background: var(--card); border-style: dashed; }
.step.is-empty .step-n { background: var(--panel); color: var(--slate); }
.step-n {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 0.9375rem;
}
:root[data-theme="dark"] .step-n { background: var(--royal); color: #04142F; }
.step-body h3 { font-size: 1.0625rem; margin-bottom: var(--s2); }
.step-body p { color: var(--slate); font-size: 0.9375rem; }

.covers-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.covers-list li {
  padding: 0.45rem 0.85rem;
  background: var(--panel);
  border-radius: var(--r-pill);
  font-size: 0.9375rem;
  color: var(--navy);
  font-weight: 500;
}

/* ==========================================================================
   36. TIMED PRACTICE
   ========================================================================== */
.timerbox {
  position: fixed; right: var(--s6); bottom: var(--s6);
  z-index: 180;
  width: min(300px, calc(100vw - 2 * var(--gutter)));
  padding: var(--s6);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 50px rgb(2 8 28 / 0.28);
  text-align: center;
}
.timerbox[hidden] { display: none; }
.timer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.timer-head .label { color: var(--slate); text-align: left; }
.timer-clock {
  font-family: var(--font-display); font-weight: 700;
  font-size: 2.75rem; line-height: 1; letter-spacing: -0.02em;
  color: var(--navy); font-variant-numeric: tabular-nums;
}
.timerbox[data-over="true"] .timer-clock { color: #C0392B; }
:root[data-theme="dark"] .timerbox[data-over="true"] .timer-clock { color: #FF8A7A; }
.timerbox[data-paused="true"] .timer-clock { opacity: 0.45; }
.timer-bar { height: 5px; background: var(--panel); border-radius: var(--r-pill); overflow: hidden; margin: var(--s3) 0; }
.timer-bar i { display: block; height: 100%; width: 0; background: var(--royal); transition: width 1s linear; }
.timerbox[data-over="true"] .timer-bar i { background: #C0392B; }
.timer-sub { font-size: var(--t-small); color: var(--slate); margin-bottom: var(--s4); }
@media (max-width: 560px) { .timerbox { right: var(--gutter); left: var(--gutter); width: auto; } }

/* ==========================================================================
   37. DASHBOARD extras
   ========================================================================== */
.streak-row { display: flex; flex-wrap: wrap; gap: var(--s6); align-items: center; }
.due-list { display: grid; gap: var(--s2); }
.due-item {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: 0.65rem var(--s4);
  background: var(--cream);
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
}
.due-item .late { font-size: var(--t-small); color: var(--amber); font-weight: 600; white-space: nowrap; }
.due-item a { font-weight: 500; color: var(--navy); text-decoration: none; flex: 1 1 180px; }
.due-item a:hover { text-decoration: underline; }
.weak-list { display: grid; gap: var(--s2); }
.weak-item {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: 0.6rem var(--s4); background: var(--card); border-radius: var(--r-sm); font-size: 0.9375rem;
}
.weak-item a { flex: 1 1 180px; color: var(--navy); text-decoration: none; font-weight: 500; }
.weak-item a:hover { text-decoration: underline; }
.weak-bar { width: 90px; height: 6px; background: var(--panel); border-radius: var(--r-pill); overflow: hidden; }
.weak-bar i { display: block; height: 100%; background: var(--royal); }

/* ==========================================================================
   38. Shared small pieces used by the exam room, progress and toolkit
   ========================================================================== */
.hint { font-size: var(--t-small); color: var(--slate); line-height: var(--lh-snug); }
.eyebrow { font-size: 0.8125rem;
           color: var(--slate); font-weight: 600; margin: 0 0 var(--s1); }
.muted { color: var(--slate); }
.mt-3 { margin-top: var(--s3) !important; }
.mt-4 { margin-top: var(--s4) !important; }
.mb-4 { margin-bottom: var(--s4) !important; }
.form-error { color: #B3261E; font-weight: 500; margin: 0 0 var(--s3); }
[data-theme="dark"] .form-error { color: #FFB4AB; }
.card-head-row { display: flex; flex-wrap: wrap; gap: var(--s4);
                 align-items: baseline; justify-content: space-between; }
.link-more { font-weight: 600; color: var(--royal); }
a.card-link:hover .link-more { text-decoration: underline; }

/* headline figures */
.figure-row { display: grid; gap: var(--s4); margin-bottom: var(--s6);
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.figure { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
        padding: var(--s4) var(--s4) var(--s3); }
.figure .figure-label { font-size: 0.8125rem;
              color: var(--slate); font-weight: 600; margin: 0; }
.figure .figure-num { font-family: var(--font-display); font-size: var(--t-h2); line-height: 1;
            color: var(--navy); margin: var(--s2) 0 var(--s1); }
.figure .figure-foot { font-size: var(--t-small); color: var(--slate); margin: 0; }

/* progress ring — one conic sweep, no SVG needed */
.clock-ring { --p: 100; --sz: 132px; --tk: 11px;
  position: relative; inline-size: var(--sz); block-size: var(--sz); flex: 0 0 auto;
  border-radius: 50%; display: grid; place-items: center;
  background:
    conic-gradient(var(--royal) calc(var(--p) * 1%), var(--panel) 0),
    var(--card);
}
.clock-ring::after { content: ""; position: absolute; inset: var(--tk);
  background: var(--card); border-radius: 50%; }
.clock-ring > span { position: relative; z-index: 1; font-family: var(--font-display);
  font-size: var(--t-h2); line-height: 1; color: var(--navy); font-variant-numeric: tabular-nums; }
.clock-ring > span.is-over { color: #B3261E; }
[data-theme="dark"] .clock-ring > span.is-over { color: #FFB4AB; }
.ring-sm { --sz: 86px; --tk: 8px; }
.ring-sm > span { font-size: var(--t-h3); }
.result-ring { --sz: 150px; }

/* ==========================================================================
   39. Exam room
   ========================================================================== */
.exam-setup { display: grid; gap: var(--s6); }
.exam-field { display: grid; gap: var(--s2); }
.exam-field .hint { margin: 0; }
.scope-grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.scope { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer;
  padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--card); transition: border-color .15s var(--ease-out), background .15s var(--ease-out); }
.scope:hover { border-color: var(--royal); }
.scope input { margin-top: 3px; flex: 0 0 auto; accent-color: var(--royal); }
.scope span { display: block; }
.scope b { display: block; color: var(--navy); }
.scope small { display: block; color: var(--slate); font-size: var(--t-small); line-height: var(--lh-snug); }
.scope:has(input:checked) { border-color: var(--royal); background: var(--panel); }
.scope:has(input:focus-visible) { outline: 2px solid var(--royal); outline-offset: 2px; }

.picklist { max-block-size: 340px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s2); display: grid; gap: 2px; background: var(--card); }
.pick { display: flex; gap: var(--s3); align-items: baseline; padding: var(--s2) var(--s3);
  border-radius: var(--r-sm); cursor: pointer; }
.pick:hover { background: var(--panel); }
.pick input { accent-color: var(--royal); flex: 0 0 auto; }
.pick b { color: var(--navy); margin-right: 2px; }
.pick small { color: var(--slate); }
.pick:has(input:focus-visible) { outline: 2px solid var(--royal); outline-offset: 1px; }

.exam-brief-meta { font-family: var(--font-display); font-size: var(--t-h3); color: var(--royal);
  margin: 0 0 var(--s4); }
.exam-clock { display: flex; gap: var(--s6); align-items: center; flex-wrap: wrap;
  margin-bottom: var(--s6); }
.exam-clock h2 { margin: 0 0 var(--s1); }
.exam-clock .hint { margin: 0; }

.sit-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.sit-row { display: flex; gap: var(--s4); align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: var(--s3) var(--s4); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--card); }
.sit-row-main { display: flex; gap: var(--s3); align-items: baseline; min-inline-size: 0; flex: 1 1 260px; }
.sit-row-main h3 { margin: 0; font-size: var(--t-body); line-height: var(--lh-snug); }
.sit-row-main .meta { margin: 2px 0 0; font-size: var(--t-small); color: var(--slate); }
.sit-n { flex: 0 0 auto; inline-size: 26px; block-size: 26px; border-radius: 50%;
  background: var(--panel); color: var(--navy); display: grid; place-items: center;
  font-size: var(--t-small); font-weight: 700; font-variant-numeric: tabular-nums; }
.sit-row-mark .sit-row-main { align-items: flex-start; flex-direction: row; }
.mark-in { display: flex; gap: var(--s2); align-items: center; flex: 0 0 auto; }
.mark-in input { inline-size: 76px; text-align: center; font-variant-numeric: tabular-nums;
  padding: var(--s2); border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--page); color: var(--ink); font: inherit; }
.mark-in input:focus-visible { outline: 2px solid var(--royal); outline-offset: 1px; }
.mark-of { color: var(--slate); font-variant-numeric: tabular-nums; }
.mark-foot { display: flex; gap: var(--s4); align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--border); }
.mark-total { font-family: var(--font-display); font-size: var(--t-h3); color: var(--navy); margin: 0;
  font-variant-numeric: tabular-nums; }

.result-head { display: flex; gap: var(--s6); align-items: center; flex-wrap: wrap; }
/* the text beside the ring takes the spare room; the ring itself stays a circle */
.result-head > div:not(.clock-ring), .exam-clock > div:not(.clock-ring) { min-inline-size: 0; flex: 1 1 200px; }
.result-head h2 { margin: 0 0 var(--s2); }
.result-head p { margin: 0 0 var(--s2); }
.res-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.res-row-top { display: flex; justify-content: space-between; gap: var(--s4); align-items: baseline;
  margin-bottom: var(--s1); }
.res-row-top b { font-variant-numeric: tabular-nums; color: var(--navy); }
.res-row a { color: var(--navy); font-weight: 500; }
.res-bar { block-size: 8px; background: var(--panel); border-radius: var(--r-pill); overflow: hidden; }
.res-bar i { display: block; block-size: 100%; background: var(--royal); }
.res-bar[data-tone="ok"] i { background: var(--green-text); }
.res-bar[data-tone="mid"] i { background: var(--gold-text); }
.res-bar[data-tone="low"] i { background: #B3261E; }
[data-theme="dark"] .res-bar[data-tone="low"] i { background: #FF8A80; }

.hist-head { display: flex; gap: var(--s6); align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: var(--s4); }
.hist-avg { font-family: var(--font-display); font-size: var(--t-h3); margin: 0; color: var(--navy); }
.hist-avg b { color: var(--royal); }
.spark { inline-size: 240px; block-size: 48px; color: var(--royal); flex: 0 0 auto; }

/* ==========================================================================
   40. Progress — rank bar, readiness, heatmap, charts
   ========================================================================== */
.xp-num { font-family: var(--font-display); font-size: var(--t-h3); color: var(--royal); margin: 0;
  font-variant-numeric: tabular-nums; }
.xp-bar { block-size: 10px; background: var(--panel); border-radius: var(--r-pill);
  overflow: hidden; margin: var(--s3) 0 var(--s2); }
.xp-bar i { display: block; block-size: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--royal), var(--cyan)); transition: width .4s var(--ease-out); }

.ready-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.ready-card { display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap;
  padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card); }
.ready-card > div { min-inline-size: 0; flex: 1 1 120px; }
.ready-card h3 { margin: 0 0 2px; font-size: var(--t-body); }
.ready-card .meta { margin: 0; font-size: var(--t-small); color: var(--slate); }

.heat-block + .heat-block { margin-top: var(--s4); }
.heat-label { font-size: var(--t-small); font-weight: 600; color: var(--navy); margin: 0 0 var(--s2); }
.heat-label small { font-weight: 400; color: var(--slate); }
.heat-row { display: flex; flex-wrap: wrap; gap: 4px; }
.heat-cell { inline-size: 24px; block-size: 24px; border-radius: 5px; display: block;
  background: var(--panel); border: 1px solid var(--border-soft);
  transition: transform .12s var(--ease-out); }
.heat-cell:hover, .heat-cell:focus-visible { transform: scale(1.22); border-color: var(--navy); }
.heat-cell[data-tone="1"] { background: var(--gold); border-color: var(--gold-text); }
.heat-cell[data-tone="2"] { background: var(--mint); border-color: var(--green-text); }
.heat-key { list-style: none; display: flex; gap: var(--s4); flex-wrap: wrap;
  margin: var(--s4) 0 0; padding: 0; font-size: var(--t-small); color: var(--slate); }
.heat-key li { display: flex; gap: var(--s2); align-items: center; }
.heat-key i { inline-size: 14px; block-size: 14px; border-radius: 4px;
  background: var(--panel); border: 1px solid var(--border-soft); }
.heat-key i[data-tone="1"] { background: var(--gold); border-color: var(--gold-text); }
.heat-key i[data-tone="2"] { background: var(--mint); border-color: var(--green-text); }

.chart-wrap { overflow-x: auto; }
.chart { inline-size: 100%; min-inline-size: 420px; block-size: auto; display: block; }
.ax-grid { stroke: var(--border); stroke-width: 1; }
.ax-text { fill: var(--slate); font-size: 11px; font-family: var(--font-body); }
.ch-line { stroke: var(--royal); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.ch-area { fill: var(--royal); opacity: .10; }
.ch-dot { fill: var(--royal); }
.ch-bar { fill: var(--royal); opacity: .85; }
.ch-bar:hover { opacity: 1; }

/* ==========================================================================
   41. Examiner's toolkit
   ========================================================================== */
.toolkit-nav { display: flex; flex-wrap: wrap; gap: var(--s2); }
.cw-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.cw { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card);
  overflow: hidden; display: flex; flex-direction: column; }
.cw-head { padding: var(--s4); background: var(--panel); border-bottom: 1px solid var(--border); }
.cw-head h3 { margin: 0 0 2px; font-size: var(--t-h3); color: var(--navy); }
.cw-ask { margin: 0; color: var(--slate); font-size: var(--t-small); line-height: var(--lh-snug); }
.cw-body { padding: var(--s4); display: grid; gap: var(--s3); }
.cw-body p { margin: 0; font-size: var(--t-small); line-height: var(--lh-body); }
.cw-body b { color: var(--navy); }
.cw-trap { padding-top: var(--s3); border-top: 1px dashed var(--border); color: var(--slate); }

.recall-card { display: grid; gap: var(--s4); }
.recall-setup { display: grid; gap: var(--s4); align-items: end;
  grid-template-columns: minmax(220px, 2fr) minmax(110px, 1fr) auto; }
.recall-run { display: grid; gap: var(--s4); }
.recall-clock { font-family: var(--font-display); font-size: clamp(2.6rem, 9vw, 4.4rem);
  line-height: 1; color: var(--navy); font-variant-numeric: tabular-nums; }
.recall-clock .is-over { color: #B3261E; }
[data-theme="dark"] .recall-clock .is-over { color: #FFB4AB; }
.recall-steps { margin: 0; padding-left: 1.3em; display: grid; gap: var(--s2); color: var(--ink); }

@media (max-width: 620px) {
  .recall-setup { grid-template-columns: 1fr; }
  .clock-ring:not(.ring-sm):not(.result-ring) { --sz: 108px; --tk: 9px; }
  .result-ring { --sz: 120px; --tk: 10px; }
  .mark-foot { flex-direction: column; align-items: stretch; }
  .mark-foot .btn { inline-size: 100%; }
}
@media print {
  .exam-setup, .toolkit-nav, .mark-foot .btn, .heat-cell:hover { display: revert; }
  .chart { min-inline-size: 0; }
}

/* ==========================================================================
   42. Topic page — the same topic on another paper, and the exam-room call
   ========================================================================== */
.twin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.twin { display: flex; gap: var(--s4); align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: var(--s4); border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--card); }
.twin h3 { margin: 0 0 2px; font-size: var(--t-h3); }
.twin h3 a { color: var(--navy); }
.twin .meta { margin: 0; }

.exam-cta { display: flex; gap: var(--s6); align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: var(--s8); border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--deep-navy), var(--mid-navy)); color: var(--on-dark); }
.exam-cta h2 { color: var(--on-dark); margin: var(--s2) 0; }
.exam-cta p { color: var(--on-dark-soft); margin: 0; max-inline-size: 52ch; }
.exam-cta .label { color: var(--gold); }
.exam-cta .btn-primary { background: #fff; color: var(--deep-navy); border-color: #fff; }
.exam-cta .btn-primary:hover { background: var(--cream); border-color: var(--cream); }

/* ==========================================================================
   43. Today's three jobs
   ========================================================================== */
.mission-head { display: flex; gap: var(--s6); align-items: flex-start;
  justify-content: space-between; flex-wrap: wrap; margin-bottom: var(--s4); }
.mission-rank { min-inline-size: 200px; flex: 0 1 240px; }
.mission-rank .eyebrow { margin-bottom: var(--s2); }
.mission-rank .hint { margin: var(--s2) 0 0; }
.mission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3);
  counter-reset: mission; }
.mission-item { display: flex; gap: var(--s4); align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: var(--s4); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--page); }
.mission-item h3 { margin: var(--s2) 0 2px; font-size: var(--t-body); line-height: var(--lh-snug); }
.mission-item .meta { margin: 0; }

/* ==========================================================================
   44. Why the marks went — the mistake log
   ========================================================================== */
.why { border: 0; margin: var(--s3) 0 0; padding: 0; flex: 1 1 100%; }
.why legend { font-size: 0.8125rem;
  color: var(--slate); font-weight: 600; padding: 0; margin-bottom: var(--s2); }
.why-chip { display: inline-flex; gap: var(--s2); align-items: center; cursor: pointer;
  font-size: var(--t-small); line-height: 1.2; padding: var(--s2) var(--s3); margin: 0 4px 4px 0;
  border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--page);
  color: var(--slate); transition: border-color .15s var(--ease-out), color .15s var(--ease-out); }
.why-chip input { accent-color: var(--royal); margin: 0; }
.why-chip:hover { border-color: var(--royal); }
.why-chip:has(input:checked) { border-color: var(--royal); color: var(--navy); background: var(--panel); }
.why-chip:has(input:focus-visible) { outline: 2px solid var(--royal); outline-offset: 2px; }

.why-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); }
.why-row-top { display: flex; justify-content: space-between; gap: var(--s4); align-items: baseline;
  margin-bottom: var(--s1); }
.why-row-top b { font-variant-numeric: tabular-nums; color: var(--navy); }
.why-row .hint { margin: var(--s2) 0 0; }

/* ==========================================================================
   45. Live quiz
   ========================================================================== */
.field-head { display: flex; gap: var(--s3); align-items: baseline; justify-content: space-between; }
.quiz-opts { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.quiz-live { display: grid; gap: var(--s4); }
.quiz-top { display: flex; gap: var(--s4); align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; }
.quiz-top .eyebrow { margin: 0; }
.quiz-top-right { display: flex; gap: var(--s3); align-items: center; }
.quiz-score { font-family: var(--font-display); font-size: var(--t-h3); margin: var(--s1) 0 0;
  color: var(--navy); font-variant-numeric: tabular-nums; }
.quiz-clock { font-family: var(--font-display); font-size: var(--t-h3); color: var(--navy);
  font-variant-numeric: tabular-nums; }
.quiz-clock.is-over { color: #B3261E; }
[data-theme="dark"] .quiz-clock.is-over { color: #FFB4AB; }
.quiz-bar { block-size: 6px; background: var(--panel); border-radius: var(--r-pill); overflow: hidden; }
.quiz-bar i { display: block; block-size: 100%; background: var(--royal); transition: width .3s var(--ease-out); }

.qdots { display: flex; flex-wrap: wrap; gap: 4px; }
.qdot { inline-size: 26px; block-size: 26px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--card); color: var(--slate); font: inherit; font-size: 11px; font-weight: 600;
  cursor: pointer; display: grid; place-items: center; padding: 0;
  font-variant-numeric: tabular-nums; }
.qdot:hover { border-color: var(--royal); }
.qdot.is-at { outline: 2px solid var(--royal); outline-offset: 1px; }
.qdot.is-right { background: var(--mint); border-color: var(--green-text); color: var(--green-text); }
.qdot.is-wrong { background: #FDE7E7; border-color: #B3261E; color: #B3261E; }
.qdot.is-done { background: var(--gold); border-color: var(--gold-text); color: var(--gold-text); }
[data-theme="dark"] .qdot.is-wrong { background: #3A1512; border-color: #FF8A80; color: #FFB4AB; }

/* the cropped question: always on white, because that is the paper */
.qwrap { position: relative; background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s3); min-block-size: 120px; overflow: hidden; }
.qwrap canvas { display: block; inline-size: 100%; block-size: auto; }
/* The page is drawn inside .qcrop, which hides its white side margins. On a
   wide screen it stops at a comfortable width; zoomed, it is wider than the
   box and the box scrolls sideways. */
.qcrop { overflow: hidden; max-inline-size: 820px; margin-inline: auto; }
/* a question that runs on to another page: each further page under the last */
.qcrop.qpart { margin-top: var(--s2); }
.qcrop.qpart[data-loading] {
  background: linear-gradient(100deg, #EEF3FF 30%, #F9FBFF 50%, #EEF3FF 70%);
  background-size: 300% 100%; animation: qskeleton 1.4s linear infinite;
}
.qcrop.qpart[data-loading] canvas { visibility: hidden; }
.qcrop.qpart-failed { padding: var(--s3); }
.qcrop.qpart-failed canvas { display: none; }
@media (prefers-reduced-motion: reduce) { .qcrop.qpart[data-loading] { animation: none; } }
.qwrap[data-zoomed] { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.qwrap[data-zoomed] .qcrop { max-inline-size: none; margin-inline: 0; }
.qwrap[data-zoomed]:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
.q-bar { display: flex; gap: var(--s3); align-items: flex-start; justify-content: space-between; }
.q-bar .meta { margin: 0; padding-top: 0.35rem; }
.q-zoom { flex: 0 0 auto; }
/* on a phone the question gets the whole width of the screen */
@media (max-width: 560px) {
  .quiz-live { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; padding-inline: var(--s4); }
  .quiz-live .qwrap { margin-inline: calc(-1 * var(--s4)); border-radius: 0; border-inline: 0; padding: var(--s2) 0; }
}

.choices { display: grid; gap: var(--s2); }
.choice-row { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
.choice { font: inherit; cursor: pointer; padding: var(--s4) var(--s3); border-radius: var(--r-md);
  border: 2px solid var(--border); background: var(--card); color: var(--navy);
  transition: border-color .12s var(--ease-out), background .12s var(--ease-out),
              transform .12s var(--ease-out); }
.choice:hover:not(:disabled) { border-color: var(--royal); background: var(--panel); }
.choice:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
.choice:disabled { cursor: default; }
.choice-k { font-family: var(--font-display); font-size: var(--t-h3); line-height: 1; }
.choice.is-right { border-color: var(--green-text); background: var(--mint); color: var(--green-text); }
.choice.is-wrong { border-color: #B3261E; background: #FDE7E7; color: #B3261E; }
.choice.is-key { border-color: var(--green-text); }
.choice.is-key::after { content: " ✓"; }
[data-theme="dark"] .choice.is-wrong { background: #3A1512; border-color: #FF8A80; color: #FFB4AB; }

.verdict { margin: 0; padding: var(--s3) var(--s4); border-radius: var(--r-md);
  border-left: 4px solid var(--royal); background: var(--panel); font-size: var(--t-small);
  line-height: var(--lh-body); }
.verdict.is-right { border-left-color: var(--green-text); background: var(--mint); }
.verdict.is-wrong { border-left-color: #B3261E; background: #FDE7E7; }
.verdict.is-part { border-left-color: var(--gold-text); background: var(--gold); }
[data-theme="dark"] .verdict.is-wrong { background: #3A1512; border-left-color: #FF8A80; }
.explain { display: grid; gap: var(--s2); }
.quiz-foot { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  padding-top: var(--s3); border-top: 1px solid var(--border); }

.qrows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.qrow { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--card); }
.qrow-n { inline-size: 26px; block-size: 26px; border-radius: 50%; background: var(--panel);
  display: grid; place-items: center; font-size: var(--t-small); font-weight: 700;
  flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.qrow-t { flex: 1 1 200px; min-inline-size: 0; }
.qrow-t small { color: var(--slate); }
.qrow-s { font-size: var(--t-small); font-weight: 600; }
.qrow-s small { display: block; font-weight: 400; color: var(--slate); }
.qrow[data-state="right"] .qrow-s { color: var(--green-text); }
.qrow[data-state="wrong"] .qrow-s { color: #B3261E; }
.qrow[data-state="part-marks"] .qrow-s { color: var(--gold-text); }
[data-theme="dark"] .qrow[data-state="wrong"] .qrow-s { color: #FFB4AB; }

@media (max-width: 620px) {
  .choice-row { grid-template-columns: repeat(4, 1fr); }
  .choice { padding: var(--s3) var(--s2); }
  .quiz-foot .btn { flex: 1 1 auto; }
}

/* ==========================================================================
   46. My schedule
   ========================================================================== */
.sched-form { display: grid; gap: var(--s6); }
.paper-group { border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s3) var(--s4) var(--s4); margin: 0 0 var(--s3); }
.paper-group legend { font-size: 0.8125rem; color: var(--slate); font-weight: 600; padding: 0 var(--s2); }

.wk-list { display: grid; gap: var(--s4); }
.wk { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card);
  padding: var(--s6); }
.wk-head { display: flex; gap: var(--s4); align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: var(--s4); padding-bottom: var(--s3);
  border-bottom: 1px solid var(--border); }
.wk-head h3 { margin: 0; font-size: var(--t-h3); }
.wk-head h3 small { font-weight: 400; color: var(--slate); font-size: var(--t-small);
  display: block; margin-top: 2px; }
.wk-mins { font-family: var(--font-display); color: var(--royal); font-size: var(--t-body);
  flex: 0 0 auto; }
.wk-review { background: var(--panel); }
.wk-review p { margin: 0; }
.wk-items { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); }
.wk-item { display: grid; gap: var(--s2); }
.wk-item-head a { color: var(--navy); font-weight: 500; }
.wk-item-head .meta { display: block; margin: 2px 0 0; }
.wk-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1);
  border-left: 3px solid var(--border); padding-left: var(--s4); }
.wk-steps li { font-size: var(--t-small); color: var(--ink); line-height: var(--lh-snug); }
.wk-t { display: inline-block; min-inline-size: 58px; font-weight: 600; color: var(--royal);
  font-variant-numeric: tabular-nums; }

@media print {
  .wk { break-inside: avoid; page-break-inside: avoid; border-color: #999; }
  .wk-steps { border-left-color: #999; }
  .figure-row, .card-head-row .cluster { display: none; }
}

/* ==========================================================================
   47. Reading settings — set in the head before first paint
   ========================================================================== */
:root[data-text="lg"]  { font-size: 112.5%; }
:root[data-text="xl"]  { font-size: 125%; }
:root[data-text="xxl"] { font-size: 140%; }
:root[data-lead="loose"]  { --lh-body: 1.8; --lh-snug: 1.6; }
:root[data-lead="looser"] { --lh-body: 2.0; --lh-snug: 1.75; }
:root[data-measure="narrow"] p, :root[data-measure="narrow"] li { max-inline-size: 58ch; }
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}

/* ==========================================================================
   48. Keyboard shortcut sheet
   ========================================================================== */
.keys { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  padding: var(--s4); background: rgb(6 14 38 / .55); }
.keys-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-raise); padding: var(--s6); max-inline-size: 560px; inline-size: 100%;
  max-block-size: 86vh; overflow-y: auto; display: grid; gap: var(--s4); }
.keys-head { display: flex; gap: var(--s4); align-items: center; justify-content: space-between; }
.keys-head h2 { margin: 0; font-size: var(--t-h3); }
.keys-panel section { display: grid; gap: var(--s2); }
.keys-panel h3 { margin: 0; font-size: 0.8125rem; color: var(--slate); }
.keys-panel dl { margin: 0; display: grid; gap: var(--s1); }
.keys-panel dl > div { display: flex; gap: var(--s4); align-items: baseline; }
.keys-panel dt { margin: 0; flex: 0 0 110px; }
.keys-panel dd { margin: 0; color: var(--ink); font-size: var(--t-small); }
.keys-panel kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--t-small); background: var(--panel); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: var(--r-sm); padding: 1px 6px; color: var(--navy); }
.keys-panel .hint { margin: 0; padding-top: var(--s3); border-top: 1px solid var(--border); }

/* ==========================================================================
   49. A year of study days, and milestones
   ========================================================================== */
.cal-wrap { overflow-x: auto; padding-bottom: var(--s2); }
.cal-months { display: grid; grid-template-columns: repeat(53, 13px); gap: 0;
  font-size: 10px; color: var(--slate); margin-bottom: 2px; min-inline-size: 689px; }
.cal { display: grid; grid-auto-flow: column; grid-template-columns: repeat(53, 13px);
  gap: 0; min-inline-size: 689px; }
.cal-col { display: grid; grid-template-rows: repeat(7, 13px); }
.cal-cell { inline-size: 11px; block-size: 11px; border-radius: 3px; background: var(--panel);
  border: 1px solid var(--border-soft); display: block; }
.cal-cell.is-on { background: var(--royal); border-color: var(--royal); }
.cal-cell.is-future { opacity: .35; }
.heat-key i.is-on { background: var(--royal); border-color: var(--royal); }

.badges { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.badge { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--card);
  color: var(--slate); }
.badge.is-got { border-color: var(--green-text); background: var(--mint); color: var(--navy); }
.badge-tick { flex: 0 0 auto; inline-size: 22px; block-size: 22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--panel); color: var(--slate);
  font-size: 12px; font-weight: 700; }
.badge.is-got .badge-tick { background: var(--green-text); color: #fff; }
.badge b { display: block; font-size: var(--t-small); line-height: var(--lh-snug); }
.badge small { display: block; color: var(--slate); font-size: var(--t-small); }

/* ==========================================================================
   50. Your own notes
   ========================================================================== */
.notes-card { display: grid; gap: var(--s3); }
.notes-area { font: inherit; inline-size: 100%; resize: vertical; min-block-size: 110px;
  padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--page); color: var(--ink); line-height: var(--lh-body); }
.notes-area:focus-visible { outline: 2px solid var(--royal); outline-offset: 1px; }
.notes-foot { display: flex; gap: var(--s3); align-items: center; }
.notes-foot .hint { margin: 0; }

/* ==========================================================================
   51. Revision sheet — built for the printer first
   ========================================================================== */
.rev-sheet { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s8); display: grid; gap: var(--s6); }
.rev-head { padding-bottom: var(--s4); border-bottom: 2px solid var(--navy); }
.rev-head h2 { margin: 0; font-size: var(--t-h2); }
.rev-head .meta { margin: var(--s1) 0 0; }
.rev-block { display: grid; gap: var(--s2); break-inside: avoid; }
.rev-block h3 { margin: 0; font-size: var(--t-h3); }
.rev-block h3 small { font-weight: 400; color: var(--slate); font-size: var(--t-small); }
.rev-block .hint { margin: 0; }
.rev-list { margin: 0; padding-left: 1.4em; display: grid; gap: var(--s1); }
.rev-row { display: flex; gap: var(--s4); justify-content: space-between; flex-wrap: wrap;
  align-items: baseline; }
.rev-row small { color: var(--slate); }
.rev-num { color: var(--slate); font-size: var(--t-small); white-space: nowrap; }
.rev-note { break-inside: avoid; margin-top: var(--s3); }
.rev-note h3 { font-size: var(--t-body); }
.rev-note p { margin: var(--s1) 0 0; font-size: var(--t-small); line-height: var(--lh-body); }
.rev-qlist { font-size: var(--t-small); line-height: var(--lh-body); color: var(--ink); }
.rev-qlist small { color: var(--slate); }
.rev-foot { padding-top: var(--s4); border-top: 1px solid var(--border); }
.rev-foot p { margin: 0; font-size: var(--t-small); color: var(--slate); }

@media print {
  .no-print, .site-header, .site-footer, .breadcrumb, .section-head > .label { display: none !important; }
  .rev-sheet { border: 0; padding: 0; box-shadow: none; }
  .rev-head { border-bottom-color: #000; }
  .rev-block { page-break-inside: avoid; }
  a[href]::after { content: ""; }
}
.find-row { display: flex; gap: var(--s3); flex-wrap: wrap; }
.find-row .input { flex: 1 1 220px; min-inline-size: 0; }

/* ==========================================================================
   52. A <select> is as wide as its longest option
   Grid and flex items do not shrink below min-content, and a select's
   min-content is its widest <option>. One long label was pushing a whole
   card 35px past a 320px viewport, so every control is told it may shrink.
   ========================================================================== */
.select, .input, select, input[type="date"], input[type="search"], input[type="number"] {
  max-inline-size: 100%; min-inline-size: 0;
}
.exam-setup, .sched-form, .exam-field, .quiz-opts > * { min-inline-size: 0; }
.exam-setup { grid-template-columns: minmax(0, 1fr); }
.sched-form { grid-template-columns: minmax(0, 1fr); }
.quiz-opts { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
.scope-grid { grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
.ready-grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.cw-grid { grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr)); }
.badges { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.figure-row { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
/* seven numbers: four then three on a wide screen and two to a row on a phone,
   with each row filling the width so no tile is left on its own */
@media screen {
  [data-prog-stats] { display: flex; flex-wrap: wrap; }
  [data-prog-stats] > .figure { flex: 1 1 calc(50% - var(--s4)); min-width: 0; }
}
@media screen and (min-width: 720px) {
  [data-prog-stats] > .figure { flex-basis: calc(25% - var(--s4)); }
}
.picklist, .pick, .pick span { min-inline-size: 0; }
.pick span { overflow-wrap: anywhere; }
/* A button whose label cannot fit must wrap rather than push the page wider. */
@media (max-width: 520px) {
  .btn { white-space: normal; max-inline-size: 100%; }
}
/* Above 520 px the same holds for a button with a line of its own (in a
   .stack) or in a row that wraps (a .cluster): there it only wraps when its
   label alone is wider than the row, as "Go to the Central Processing Unit
   (CPU) Architecture topic page" and the C.R.O. worksheet's buttons were,
   which made 11 pages wider than the screen at 521 to 669 px. Buttons in a
   table, such as "Open topic" and "Questions", keep one line, and the table
   scrolls sideways as before. */
.stack > .btn, .cluster > .btn { white-space: normal; max-inline-size: 100%; }

/* ==========================================================================
   53. Quiz modes, real past papers, confidence
   ========================================================================== */
.modetabs { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4);
  border-bottom: 1px solid var(--border); padding-bottom: var(--s2); }
.modetab { font: inherit; font-weight: 600; font-size: var(--t-small); cursor: pointer;
  padding: var(--s2) var(--s4); border: 1px solid transparent; border-radius: var(--r-pill);
  background: transparent; color: var(--slate); }
.modetab:hover { color: var(--navy); background: var(--panel); }
.modetab[aria-selected="true"] { background: var(--navy); color: var(--on-dark);
  border-color: var(--navy); }
/* In dark mode --navy inverts to a light blue, so white on it reads at 1.8:1.
   The selected tab follows the same treatment as the other selected controls. */
:root[data-theme="dark"] .modetab[aria-selected="true"] { background: var(--royal);
  border-color: var(--royal); color: #04142F; }
.modetab:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }

.paper-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2);
  max-block-size: 540px; overflow-y: auto; }
/* the rows in the quiz's "Sit a past paper" list. The past papers page has
   rows with the same class name but a different layout, so these rules are
   kept to the list. */
.paper-list .paper-row { display: flex; gap: var(--s4); align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: var(--s3) var(--s4); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--card); margin-bottom: 0; }
.paper-list .paper-row b { color: var(--navy); display: block; }
.paper-list .paper-row .meta { display: block; margin: 2px 0 0; }

.choice-head { display: flex; gap: var(--s3); align-items: center; justify-content: space-between;
  flex-wrap: wrap; }
.choice-head .label { margin: 0; }
[data-unsure][aria-pressed="true"] { background: var(--gold); color: var(--gold-text);
  border-color: var(--gold-text); }
[data-flag][aria-pressed="true"] { color: #B3261E; }
[data-theme="dark"] [data-flag][aria-pressed="true"] { color: #FFB4AB; }
.q-tariff { margin: 0; font-weight: 600; color: var(--royal); font-size: var(--t-small); }
.pill-outline { border: 1px solid var(--border); background: transparent; color: var(--slate); }

/* ==========================================================================
   54. Notebook — mistakes, cards, your own formula sheet
   ========================================================================== */
.section-head-sm { margin-bottom: var(--s6); }
.section-head-sm h2 { margin: 0 0 var(--s2); font-size: var(--t-h3); }
.section-head-sm h2 small { font-weight: 500; font-size: var(--t-small); color: var(--slate);
  margin-inline-start: var(--s2); }
.section-head-sm p { margin: 0; color: var(--slate); max-inline-size: 68ch; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
.form-grid { display: grid; gap: var(--s4); margin-bottom: var(--s4);
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }

.mistake-group { margin-bottom: var(--s6); }
.mistake-group h3 { margin: 0 0 var(--s3); font-size: var(--t-body); }
.mistake-group h3 small { font-weight: 500; color: var(--slate); margin-inline-start: var(--s2); }
.mistake { padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--card); margin-bottom: var(--s3); }
.mistake-head { display: flex; gap: var(--s2) var(--s4); flex-wrap: wrap;
  align-items: baseline; justify-content: space-between; margin-bottom: var(--s3); }
.mistake-head b { font-size: 0.9375rem; }
.mistake-head .meta { font-size: var(--t-small); color: var(--slate); }

.flashcard { position: relative; display: grid; align-content: center; gap: var(--s3);
  min-block-size: 260px; padding: var(--s6); cursor: pointer; text-align: center;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card);
  box-shadow: var(--shadow-rest); }
.flashcard:hover { border-color: var(--royal); }
.flashcard:focus-visible { outline: 2px solid var(--royal); outline-offset: 3px; }
.flashcard .flashcard-back { display: none; }
.flashcard.is-flipped .flashcard-face { display: none; }
.flashcard.is-flipped .flashcard-back { display: block; }
.flashcard-front { margin: 0; font-size: var(--t-h3); font-weight: 600; line-height: 1.25; }
.flashcard p { margin: 0 0 var(--s2); }
.flashcard .hint { color: var(--slate); }
.flashcard-back { text-align: start; }
.flashcard-back p { white-space: pre-wrap; }

.card-nav { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center;
  justify-content: center; margin-top: var(--s4); }
.card-nav .meta { font-size: var(--t-small); color: var(--slate); }

.formula-group { margin-bottom: var(--s6); }
.formula-group h3 { margin: 0 0 var(--s3); font-size: var(--t-body); }
.formula { display: flex; gap: var(--s4); align-items: start; justify-content: space-between;
  padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--card); margin-bottom: var(--s2); }
.formula p { margin: var(--s1) 0 0; white-space: pre-wrap; font-size: 0.9375rem; color: var(--slate); }

@media print {
  #zk-notebook .modetabs, #zk-notebook [data-nbpanel="mistakes"],
  #zk-notebook [data-nbpanel="cards"] { display: none !important; }
  #zk-notebook [data-nbpanel="formulas"] { display: block !important; }
  .formula { break-inside: avoid; border-color: #ccc; }
  .formula button { display: none; }
}

/* ==========================================================================
   55. Worksheet builder — on screen, and on paper
   ========================================================================== */
.ws-topics { border: 0; padding: 0; margin: 0 0 var(--s4); min-inline-size: 0; }
.ws-topics legend { padding: 0; margin-bottom: var(--s2); }
.ws-opts { display: grid; gap: var(--s1); margin-bottom: var(--s4); }

.ws-sheet { margin-top: var(--s8); padding-top: var(--s6); border-top: 2px solid var(--navy); }
.ws-head h2 { margin: 0 0 var(--s2); }
.ws-head .meta { margin: 0 0 var(--s3); font-size: var(--t-small); color: var(--slate); }
.ws-rule { margin: 0 0 var(--s6); font-size: var(--t-small); color: var(--slate);
  padding-bottom: var(--s3); border-bottom: 1px solid var(--border); }

.ws-q { margin-bottom: var(--s8); }
.ws-q header { display: flex; gap: var(--s3); align-items: baseline; margin-bottom: var(--s2);
  padding-bottom: var(--s2); border-bottom: 1px solid var(--border); }
.ws-q header b { font-family: var(--font-display); font-size: var(--t-h3); color: var(--royal);
  min-inline-size: 1.4em; }
.ws-q header .meta { font-size: var(--t-small); color: var(--slate); flex: 1 1 auto; }
.ws-marks { font-weight: 600; font-size: var(--t-small); white-space: nowrap; }
.ws-crop canvas { display: block; max-inline-size: 100%; height: auto;
  background: #fff; border-radius: var(--r-sm); }

.ws-ms { margin-top: var(--s12); padding-top: var(--s6); border-top: 2px solid var(--navy); }
.ws-ms h2 { margin: 0 0 var(--s2); }
.ws-a { margin-bottom: var(--s6); }
.ws-a b { font-family: var(--font-display); color: var(--royal); margin-right: var(--s2); }
.ws-key { display: inline-block; font-weight: 700; padding: 1px var(--s2); border-radius: var(--r-sm);
  background: var(--panel); color: var(--navy); }
.ws-foot { margin-top: var(--s8); padding-top: var(--s3); border-top: 1px solid var(--border);
  font-size: var(--t-small); color: var(--slate); }

@media print {
  #zk-worksheet .no-print, #zk-worksheet .empty-state { display: none !important; }
  .ws-sheet { margin: 0; padding: 0; border: 0; }
  .ws-q, .ws-a { break-inside: avoid; }
  .ws-ms { break-before: page; }
  .ws-q header { border-color: #999; }
}

/* ==========================================================================
   56. Progress — pace, paper against paper, and the session log
   ========================================================================== */
.row-flag th[scope="row"] { position: relative; padding-left: var(--s4); }
.row-flag th[scope="row"]::before { content: ""; position: absolute; inset-block: 2px;
  inset-inline-start: 0; inline-size: 3px; border-radius: 2px; background: var(--royal); }

.log-day { margin-bottom: var(--s4); }
.log-day h3 { margin: 0 0 var(--s2); font-size: var(--t-small); color: var(--slate); padding-bottom: var(--s1);
  border-bottom: 1px solid var(--border); }
.log-day h3 small { text-transform: none; letter-spacing: 0; margin-inline-start: var(--s2); }
.log-row { display: grid; gap: var(--s1) var(--s4); padding: var(--s2) 0;
  grid-template-columns: minmax(0, 7.5rem) minmax(0, 10rem) minmax(0, 1fr) auto;
  align-items: baseline; font-size: 0.9375rem; }
.log-kind { font-weight: 600; color: var(--navy); }
.log-paper { color: var(--slate); }
.log-paper small { display: block; font-size: var(--t-small); }
.log-line { color: var(--ink); }
.log-pct { font-family: var(--font-display); color: var(--royal); text-align: end; }
@media (max-width: 640px) {
  .log-row { grid-template-columns: minmax(0, 1fr) auto; }
  .log-paper, .log-line { grid-column: 1 / -1; }
}

/* ==========================================================================
   58. Teaching mode — the worked example
   ========================================================================== */
.teach-note { padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  border: 1px solid var(--royal); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--royal) 7%, var(--card)); }
.teach-note .label { color: var(--royal); margin: 0 0 var(--s1); }
.teach-note p:last-child { margin: 0; font-size: 0.9375rem; }

/* ==========================================================================
   59. The printable report
   ========================================================================== */
.rp-sheet { padding-top: var(--s6); border-top: 2px solid var(--navy); }
.rp-head h2 { margin: 0 0 var(--s1); }
.rp-head .meta { margin: 0 0 var(--s6); font-size: var(--t-small); color: var(--slate); }
.rp-sheet h3 { margin: var(--s8) 0 var(--s3); font-size: var(--t-h3); }
.rp-sheet > p { max-inline-size: 76ch; }
.rp-ask { margin: 0 0 var(--s3); padding-inline-start: var(--s6); }
.rp-ask li { margin-bottom: var(--s2); }
.rp-ask .meta { display: block; font-size: var(--t-small); color: var(--slate); }

@media print {
  #zk-report .no-print { display: none !important; }
  .rp-sheet { border: 0; padding: 0; }
  .rp-sheet h3 { break-after: avoid; }
  .table-wrap, .rp-ask li { break-inside: avoid; }
}

/* ==========================================================================
   60. Question difficulty badge
   ========================================================================== */
/* the difficulty badge on a question */
.qband { display: inline-block; font-size: var(--t-small); font-weight: 600;
  padding: 1px var(--s2); border-radius: var(--r-sm); background: var(--panel);
  color: var(--slate); }
.qband[data-d="hard"] { background: color-mix(in srgb, var(--royal) 14%, var(--card));
  color: var(--royal); }
.qband[data-curated] { background: var(--gold); color: #1A1200; }

/* ==========================================================================
   61. Reader — thumbnails, find, fit, rotation, spread and page colours
   ========================================================================== */
.viewer-body { display: flex; min-block-size: 0; flex: 1 1 auto; }
.viewer-rail { flex: 0 0 148px; overflow-y: auto; overflow-x: hidden;
  padding: var(--s3); border-inline-end: 1px solid var(--border);
  background: var(--panel); display: grid; gap: var(--s3);
  grid-template-columns: 1fr; align-content: start; }
.viewer-rail[hidden] { display: none; }
.vthumb { position: relative; display: block; inline-size: 100%; padding: 0;
  border: 2px solid transparent; border-radius: var(--r-sm); background: #fff;
  cursor: pointer; line-height: 0; }
.vthumb canvas { display: block; inline-size: 100%; height: auto; min-block-size: 40px; }
.vthumb span { position: absolute; inset-block-end: 2px; inset-inline-end: 2px;
  font-size: 11px; line-height: 1.4; padding: 0 4px; border-radius: 4px;
  background: rgba(0,0,0,.62); color: #fff; }
.vthumb[aria-current="true"] { border-color: var(--royal); }
.vthumb:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
.vthumb[data-marked]::before { content: ""; position: absolute; inset-block-start: 3px;
  inset-inline-start: 3px; inline-size: 8px; block-size: 12px; border-radius: 1px;
  background: var(--gold); }

.viewer-find { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap;
  padding: var(--s2) var(--s4); border-block-end: 1px solid var(--border);
  background: var(--panel); }
.viewer-findinput { flex: 1 1 260px; min-inline-size: 0; padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink); font: inherit; }
.viewer-findcount { font-size: var(--t-small); color: var(--slate); }

.viewer-sel { padding: 4px var(--s2); border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--card); color: var(--ink);
  font: inherit; font-size: var(--t-small); max-inline-size: 100%; min-inline-size: 0; }

.viewer-progress { block-size: 3px; background: var(--border); }
.viewer-progress > span { display: block; block-size: 100%; inline-size: 0;
  background: var(--royal); transition: inline-size 180ms ease; }
.viewer-pos { font-size: var(--t-small); color: var(--slate); }
.viewer-resume { font: inherit; font-size: var(--t-small); padding: 2px var(--s3);
  border: 1px solid var(--royal); border-radius: var(--r-pill);
  background: transparent; color: var(--royal); cursor: pointer; }

/* page colours: applied to the canvases only, so the chrome keeps its own theme */
.viewer-stage[data-vtheme-on="warm"] canvas { filter: sepia(0.28) saturate(0.92) brightness(0.98); }
.viewer-stage[data-vtheme-on="contrast"] canvas { filter: contrast(1.35) grayscale(1); }
.viewer-stage[data-vtheme-on="dark"] canvas { filter: invert(1) hue-rotate(180deg); }
.viewer-stage[data-vtheme-on="dark"] .viewer-page { background: #111; }

/* two pages side by side */
.viewer-stage[data-spread="on"] { display: flex; flex-wrap: wrap;
  align-content: flex-start; justify-content: center; gap: var(--s4); }
.viewer-stage[data-spread="on"] .viewer-page { margin-inline: 0; }

@media (max-width: 760px) { .viewer-rail { flex-basis: 96px; } }
@media (prefers-reduced-motion: reduce) {
  .viewer-progress > span { transition: none; }
}

/* ==========================================================================
   62. Quiz — pause, second pass, the run of right answers
   ========================================================================== */
.quiz-resume { border-color: var(--royal); margin-bottom: var(--s6); }
.quiz-resume h3 { margin: 0 0 var(--s2); }
.quiz-resume p { margin: 0 0 var(--s3); color: var(--slate); }
.quiz-combo { margin: var(--s1) 0 0; font-size: var(--t-small); font-weight: 600;
  color: var(--royal); }
.pause-note { margin: 0 0 var(--s3); padding: var(--s2) var(--s4);
  border-radius: var(--r-md); background: var(--panel); color: var(--slate);
  font-size: var(--t-small); }
[data-qwrap][data-paused="on"] { filter: blur(6px); opacity: .5; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  [data-qwrap][data-paused="on"] { filter: none; opacity: .35; }
}

/* ==========================================================================
   63. Every past paper
   ========================================================================== */
.paper-row { padding: var(--s4); margin-bottom: var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--card); }
.paper-head { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4);
  align-items: baseline; justify-content: space-between; margin-bottom: var(--s2); }
.paper-head h3 { margin: 0; font-size: var(--t-body); font-family: var(--font-display); }
.paper-head .meta { font-size: var(--t-small); color: var(--slate); }
.paper-stats { margin: 0 0 var(--s2); font-size: 0.9375rem; color: var(--slate); }
.paper-stats b { color: var(--ink); }
.paper-topics { display: flex; flex-wrap: wrap; gap: var(--s1); margin: 0 0 var(--s3); }
.paper-topic { font-size: var(--t-small); padding: 1px var(--s2);
  border-radius: var(--r-sm); background: var(--panel); color: var(--slate); }
.paper-topic small { opacity: .75; }

/* ==========================================================================
   64. Progress — trend chart
   ========================================================================== */
.trend-chart { color: var(--royal); margin-bottom: var(--s3); }
.spark { display: block; inline-size: 100%; block-size: 64px; }
.trend-read { margin: 0 0 var(--s2); }
.trend-read b { font-family: var(--font-display); color: var(--royal); }
.trend-read .meta { font-size: var(--t-small); color: var(--slate); }

/* ==========================================================================
   66. Goals, the focus timer and the week
   ========================================================================== */
.goal-today { display: flex; flex-wrap: wrap; gap: var(--s6); align-items: center; }
.goal-ring { position: relative; inline-size: 120px; flex: 0 0 120px; color: var(--royal); }
.goal-ring svg { display: block; inline-size: 100%; }
.goal-ring-mid { position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; }
.goal-ring-mid b { display: block; font-family: var(--font-display); font-size: var(--t-h3);
  color: var(--royal); line-height: 1; }
.goal-ring-mid span { font-size: var(--t-small); color: var(--slate); }
.goal-words { flex: 1 1 260px; min-inline-size: 0; }
.goal-words p { margin: 0 0 var(--s2); }

.goal-week { display: flex; gap: var(--s2); align-items: flex-end; block-size: 120px;
  margin-bottom: var(--s3); }
.goal-day { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end;
  block-size: 100%; min-inline-size: 0; }
.goal-day > span { display: block; inline-size: 100%; border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--border); }
.goal-day.is-hit > span { background: var(--royal); }
.goal-day small { display: block; text-align: center; font-size: 11px; color: var(--slate);
  margin-block-start: 4px; }

.focus { margin-bottom: var(--s4); }
.focus-clock { margin: 0; font-family: var(--font-display); font-size: 3rem; line-height: 1;
  color: var(--royal); font-variant-numeric: tabular-nums; }
.focus-mode { margin: 0 0 var(--s3); font-size: var(--t-small); color: var(--slate); }
.focus-bar { block-size: 6px; border-radius: var(--r-pill); background: var(--panel);
  overflow: hidden; margin-bottom: var(--s4); }
.focus-bar > span { display: block; block-size: 100%; inline-size: 0; background: var(--royal); }

/* ==========================================================================
   67. A question's own history and notes
   ========================================================================== */
.qhist { margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  background: var(--panel); color: var(--slate); font-size: var(--t-small); }
.qnote-wrap { margin-top: var(--s4); border-top: 1px solid var(--border);
  padding-top: var(--s3); }
.qnote-wrap summary { cursor: pointer; font-size: var(--t-small); color: var(--slate); }
.qnote-wrap summary:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
.qnote-wrap .notes-area { margin-top: var(--s2); }

/* ==========================================================================
   69. The sidebar
   Every page, grouped as in the main menu, with a box to find one.
   On a laptop or desktop at least 1169 px wide it sits beside the page all
   the time, below the header, and the page moves over to make room. "Hide
   sidebar" at its top puts it away and "Show sidebar" in the header brings it
   back; the choice is kept on this device and applied before the page is
   drawn (THEME_SCRIPT in tools/build.py).
   On a phone or a tablet (no hover, a finger rather than a pointer), and in a
   window narrower than 1169 px, only the Show sidebar icon is there (and
   "Sidebar" in a phone's bottom bar); it slides the sidebar in from the left
   over the page.
   The rule for where it docks is also in assets/js/directory.js (DOCK), in
   the footer, small print and quiz builder rules marked "beside the
   sidebar", and in the home and About pictures' sizes (section 25 and the
   About page), which go by the window's width alone.
   ========================================================================== */
:root { --sb-w: 248px; }

.dir-scrim { position: fixed; inset: 0; z-index: 190; background: rgba(2, 10, 32, .52);
  backdrop-filter: blur(2px); }
.dir-scrim[hidden] { display: none; }

/* narrow screens: it slides in over the page */
.directory { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 191;
  inline-size: min(380px, 92vw); display: none; flex-direction: column;
  background: var(--card); border-inline-end: 1px solid var(--border);
  box-shadow: var(--shadow-raise); transform: translateX(-102%);
  transition: transform 200ms ease; }
.directory[data-open] { display: flex; }
.directory[data-shown] { transform: translateX(0); }

.dir-head { display: flex; align-items: center;
  padding: var(--s3); border-block-end: 1px solid var(--border); }
.sb-hide { display: inline-flex; align-items: center; gap: var(--s2);
  inline-size: 100%; min-block-size: 42px; padding: 0 var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: transparent; color: var(--ink); cursor: pointer;
  font: inherit; font-size: 0.9375rem; font-weight: 500; text-align: start; }
.sb-hide svg { flex: 0 0 20px; inline-size: 20px; block-size: 20px; color: var(--navy); }
.sb-hide:hover { border-color: var(--royal); color: var(--royal); }
.sb-hide:hover svg { color: var(--royal); }
.sb-hide:focus-visible { outline: 2px solid var(--royal); outline-offset: 1px; }

.dir-find { padding: var(--s3) var(--s4); border-block-end: 1px solid var(--border); }
.dir-input { inline-size: 100%; min-inline-size: 0; padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink); font: inherit; font-size: 0.9375rem; }
.dir-input:focus-visible { outline: 2px solid var(--royal); outline-offset: 1px; }
.dir-nohits { margin: var(--s2) 0 0; font-size: var(--t-small); color: var(--slate); }

.dir-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s2) 0; }

.dir-group { border-block-end: 1px solid var(--border); }
.dir-group[hidden] { display: none; }
.dir-group > summary { display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); cursor: pointer; list-style: none;
  font-weight: 600; font-size: 0.9375rem; color: var(--navy); }
.dir-group > summary::-webkit-details-marker { display: none; }
.dir-group > summary:hover { background: var(--panel); }
.dir-group > summary:focus-visible { outline: 2px solid var(--royal); outline-offset: -2px; }
.dir-group > summary svg { flex: 0 0 18px; inline-size: 18px; block-size: 18px;
  color: var(--royal); }
.dir-group > summary > span:first-of-type { flex: 1 1 auto; }
.dir-count { flex: 0 0 auto; font-weight: 500; font-size: var(--t-small);
  color: var(--slate); font-variant-numeric: tabular-nums; }
/* the twisty, drawn rather than relying on a marker glyph */
.dir-group > summary::after { content: ""; flex: 0 0 auto; inline-size: 7px; block-size: 7px;
  margin-inline-start: var(--s1); border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor; transform: rotate(-45deg);
  transition: transform 150ms ease; opacity: .55; }
.dir-group[open] > summary::after { transform: rotate(45deg); }

.dir-group ul { margin: 0 0 var(--s2); padding: 0; list-style: none; }
.dir-group li[hidden] { display: none; }
.dir-group li a { display: block; padding: var(--s2) var(--s4) var(--s2) calc(var(--s4) + 30px);
  font-size: 0.9375rem; color: var(--ink); text-decoration: none; }
.dir-group li a small { display: block; font-size: var(--t-small); color: var(--slate); }
.dir-group li a:hover { background: var(--panel); color: var(--royal); }
.dir-group li a:focus-visible { outline: 2px solid var(--royal); outline-offset: -2px; }
.dir-group li a[aria-current="page"] { background: var(--panel);
  box-shadow: inset 3px 0 0 var(--royal); font-weight: 600; }

body.dir-open { overflow: hidden; }

/* a laptop or desktop at least 1169 px wide: beside the page, all the time,
   unless you hide it. Phones and tablets (no hover, a finger rather than a
   pointer) keep it put away at every width, with only the Show sidebar icon. */
@media (min-width: 1169px) and (hover: hover) and (pointer: fine) {
  .directory {
    display: flex;
    inset-block-start: calc(var(--header-h) + 1px);     /* just below the header and its rule */
    inline-size: var(--sb-w);
    z-index: 80;                                        /* under the header, its menus and every overlay */
    background: var(--page);
    box-shadow: none;
    transform: none;
    transition: none;
  }
  :root[data-sidebar="hidden"] .directory { display: none; }
  .dir-scrim { display: none; }
  /* the page moves over */
  :root:not([data-sidebar="hidden"]) #main,
  :root:not([data-sidebar="hidden"]) .site-footer { margin-inline-start: var(--sb-w); }
  /* the header runs the full width, its logo over the sidebar */
  .site-header > .header-inner { width: auto; margin-inline: 0; padding-inline: var(--gutter); }
  /* "Show sidebar" is only there while the sidebar is hidden */
  :root:not([data-sidebar="hidden"]) .sb-show { display: none; }
  /* tighter rows, so the names fit the narrower column */
  .dir-find { padding: var(--s3); }
  .dir-group > summary { gap: var(--s2); padding: var(--s3); }
  .dir-group li a { padding: 0.45rem var(--s3) 0.45rem calc(var(--s3) + 26px); }
}

@media (prefers-reduced-motion: reduce) {
  .directory { transition: none; }
  .dir-group > summary::after { transition: none; }
}
@media print {
  .directory, .dir-scrim, .sb-show { display: none !important; }
  #main, .site-footer { margin-inline-start: 0 !important; }
}

/* ==========================================================================
   70. Small shared pieces
   ========================================================================== */
.container.narrow { max-width: 820px; }
.mb-3 { margin-bottom: var(--s3) !important; }
.ico { width: 20px; height: 20px; flex: 0 0 auto; }
:target { scroll-margin-top: calc(var(--header-h) + var(--s4)); }

.info-card {
  padding: var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card-solid);
}
.info-card h3 { font-size: 1.0625rem; margin-bottom: var(--s2); }
.info-card p { font-size: 0.9375rem; color: var(--slate); }
.info-card p + p { margin-top: var(--s2); }

.fact-list { display: grid; gap: var(--s3); max-width: 72ch; }
.fact-list li { position: relative; padding-left: var(--s6); color: var(--slate); }
.fact-list li::before {
  content: ""; position: absolute; left: 0; top: 0.6em;
  width: 8px; height: 8px; border-radius: 2px; background: var(--royal);
}
.fact-list b { color: var(--ink); }

.band-cta > * + * { margin-top: var(--s4); }
.band-cta p { max-width: 54ch; margin-inline: auto; }
.band-kicker { font-size: var(--t-small); font-weight: 500; color: var(--on-dark-soft); margin-bottom: var(--s2); }
.jump-label { font-size: var(--t-small); color: var(--on-dark-soft); margin: var(--s6) 0 var(--s2); }
.jump-row { margin-bottom: var(--s8); }
.quick-types { margin-bottom: var(--s6); }
.h-code { font-size: 0.6em; font-weight: 500; color: var(--slate); font-variant-numeric: tabular-nums; margin-left: 0.3em; }

.paper-section + .paper-section { margin-top: var(--s16); }
.paper-section > .section-head { border-left: 4px solid var(--accent, var(--royal)); padding-left: var(--s4); }
.paper-section > .section-head .cluster { margin-top: var(--s4); }

/* selected controls in dark mode: --navy turns light there, so the text on it
   has to turn dark */
:root[data-theme="dark"] .finder-subject[aria-pressed="true"],
:root[data-theme="dark"] .pp-subject[aria-pressed="true"],
:root[data-theme="dark"] .pp-paper[aria-pressed="true"],
:root[data-theme="dark"] .quiz-step-title .step-n { background: var(--royal); border-color: var(--royal); color: #04142F; }

/* ==========================================================================
   71. Home
   ========================================================================== */
.hero-search {
  display: flex; align-items: center; gap: 0.7rem;
  width: min(100%, 30rem);
  margin-bottom: var(--s4);
  padding: 0.85rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: #fff;
  color: #4A5674;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 30px rgb(2 12 40 / 0.35);
}
.hero-search:hover { border-color: #01DCFD; color: #101B3A; }
.hero-search .ico { color: #005EFC; }
.hero-search.on-light {
  margin: var(--s6) 0 0;
  background: var(--card);
  border-color: var(--border);
  color: var(--slate);
  box-shadow: none;
}
.hero-search.on-light:hover { border-color: var(--royal); color: var(--ink); }
.hero-search.on-light .ico { color: var(--royal); }

.resume-strip { padding-block: var(--s6); border-bottom: 1px solid var(--border-soft); }
.strip-title { font-size: 1rem; font-weight: 600; color: var(--slate); margin-bottom: var(--s3); }
.resume-strip .recent-row + [data-recent] { margin-top: var(--s3); }
.recent-chip.is-quiz { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.recent-chip.is-quiz:hover { color: #fff; border-color: var(--royal); }
:root[data-theme="dark"] .recent-chip.is-quiz { background: var(--royal); border-color: var(--royal); color: #04142F; }

/* the topic finder: subject, then paper, then every topic */
.finder {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: var(--s6) var(--s8);
  padding: var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--card-solid);
  box-shadow: var(--shadow-rest);
}
.finder-subjects { display: grid; gap: var(--s2); align-content: start; }
.finder-subject {
  display: grid; gap: 2px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent, var(--royal));
  border-radius: var(--r-md);
  background: var(--card);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--navy);
  text-align: left;
  cursor: pointer;
}
.finder-subject .code { font-size: 0.75rem; font-weight: 500; color: var(--slate); font-variant-numeric: tabular-nums; }
.finder-subject:hover { border-color: var(--royal); border-left-color: var(--accent, var(--royal)); }
.finder-subject[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.finder-subject[aria-pressed="true"] .code { color: inherit; opacity: 0.8; }
.finder-panel { min-width: 0; container: finder / inline-size; }
.finder-panel > .chip-row { margin-bottom: var(--s4); }
.finder-topics { columns: 2; column-gap: var(--s6); }
.finder-topics li { break-inside: avoid; }
.finder-topics a {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: baseline;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
}
.finder-topics a:hover { background: var(--panel); }
.finder-topics .n {
  padding: 0.1rem 0;
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--navy);
  font-size: 0.8125rem; font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.finder-topics .t { font-weight: 500; }
.finder-topics .q { font-size: 0.8125rem; color: var(--slate); white-space: nowrap; font-variant-numeric: tabular-nums; }
.finder-topics a[data-state="1"] .n { background: var(--cream); color: var(--amber); }
.finder-topics a[data-state="2"] .n { background: var(--mint); color: var(--green-text); }
.finder-foot {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); justify-content: space-between;
  margin-top: var(--s4); padding-top: var(--s4);
  border-top: 1px solid var(--border-soft);
  font-size: var(--t-small); color: var(--slate);
}
.finder-foot a { font-weight: 600; }
@media (max-width: 860px) {
  .finder { grid-template-columns: 1fr; padding: var(--s4); }
  .finder-subjects { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finder-subject { padding: 0.6rem 0.7rem; font-size: 0.9375rem; }
}
/* When the list is too narrow for a long topic name and its count side by
   side ("Superposition", "Communication"), the count goes under the name. It
   is that narrow at 621 to 687 px and 861 to 965 px wide, and beside the
   sidebar at 1169 to 1213 px, so this goes by the list's own width rather
   than the window's. */
@container finder (max-width: 620px) {
  .finder-topics a { grid-template-columns: 3rem minmax(0, 1fr); row-gap: 0; }
  .finder-topics .q { grid-column: 2; }
}
@media (max-width: 620px) {
  .finder-topics { columns: 1; }
  .finder-topics a { grid-template-columns: 2.6rem minmax(0, 1fr); row-gap: 0; }
  .finder-topics .q { grid-column: 2; }
}
/* on a phone the three subjects sit in a row that wraps, each as wide as its
   name needs, so a long name is never split in the middle of the word */
@media (max-width: 520px) {
  .finder-subjects { display: flex; flex-wrap: wrap; }
  .finder-subject { flex: 1 1 auto; font-size: 0.875rem; padding: 0.55rem 0.8rem; }
}

/* six ways in */
.doors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 900px) { .doors { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .doors { grid-template-columns: 1fr; } }
.door {
  display: flex; gap: var(--s4); align-items: flex-start;
  padding: var(--s4) var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card-solid);
  color: var(--slate);
  font-size: 0.9375rem;
  text-decoration: none;
}
.door:hover { border-color: var(--royal); }
.door .ico {
  width: 44px; height: 44px; padding: 11px;
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--royal);
}
.door b { display: block; font-family: var(--font-display); font-size: 1.0625rem; font-weight: 600; color: var(--navy); margin-bottom: 2px; }

.subject-tile {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s6);
  border: 1px solid var(--border);
  border-top: 5px solid var(--accent, var(--royal));
  border-radius: var(--r-md);
  background: var(--card-solid);
}
.subject-tile .code { font-family: var(--font-display); font-size: 0.875rem; font-weight: 600; color: var(--accent, var(--royal)); font-variant-numeric: tabular-nums; }
.subject-tile h3 { font-size: var(--t-h2); }
.subject-tile h3 a { color: inherit; text-decoration: none; }
.subject-tile h3 a:hover { text-decoration: underline; }
.subject-tile > p { font-size: 0.9375rem; color: var(--slate); }
.paper-links { display: grid; }
.paper-links a {
  display: flex; gap: var(--s3); align-items: baseline;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border-soft);
  color: var(--ink);
  font-size: 0.9375rem;
  text-decoration: none;
}
.paper-links a:hover { color: var(--royal); }
.paper-links b { font-family: var(--font-display); font-weight: 600; color: var(--navy); white-space: nowrap; }
.paper-links a:hover b { color: inherit; }
.subject-tile .tile-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--border-soft); font-size: var(--t-small); }

.about-teaser {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: var(--s8) var(--s12);
  align-items: center;
}
.about-teaser img { border-radius: var(--r-lg); width: 260px; height: 334px; }    /* fixed sizes with their own files, as for the home picture */
.about-teaser h2 { margin-bottom: var(--s4); }
.about-teaser p { max-width: 62ch; }
.about-teaser p + p { margin-top: var(--s4); }
@media (max-width: 700px) {
  .about-teaser { grid-template-columns: 1fr; }
  .about-teaser picture { max-width: 200px; }
  .about-teaser img { width: 200px; height: 257px; }
}

.coverage td:first-child { font-weight: 500; color: var(--navy); }

/* ==========================================================================
   72. About, subjects, explore
   ========================================================================== */
.about-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;    /* the photo keeps its own size; the text takes the rest */
  gap: var(--s8) var(--s12);
  align-items: start;
}
.about-copy > * + * { margin-top: var(--s4); }
.about-copy h2 { margin-top: var(--s8); font-size: var(--t-h3); }
.about-copy p { max-width: 64ch; }
.about-two { display: grid; gap: var(--s3); }
.about-two li {
  padding: var(--s4) var(--s6);
  border-left: 4px solid var(--royal);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--card);
  color: var(--slate);
}
.about-two b { display: block; font-family: var(--font-display); font-size: 1.0625rem; font-weight: 600; color: var(--navy); margin-bottom: 2px; }
.about-photo img { border-radius: var(--r-lg); width: 400px; height: 514px; max-width: none; }
.about-photo figcaption { margin-top: var(--s3); font-size: var(--t-small); color: var(--slate); }
@media (max-width: 1497px) {    /* 1249 px before the sidebar; it takes 248 px from 1169 px up */
  .about-photo img { width: 300px; height: 385px; }
}
@media (max-width: 820px) {
  .about-top { grid-template-columns: 1fr; }
  .about-photo { max-width: 260px; order: -1; }
  .about-photo img { width: 260px; height: 334px; }
}

.subject-blocks { display: grid; gap: var(--s8); }
.subject-block {
  padding: var(--s8);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent, var(--royal));
  border-radius: var(--r-lg);
  background: var(--card-solid);
}
.subject-block > * + * { margin-top: var(--s4); }
.subject-block h2 a { color: inherit; text-decoration: none; }
.subject-block h2 a:hover { text-decoration: underline; }
.subject-block h3 { font-size: 1rem; margin-top: var(--s6); }
.subject-block > p { color: var(--slate); max-width: 70ch; }
@media (max-width: 560px) { .subject-block { padding: var(--s6) var(--s4); } }

.explore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--s6); align-items: start; }
.explore-group {
  padding: var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card-solid);
}
.explore-group h2 { display: flex; align-items: center; gap: var(--s3); font-size: var(--t-h3); }
.explore-group h2 .ico { width: 22px; height: 22px; color: var(--royal); }
.explore-group > p { margin: var(--s2) 0 var(--s4); font-size: var(--t-small); color: var(--slate); }
.explore-group ul { display: grid; }
.explore-group li { padding: 0.5rem 0; border-top: 1px solid var(--border-soft); }
.explore-group li a { font-weight: 500; text-decoration: none; }
.explore-group li a:hover { text-decoration: underline; }
.explore-group li small { display: block; font-size: var(--t-small); color: var(--slate); }

/* ==========================================================================
   73. Getting around: the bar on phones, back to top, footer
   ========================================================================== */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--page) 94%, transparent);
    backdrop-filter: blur(14px) saturate(1.4);
    border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    display: grid; justify-items: center; gap: 2px;
    min-height: 56px; padding: 8px 2px 6px;
    color: var(--slate);
    font-size: 0.6875rem; font-weight: 500; line-height: 1.2;
    text-decoration: none;
  }
  .tabbar .ico { width: 22px; height: 22px; }
  .tabbar a[data-link="youtube"] .ico { color: #D60000; }
  :root[data-theme="dark"] .tabbar a[data-link="youtube"] .ico { color: #FF5A5A; }
  .tabbar .is-here { color: var(--royal); font-weight: 600; }
  .tabbar a:focus-visible, .tabbar button:focus-visible { outline-offset: -3px; }
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  /* a quiz in progress gets the whole screen */
  body:has(#zk-quiz[data-at="run"]) .tabbar { display: none; }
  body:has(#zk-quiz[data-at="run"]) { padding-bottom: 0; }
}
@media (prefers-color-scheme: dark) and (max-width: 760px) {
  :root:not([data-theme="light"]) .tabbar a[data-link="youtube"] .ico { color: #FF5A5A; }
}
@media print { .tabbar, .to-top { display: none !important; } }

.to-top {
  position: fixed; right: var(--s4); bottom: var(--s4); z-index: 90;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card-solid);
  color: var(--navy);
  box-shadow: var(--shadow-raise);
  cursor: pointer;
}
.to-top:hover { border-color: var(--royal); color: var(--royal); }
.to-top svg { width: 20px; height: 20px; }
@media (max-width: 760px) { .to-top { bottom: calc(56px + env(safe-area-inset-bottom, 0px) + var(--s3)); } }

.footer-about { margin: var(--s4) 0; max-width: 36ch; font-size: 0.9375rem; color: var(--on-dark-soft); }

/* ==========================================================================
   74. Quiz: setting one up
   ========================================================================== */
.quiz-step-title { display: flex; align-items: center; gap: var(--s3); font-size: var(--t-h3); }
.quiz-step-title .step-n { width: 30px; height: 30px; font-size: 0.875rem; flex: 0 0 auto; }
.quiz-step-head { margin: var(--s8) 0 var(--s4); }
.quiz-step-head .hint { margin-top: var(--s1); }
.quiz-resume { margin-bottom: var(--s6); border-color: var(--royal); }

.paper-picker { display: grid; gap: var(--s3); }
.pp-subjects { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pp-subject {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--card-solid);
  font-family: var(--font-display); font-weight: 600; font-size: 0.9375rem;
  color: var(--navy);
  cursor: pointer;
}
.pp-subject small { margin-left: 0.4rem; font-family: var(--font-body); font-weight: 500; font-size: 0.75rem; color: var(--slate); font-variant-numeric: tabular-nums; }
.pp-subject:hover { border-color: var(--royal); }
/* on a phone the subject buttons are a little tighter, so two fit on a row */
@media (max-width: 480px) {
  .pp-subject { padding: 0.5rem 0.8rem; font-size: 0.875rem; }
  .pp-subject small { margin-left: 0.3rem; }
}
.pp-subject[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.pp-subject[aria-pressed="true"] small { color: inherit; opacity: 0.8; }
.pp-papers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: var(--s2); }
.pp-paper {
  display: grid; gap: 1px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card-solid);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.pp-paper b { font-family: var(--font-display); font-weight: 600; color: var(--navy); }
.pp-paper small { font-size: 0.8125rem; color: var(--slate); }
.pp-paper:hover { border-color: var(--royal); }
.pp-paper[aria-pressed="true"] { border-color: var(--royal); background: var(--panel); }
:root[data-theme="dark"] .pp-paper[aria-pressed="true"] { background: var(--panel); color: var(--ink); border-color: var(--royal); }
.pp-paper[aria-busy="true"] { opacity: 0.7; }

.quick-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s8); }
@media (max-width: 900px) { .quick-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.quick {
  display: grid; gap: 2px; align-content: start;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card-solid);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.quick b { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 600; color: var(--navy); }
.quick small { font-size: 0.8125rem; color: var(--slate); line-height: 1.4; }
.quick:hover:not(:disabled) { border-color: var(--royal); background: var(--card); }
.quick:disabled { cursor: not-allowed; opacity: 0.6; }

.topic-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  max-block-size: 320px;
}
.seg {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--panel);
}
.seg-btn {
  flex: 1 1 auto;
  min-height: 36px; padding: 0.35rem 0.75rem;
  border-radius: 7px;
  color: var(--slate);
  font-size: 0.9375rem; font-weight: 500;
  cursor: pointer;
}
.seg-btn:hover { color: var(--navy); }
.seg-btn[aria-checked="true"] { background: var(--card-solid); color: var(--navy); font-weight: 600; box-shadow: var(--shadow-rest); }
.seg-btn:focus-visible { outline: 2px solid var(--royal); outline-offset: 1px; }

.more-opts { margin-top: var(--s4); border-top: 1px solid var(--border-soft); padding-top: var(--s3); }
.more-opts > summary {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 0.4rem 0;
  color: var(--royal); font-weight: 600; font-size: 0.9375rem;
  cursor: pointer; list-style: none;
}
.more-opts > summary::-webkit-details-marker { display: none; }
.more-opts > summary::after {
  content: ""; width: 7px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); margin-top: -3px;
}
.more-opts[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
.more-opts > .quiz-opts { margin-top: var(--s3); }

.start-bar {
  display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between;
  margin-top: var(--s6); padding-top: var(--s4);
  border-top: 1px solid var(--border);
}
.start-summary { margin: 0; font-weight: 500; color: var(--navy); }
.start-summary small { display: block; font-weight: 400; font-size: var(--t-small); color: var(--slate); }
.quiz-pos { margin: 0; font-size: var(--t-small); font-weight: 600; color: var(--slate); }
.result-line { margin: var(--s1) 0; font-size: var(--t-lead); font-weight: 500; color: var(--navy); }
@media (max-width: 620px) {
  .start-bar .cluster, .start-bar .btn-lg { width: 100%; }
}

/* ==========================================================================
   75. Quiz: the loading screen
   Shown from the moment a quiz is asked for until its first question has been
   drawn. The ring is the Zakademy logo's own orbit.
   ========================================================================== */
.qloader {
  position: fixed; inset: 0; z-index: 250;
  display: grid; place-items: center;
  padding: var(--s4);
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 180ms var(--ease-out);
  overflow-y: auto;
}
.qloader[data-shown] { opacity: 1; }
.qloader-panel {
  width: min(100%, 430px);
  padding: var(--s8) var(--s6) var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--card-solid);
  box-shadow: 0 24px 60px rgb(1 33 111 / 0.18);
  text-align: center;
}
.qloader-panel:focus { outline: none; }
.qloader-ring { position: relative; width: 132px; height: 132px; margin: 0 auto var(--s3); }
.qloader-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.qloader-ring circle { fill: none; stroke-width: 7; }
.qloader-ring .track { stroke: var(--panel); }
.qloader-ring .bar {
  stroke: var(--royal);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--p, 0));
  transition: stroke-dashoffset 320ms var(--ease-out);
}
.qloader-ring img { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; }
/* a small gold dot travelling round the ring, so the screen never looks stuck */
.qloader-ring::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 9px; height: 9px; margin: -4.5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--card-solid);
  transform: rotate(0turn) translateY(-57px);
  animation: qloader-orbit 2.6s linear infinite;
}
.qloader[data-state="error"] .qloader-ring::after,
.qloader[data-state="done"] .qloader-ring::after { display: none; }
.qloader[data-state="error"] .qloader-ring .bar { stroke: #B3261E; }
@keyframes qloader-orbit { to { transform: rotate(1turn) translateY(-57px); } }

.qloader-pct { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
.qloader h2 { margin: var(--s1) 0 0; font-size: var(--t-h3); }
.qloader-step { min-height: 1.5em; margin: var(--s1) 0 var(--s4); font-size: 0.9375rem; color: var(--slate); }
.qloader-steps { display: grid; gap: 0.45rem; max-width: 300px; margin: 0 auto var(--s4); text-align: left; }
.qloader-steps li {
  position: relative;
  padding-left: 30px;
  font-size: 0.9375rem; color: var(--slate);
}
.qloader-steps li small { display: block; font-size: 0.8125rem; color: var(--slate); font-variant-numeric: tabular-nums; }
.qloader-steps li::before {
  content: ""; position: absolute; left: 0; top: 0.15em;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
}
.qloader-steps li[data-state="active"] { color: var(--ink); font-weight: 500; }
.qloader-steps li[data-state="active"]::before {
  border-color: var(--panel); border-top-color: var(--royal);
  animation: qloader-spin 0.8s linear infinite;
}
.qloader-steps li[data-state="done"] { color: var(--ink); }
.qloader-steps li[data-state="done"]::before { border-color: var(--royal); background: var(--royal); }
.qloader-steps li[data-state="done"]::after {
  content: ""; position: absolute; left: 6px; top: calc(0.15em + 3px);
  width: 5px; height: 9px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}
:root[data-theme="dark"] .qloader-steps li[data-state="done"]::after { border-color: #04142F; }
@keyframes qloader-spin { to { transform: rotate(1turn); } }

.qloader-slow { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--cream); color: var(--amber); font-size: var(--t-small); text-align: left; }
.qloader-tip { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--panel); font-size: var(--t-small); color: var(--ink); text-align: left; }
.qloader-tip b { display: block; font-family: var(--font-display); color: var(--navy); margin-bottom: 2px; }
.qloader-error { margin-bottom: var(--s2); }
.qloader-error p { margin: 0 0 var(--s4); color: #B3261E; font-weight: 500; }
:root[data-theme="dark"] .qloader-error p { color: #FFB4AB; }
.qloader-error .btn-row { justify-content: center; margin-top: 0; }
.qloader-cancel { margin-top: var(--s4); }
@media (max-height: 640px) {
  .qloader { place-items: start center; }
  .qloader-ring { width: 104px; height: 104px; }
  .qloader-ring::after { transform: rotate(0turn) translateY(-45px); animation-name: qloader-orbit-sm; }
  .qloader-ring img { width: 50px; height: 50px; }
  .qloader-tip { display: none; }
}
@keyframes qloader-orbit-sm { to { transform: rotate(1turn) translateY(-45px); } }
@media (prefers-reduced-motion: reduce) {
  .qloader { transition: none; }
  .qloader-ring::after { display: none; }
  .qloader-ring .bar { transition: none; }
}
:root[data-motion="off"] .qloader-ring::after { display: none; }
@media print { .qloader { display: none !important; } }

/* the box a question is drawn into, while it waits for its page */
.qwrap[data-loading] { min-block-size: 220px; }
.qwrap[data-loading]::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, #EEF3FF 30%, #F9FBFF 50%, #EEF3FF 70%);
  background-size: 300% 100%;
  animation: qskeleton 1.4s linear infinite;
}
@keyframes qskeleton { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* loading screen and quiz odds and ends */
body.ql-open { overflow: hidden; }
.qloader-error .cluster { justify-content: center; }
.choice.is-chosen { border-color: var(--royal); background: var(--panel); }
[data-pos]:focus, [data-screen="result"] h2:focus { outline: none; }
[data-qerror] .btn { margin-left: var(--s2); }
#zk-quiz[data-busy] .topic-grid, #zk-quiz[data-busy] .start-bar { opacity: 0.6; }
.quiz-build-card .quiz-opts { margin-top: var(--s4); }
@media (min-width: 1000px) {
  .quiz-build-card > .quiz-opts { grid-template-columns: minmax(0, 1fr) minmax(0, 1.65fr) minmax(0, 1.2fr); }
}
/* beside the sidebar (section 69) the card is 248 px narrower than the window,
   so the three columns wait until it has the same room */
@media (min-width: 1169px) and (max-width: 1247px) and (hover: hover) and (pointer: fine) {
  :root:not([data-sidebar="hidden"]) .quiz-build-card > .quiz-opts {
    grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
}
[data-findlist]:empty, [data-findout]:empty, [data-shortnote]:empty, [data-sit-note]:empty,
[data-mnote]:empty, [data-poolnote]:empty, [data-mode-note]:empty, [data-bandnote]:empty { display: none; }
.chip[aria-current="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .chip[aria-current="true"],
:root[data-theme="dark"] .chip[aria-pressed="true"] { background: var(--royal); border-color: var(--royal); color: #04142F; }
body:has(#zk-exam[data-at="sitting"]) .tabbar { display: none; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); align-items: center; }

/* row headings in tables read from the left, like the rest of the row */
.data-table tbody th, .table tbody th { text-align: left; }
.coverage tbody th { font-weight: 500; }
.coverage tbody th a { font-weight: 600; text-decoration: none; }
.coverage tbody th a:hover { text-decoration: underline; }
.coverage tbody th small { display: block; font-size: var(--t-small); font-weight: 400; color: var(--slate); }
.subject-blocks { grid-template-columns: minmax(0, 1fr); }
.empty-state h2 { font-size: var(--t-h3); margin-bottom: var(--s2); }
.cal-wrap:focus-visible, .chart-wrap:focus-visible, .table-wrap:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
