/* FMPR design system — from the FMPR front-page prototype.
   Paper: cream squared paper (19px). Ink: navy-black. Cards: off-white with a 1.5px ink rule.
   Type: Newsreader (headings), Atkinson Hyperlegible (text and UI), STIX Two (codes and maths),
   no handwriting font. Module families: pure blue, statistics ochre,
   mechanics plum, decision teal. */

@font-face { font-family: "Newsreader"; src: url("/assets/fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/assets/fonts/newsreader-italic.woff2") format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/assets/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/assets/fonts/atkinson-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/assets/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "STIX Two Text"; src: url("/assets/fonts/stix-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "STIX Two Text"; src: url("/assets/fonts/stix-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "STIX Two Text"; src: url("/assets/fonts/stix-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "STIX Two Math"; src: url("/assets/fonts/stix-math.woff2") format("woff2"); font-display: swap; }

:root {
  --paper: #F7F4EC;
  --grid: #E9E3D5;
  --card: #FFFDF7;
  --ink: #1B1F2A;
  --text-2: #3D4250;
  --muted: #5A5F6B;
  --divider: #CFC8B8;
  --dashed: #9C9584;
  --link: #2B4C7E;
  --red: #A93226;
  --on-ink: #F7F4EC;
  --pure: #2B4C7E; --pure-dark: #2B4C7E;
  --stats: #C08A2E; --stats-dark: #8A5F14;
  --mech: #6B3F69; --mech-dark: #6B3F69;
  --dec: #2F6F6A; --dec-dark: #2F6F6A;
  --opt: #7A5A2E; --opt-dark: #7A5A2E;
  --core: #1B1F2A; --core-dark: #1B1F2A;

  --serif: "Newsreader", Georgia, serif;
  --sans: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --stix: "STIX Two Text", "Times New Roman", serif;
  --pen: #1E3A7B;        /* answer ink */

  --u: 19px;            /* grid unit: one square */
  --rule: 1.5px;
  --gutter: 24px;
  --maxw: 1140px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14161C; --grid: #1F232C; --card: #1A1D25; --ink: #ECE7DC; --text-2: #C9C4B8; --muted: #9B978D;
    --divider: #343945; --dashed: #5C6070; --link: #9DB8E8; --red: #E38476; --on-ink: #14161C; --pen: #A9C1F2;
    --pure: #7FA2DA; --pure-dark: #3B5F96; --stats: #E1B260; --stats-dark: #9A6C1E; --mech: #B98BB6; --mech-dark: #7A4C77;
    --dec: #6DB8AF; --dec-dark: #2F716B; --opt: #C9A16A; --opt-dark: #866435; --core: #ECE7DC; --core-dark: #3A3F4C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14161C; --grid: #1F232C; --card: #1A1D25; --ink: #ECE7DC; --text-2: #C9C4B8; --muted: #9B978D;
  --divider: #343945; --dashed: #5C6070; --link: #9DB8E8; --red: #E38476; --on-ink: #14161C; --pen: #A9C1F2;
  --pure: #7FA2DA; --pure-dark: #3B5F96; --stats: #E1B260; --stats-dark: #9A6C1E; --mech: #B98BB6; --mech-dark: #7A4C77;
  --dec: #6DB8AF; --dec-dark: #2F716B; --opt: #C9A16A; --opt-dark: #866435; --core: #ECE7DC; --core-dark: #3A3F4C;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: var(--u);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--u) var(--u);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 600; }
p { margin: 0; }
button { font-family: var(--sans); color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--on-ink); padding: 8px 12px; }
.skip-link:focus { top: 12px; }
math { font-family: "STIX Two Math", math; }

/* ---------- type helpers (from the prototype) */
.kicker { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); line-height: var(--u); }
.kicker-blue { color: var(--link); }
.h1 { font-size: 34px; line-height: 38px; letter-spacing: -0.01em; }
.h2 { font-size: 24px; line-height: 38px; }
.lede { font-size: 15px; line-height: var(--u); color: var(--text-2); max-width: 60ch; }
.small { font-size: 13px; line-height: var(--u); color: var(--text-2); }
.muted { color: var(--muted); }
.hand { font-size: 15px; font-style: italic; line-height: var(--u); color: var(--red); }
.code { font-family: var(--stix); }
.stack { display: flex; flex-direction: column; gap: var(--u); }

/* ---------- logo */
.logo { width: 44px; height: 38px; flex: none; color: var(--ink); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-text { display: flex; flex-direction: column; }
.brand-word { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: var(--u); letter-spacing: 0.04em; }
.brand-full { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); line-height: var(--u); }
.brand:hover { color: var(--ink); }

/* ---------- header */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: var(--rule) solid var(--ink); }
.header-inner { height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.site-nav ul { list-style: none; display: flex; gap: 22px; margin: 0; padding: 0; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.header-tools { display: flex; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--card); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; } :root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .i-sun { display: block; } :root:not([data-theme="light"]) .i-moon { display: none; } }

/* ---------- mobile tab bar */
.tabbar { display: none; }
@media (max-width: 860px) {
  .site-nav { display: none; }
  .brand-full { display: none; }
  .header-inner { padding-right: 10px; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(76px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 4px 2px calc(8px + env(safe-area-inset-bottom));
    background: var(--paper); border-top: var(--rule) solid var(--ink);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: var(--muted); font-size: 11px; white-space: nowrap; }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
  body { padding-bottom: 76px; }
}

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 var(--u); border: var(--rule) solid var(--ink); background: transparent; color: var(--ink); font-family: var(--sans); font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--card); color: var(--ink); }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-ink:hover { background: var(--ink); color: var(--on-ink); opacity: 0.9; }
.text-btn { border: none; background: none; color: var(--link); font-size: 15px; font-weight: 700; cursor: pointer; padding: 8px; }

/* ---------- cards and lists */
.card { background: var(--card); border: var(--rule) solid var(--ink); padding: var(--u); }
.card-link { display: flex; align-items: center; gap: var(--u); text-decoration: none; color: var(--ink); }
.card-link:hover { color: var(--ink); background: var(--card); box-shadow: 4px 4px 0 var(--ink); }
.rows { display: flex; flex-direction: column; gap: 1px; background: var(--divider); border: var(--rule) solid var(--ink); }
.row { min-height: 57px; display: flex; align-items: center; gap: 14px; padding: 9px 14px; background: var(--card); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 700; line-height: var(--u); }
.row-sub { font-size: 12px; line-height: var(--u); color: var(--muted); }
.row-code { font-family: var(--stix); font-size: 14px; color: var(--text-2); white-space: nowrap; }
a.row { text-decoration: none; color: var(--ink); }
a.row:hover .row-title { text-decoration: underline; }
.sq { width: 9px; height: 9px; flex: none; background: var(--core); display: inline-block; }
.sq.pure { background: var(--pure); } .sq.stats { background: var(--stats); } .sq.mech { background: var(--mech); }
.sq.dec { background: var(--dec); } .sq.opt { background: var(--opt); } .sq.none { background: var(--divider); }
.chev { flex: none; }

/* ---------- segmented controls and option tiles */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px; background: var(--ink); border: var(--rule) solid var(--ink); }
.seg button, .seg a { height: 57px; border: none; background: var(--card); color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; line-height: var(--u); padding: 0 8px; text-align: center; }
.seg .seg-sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.seg [aria-pressed="true"], .seg [aria-current="true"] { background: var(--ink); color: var(--on-ink); }
.seg [aria-pressed="true"] .seg-sub, .seg [aria-current="true"] .seg-sub { color: var(--on-ink); opacity: 0.8; }
.seg-small button { height: 44px; }
.tiles-head { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); height: 38px; align-items: center; }
.tiles-head span { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tiles-head span + span { padding-left: 14px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--divider); border: var(--rule) solid var(--ink); }
.tiles.cols-1 { grid-template-columns: 1fr; }
.tile { min-height: 57px; padding-top: 8px !important; padding-bottom: 8px !important; border: none; background: var(--card); color: var(--ink); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 14px; text-align: left; cursor: pointer; }
.tile-code { display: flex; align-items: center; gap: 8px; font-family: var(--stix); font-size: 15px; font-weight: 600; line-height: var(--u); }
.tile-name { font-size: 13px; line-height: var(--u); }
.tile[aria-pressed="true"] { color: #FFFDF7; }
.tile[aria-pressed="true"] .sq { background: #FFFDF7; }
.tile.pure[aria-pressed="true"] { background: var(--pure-dark); } .tile.stats[aria-pressed="true"] { background: var(--stats-dark); }
.tile.mech[aria-pressed="true"] { background: var(--mech-dark); } .tile.dec[aria-pressed="true"] { background: var(--dec-dark); }
.tile.opt[aria-pressed="true"] { background: var(--opt-dark); } .tile.core[aria-pressed="true"] { background: var(--core-dark); }
.tile:hover:not([aria-pressed="true"]) { background: var(--paper); }
.route { display: flex; align-items: center; gap: 14px; min-height: 57px; }
.route-box { flex: none; width: 57px; height: 57px; display: flex; align-items: center; justify-content: center; background: var(--ink); color: var(--on-ink); font-family: var(--stix); font-size: 26px; font-weight: 600; }
.route-box.empty { background: transparent; border: var(--rule) dashed var(--dashed); color: var(--muted); }
.route-title { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: var(--u); padding-bottom: 6px; display: block; }
.route-prompt { font-size: 15px; font-weight: 700; line-height: var(--u); display: block; }
.note-red { font-size: 13px; line-height: var(--u); color: var(--red); }

/* ---------- page layouts */
.page { padding-top: 38px; padding-bottom: 57px; }
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 57px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 57px; min-width: 0; }
.section { display: flex; flex-direction: column; gap: var(--u); }
.page-head { display: flex; flex-direction: column; gap: var(--u); padding-bottom: 38px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; }
.crumbs a { color: var(--muted); }
.head-links { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 14px; }
@media (max-width: 860px) {
  .page-grid { grid-template-columns: 1fr; gap: 57px; }
  .page { padding-top: 28px; }
  :root { --gutter: 16px; }
}

/* ---------- map glyph card */
.map-glyph { width: 76px; height: 76px; flex: none; }
.map-glyph .ring { fill: none; stroke: var(--ink); stroke-width: 6; }
.map-glyph .axis { stroke: var(--ink); stroke-width: 4; }
.map-glyph .hub { fill: var(--ink); }
.map-glyph .sector { opacity: 0.85; }
.map-glyph .sector.off { opacity: 0.12; }
.fill-pure { fill: var(--pure); } .fill-stats { fill: var(--stats); } .fill-mech { fill: var(--mech); } .fill-dec { fill: var(--dec); } .fill-opt { fill: var(--opt); } .fill-core { fill: var(--muted); }

/* ---------- formula of the day */
.formula { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 57px; font-family: var(--stix); font-size: 24px; }
.formula math { font-size: 26px; }
.formula-blank { display: inline-block; width: 120px; height: 38px; border-bottom: var(--rule) dashed var(--red); }
.badge-red { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--red); border: 1px solid var(--red); padding: 2px 6px; line-height: 15px; }
.formula-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

/* ---------- subject list (home and subjects page) */
.subject-rows .row-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }

/* ---------- topic lists */
.toolbar { position: sticky; top: 76px; z-index: 5; background: var(--paper); padding: 10px 0; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--divider); }
.toolbar .seg { min-width: 300px; }
.group { display: flex; flex-direction: column; gap: 0; margin-top: 38px; }
.group-head { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; }
.group-title { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 38px; }
.group-note { font-size: 13px; color: var(--muted); line-height: var(--u); margin-bottom: 10px; }
.topics { display: flex; flex-direction: column; gap: 1px; background: var(--divider); border: var(--rule) solid var(--ink); }
.topic { background: var(--card); }
.topic > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto 18px; gap: 12px; align-items: center; padding: 12px 14px; min-height: 57px; border-bottom: 1px solid var(--divider); }
.topic:not([open]) > summary { border-bottom: none; }
.topic > summary::-webkit-details-marker { display: none; }
.topic-ref { font-family: var(--stix); font-size: 15px; font-weight: 600; }
.topic-text { display: flex; flex-direction: column; min-width: 0; }
.topic-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topic-title { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 24px; }
.topic-desc { font-size: 14px; line-height: 20px; color: var(--text-2); }
.topic-body { padding-bottom: 6px; }
.topic-practice { display: flex; justify-content: space-between; margin: 0 14px 8px; padding: 10px 12px; border: var(--rule) solid var(--ink); font-weight: 700; text-decoration: none; color: var(--ink); }
.topic-practice:hover { background: var(--paper); color: var(--ink); }
.topic-preview { font-size: 12px; line-height: var(--u); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topic > summary::after { content: ""; width: 10px; height: 10px; border-right: 1.8px solid var(--ink); border-bottom: 1.8px solid var(--ink); transform: rotate(45deg) translate(-2px, -2px); justify-self: center; }
.topic[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.topic[open] .topic-preview { display: none; }
.topic > summary:hover .topic-title { text-decoration: underline; }
.points { list-style: none; margin: 0; padding: 0 14px 6px; }
.point { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 10px 0; }
.point + .point { border-top: 1px dashed var(--divider); }
.point-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.point-ref { font-family: var(--stix); font-size: 14px; color: var(--text-2); }
.point-title { font-size: 15px; line-height: 21px; }
.skills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skills li { font-size: 13px; line-height: 17px; color: var(--text-2); background: var(--paper); border: 1px solid var(--divider); padding: 2px 8px; }
.skills li.hit { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.point-sub { padding: 14px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.yr { font-size: 12px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.yr::before { content: ""; width: 9px; height: 9px; border: 1.5px solid var(--ink); }
.yr.y13::before { background: var(--ink); }
.yr.y1213::before { background: linear-gradient(90deg, transparent 50%, var(--ink) 50%); }
.papers-table { width: 100%; border-collapse: collapse; }

/* ---------- exam board page: course bar, toolbar, contents */
.h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 28px; }
.course-bar { display: flex; align-items: center; gap: 14px; justify-content: space-between; padding: 14px var(--u); }
.course-bar .route { min-height: 0; }
.course-bar .btn { white-space: nowrap; flex: none; }
.board-groups a { color: var(--ink); text-decoration: none; }
.board-groups a:hover { text-decoration: underline; }
.route-box.none { background: transparent; border: var(--rule) solid var(--divider); color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, auto)); gap: 6px 38px; margin: 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); line-height: var(--u); }
.facts dd { margin: 0; font-size: 16px; font-weight: 700; line-height: 24px; }
.facts dd .code { font-weight: 400; color: var(--text-2); }
.course-edit { display: flex; flex-direction: column; gap: var(--u); }
.course-edit-home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 38px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.board-grid { margin-bottom: 57px; }
.topics-head { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.toolbar .filter { flex: 1 1 280px; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; background: var(--card); border: var(--rule) solid var(--ink); color: var(--muted); }
.filter input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--ink); font: 400 16px var(--sans); outline: none; }
.filter:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
.toolbar .seg { min-width: 260px; }
.filter-status { flex-basis: 100%; }
.topics-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 38px; align-items: start; }
.toc { position: sticky; top: 196px; max-height: calc(100vh - 216px); overflow-y: auto; padding: 38px 4px 19px 0; font-size: 13px; line-height: 17px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc > ol > li { margin-top: 12px; }
.toc a { display: block; text-decoration: none; color: var(--text-2); padding: 3px 0 3px 10px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--ink); text-decoration: underline; }
.toc a[aria-current="true"] { color: var(--ink); font-weight: 700; border-left-color: var(--ink); }
.toc .toc-group { display: flex; align-items: center; gap: 8px; padding-left: 0; font-weight: 700; color: var(--ink); border-left: none; }
.toc .code { color: var(--muted); margin-right: 6px; font-size: 12px; }
.topics-main .group:first-child { margin-top: 19px; }
.topic { scroll-margin-top: 200px; }
.group { scroll-margin-top: 200px; }
.filter-empty { margin-top: 38px; padding: var(--u); border: var(--rule) dashed var(--dashed); color: var(--text-2); }
.badge-ink { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-ink); background: var(--ink); padding: 2px 6px; line-height: 15px; }

/* ---------- subject page: one card per exam board */
.board-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 38px; align-items: stretch; }
.board-card { display: flex; flex-direction: column; gap: var(--u); }
.board-card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.board-card .btn { align-self: flex-start; margin-top: auto; }
.board-groups { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--divider); }
.board-groups li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--divider); font-size: 14px; line-height: var(--u); }
.board-groups .muted { font-size: 12px; }

/* ---------- homepage */
.page-home .page > * + * { margin-top: 57px; }
.h1-big { font-size: 42px; line-height: 47px; max-width: 16ch; }
.formula-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.course-bar-home { padding: 14px var(--u); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 19px; flex-wrap: wrap; }
.text-link { font-size: 15px; font-weight: 700; }
.tgroup + .tgroup { margin-top: 38px; }
.tgroup-title { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 38px; margin-bottom: 10px; }
.tcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tcard { display: flex; flex-direction: column; gap: 4px; padding: 14px; background: var(--card); border: var(--rule) solid var(--ink); text-decoration: none; color: var(--ink); min-height: 133px; text-align: left; font: inherit; }
.tcard:hover { color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.tcard:hover .tcard-title { text-decoration: underline; }
.tcard-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); line-height: var(--u); }
.tcard-top .code { font-size: 15px; font-weight: 600; color: var(--ink); }
.tcard-title { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 24px; }
.tcard-skills { font-size: 13px; line-height: 18px; color: var(--text-2); }
.tcard-wide { min-height: 0; max-width: 760px; }
.tcard-empty { border-style: dashed; border-color: var(--dashed); background: transparent; cursor: pointer; max-width: 520px; min-height: 0; }
.home-foot { align-items: stretch; }

/* ---------- learning map */
.map-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--ink); border: var(--rule) solid var(--ink); }
.map-tabs a { background: var(--card); color: var(--ink); text-decoration: none; padding: 9px 12px; display: flex; flex-direction: column; font-weight: 700; font-size: 14px; line-height: var(--u); }
.map-tabs a span { font-weight: 400; font-size: 12px; color: var(--muted); }
.map-tabs a[aria-current="true"] { background: var(--ink); color: var(--on-ink); }
.map-tabs a[aria-current="true"] span { color: var(--on-ink); opacity: 0.8; }
.map-spec { margin-top: 38px; }
.js .map-spec:not(.is-active) { display: none; }
.map-cols, .map-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: center; }
.map-cols { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0 14px 6px; }
.map-group { margin-top: 19px; }
.map-group-head { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 38px; }
.map-row { min-height: 44px; padding: 6px 14px; background: var(--card); text-decoration: none; color: var(--ink); }
.map-row:hover .map-name { text-decoration: underline; }
.map-name { font-size: 14px; line-height: var(--u); }
.map-name .code { color: var(--muted); margin-right: 6px; }
.dots { display: flex; flex-wrap: wrap; gap: 3px; }
.dots i { width: 9px; height: 9px; border: 1.5px solid var(--ink); }
.dots i.d13 { background: var(--ink); }

/* ---------- search */
.search { border: var(--rule) solid var(--ink); background: var(--paper); color: var(--ink); padding: 0; width: min(680px, calc(100vw - 24px)); max-height: min(80vh, 720px); margin: 10vh auto auto; }
.search::backdrop { background: rgba(20, 22, 28, 0.45); }
.search-inner { display: flex; flex-direction: column; max-height: inherit; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: var(--rule) solid var(--ink); background: var(--card); }
.search-bar input { flex: 1; border: none; background: transparent; color: var(--ink); font: 400 17px var(--sans); padding: 10px 0; outline: none; }
.search-scope { font-size: 12px; color: var(--muted); padding: 8px 14px 0; }
.search-results { list-style: none; margin: 0; padding: 6px 14px 14px; overflow-y: auto; }
.search-results li a { display: block; padding: 9px 0; border-bottom: 1px solid var(--divider); text-decoration: none; color: var(--ink); }
.search-results li a:hover .sr-title, .search-results li a:focus .sr-title { text-decoration: underline; }
.sr-meta { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sr-title { font-size: 15px; display: block; }
.sr-skill { display: block; font-size: 13px; color: var(--text-2); }
.sr-empty { padding: 14px 0; color: var(--muted); font-size: 14px; }

/* ---------- worked answers: working in pen ink, marks in red */
.worked { margin: 0; background: var(--card); border: var(--rule) solid var(--ink); }
.question { padding: var(--u); border-bottom: var(--rule) solid var(--ink); display: flex; flex-direction: column; gap: 8px; }
.question-marks { align-self: flex-end; font-weight: 700; }
.working { list-style: none; margin: 0; padding: 0; }
.working li { display: grid; grid-template-columns: minmax(0, 1fr) 64px; align-items: stretch; min-height: 44px; border-bottom: 1px solid var(--divider); }
.step { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px 10px var(--u); min-width: 0; }
.mpiece { white-space: nowrap; }
.why { font-size: 14px; line-height: 20px; color: var(--text-2); }
.why math { font-size: 15px; }
.working li:last-child { border-bottom: none; }
.working .line { color: var(--ink); font-size: 16px; line-height: 26px; overflow-wrap: anywhere; }
.working .line math { color: var(--ink); font-size: 17px; }
.working .aside { display: block; font-size: 14px; opacity: 0.85; }
.working .mark, .mark-key { color: var(--red); font-family: var(--stix); font-weight: 600; font-size: 16px; letter-spacing: 0.02em; }
.working .mark { text-align: center; border-left: var(--rule) solid var(--red); display: flex; align-items: center; justify-content: center; }
.total { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 10px 14px; border-top: var(--rule) solid var(--ink); font-size: 14px; font-weight: 700; }
.total .mark { font-family: var(--stix); font-weight: 600; color: var(--red); font-size: 17px; border: 1.5px solid var(--red); padding: 2px 10px; }
.worked figcaption { padding: 10px var(--u) 14px; font-size: 13px; color: var(--text-2); border-top: 1px solid var(--divider); }

/* ---------- practice questions */
.practice-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 38px; align-items: start; }
.practice-side { display: flex; flex-direction: column; gap: 19px; position: sticky; top: 96px; }
.q-list { display: flex; flex-direction: column; gap: 19px; margin-top: 19px; }
.q { background: var(--card); border: var(--rule) solid var(--ink); }
.q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px var(--u); border-bottom: 1px solid var(--divider); flex-wrap: wrap; }
.q-names { display: flex; flex-direction: column; gap: 2px; }
.q-sub { font-size: 14px; color: var(--text-2); }
.q-tags { display: flex; align-items: center; gap: 10px; }
.q-title { font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 26px; margin: 0; }
.q-meta { font-size: 13px; color: var(--muted); }
.lvl { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border: 1.5px solid currentColor; line-height: 15px; }
.lvl-easy { color: var(--dec); } .lvl-medium { color: var(--stats-dark); } .lvl-hard { color: var(--red); }
.q-body { padding: 14px var(--u); display: flex; flex-direction: column; gap: 10px; font-size: 16px; line-height: 24px; }
.q-stem { margin: 0; }
.q-parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.q-parts li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; }
.q-label { font-weight: 700; }
.q-marks { font-weight: 700; white-space: nowrap; }
.q-text { min-width: 0; overflow-wrap: anywhere; }
.answer { border-top: var(--rule) solid var(--ink); }
.answer > summary { cursor: pointer; padding: 14px var(--u); font-weight: 700; font-size: 16px; color: var(--ink); list-style: none; background: var(--paper); }
.answer > summary::-webkit-details-marker { display: none; }
.answer > summary::before { content: "+ "; }
.answer[open] > summary::before { content: "− "; }
.ans-part { border-top: 1px solid var(--divider); }
.ans-part > .q-label { display: block; padding: 10px var(--u) 0; }
.q-topics { padding: 10px var(--u); border-top: 1px solid var(--divider); display: flex; gap: 6px 14px; flex-wrap: wrap; margin: 0; }
.p-topic-note { margin: 14px 0 0; padding: 10px 14px; border: var(--rule) dashed var(--dashed); font-size: 14px; }
.levels { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.levels div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.levels dd { margin: 0; font-size: 14px; line-height: 20px; color: var(--text-2); }

/* ---------- shared controls: every segmented control on a row is the same size */
.controls { display: flex; flex-direction: column; gap: 12px; margin-bottom: 19px; }
.controls-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.controls .seg { width: 100%; min-width: 0; }
.controls-row-small { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.select { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.select select { height: 48px; min-width: 260px; padding: 0 12px; border: var(--rule) solid var(--ink); background: var(--card); color: var(--ink); font: 400 16px var(--sans); }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
.btn-big { height: 52px; padding: 0 28px; font-size: 16px; }
.p-status { margin: 0 0 4px; font-weight: 700; color: var(--text-2); }
.mixed-nav { display: flex; justify-content: center; margin-top: 19px; }
.q-list { margin-top: 10px; }

/* ---------- formulae */
.f-subject { display: flex; flex-direction: column; gap: 19px; }
.f-intro { max-width: 680px; }
.f-year { display: flex; flex-direction: column; gap: 14px; padding-top: 19px; border-top: var(--rule) solid var(--ink); }
.f-area { display: flex; flex-direction: column; gap: 6px; }
.f-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.f-item { background: var(--card); border: var(--rule) solid var(--ink); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f-name { font-size: 14px; font-weight: 700; }
.f-board { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-left: 6px; }
.f-tex { font-size: 17px; min-width: 0; }
.f-tex math[display="block"] { display: inline math; margin: 4px 0; }
.f-tex { display: flex; flex-direction: column; gap: 2px; }

/* ---------- my course */
.page-narrow { max-width: 860px; }
.prefs { display: flex; flex-direction: column; gap: 38px; }
.pref-step { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 14px; align-items: start; }
.step-n { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--ink); color: var(--on-ink); font-family: var(--stix); font-weight: 600; font-size: 18px; }
.pref-subject { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: center; }
.pref-name { font-weight: 700; }
.pref-options { display: flex; flex-direction: column; gap: 10px; }
.pref-options .route { margin-top: 14px; }
[data-p-board="none"] { font-size: 20px !important; }
.pref-opt-title { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.pref-done { display: flex; justify-content: flex-end; padding-top: 19px; border-top: var(--rule) solid var(--ink); }
.help { margin-top: 38px; }
.help > summary { cursor: pointer; font-weight: 700; }
.glossary { margin: 14px 0 0; display: flex; flex-direction: column; gap: 12px; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 2px 0 0; color: var(--text-2); font-size: 15px; }

/* ---------- footer *//* ---------- footer */
.site-footer { border-top: var(--rule) solid var(--ink); background: var(--paper); padding: 38px 0; }
.footer-inner { display: grid; grid-template-columns: 1.1fr 1.3fr 1.5fr; gap: 38px; align-items: start; }
.footer-links { display: flex; gap: 38px; }
.footer-links ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.footer-links a { color: var(--ink); text-decoration: none; white-space: nowrap; }
.footer-links a:hover { text-decoration: underline; }
.footer-note { font-size: 12px; line-height: var(--u); color: var(--muted); }
@media (max-width: 860px) {
  .footer-inner { grid-template-columns: 1fr; gap: 19px; }
  .site-footer .brand-full { display: block; }
}

/* ---------- course line, home extras */
.btn-small { height: 36px; padding: 0 14px; font-size: 14px; }
.course-line { margin-bottom: 19px; }
.course-note { margin: 0; padding: 12px 14px; border: var(--rule) dashed var(--dashed); font-size: 15px; }
.papers-section { margin-top: 57px; }
.welcome { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 640px; }
.welcome .h3 { margin: 0; }
.subject-tabs { display: flex; gap: 0; border-bottom: var(--rule) solid var(--ink); margin-bottom: 14px; overflow-x: auto; }
.subject-tabs button { border: none; background: transparent; padding: 10px 16px; font: 700 15px var(--sans); color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1.5px; white-space: nowrap; }
.subject-tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.quick-card { display: flex; flex-direction: column; gap: 4px; padding: 14px var(--u); background: var(--card); border: var(--rule) solid var(--ink); text-decoration: none; color: var(--ink); }
.quick-card:hover { color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.quick-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.quick-card .small { color: var(--text-2); }
.formula-note { color: var(--red); margin: 0; }
.home-hero { max-width: 760px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- tablets and phones (after the component rules so they win) */
@media (max-width: 860px) {
  .board-cards, .course-edit-home, .practice-grid { grid-template-columns: 1fr; gap: 38px; }
  .practice-side { position: static; }
  .quick { grid-template-columns: 1fr; gap: 10px; }
  .topics-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .tcards { gap: 8px; }
  .tcard { padding: 12px 14px; }
  .tcard .tcard-skills { display: none; }
  .tcard-title { font-size: 17px; line-height: 22px; }
  .topic:not([open]) .topic-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .q-parts li { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .q-parts .q-marks { grid-column: auto; }
  .toolbar { position: static; }
  .topic, .group { scroll-margin-top: 90px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 19px; }
  .course-bar-home { flex-direction: column; align-items: stretch; }
}

/* ---------- small screens */
@media (max-width: 520px) {
  .h1 { font-size: 30px; line-height: 38px; }
  .toolbar .seg { min-width: 0; width: 100%; }
  .toolbar { gap: 8px; }
  .topic > summary { grid-template-columns: 40px minmax(0, 1fr) 14px; padding: 9px 12px; }
  .topic-count { display: none; }
  .h1-big { font-size: 32px; line-height: 38px; }
  .tcards { grid-template-columns: 1fr; }
  .tcard { min-height: 0; }
  .board-grid { margin-bottom: 38px; }
  .course-bar { flex-wrap: wrap; }
  .course-bar .btn { width: 100%; }
  .points { padding: 0 12px 12px; }
  .point { grid-template-columns: 40px minmax(0, 1fr); }
  .point .yr { grid-column: 2; }
  .map-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-home .page > * + * { margin-top: 38px; }
  .h1-big { font-size: 28px; line-height: 34px; }
  .lede { font-size: 16px; line-height: 24px; }
  .topic-desc { font-size: 13px; line-height: 18px; }
  .topic > summary { padding: 12px; }
  .pref-step { grid-template-columns: 1fr; gap: 10px; }
  .pref-subject { grid-template-columns: 1fr; gap: 6px; }
  .controls-row { grid-template-columns: 1fr; }
  .select, .select select { width: 100%; min-width: 0; }
  .select { flex-direction: column; align-items: stretch; gap: 4px; }
  .step { padding-left: 14px; }
  .pref-done .btn { width: 100%; }
  .f-list { grid-template-columns: 1fr; }
  .q-head { padding: 10px 14px; } .q-body { padding: 12px 14px; }
  .working li { grid-template-columns: minmax(0, 1fr) 52px; }
  .working .line { padding-left: 14px; }
  .toolbar .btn-small { width: 100%; }
  .toc { display: none; }
  .map-cols, .map-row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding-left: 10px; padding-right: 10px; }
  .dots i { width: 7px; height: 7px; border-width: 1.2px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.working li > .line { padding: 10px 14px 10px var(--u); align-self: center; }
