/* =========================================================
   ICT Revise – design system
   Colours are tokens on :root; dark theme redefines them.
   ========================================================= */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #1b2030;
  --text-2: #4a5268;
  --border: #d9deea;
  --brand: #3b4cca;
  --brand-ink: #ffffff;
  --brand-soft: #e6e9fb;
  --theory: #3b4cca;
  --theory-soft: #e6e9fb;
  --practical: #0c7560;
  --practical-soft: #dcf3ec;
  --good: #166b2e;
  --good-soft: #e3f4e8;
  --bad: #c2352b;
  --bad-soft: #fbe7e5;
  --warn: #9a6400;
  --warn-soft: #fff3d6;
  --beyond: #7b3fb5;
  --beyond-soft: #f1e8fb;
  --focus: #ff9f1c;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11141c; --surface: #1a1e29; --surface-2: #232837; --text: #e8eaf2; --text-2: #a9b0c4;
    --border: #333a4d; --brand: #8c98ff; --brand-ink: #10131b; --brand-soft: #262c4a;
    --theory: #8c98ff; --theory-soft: #262c4a; --practical: #4fd1ad; --practical-soft: #173a31;
    --good: #5cd17e; --good-soft: #17331f; --bad: #ff7d72; --bad-soft: #3d1c1a;
    --warn: #f2c14e; --warn-soft: #3a2f12; --beyond: #c79bff; --beyond-soft: #2f2342;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11141c; --surface: #1a1e29; --surface-2: #232837; --text: #e8eaf2; --text-2: #a9b0c4;
  --border: #333a4d; --brand: #8c98ff; --brand-ink: #10131b; --brand-soft: #262c4a;
  --theory: #8c98ff; --theory-soft: #262c4a; --practical: #4fd1ad; --practical-soft: #173a31;
  --good: #5cd17e; --good-soft: #17331f; --bad: #ff7d72; --bad-soft: #3d1c1a;
  --warn: #f2c14e; --warn-soft: #3a2f12; --beyond: #c79bff; --beyond-soft: #2f2342;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 17px; line-height: 1.6;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--brand); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.4em 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin-top: .3em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: .6em 0; }
code, .mono { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header / nav ---------- */
/* v4: a dark blue header bar with the site name, the course label and a five-item menu (Home, Topics, Practice,
   Progress, Help). Topics, Practice, Progress and Help open a short list of their pages (a dropdown; on phones,
   inside the Menu button, a list that opens under its name).
   js/app.js (fitHeader) picks the widest layout that fits the screen and the user's fonts:
   one row (title, menu, buttons); two rows (.hdr-stack: title row, then the menu row, which stays
   pinned at the top when the page scrolls); or a Menu button (.hdr-menu). It also sets --hdr-h, the
   height of the header that stays on screen, which sticky panels and jump links use. */
:root { --hdr-h: 68px; --hdr-bg: #15295a; --hdr-ink: #ffffff; --hdr-ink-2: #d3dbf6; --hdr-line: rgba(255, 255, 255, .3); --hdr-hover: rgba(255, 255, 255, .1); --hdr-current: rgba(255, 255, 255, .17); }
:root[data-theme="dark"] { --hdr-bg: #0e1a3d; --hdr-line: rgba(255, 255, 255, .24); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hdr-bg: #0e1a3d; --hdr-line: rgba(255, 255, 255, .24); } }
.site-header { background: var(--hdr-bg); color: var(--hdr-ink); border-bottom: 1px solid rgba(0, 0, 0, .25); position: sticky; top: 0; z-index: 50; }
.site-header :focus-visible { outline-color: var(--focus); }
.header-inner { max-width: var(--page-max); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.brand { flex: none; display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--hdr-ink); font-weight: 700; white-space: nowrap; }
.brand:hover .brand-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.brand-text { min-width: 0; }
.brand-name { display: block; font-size: 1.6rem; line-height: 1.15; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 500; font-size: .8rem; line-height: 1.25; margin-top: 3px; color: var(--hdr-ink-2); white-space: normal; max-width: 15.5em; } /* v5: the longer course label wraps onto two lines */
.main-nav { flex: none; margin-left: auto; }
.main-nav ul { list-style: none; margin: 0; padding: 0; }
.main-nav .nav-top { display: flex; gap: 2px; }
.main-nav .nav-top > li > a, .nav-group-btn { display: flex; align-items: center; gap: 4px; padding: 9px 8px; border: 0; border-radius: 8px; background: none; text-decoration: none; color: var(--hdr-ink-2); font: inherit; font-weight: 600; font-size: 1.125rem; line-height: 1.3; white-space: nowrap; cursor: pointer; }
.main-nav .nav-top > li > a:hover, .nav-group-btn:hover { background: var(--hdr-hover); color: var(--hdr-ink); }
.main-nav .nav-top > li > a[aria-current="page"], .nav-group.current > .nav-group-btn { background: var(--hdr-current); color: var(--hdr-ink); }
.nav-group-btn svg { width: 16px; height: 16px; flex: none; transition: transform .15s; }
.nav-group-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.nav-group { position: relative; }
/* Dropdown list (one row and two-row layouts) */
.nav-sub { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 236px; padding: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(10, 20, 50, .22); z-index: 60; }
.nav-sub.align-right { left: auto; right: 0; }
.nav-group.open > .nav-sub { display: block; }
.nav-sub a, .nav-sub-btn { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; text-align: left; text-decoration: none; color: var(--text); font: inherit; font-size: 1.02rem; font-weight: 500; line-height: 1.35; cursor: pointer; white-space: nowrap; }
.nav-sub a:hover, .nav-sub-btn:hover { background: var(--surface-2); }
.nav-sub a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav-sub-head { margin: 6px 12px 2px; padding-top: 8px; border-top: 1px solid var(--border); font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.nav-sub-btn { color: var(--brand); font-weight: 600; }
/* Buttons on the dark bar: Menu, Contact, Support, search and dark mode */
.nav-toggle, .theme-toggle, .search-link { flex: none; border: 1px solid var(--hdr-line); background: transparent; color: var(--hdr-ink); border-radius: 8px; padding: 8px 11px; font: inherit; font-size: 1rem; line-height: 1.4; cursor: pointer; }
.nav-toggle:hover, .theme-toggle:hover, .search-link:hover { background: var(--hdr-hover); border-color: rgba(255, 255, 255, .6); }
.search-link { display: inline-flex; align-items: center; text-decoration: none; }
.search-link svg { width: 20px; height: 20px; display: block; }
.search-link[aria-current="page"] { background: var(--hdr-current); border-color: rgba(255, 255, 255, .6); }
.main-nav li.nav-search { display: none; }
@media (max-width: 440px) { .search-link { display: none; } .hdr-menu .main-nav li.nav-search { display: list-item; } }
.nav-toggle { display: none; margin-left: auto; font-weight: 600; }
/* Two rows: the title and buttons, then the menu across the full width */
.hdr-stack .header-inner { flex-wrap: wrap; row-gap: 8px; padding-top: 12px; padding-bottom: 5px; }
.hdr-stack .search-link { order: 1; margin-left: auto; }
.hdr-stack .theme-toggle { order: 1; }
.hdr-stack .main-nav { order: 2; flex: 1 0 100%; margin: 0; padding-top: 5px; border-top: 1px solid var(--hdr-line); }
.hdr-stack .main-nav .nav-top { margin-left: -10px; }
/* Menu button (phones): the menu opens under the header; each section opens under its name */
.hdr-menu .brand { flex: 0 1 auto; min-width: 0; }
.hdr-menu .brand-name { overflow: hidden; text-overflow: ellipsis; }
.hdr-menu .nav-toggle { display: inline-block; }
.hdr-menu .main-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; max-height: calc(100vh - var(--hdr-h) - 8px); overflow-y: auto; background: var(--hdr-bg); border-top: 1px solid var(--hdr-line); border-bottom: 1px solid rgba(0, 0, 0, .3); box-shadow: 0 12px 24px rgba(10, 20, 50, .25); padding: 8px 16px 14px; margin: 0; }
.hdr-menu .main-nav.open { display: block; }
.hdr-menu .main-nav .nav-top { flex-direction: column; }
.hdr-menu .main-nav .nav-top > li > a, .hdr-menu .nav-group-btn { width: 100%; padding: 11px 12px; font-size: 1.15rem; }
.hdr-menu .nav-group-btn { justify-content: space-between; }
.hdr-menu .nav-sub { position: static; min-width: 0; padding: 0 0 6px 12px; margin: 0 0 4px; background: none; border: 0; border-left: 2px solid var(--hdr-line); border-radius: 0; box-shadow: none; }
.hdr-menu .nav-sub a, .hdr-menu .nav-sub-btn { color: var(--hdr-ink-2); padding: 9px 12px; font-size: 1.05rem; white-space: normal; }
.hdr-menu .nav-sub a:hover, .hdr-menu .nav-sub-btn:hover { background: var(--hdr-hover); color: var(--hdr-ink); }
.hdr-menu .nav-sub a[aria-current="page"] { background: var(--hdr-current); color: var(--hdr-ink); }
.hdr-menu .nav-sub-head { border-top-color: var(--hdr-line); color: var(--hdr-ink-2); }
.hdr-menu .nav-sub-btn { color: var(--hdr-ink); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 520px) {
  .header-inner { gap: 8px; }
  .brand { gap: 10px; }
  .brand small { display: none; }
  .brand-name { font-size: 1.35rem; }
}
@media (max-width: 360px) {
  .brand-name { font-size: 1.2rem; }
  .nav-toggle, .theme-toggle, .search-link { padding: 8px 10px; }
}
@media (max-width: 340px) {
  .brand { gap: 8px; }
  .brand-name { font-size: 1.1rem; }
  .nav-toggle, .theme-toggle, .search-link { padding: 8px 8px; }
}
/* Contact and Support (Ko-fi) buttons beside search and dark mode (js/app.js). fitHeader adds, only when the
   title row is too narrow: .hdr-icons (icons without labels), then in Menu layout .hdr-notheme (the dark-mode
   button moves into the menu) and .hdr-menuicon (the Menu button shows a menu icon). */
.hdr-actions { flex: none; display: flex; align-items: center; gap: inherit; }
.hdr-btn { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--hdr-line); background: transparent; color: var(--hdr-ink); border-radius: 8px; padding: 8px 11px; font-size: 1rem; line-height: 20px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.hdr-btn svg { width: 20px; height: 20px; display: block; flex: none; }
.hdr-btn:hover { background: var(--hdr-hover); border-color: rgba(255, 255, 255, .6); }
.hdr-btn[aria-current="page"] { background: var(--hdr-current); border-color: rgba(255, 255, 255, .6); }
.hdr-support { border-color: rgba(255, 159, 28, .75); }
.hdr-support:hover { border-color: #ff9f1c; }
.mug-icon { display: inline-block; flex: none; width: 22px; height: 22px; border-radius: 5px; vertical-align: middle; }
.hdr-btn .mug-icon { margin: -1px 0; }
.hdr-icons .hdr-label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* v5: hidden but still read out, so the icon keeps its name */
.hdr-nolabel .brand small { display: none; }
.hdr-icons .hdr-btn { padding: 8px 10px; }
.has-actions.hdr-stack .hdr-actions { order: 1; margin-left: auto; }
.has-actions.hdr-stack .search-link { margin-left: 0; }
.has-actions.hdr-menu .hdr-actions { margin-left: auto; }
.has-actions.hdr-menu .nav-toggle { order: 1; margin-left: 0; }
.has-actions.hdr-menu .search-link, .has-actions.hdr-menu .theme-toggle { order: 1; }
.nav-toggle svg { display: none; width: 20px; height: 20px; }
.hdr-menuicon .nav-toggle { display: inline-flex; align-items: center; padding-left: 10px; padding-right: 10px; }
.hdr-menuicon .nav-toggle svg { display: block; }
.hdr-menuicon .nav-toggle .menu-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.main-nav li.nav-theme { display: none; }
.hdr-notheme .theme-toggle { display: none; }
.hdr-menu.hdr-notheme .main-nav li.nav-theme { display: list-item; border-top: 1px solid var(--hdr-line); margin-top: 6px; padding-top: 6px; }
.nav-theme-btn { display: block; width: 100%; text-align: left; padding: 11px 12px; border: 0; border-radius: 8px; background: none; color: var(--hdr-ink-2); font: inherit; font-size: 1.15rem; font-weight: 600; line-height: 1.3; cursor: pointer; }
.nav-theme-btn:hover { background: var(--hdr-hover); color: var(--hdr-ink); }
@media (max-width: 360px) { .hdr-icons .hdr-btn { padding: 8px 9px; } }
@media (max-width: 340px) {
  .header-inner { gap: 6px; }
  .hdr-icons .hdr-btn { padding: 8px 7px; }
  .hdr-menuicon .nav-toggle { padding-left: 8px; padding-right: 8px; }
}

/* ---------- Layout ---------- */
/* v5.1: the header and the page content share one width, so their left and right edges line up on every page */
:root { --page-max: 1320px; }
.container { max-width: var(--page-max); margin: 0 auto; padding: 0 16px; }
main { padding: 20px 0 56px; }
.breadcrumb { font-size: .88rem; color: var(--text-2); margin: 4px 0 4px; }
.breadcrumb a { color: var(--text-2); }
.lead { font-size: 1.12rem; color: var(--text-2); } /* v5.1: as wide as the content below it */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.card-link { text-decoration: none; color: inherit; display: block; transition: transform .12s ease, border-color .12s; }
.card-link:hover { transform: translateY(-2px); border-color: var(--brand); }
.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); letter-spacing: .01em; }
.pill.theory { background: var(--theory-soft); color: var(--theory); }
.pill.practical { background: var(--practical-soft); color: var(--practical); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.beyond { background: var(--beyond-soft); color: var(--beyond); }
.pill.soon { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--text-2); }
.small { font-size: .88rem; }
.footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .88rem; }
.footer .container { padding: 18px 16px; display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: space-between; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(135deg, var(--brand-soft), var(--practical-soft)); border-radius: 18px; padding: clamp(20px, 4vw, 40px); margin: 8px 0 22px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center; }
.hero p { max-width: 560px; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-art { display: none; } }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { filter: brightness(1.07); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.practical { background: var(--practical); }
.btn.small { padding: 6px 11px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.section-card { border-top: 5px solid var(--theory); }
.section-card.practical { border-top-color: var(--practical); }
.progress-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s ease; }
.progress-bar.practical > span { background: var(--practical); }
.stat { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }

.notice { border-left: 4px solid var(--brand); background: var(--brand-soft); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 14px 0; }
.notice.local { border-left-color: var(--warn); background: var(--warn-soft); }

/* ---------- Topic list ---------- */
.topic-block { margin-bottom: 26px; }
.sub-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.sub-list li a, .sub-list li .sub-soon { display: flex; gap: 12px; align-items: center; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); }
.sub-list li a:hover { border-color: var(--brand); }
.sub-list .num { font-weight: 800; color: var(--brand); min-width: 2.6em; }
.sub-list .grow { flex: 1; }
.sub-soon { opacity: .75; }

/* ---------- Topic page ---------- */
.topic-layout > * { min-width: 0; }
.topic-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; align-items: start; }
.toc { position: sticky; top: calc(var(--hdr-h) + 9px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; font-size: .9rem; max-height: calc(100vh - var(--hdr-h) - 29px); overflow: auto; }
.toc ol { padding-left: 1.2em; margin: 6px 0; }
.toc a { color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--brand); text-decoration: underline; }
@media (max-width: 900px) { .topic-layout { grid-template-columns: minmax(0, 1fr); } .toc { position: static; max-height: none; } }
/* v4 (external review): learning objective, "In this topic" menu, key idea and quick check panels, Previous / Next */
.learning-objective { margin: -4px 0 12px; font-size: 1.05rem; color: var(--text-2); }
.learning-objective strong { color: var(--text); }
.toc-box > summary { list-style: none; font-weight: 700; color: var(--text); cursor: default; }
.toc-box > summary::-webkit-details-marker { display: none; }
.toc li { margin: 1px 0; }
.toc a { display: block; padding: 3px 8px; margin-left: -4px; border-radius: 6px; }
.toc a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
@media (max-width: 900px) {
  .toc-box > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
  .toc-box > summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: 0 6px 4px 0; transition: transform .15s; }
  .toc-box[open] > summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
}
.book-notes .box.box-keyidea { background: var(--brand-soft); border-color: transparent; }
.book-notes .box-keyidea .box-h { color: var(--brand); }
.book-notes .box-keyidea ul { margin: 2px 0 8px; }
.book-notes .box.box-check { background: var(--surface); border: 2px solid var(--good); padding-bottom: 12px; }
.book-notes .box-check .box-h { color: var(--good); }
.book-notes .box-check .q-item { padding: 2px 0 0; border-top: 0; }
.book-notes .box-mistakes ul { margin: 2px 0 8px; }
.pager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin: 28px 0 8px; }
.pager-link { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.pager-link:hover, .pager-link:focus-visible { border-color: var(--brand); }
.pager-link:hover .pager-title { text-decoration: underline; }
.pager-next { grid-column: 2; text-align: right; }
.pager-dir { font-size: .85rem; font-weight: 700; color: var(--brand); }
.pager-title { font-weight: 600; overflow-wrap: break-word; }
@media (max-width: 600px) { .pager { grid-template-columns: minmax(0, 1fr); } .pager-next { grid-column: auto; } .pager-gap { display: none; } }
.topic-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 22px 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.topic-section > h2 { margin-top: 16px; }
.lo-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lo-list label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 8px 10px; border-radius: 8px; }
.lo-list label:hover { background: var(--surface-2); }
.lo-list input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--good); flex: none; }
.lo-id { font-weight: 800; color: var(--brand); }
.table-wrap { position: relative; overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data thead th { background: var(--surface-2); font-weight: 700; }
table.data tbody th { background: var(--surface-2); font-weight: 700; min-width: 6.5em; }
table.data tr:last-child td, table.data tr:last-child th { border-bottom: 0; }
@media (max-width: 600px) { table.data { font-size: .88rem; } table.data th, table.data td { padding: 8px 8px; } }
.table-caption { font-size: .85rem; color: var(--text-2); margin: -4px 0 12px; }
figure { margin: 16px 0; }
figure .fig-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; display: grid; place-items: center; }
figcaption { font-size: .86rem; color: var(--text-2); margin-top: 6px; }
.callout { border-radius: var(--radius-sm); padding: 12px 16px; margin: 14px 0; border-left: 4px solid; }
.callout .callout-title { font-weight: 800; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; display: block; }
.callout.hint { background: var(--brand-soft); border-color: var(--brand); }
.callout.hint .callout-title { color: var(--brand); }
.callout.mistake { background: var(--bad-soft); border-color: var(--bad); }
.callout.mistake .callout-title { color: var(--bad); }
.callout.dyk { background: var(--warn-soft); border-color: var(--warn); }
.callout.dyk .callout-title { color: var(--warn); }
.callout.beyond { background: var(--beyond-soft); border-color: var(--beyond); }
.callout.beyond .callout-title { color: var(--beyond); }
.callout.textbook { background: var(--surface-2); border-color: var(--text-2); }
.callout.keypoint { background: var(--good-soft); border-color: var(--good); }
.callout.keypoint .callout-title { color: var(--good); }
.terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 10px 0; }
.term { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.term dt { font-weight: 800; }
.term dd { margin: 2px 0 0; color: var(--text-2); font-size: .94rem; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .compare { grid-template-columns: 1fr; } }
.compare > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.compare h4 { margin: 4px 0; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 6px 0 10px 46px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 4px; width: 32px; height: 32px; border-radius: 50%; background: var(--practical); color: #fff; font-weight: 800; display: grid; place-items: center; }
.source-note { font-size: .8rem; color: var(--text-2); }

/* ---------- Activities ---------- */
.activity { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 16px 0; box-shadow: var(--shadow); overflow: hidden; }
.activity-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 12px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.activity-head h3 { margin: 0; font-size: 1.05rem; flex: 1 1 220px; }
.activity-body { padding: 14px 18px 18px; }
.instructions { color: var(--text-2); font-size: .94rem; margin: 0 0 10px; }
.q-item { padding: 12px 0; border-top: 1px dashed var(--border); }
.q-item:first-child { border-top: 0; padding-top: 0; }
.q-text { font-weight: 600; margin-bottom: 8px; }
.q-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.options { display: grid; gap: 8px; }
.opt { text-align: left; border: 2px solid var(--border); background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: 10px; font: inherit; cursor: pointer; display: flex; gap: 10px; align-items: center; min-height: 44px; }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt .key { font-weight: 800; color: var(--text-2); min-width: 1.2em; }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt:disabled { cursor: default; }
.tf-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tf-row .opt { flex: 1 1 120px; justify-content: center; font-weight: 700; }
.feedback { margin-top: 10px; padding: 10px 14px; border-radius: 10px; font-size: .95rem; }
.feedback.good { background: var(--good-soft); border: 1px solid var(--good); }
.feedback.bad { background: var(--bad-soft); border: 1px solid var(--bad); }
.feedback.info { background: var(--surface-2); border: 1px solid var(--border); }
.feedback > strong:first-child { display: block; }
.score-line { margin-top: 12px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
input.gap { font: inherit; border: 2px solid var(--border); border-radius: 8px; padding: 2px 8px; width: 7.5em; background: var(--surface); color: var(--text); }
input.gap.correct { border-color: var(--good); background: var(--good-soft); }
input.gap.wrong { border-color: var(--bad); background: var(--bad-soft); }
.gap-text { line-height: 2.3; }
select.pick { font: inherit; font-size: .95rem; border: 2px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--surface); color: var(--text); max-width: 100%; }
select.pick.correct { border-color: var(--good); }
select.pick.wrong { border-color: var(--bad); }
.match-grid { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr; gap: 8px 14px; align-items: center; }
@media (max-width: 600px) { .match-grid { grid-template-columns: 1fr; } .match-grid .term-cell { margin-top: 8px; } }
.term-cell { font-weight: 700; }
textarea.answer { width: 100%; min-height: 110px; font: inherit; border: 2px solid var(--border); border-radius: 10px; padding: 10px; background: var(--surface); color: var(--text); }
textarea.answer.code-answer { min-height: 64px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .95rem; }
.markpoints { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.markpoints label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.markpoints input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--good); }
.model { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; margin-top: 8px; }

/* Drag and drop / sorting */
.chip-bank { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; padding: 10px; border: 2px dashed var(--border); border-radius: 10px; margin-bottom: 12px; }
.chip { background: var(--surface); border: 2px solid var(--border); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .93rem; cursor: grab; touch-action: none; user-select: none; color: var(--text); min-height: 40px; }
.chip.picked { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }
.chip.correct { border-color: var(--good); background: var(--good-soft); }
.chip.wrong { border-color: var(--bad); background: var(--bad-soft); }
.chip.dragging { opacity: .4; }
.drop-zones { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.zone { border: 2px dashed var(--border); border-radius: 12px; padding: 10px; min-height: 120px; background: var(--surface-2); }
.zone h4 { margin: 0 0 8px; font-size: .95rem; }
.zone.over, .cell-drop.over { border-color: var(--brand); background: var(--brand-soft); }
.zone .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cell-drop { min-height: 46px; border: 2px dashed var(--border); border-radius: 8px; padding: 4px; display: flex; align-items: center; justify-content: center; }
.cell-drop.target-ready { cursor: pointer; }

/* Ordering */
.order-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.order-list li { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 2px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.order-list li.correct { border-color: var(--good); background: var(--good-soft); }
.order-list li.wrong { border-color: var(--bad); background: var(--bad-soft); }
.order-list .pos { font-weight: 800; color: var(--text-2); min-width: 1.5em; }
.order-list .txt { flex: 1; }
.icon-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; width: 38px; height: 38px; font-size: 1rem; cursor: pointer; }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* Identify the mistake */
.mistake-text { line-height: 2; }
.seg { border: 0; background: transparent; color: inherit; font: inherit; padding: 2px 4px; border-radius: 6px; cursor: pointer; text-align: left; border-bottom: 2px dotted var(--text-2); }
.seg:hover { background: var(--surface-2); }
.seg.flagged { background: var(--warn-soft); border-bottom-color: var(--warn); }
.seg.correct { background: var(--good-soft); border-bottom-color: var(--good); }
.seg.wrong { background: var(--bad-soft); border-bottom-color: var(--bad); }
.seg.missed { outline: 2px solid var(--bad); }

/* Flashcards */
.flash-wrap { display: grid; justify-items: center; gap: 12px; }
.flashcard { width: min(520px, 100%); min-height: 210px; perspective: 1000px; border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.flash-inner { position: relative; width: 100%; min-height: 210px; transition: transform .45s ease; transform-style: preserve-3d; }
.flashcard.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; display: grid; place-items: center; padding: 22px; text-align: center; font-size: 1.15rem; border: 2px solid var(--border); background: var(--surface); }
.flash-face.front { font-weight: 800; font-size: 1.35rem; background: var(--brand-soft); }
.flash-face.back { transform: rotateY(180deg); }
.flash-face .hint-small { position: absolute; bottom: 10px; font-size: .78rem; color: var(--text-2); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .flash-inner { transition: none; } .card-link { transition: none; } }

/* Labelling */
.label-wrap { display: grid; grid-template-columns: minmax(260px, 1.3fr) 1fr; gap: 16px; align-items: start; }
@media (max-width: 700px) { .label-wrap { grid-template-columns: 1fr; } }
.label-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.label-list li { display: flex; gap: 10px; align-items: center; }
.marker-num { width: 28px; height: 28px; border-radius: 50%; background: var(--focus); color: #1b1300; font-weight: 800; display: grid; place-items: center; flex: none; }

/* Quick-fire */
.qf-timer { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.qf-q { font-size: 1.2rem; font-weight: 700; margin: 10px 0; }
.qf-input { font: inherit; font-size: 1.1rem; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--border); width: min(320px, 100%); background: var(--surface); color: var(--text); }
.qf-flash { min-height: 1.6em; font-weight: 700; }

/* Scenario */
.scenario-box { background: var(--practical-soft); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.part { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border); }

/* Challenge */
.setup-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.setup-grid > * { min-width: 0; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0; background: var(--surface); }
legend { font-weight: 800; padding: 0 6px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label { border: 2px solid var(--border); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.radio-row input { accent-color: var(--brand); }
.radio-row label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.result-big { font-size: 3rem; font-weight: 900; line-height: 1; }
.review-item { border-left: 4px solid var(--border); padding: 6px 12px; margin: 10px 0; }
.review-item.good { border-left-color: var(--good); }
.review-item.bad { border-left-color: var(--bad); }

/* Formula sandbox */
.sheet-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.sheet { border-collapse: collapse; font-size: .9rem; font-family: var(--mono); min-width: 560px; width: 100%; }
table.sheet th { background: var(--surface-2); color: var(--text-2); font-weight: 600; padding: 4px 8px; border: 1px solid var(--border); text-align: center; }
table.sheet td { border: 1px solid var(--border); padding: 4px 8px; white-space: nowrap; }
table.sheet td.num { text-align: right; }
table.sheet td.hl { background: var(--brand-soft); }
.formula-bar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.formula-bar label { font-weight: 800; font-family: var(--mono); }
.formula-bar input { flex: 1 1 260px; font-family: var(--mono); font-size: 1rem; padding: 8px 10px; border: 2px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.formula-out { font-family: var(--mono); font-size: 1.05rem; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; min-height: 2.4em; }

/* Glossary */
.az { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 16px; }
.az a { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-weight: 700; }
.search-input { width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text); }
.gloss-list dt { font-weight: 800; margin-top: 12px; }
.gloss-list dd { margin: 2px 0 0; color: var(--text-2); }
.result-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.result-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
mark { background: var(--warn-soft); color: inherit; padding: 0 2px; border-radius: 3px; }

/* Dashboard */
.bar-row { display: grid; grid-template-columns: minmax(150px, 260px) 1fr minmax(130px, 190px); gap: 10px; align-items: center; margin: 8px 0; font-size: .93rem; }
@media (max-width: 620px) { .bar-row { grid-template-columns: 1fr; gap: 4px; margin: 14px 0; } }

.formula-out.good { background: var(--good-soft); }
.formula-out.bad { background: var(--bad-soft); font-family: var(--font); font-size: .95rem; }
.formula-out.bad strong { font-family: var(--mono); color: var(--bad); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
details summary { cursor: pointer; font-weight: 600; margin: 4px 0; }
.az span { display: inline-grid; place-items: center; width: 34px; height: 34px; opacity: .45; }
.widget { margin: 12px 0; }
.grid + .grid, .card + .grid, .grid + .card { margin-top: 16px; }
[id] { scroll-margin-top: calc(var(--hdr-h) + 13px); }
.toc .btn, .toc .btn:hover { margin-top: 10px; color: var(--brand-ink); text-decoration: none; }
.hero h1 { margin-top: .4em; }
.hero-side h2 { font-size: 1.1rem; }
.hero-side .steps { margin-bottom: 0; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
.credit-list { display: grid; gap: 12px; }
.credit-item { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.credit-item img { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
@media (max-width: 520px) { .credit-item { grid-template-columns: 1fr; } .credit-item img { max-width: 160px; } }
pre.code { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-family: var(--mono); font-size: .85rem; line-height: 1.5; }
p code, li code, td code, .callout code, .feedback code { overflow-wrap: anywhere; word-break: break-word; }
@media print {
  .site-header, .footer, .toc, .btn, .nav-toggle, .pager, .book-notes .box-check { display: none !important; }
  body { background: #fff; color: #000; }
  .topic-section, .card, .activity { box-shadow: none; break-inside: avoid; }
}
/* Widgets */
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.form-row input[type=text] { flex: 1 1 220px; min-width: 0; }
.form-row input[type=number] { width: 5em; }
.widget pre.code { overflow-x: auto; font-size: .85rem; }
.form-row input, .form-row select { font: inherit; border: 2px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); color: var(--text); min-height: 40px; }
.widget .formula-out { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }

/* ---- Practical challenges and troubleshooting ---- */
.task { border-top: 4px solid var(--practical, #0f7b5f); }
.task h3 { margin-top: 6px; }
.task-files { display: flex; flex-wrap: wrap; gap: 8px; }
.task-list { list-style: none; padding-left: 0; counter-reset: t; }
.task-list li { counter-increment: t; margin: 6px 0; }
.task-list label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.task-list label::before { content: counter(t) "."; font-weight: 700; min-width: 1.4em; color: var(--text-2); }
.task-list input { margin-top: 4px; flex: none; width: 18px; height: 18px; }
.task details { margin-top: 8px; }
.trouble details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; margin: 6px 0; background: var(--surface); }
.trouble-fix { padding: 4px 0 6px; }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cc-sample { padding: 18px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 1.15rem; font-weight: 700; }
.form-row .btn { margin: 2px 0; }
.wp-page { background: #fff; color: #111; border: 1px solid var(--border); border-radius: 4px; padding: 20px 24px; box-shadow: 0 2px 6px rgba(0,0,0,.08); max-width: 640px; }
.wp-page .wp-head { font-weight: 700; font-size: 1.2rem; margin: 0 0 8px; }
.wp-page p, .wp-page ol { margin: 0 0 8px; }
.mm-doc { background: #fff; color: #111; border: 1px solid var(--border); border-radius: 4px; padding: 16px 20px; white-space: pre-wrap; font-family: Arial, Helvetica, sans-serif; font-size: .95rem; max-width: 560px; }
.mm-doc mark { background: #fef08a; color: #111; padding: 0 2px; }
.mm-field { color: #4338ca; font-weight: 700; }
.dq-grid { font-size: .78rem; white-space: pre; overflow-x: auto; }
td.ok { color: var(--good); font-weight: 600; }
td.bad { color: var(--bad); font-weight: 600; }
.form-row label.small { display: inline-flex; gap: 4px; align-items: center; }

/* Stage 4: chart builder and formula copy */
.chart-view { border: 1px solid var(--border); border-radius: 8px; padding: .25rem; margin: .5rem 0; max-width: 640px; }
.chart-view svg { display: block; width: 100%; height: auto; }
.bad-note { background: var(--bad-soft); border-left: 4px solid var(--bad); padding: .4rem .6rem; border-radius: 4px; }
span.bad { color: var(--bad); font-weight: 600; }
label.check { display: inline-flex; align-items: center; gap: .25rem; margin-right: .75rem; font-weight: normal; }
.hp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .5rem; }
@media (max-width: 760px) { .hp-grid { grid-template-columns: 1fr; } }
.code-edit { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: .82rem; line-height: 1.45; padding: .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); resize: vertical; tab-size: 2; }
.hp-browser { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #e5e7eb; }
.hp-tab { display: inline-block; margin: 6px 0 0 8px; padding: 4px 12px; background: #fff; color: #111827; border-radius: 6px 6px 0 0; font-size: .8rem; max-width: 85%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-frame { display: block; width: 100%; height: 330px; border: 0; background: #fff; }
.sm-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: .5rem 0; }
@media (max-width: 640px) { .sm-row { grid-template-columns: 1fr; } }
.sm-fig { margin: 0; }
.sm-slide { aspect-ratio: 16 / 9; border-radius: 6px; padding: 6% 7% 0; position: relative; box-sizing: border-box; overflow: hidden; font-family: Verdana, Arial, sans-serif; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.sm-title { font-size: clamp(.8rem, 1.6vw, 1.05rem); margin-bottom: .35rem; }
.sm-titleslide { display: flex; flex-direction: column; justify-content: center; text-align: center; padding-top: 0; }
.sm-titleslide .sm-title { font-size: clamp(.95rem, 2vw, 1.3rem); }
.sm-body { font-size: clamp(.6rem, 1.1vw, .78rem); }
.sm-body ul { margin: 0; padding-left: 1.1em; }
.sm-sub { opacity: .85; }
.sm-foot { position: absolute; left: 6%; right: 6%; bottom: 5%; display: flex; justify-content: space-between; font-size: .6rem; opacity: .85; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.sm-body { line-height: 1.25; } .sm-body li { margin: 0; } .sm-title { line-height: 1.2; }
.bv-grid { display: flex; flex-wrap: wrap; gap: 1rem; margin: .5rem 0; }
.bv-grid figure { margin: 0; text-align: center; }
.bv-canvas, .bv-svg svg { display: block; width: 240px; height: 240px; max-width: 100%; border: 1px solid var(--border); background: #fff; }
.bv-canvas { image-rendering: pixelated; }
.ir-view { min-height: 210px; display: flex; align-items: flex-start; margin: .5rem 0; overflow: hidden; }
.ir-view svg { border: 1px solid var(--border); max-width: 100%; }
.fn-list { font-size: .9rem; margin: .4rem 0; }
.fn-tips { list-style: none; padding-left: 0; }
.fn-tips li.ok { color: var(--good, #047857); }
.fn-tips li.bad { color: var(--bad); font-weight: 600; }
.widget select, .widget input[type="text"] { max-width: 100%; }

/* ---------- Stage 5: Revision Challenge ---------- */
.opt.chosen { box-shadow: inset 0 0 0 2px currentColor; }
/* Exam mode: hide right/wrong until the review. Short-answer mark schemes (.feedback.info) stay visible. */
.defer .feedback.good, .defer .feedback.bad, .defer .q-item .score-line { display: none; }
.defer .opt.correct, .defer .opt.wrong, .defer .chip.correct, .defer .chip.wrong,
.defer input.gap.correct, .defer input.gap.wrong, .defer select.pick.correct, .defer select.pick.wrong,
.defer .order-list li.correct, .defer .order-list li.wrong { border-color: var(--border); background: var(--surface); }
.defer .opt.chosen { border-color: var(--brand); background: var(--brand-soft); box-shadow: none; }
.defer .seg.correct, .defer .seg.wrong { background: var(--brand-soft); border-bottom-color: var(--brand); }
.defer .seg.missed { outline: 0; }
.breakdown summary { font-weight: 700; cursor: pointer; }
.breakdown table caption { text-align: left; font-weight: 700; padding: 10px 0 4px; }
tr.row-good th, tr.row-good td { background: var(--good-soft); }
tr.row-bad th, tr.row-bad td { background: var(--bad-soft); }
/* Long matching answers must not widen the page on phones. */
.match-grid > * { min-width: 0; }
.match-grid select.pick { width: 100%; text-overflow: ellipsis; }
@media (max-width: 600px) { .match-grid { grid-template-columns: minmax(0, 1fr); } }
/* Question bank browser */
.filter-row { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.filter-row > * { min-width: 0; width: 100%; }
.filter-row .search-input { font-size: .95rem; padding: 6px 10px; border-radius: 8px; }
.bank-item { padding: 10px 14px; margin: 8px 0; }
.bank-item summary { cursor: pointer; line-height: 1.8; overflow-wrap: anywhere; }
.bank-item .bank-q { display: block; font-weight: 600; line-height: 1.4; margin-top: 2px; }
.bank-body { padding-top: 8px; }
.bank-item[open] .bank-q { display: none; }

/* ---------- Stage 6: progress dashboard ---------- */
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.grid > * { min-width: 0; }
.continue-card { border-left: 5px solid var(--brand); margin-bottom: 16px; }
.continue-card h2 { margin-top: 0; }
.pill.status-completed { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.pill.status-in-progress { background: var(--warn-soft); color: var(--text); border-color: var(--warn); }
.pill.status-not-started { background: var(--surface-2); color: var(--text-2); }
.my-status { margin: 4px 0 14px; color: var(--text-2); }
.topic-map { margin: 12px 0; }
.topic-map-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.topic-map-head h3 { margin: 0; }
.tiles { display: grid; gap: 10px; margin-top: 12px; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); }
.tile { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--border); border-left-width: 6px; background: var(--surface); color: var(--text); text-decoration: none; min-width: 0; }
a.tile:hover { border-color: var(--brand); }
.tile-id { font-weight: 800; }
.tile-score { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 800; font-size: 1.15rem; }
.tile-title { grid-column: 1; font-weight: 600; font-size: .9rem; line-height: 1.25; }
.tile-meta { grid-column: 1 / -1; font-size: .78rem; color: var(--text-2); }
.tile.status-completed { border-left-color: var(--good); background: var(--good-soft); }
.tile.status-in-progress { border-left-color: var(--warn); }
.tile.status-not-started { border-left-color: var(--border); }
.tile.perf-good .tile-score { color: var(--good); }
.tile.perf-mid .tile-score { color: var(--warn); }
.tile.perf-bad .tile-score { color: var(--bad); }
ul.compact { padding-left: 1.1em; margin: 0; }
ul.compact li { margin: 4px 0; }
.chart-fig { margin: 0; }
.quiz-chart { width: 100%; height: auto; display: block; }
.quiz-chart .grid-line { stroke: var(--border); stroke-width: 1; }
.quiz-chart .axis { fill: var(--text-2); font-size: 12px; font-family: inherit; }
.quiz-chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; }
.quiz-chart .dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2.5; }
.home-continue { margin: 16px 0; }
/* Coverage checklist */
table.coverage th[scope=row] { font-weight: 400; min-width: 260px; width: 38%; white-space: normal; }
table.coverage td { white-space: normal; vertical-align: top; }
table.coverage th { vertical-align: top; }
table.coverage .cov-tick { font-weight: 800; color: var(--good); text-align: center; }
table.coverage tr.row-bad .cov-tick { color: var(--bad); }
/* v3 Stage 6: the question bank against the plan's minimums */
table.plan-table th[scope=row] { min-width: 180px; width: auto; }
table.plan-table td { white-space: nowrap; }
table.plan-table td.plan-ok .cov-tick { color: var(--good); }
table.plan-table td.plan-short { background: var(--bad-soft); }
table.plan-table td.plan-short .cov-tick { color: var(--bad); }
@media print {
  .site-header, .site-footer, .no-print, .notice.local { display: none !important; }
  table.coverage { font-size: 8pt; }
  table.coverage th, table.coverage td { padding: 3px 5px; }
  table.coverage .small { font-size: 7.5pt; }
  table.coverage th[scope=row] { min-width: 0; width: 34%; }
  table.coverage a { color: inherit; }
  .table-wrap { overflow: visible !important; }
  h2 { break-after: avoid; }
  tr { break-inside: avoid; }
}

/* =========================================================
   v2: learning units, rewards and games
   ========================================================= */
.crumbs { font-size: .88rem; color: var(--text-2); margin: 10px 0 4px; }
.crumbs a { color: var(--text-2); }

/* Rewards strip and toasts */
.reward-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.rs-item { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .88rem; }
.rs-item svg { width: 16px; height: 16px; }
.rs-item.xp svg { color: var(--brand); }
.rs-item.streak svg { color: var(--bad); }
.rs-item.stars svg { color: var(--warn); }
.toast-tray { position: fixed; right: 16px; top: 80px; display: grid; gap: 8px; z-index: 200; max-width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: .92rem; display: flex; gap: 10px; align-items: center; animation: toast-in .25s ease; transition: opacity .5s ease, transform .5s ease; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.badge { background: var(--surface); color: var(--text); border: 2px solid var(--warn); }
.toast-badge svg { width: 30px; height: 30px; color: var(--warn); display: block; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .toast-tray { left: 16px; right: 16px; top: 70px; max-width: none; } .toast { justify-content: center; } }
@media (max-width: 600px) { .cycle { gap: 3px; } .cycle li { font-size: .64rem; padding: 2px 7px; } .cycle li + li::before { margin-right: 4px; } }

/* Stars */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars .star svg { width: 20px; height: 20px; color: var(--border); }
.stars .star.on svg { color: var(--warn); fill: var(--warn); }

/* Units path */
.path-head { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; align-items: end; }
.path-head h1 { margin-top: .2em; }
.path-score { text-align: center; }
.ps-num { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.path-score .progress-bar { margin: 10px 0; }
.ps-stars { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
.ps-stars svg { width: 18px; height: 18px; color: var(--warn); fill: var(--warn); }
@media (max-width: 720px) { .path-head { grid-template-columns: 1fr; } .path-score { text-align: left; } }
.path { list-style: none; margin: 8px 0 24px; padding: 0; position: relative; }
.path::before { content: ""; position: absolute; left: 21px; top: 24px; bottom: 24px; width: 3px; background: var(--border); border-radius: 2px; }
.path-step { position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 12px; margin: 0 0 14px; }
.path-dot { position: relative; z-index: 1; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface); border: 3px solid var(--border); color: var(--text-2); margin-top: 14px; }
.path-dot svg { width: 22px; height: 22px; }
.path-step.done .path-dot { background: var(--good); border-color: var(--good); color: #fff; }
.path-step.started .path-dot { border-color: var(--brand); color: var(--brand); }
.path-step.next .path-dot { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 5px var(--brand-soft); }
.path-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.path-step.next .path-card { border-color: var(--brand); border-width: 2px; }
.path-card h2 { font-size: 1.15rem; margin: 4px 0 2px; }
.path-card p { margin: 0 0 6px; }
.path-card-main { min-width: 0; }
.path-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 600px) { .path-card { flex-direction: column; align-items: stretch; } .path-card .btn { justify-content: center; } .path::before { left: 17px; } .path-step { grid-template-columns: 36px minmax(0, 1fr); gap: 8px; } .path-dot { width: 36px; height: 36px; font-size: .9rem; } }
.path-more { margin-top: 8px; }

/* Unit player */
.player { max-width: 860px; margin: 0 auto 32px; scroll-margin-top: calc(var(--hdr-h) + 13px); }
.player-crumbs { max-width: 860px; margin-left: auto; margin-right: auto; } /* v5.1: the breadcrumb lines up with the unit */
.player-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.player-top h1 { margin: .1em 0 .3em; font-size: clamp(1.5rem, 3.6vw, 2rem); }
.player-kicker { margin: 10px 0 0; }
.seg-strip { display: flex; gap: 4px; margin: 6px 0 10px; }
.seg { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); }
.seg.past { background: var(--brand); border-color: var(--brand); }
.seg.now { background: var(--brand-soft); border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.seg.quiz, .seg.summary { border-radius: 4px 4px 4px 4px; }
.cycle { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0 0 12px; counter-reset: c; }
.cycle li { font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid transparent; }
.cycle li + li::before { content: "→"; margin-right: 6px; color: var(--border); font-weight: 400; }
.cycle li.on { background: var(--brand); color: var(--brand-ink); }
.cycle li.on::before { color: var(--brand-ink); }
.player-card { min-height: 320px; padding: 22px 26px; outline: none; }
.player-card h2 { margin-top: .2em; }
.card-kicker { margin: 0; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }
.player-card.t-check .card-kicker, .player-card.t-retry .card-kicker { color: var(--practical); }
.player-card.t-summary .card-kicker, .player-card.t-quiz .card-kicker { color: var(--warn); }
.player-card.t-check, .player-card.t-retry { border-top: 4px solid var(--practical); }
.player-card.t-learn { border-top: 4px solid var(--brand); }
.player-card.t-summary, .player-card.t-quiz { border-top: 4px solid var(--warn); }
.player-nav { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 12px; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; z-index: 5; }
.player-hint { flex: 1; text-align: center; }
@media (max-width: 600px) { .player-card { padding: 16px; min-height: 0; } .player-nav { padding: 10px 0 14px; } .player-top h1 { font-size: 1.35rem; margin-bottom: .2em; } .player-top > .btn { display: none; } .player-kicker { margin-top: 4px; } }
.card-questions .q-item:first-child { padding-top: 6px; }
.keyterm { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0; }
.kt-label, .ex-label { display: block; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }
.keyterm dfn { font-style: normal; font-weight: 800; }
.example { background: var(--practical-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0; }
.example .ex-label { color: var(--practical); }
.example p { margin: 2px 0 0; }
.gallery { display: grid; gap: 12px; margin: 14px 0; }
.gallery.g1 { grid-template-columns: minmax(0, 360px); }
.gallery.g2 { grid-template-columns: repeat(2, minmax(0, 330px)); }
.gallery.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) { .gallery.g3, .gallery.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gal-item { margin: 0; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; display: flex; flex-direction: column; }
.gal-img { background: #fff; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; min-height: 0; }
.gal-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gal-item figcaption { padding: 8px 10px; font-size: .88rem; display: grid; gap: 2px; }
.gal-item figcaption span { color: var(--text-2); }
.credit { color: var(--text-2); font-size: .72rem; }
.credit a { color: inherit; }
details.more { margin: 14px 0; border: 1px dashed var(--beyond); border-radius: var(--radius-sm); padding: 8px 14px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--beyond); }
.summary-list li { margin: 6px 0; }
.term-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.term-card { text-align: left; font: inherit; color: var(--text); background: var(--surface-2); border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; display: grid; gap: 6px; min-height: 64px; }
.term-card:hover { border-color: var(--brand); }
.term-card .term-def { display: none; color: var(--text-2); font-size: .92rem; }
.term-card.open { border-color: var(--good); background: var(--good-soft); }
.term-card.open .term-def { display: block; }
.term-card:not(.open)::after { content: "Tap to reveal"; font-size: .75rem; color: var(--text-2); }
.unit-result { margin-top: 18px; }
.unit-result:empty { display: none; }
.unit-result.pass { border: 2px solid var(--good); background: var(--good-soft); border-radius: var(--radius); padding: 14px 18px; }
.unit-result.fail { border: 2px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 14px 18px; }
.unit-result h3 { margin: 0 0 6px; }
.result-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 6px 0; }
.result-pct { font-size: 2rem; font-weight: 800; }
.xp-pill { background: var(--brand); color: var(--brand-ink); }
.units-banner { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-left: 5px solid var(--brand); margin: 14px 0; }
.units-banner h2 { margin: 0 0 4px; font-size: 1.2rem; }
.units-banner > :first-child { flex: 1 1 22rem; min-width: 0; }
.units-banner p { margin: 0; }
.units-banner .btn-row { margin-top: 0; }
.pill.units-pill { background: var(--brand-soft); color: var(--brand); }

/* Pick the picture (question type) and image above a question */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pick-opt { font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-radius: 10px; padding: 0; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; text-align: left; }
.pick-opt:hover:not(:disabled) { border-color: var(--brand); }
.pick-img { background: #fff; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; min-height: 0; }
.pick-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pick-cap { display: flex; gap: 8px; align-items: center; padding: 6px 10px; font-size: .9rem; flex-wrap: wrap; }
.pick-cap .key { font-weight: 800; color: var(--text-2); }
.pick-name { font-weight: 700; }
.pick-opt.correct { border-color: var(--good); background: var(--good-soft); }
.pick-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.pick-opt:disabled { cursor: default; }
.q-figure { margin: 0 0 10px; }
.q-figure .fig-box img { max-height: 260px; }
.player-card figure { margin: 14px 0; }
.player-card .fig-box img { max-height: 340px; width: auto; max-width: 100%; }
@media (max-width: 600px) { .player-card .fig-box img { max-height: 260px; } }

/* Games */
.games-filter { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: flex-end; margin-bottom: 18px; }
.gf-field { display: grid; gap: 6px; min-width: 0; max-width: 100%; }
.gf-field:first-child { flex: 0 1 420px; }
.gf-field label, .gf-label { font-weight: 700; font-size: .9rem; }
.gf-field select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%; max-width: 100%; min-width: 0; }
.level-pick { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.level-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.level-pick label { padding: 8px 16px; cursor: pointer; font-weight: 700; font-size: .9rem; background: var(--surface); }
.level-pick label + input + label, .level-pick input + label ~ label { border-left: 1px solid var(--border); }
.level-pick input:checked + label { background: var(--brand); color: var(--brand-ink); }
.level-pick input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -3px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 14px; }
.game-card { display: flex; flex-direction: column; gap: 4px; }
.game-card h2 { font-size: 1.08rem; margin: 6px 0 0; }
.game-card p { margin: 0 0 8px; flex: 1; }
.game-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.game-icon svg { width: 26px; height: 26px; }
.game-card.locked { opacity: .72; }
.game-card.locked .game-icon { background: var(--surface-2); color: var(--text-2); }
.game-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.game-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.game-head > div { flex: 1 1 auto; min-width: 0; }
.game-head > .btn { flex: none; margin-bottom: 6px; }
.game-head h1 { margin-bottom: .2em; }
.hud { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; position: sticky; top: var(--hdr-h); z-index: 6; background: var(--bg); padding: 6px 0; }
.hud:empty { display: none; }
@media (max-width: 640px) {
  .hud { top: 60px; gap: 6px; }
  .hud-item { min-width: 0; padding: 4px 10px; }
  .pair-feedback { position: sticky; bottom: 0; background: var(--bg); padding: 4px 0 8px; z-index: 4; }
  .pair-feedback:empty { display: none; }
}
.hud-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px; display: grid; min-width: 96px; }
.hud-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.hud-val { font-size: 1.2rem; }
.hud-item.time.low { border-color: var(--bad); color: var(--bad); }
.game-board { max-width: 900px; }
.game-board h2 { margin-top: 0; }
.id-photo { background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); display: grid; place-items: center; max-width: 520px; aspect-ratio: 4 / 3; margin: 0 0 14px; overflow: hidden; }
.id-photo img { width: 100%; height: 100%; object-fit: contain; }
.id-photo.small-photo { max-width: 260px; margin-top: 10px; }
.clue-list { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 12px 12px 36px; font-size: 1.05rem; }
.clue-list li { margin: 4px 0; }
.id-options { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin-top: 14px; }
.id-feedback .btn-row { margin-top: 10px; }
.pair-board { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 14px; }
.pair-col { display: grid; gap: 8px; align-content: start; }
.pair-h { font-size: .8rem !important; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 0 !important; }
.pair-btn { font: inherit; text-align: left; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; min-height: 48px; font-size: .95rem; }
.pair-btn:hover:not(:disabled) { border-color: var(--brand); }
.pair-btn.sel { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand); }
.pair-btn.matched { border-color: var(--good); background: var(--good-soft); opacity: .8; cursor: default; }
.pair-btn.shake { animation: shake .4s; border-color: var(--bad); background: var(--bad-soft); }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { .pair-btn.shake, .toast { animation: none; } }
@media (max-width: 640px) { .pair-board { grid-template-columns: 1fr; } }
.pair-feedback { margin-top: 12px; min-height: 2em; }
.pair-review .term.slipped { border-left: 4px solid var(--warn); }
td.ok { color: var(--good); font-weight: 800; }
td.no { color: var(--bad); font-weight: 800; }

/* Dashboard rewards */
.rewards-card { margin-bottom: 18px; }
.rewards-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; margin: 8px 0 14px; }
.rw-stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.rw-stat .stat { font-size: 1.6rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.badge-chip { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: .84rem; }
.badge-chip svg { width: 30px; height: 30px; color: var(--warn); }
.badge-chip.locked { opacity: .55; }
.badge-chip.locked svg { color: var(--text-2); }
.badge-chip strong { display: block; font-size: .88rem; }

/* Long file names, paths and URLs (e.g. Hillcrest_School_Logo_v1.02) wrap instead of making phones scroll sideways */
main :is(p, li, dd, dt, h1, h2, h3, h4, figcaption, .callout-title, .q-text) { overflow-wrap: break-word; }
main :is(.opt, .order-list .txt, .chip, .pair-btn, .seg, .credit, .pp-opt, .pp-text, .pp-review-opts li) { overflow-wrap: anywhere; }
.credit-item > div { min-width: 0; }
.credit-item p { overflow-wrap: anywhere; }

/* v2 Stage 3: "Extra, not examinable" units under the learning path */
.path-extra { margin-top: 28px; }
.path-extra h2 { font-size: 1.2rem; margin-bottom: 4px; }
.path-card.extra { border-style: dashed; margin-top: 12px; }
.path-card.extra h3 { font-size: 1.05rem; margin: 4px 0 2px; }
/* Long codes such as IPv6 addresses may break anywhere rather than run off a phone screen */
.player-card li, .player-card p { overflow-wrap: anywhere; }

/* Learning units list: one heading per topic */
.h-topic { font-size: 1.15rem; margin: 22px 0 8px; }
/* Phones: subtopic rows wrap their pills onto a second line, under the title */
@media (max-width: 560px) {
  .sub-list li a { flex-wrap: wrap; row-gap: 6px; }
  .sub-list li a .grow { flex-basis: calc(100% - 2.6em - 12px); min-width: 0; }
  .sub-list li a .grow + .pill { margin-left: calc(2.6em + 12px); }
}
/* v2 Stage 3: link from a practical learning unit to the tasks on the subtopic page */
.callout.tasklink { background: var(--practical-soft); border-color: var(--practical); }
.callout.tasklink .callout-title { color: var(--practical); }
.tasklink-list { margin: 6px 0 4px; padding-left: 1.2em; }
.tasklink-list li { margin: 4px 0; }
.tasklink-list a { font-weight: 700; }

/* =========================================================
   v3 additions
   ========================================================= */
/* Fonts used inside the Revision Guide diagrams (SIL Open Font License, see fonts/) */
@font-face { font-family: 'Lexend'; font-weight: 400; font-display: swap; src: url(../fonts/lexend-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Lexend'; font-weight: 500 600; font-display: swap; src: url(../fonts/lexend-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Lexend'; font-weight: 700; font-display: swap; src: url(../fonts/lexend-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(../fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 700; font-display: swap; src: url(../fonts/jetbrains-mono-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Patrick Hand'; font-weight: 400; font-display: swap; src: url(../fonts/patrick-hand-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 400; font-display: swap; src: url(../fonts/source-sans-3-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 400; font-style: italic; font-display: swap; src: url(../fonts/source-sans-3-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 500 600; font-display: swap; src: url(../fonts/source-sans-3-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 700; font-display: swap; src: url(../fonts/source-sans-3-latin-700-normal.woff2) format('woff2'); }

:root { --real: #1d5fa6; --real-soft: #e6eef8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --real: #8cb8ec; --real-soft: #1b2a3d; } }
:root[data-theme="dark"] { --real: #8cb8ec; --real-soft: #1b2a3d; }

/* ---------- Revision Guide notes ---------- */
.book-notes > :first-child { margin-top: 0; }
.book-notes h4 { font-size: 1.02rem; margin: 1.1em 0 .4em; }
.book-notes ul, .book-notes ol { padding-left: 1.3em; }
.book-notes li { margin: .2em 0; }
.book-notes .box { border-radius: var(--radius-sm); padding: 12px 16px 6px; margin: 14px 0; border: 1px solid var(--border); background: var(--surface); }
.book-notes .box-h { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .92rem; letter-spacing: .01em; margin-bottom: 4px; }
.book-notes .box-h svg { width: 20px; height: 20px; flex: none; }
.book-notes .box-b > :first-child { margin-top: 0; }
.book-notes .box-keypoints { background: var(--brand-soft); border: none; border-left: 6px solid var(--brand); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.book-notes .box-keypoints .box-h { color: var(--brand); }
.book-notes .box-tip { background: var(--good-soft); border-color: transparent; }
.book-notes .box-tip .box-h { color: var(--good); }
.book-notes .box-mistake { background: var(--bad-soft); border-color: transparent; }
.book-notes .box-mistake .box-h { color: var(--bad); }
.book-notes .box-real { background: var(--real-soft); border-color: transparent; }
.book-notes .box-real .box-h { color: var(--real); }
.book-notes .box-try { background: var(--warn-soft); border: 2px dashed var(--warn); }
.book-notes .box-try .box-h { color: var(--warn); }
.book-notes .box-steps, .book-notes .box-note { background: var(--surface-2); border-color: var(--border); }
.book-notes .box-beyond { border-style: dashed; }
.book-notes .box-beyond .box-h { color: var(--beyond); }
.book-notes .box-term { border: 2px solid var(--brand); }
.book-notes .box-term .box-h { color: var(--brand); }
.book-notes .box-term .term-word { color: var(--text); font-size: 1.02rem; }
.book-notes .box-term .lbl { margin-left: auto; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.book-notes .box-steps ol { counter-reset: step; list-style: none; padding-left: 0; }
.book-notes .box-steps ol > li { counter-increment: step; position: relative; padding-left: 34px; margin-bottom: 8px; }
.book-notes .box-steps ol > li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: .8rem; display: grid; place-items: center; }
.book-notes .duo, .book-notes .trio, .book-notes .terms { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; align-items: start; }
.book-notes .trio { grid-template-columns: 1fr 1fr 1fr; }
.book-notes .duo-wide { grid-template-columns: 1.35fr 1fr; }
.book-notes .duo-narrow { grid-template-columns: 1fr 1.35fr; }
.book-notes .duo .terms, .book-notes .trio .terms { grid-template-columns: 1fr; }
@media (max-width: 760px) { .book-notes .duo, .book-notes .trio, .book-notes .terms, .book-notes .duo-wide, .book-notes .duo-narrow { grid-template-columns: 1fr; } }
.book-notes .pc { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 14px 0; overflow: hidden; background: var(--surface); }
.book-notes .pc > div { padding: 10px 14px 4px; }
.book-notes .pc > .pro { border-right: 1px solid var(--border); }
.book-notes .pc-title { grid-column: 1 / -1; background: var(--brand-soft); color: var(--brand); font-weight: 700; border-bottom: 1px solid var(--border); padding: 8px 14px !important; }
.book-notes .pc h5 { display: flex; align-items: center; gap: 6px; font-size: .95rem; margin: 0 0 6px; }
.book-notes .pc h5 svg { width: 18px; height: 18px; }
.book-notes .pro h5 { color: var(--good); }
.book-notes .con h5 { color: var(--bad); }
@media (max-width: 560px) { .book-notes .pc { grid-template-columns: 1fr; } .book-notes .pc > .pro { border-right: none; border-bottom: 1px solid var(--border); } }
.book-notes ul.ticks, .book-notes ul.crosses { list-style: none; padding-left: 0; }
.book-notes ul.ticks li, .book-notes ul.crosses li { position: relative; padding-left: 24px; }
.book-notes ul.ticks li::before, .book-notes ul.crosses li::before { position: absolute; left: 2px; top: 0; font-weight: 800; }
.book-notes ul.ticks li::before { content: '✓'; color: var(--good); }
.book-notes ul.crosses li::before { content: '✗'; color: var(--bad); }
.book-notes svg.yes, .book-notes svg.no { width: 16px; height: 16px; vertical-align: -2px; }
.book-notes table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .95rem; background: var(--surface); }
.book-notes th, .book-notes td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
.book-notes thead th { background: var(--brand-soft); }
.book-notes .table-scroll { overflow-x: auto; }
.book-notes figure { margin: 16px 0; }
.book-notes figure > svg { display: block; width: 100%; height: auto; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 6px; }
.book-notes figcaption { font-size: .88rem; color: var(--text-2); margin-top: 6px; }
.book-notes figcaption b { margin-right: .45em; color: var(--text); }
.fig-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fig-hint { display: none; font-size: .8rem; color: var(--text-2); margin: 2px 0 0; }
@media (max-width: 620px) {
  .book-notes figure .fig-scroll > svg { min-width: 600px; }
  .book-notes figure.fig-wide .fig-hint { display: block; }
}
.book-notes .improve { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 16px 0; background: var(--surface); }
.book-notes .improve-head { background: var(--brand); color: var(--brand-ink); font-weight: 700; padding: 8px 14px; display: flex; gap: 8px; align-items: center; }
.book-notes .improve-head svg { width: 20px; height: 20px; }
.book-notes .improve-body { padding: 4px 16px 10px; }
.book-notes .student { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; font-style: italic; }
.book-notes .student mark.f { background: var(--bad-soft); color: inherit; }
.book-notes .student mark.g { background: var(--good-soft); color: inherit; }
.book-notes sup.cn, .book-notes .comments .cn { display: inline-grid; place-items: center; min-width: 18px; height: 18px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: .7rem; font-style: normal; font-weight: 700; margin-right: 4px; }
.book-notes .comments { list-style: none; padding-left: 0; }
.book-notes .comments li { display: flex; gap: 6px; margin: 6px 0; }
.book-notes .verdict { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; }
.book-notes .model { background: var(--good-soft); border-radius: var(--radius-sm); padding: 4px 12px; }
.book-notes .cmd { font-weight: 700; }

/* ---------- Written answers: estimated mark ---------- */
.mark-result .est-mark { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.mark-result .est-num { font-size: 1.8rem; font-weight: 800; min-width: 74px; text-align: center; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 2px solid var(--brand); color: var(--brand); }
.mp-title { margin: 10px 0 4px; }
.mp-list { list-style: none; padding-left: 0; margin: 4px 0 8px; }
.mp-list li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.mp-list li.dev { padding-left: 26px; }
.mp-icon { font-weight: 800; width: 18px; flex: none; text-align: center; }
.mp-list li.got .mp-icon { color: var(--good); }
.mp-list li.miss .mp-icon { color: var(--bad); }
.mp-list li.near .mp-icon { color: var(--warn); }
.mp-hint { color: var(--text-2); font-size: .9rem; }
.mark-tips { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; }
.mark-tips ul { margin: 4px 0; padding-left: 1.2em; }
.improved { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; }
.improved ul { margin: 4px 0; padding-left: 1.2em; }
/* v4: written feedback in three parts (what you got right, what was missing, how to improve) */
.fb-part { border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; border-left: 4px solid var(--border); background: var(--surface); }
.fb-right { border-left-color: var(--good); }
.fb-missing { border-left-color: var(--bad); }
.fb-part.fb-how { border-left-color: var(--warn); background: var(--warn-soft); }
.fb-head { margin: 0 0 4px; }
.fb-list { list-style: none; padding-left: 0; margin: 4px 0; }
.fb-list > li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; overflow-wrap: anywhere; }
.fb-list > li + li { border-top: 1px dashed var(--border); }
.fb-list li.got > .mp-icon, .fb-dev .mp-icon { color: var(--good); }
.fb-list li.miss > .mp-icon { color: var(--bad); }
.fb-list li.near > .mp-icon, .fb-list li.dev > .mp-icon { color: var(--warn); }
.fb-quote, .fb-dev { display: block; font-size: .92rem; margin-top: 2px; }
.fb-quote q { font-style: italic; }
.fb-dev .mp-icon { display: inline-block; width: auto; margin-right: 4px; }
.mark-result .est-num { white-space: nowrap; flex: none; }
details.all-points { margin: 8px 0; }
details.all-points .mp-title { margin: 4px 0; }
.levels-tips { margin-top: 0; }
.adjust { align-items: center; }
.small-select { width: auto; min-width: 90px; }
.q-marks { color: var(--text-2); font-weight: 600; white-space: nowrap; }
.why-chosen { margin-top: 6px; }
.why-others { margin-top: 6px; }
.why-others summary { cursor: pointer; font-weight: 600; }
.why-others ul { margin: 4px 0; padding-left: 1.2em; }
.challenge-stage.defer .why-others, .challenge-stage.defer .mark-result { display: none; }
.review-item .why-others, .review-item .mark-result { display: block; }

/* ---------- Topic hub ---------- */
.hub-section { margin: 28px 0; }
.hub-section > h2 { margin-bottom: .2em; }
.topic-block-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.topic-block-head h2 { margin-bottom: .3em; }
.sub-grid, .mode-grid, .level-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin-top: 12px; }
.level-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sub-card h3 { margin: .4em 0 .2em; font-size: 1.05rem; }
.sub-card h3 a { text-decoration: none; color: var(--text); }
.sub-card-top, .level-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub-num { font-weight: 800; color: var(--brand); }
.mode-card { display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer; border: 1px solid var(--border); font: inherit; color: var(--text); }
.mode-card:hover:not([disabled]) { border-color: var(--brand); }
.mode-card[disabled] { opacity: .65; cursor: default; }
.mode-card strong { color: var(--brand); font-size: 1.05rem; }
.mode-card.mistakes strong { color: var(--bad); }
.scope-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.scope-row select { max-width: 100%; width: auto; }
.level-card.locked { opacity: .75; }
.level-card.passed { border-color: var(--good); }
.level-badge { display: inline-block; background: var(--brand); color: var(--brand-ink); font-weight: 800; border-radius: 999px; padding: 2px 12px; font-size: .85rem; }
.level-card h3 { margin: .4em 0 .2em; }
.progress-bar.slim { height: 8px; }
.exam-group summary { cursor: pointer; }
.exam-list .q-item { margin: 14px 0; }
.pill-link { text-decoration: none; }
.pill-link:hover { text-decoration: underline; }
.runner .back-btn { margin-bottom: 10px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.quiz-title { margin: 0 0 8px; font-size: 1.2rem; }
.quiz-clock { font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.quiz-clock.low { background: var(--bad-soft); color: var(--bad); }
.revise-next ul { margin: 4px 0; }
/* v3: grid columns in the guide's layouts may shrink below a wide diagram's width (the diagram scrolls instead) */
.book-notes .duo > *, .book-notes .trio > *, .book-notes .terms > * { min-width: 0; }
@media (max-width: 760px) { .book-notes .duo, .book-notes .trio, .book-notes .terms, .book-notes .duo-wide, .book-notes .duo-narrow { grid-template-columns: minmax(0, 1fr); } }
.book-notes p, .book-notes li, .book-notes td { overflow-wrap: break-word; }

/* =========================================================
   v3 Stage 5: activities (js/games.js, games-words.js, games-bank.js)
   ========================================================= */
.seg-toggle { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.not-here { flex: 1 1 100%; }
.term-review .term.slipped { border-left: 4px solid var(--warn); }

/* Match the Pair: drag a term onto its definition */
.drag-ghost { position: fixed; z-index: 300; pointer-events: none; background: var(--surface); color: var(--text); border: 2px solid var(--brand); border-radius: 10px; padding: 8px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.22); font-size: .95rem; opacity: .95; }
.pair-btn.dragging { opacity: .45; }
.pair-btn.drop-over { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand); }
@media (min-width: 641px) { .pair-btn.t { touch-action: none; } }

/* Speedy Typing */
.type-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 10px; }
.type-label { margin: 0; font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.type-target { font-family: var(--mono); font-size: 1.25rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
.type-target span.ok { color: var(--good); }
.type-target span.bad { color: var(--bad); background: var(--bad-soft); border-radius: 2px; }
.type-target span.now { color: var(--text); box-shadow: inset 0 -3px 0 var(--focus); }
.type-target span.sp.bad { text-decoration: underline wavy; }
.type-input { font-family: var(--mono); font-size: 1.15rem; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; min-height: 48px; }
.type-input:focus { border-color: var(--brand); }
.type-def, .type-next { margin: 0; }

/* Guess the Key Term */
.guess-clue { margin: 0 0 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--brand); border-radius: var(--radius-sm); font-size: 1.08rem; }
.hint-row { margin: 8px 0; }
.hint-box .hint { margin: 4px 0; font-weight: 700; }
.hint-box .hint.pattern { font-family: var(--mono); font-size: 1.15rem; letter-spacing: .04em; white-space: pre-wrap; }
.guess-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.guess-input { flex: 1 1 220px; font: inherit; padding: 9px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); min-height: 46px; }
.guess-input:focus { border-color: var(--brand); }
.guess-choices { margin: 10px 0; }

/* Crossword */
.cw-bar { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 12px; min-height: 2.6em; font-size: .95rem; }
.cw-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 24px; align-items: start; }
@media (max-width: 820px) { .cw-wrap { grid-template-columns: minmax(0, 1fr); } }
.cw-scroll { overflow-x: auto; max-width: 100%; padding: 2px; }
.cw-grid { display: inline-block; --cell: 34px; }
.cw-row { display: flex; }
.cw-cell { position: relative; flex: 0 0 auto; width: var(--cell); height: var(--cell); margin: 0 -1px -1px 0; border: 1px solid var(--text-2); background: var(--surface); }
.cw-cell.block { border-color: transparent; background: transparent; }
.cw-cell.in-word { background: var(--brand-soft); }
.cw-cell.active { background: color-mix(in srgb, var(--focus) 28%, var(--surface)); box-shadow: inset 0 0 0 2px var(--focus); z-index: 1; }
.cw-cell.wrong { background: var(--bad-soft); }
.cw-cell.wrong .cw-in, .cw-cell.wrong .cw-letter { color: var(--bad); }
.cw-cell.revealed .cw-in, .cw-cell.revealed .cw-letter { color: var(--brand); }
.cw-cell.given .cw-in { color: var(--text-2); }
.cw-num { position: absolute; top: 1px; left: 2px; font-size: calc(var(--cell) * .3); line-height: 1; font-weight: 700; color: var(--text-2); pointer-events: none; }
.cw-in { width: 100%; height: 100%; border: 0; margin: 0; padding: calc(var(--cell) * .14) 0 0; background: transparent; color: var(--text); text-align: center; font: inherit; font-weight: 800; font-size: calc(var(--cell) * .52); text-transform: uppercase; caret-color: transparent; border-radius: 0; }
.cw-in:focus { outline: none; }
.cw-letter { display: grid; place-items: center; height: 100%; padding-top: calc(var(--cell) * .12); font-weight: 800; font-size: calc(var(--cell) * .5); }
.cw-clues h3 { margin: 0 0 6px; font-size: 1rem; }
.cw-clues h3 ~ h3 { margin-top: 14px; }
.cw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cw-clue { font: inherit; font-size: .94rem; text-align: left; width: 100%; background: none; border: 0; border-radius: 8px; padding: 6px 8px; color: var(--text); cursor: pointer; }
.cw-clue:hover { background: var(--surface-2); }
.cw-list li.on .cw-clue { background: var(--brand-soft); }
.cw-solution-wrap { margin: 14px 0; }

/* Word Search */
.ws-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 24px; align-items: start; }
@media (max-width: 820px) { .ws-wrap { grid-template-columns: minmax(0, 1fr); } }
.ws-box { max-width: 100%; overflow-x: auto; padding: 2px; }
.ws-grid { display: inline-block; touch-action: none; user-select: none; -webkit-user-select: none; --ws: 30px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; }
.ws-row { display: flex; }
.ws-cell { flex: 0 0 auto; width: var(--ws); height: var(--ws); margin: 1px; padding: 0; border: 0; border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: calc(var(--ws) * .5); line-height: 1; cursor: pointer; }
.ws-cell.found.f0 { background: var(--good-soft); }
.ws-cell.found.f1 { background: var(--warn-soft); }
.ws-cell.found.f2 { background: var(--beyond-soft); }
.ws-cell.found.f3 { background: var(--practical-soft); }
.ws-cell.found.f4 { background: var(--theory-soft); }
.ws-cell.found.f5 { background: color-mix(in srgb, var(--focus) 30%, var(--surface)); }
.ws-cell.sel { background: var(--brand); color: var(--brand-ink); }
.ws-cell.missed { box-shadow: inset 0 0 0 2px var(--bad); color: var(--bad); }
.ws-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ws-list li { padding: 4px 0 4px 10px; border-left: 3px solid var(--border); font-size: .95rem; }
.ws-list li.done { border-left-color: var(--good); color: var(--text-2); }
.ws-list li.done strong { color: var(--good); }
.ws-list:not(.clues) li:not(.done) .ws-word { font-weight: 700; }
.ws-feedback { min-height: 2.6em; }
.ws-feedback .feedback { display: inline-block; }

/* True or False */
.tf-statement { font-size: 1.15rem; font-weight: 600; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 4px 0 14px; }
.tf-btn { font-size: 1.05rem; }
.tf-review { padding-left: 1.2em; }
.tf-review li { margin-bottom: 10px; }

/* Fill the Gaps */
.word-bank { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 12px; }
.word-bank .chip { cursor: default; touch-action: auto; min-height: 0; padding: 3px 12px; }
select.gap-select { font: inherit; font-size: .95rem; border: 2px solid var(--border); border-radius: 8px; padding: 2px 4px; background: var(--surface); color: var(--text); max-width: 100%; }
select.gap-select.correct { border-color: var(--good); background: var(--good-soft); }
select.gap-select.wrong { border-color: var(--bad); background: var(--bad-soft); }
.gaps-game { font-size: 1.04rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.gap-review { padding-left: 1.3em; }
.gap-review li { margin-bottom: 8px; }
.gap-review li.slipped { border-left: 4px solid var(--warn); padding-left: 8px; }

/* =========================================================
   v3 Stage 5: Smart Practice, Review My Mistakes, recommendations
   ========================================================= */
.why-line { margin: 0 0 6px; }
.pill.why { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); }
.smart-stats .card-kicker { margin-bottom: 4px; }
.smart-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 16px; }
.smart-form h2 { margin: 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.form-label { font-weight: 700; }
.smart-form select.pick { min-width: min(100%, 320px); max-width: 100%; }
.form-row { min-width: 0; max-width: 100%; }
.form-row select.pick { min-width: 0; text-overflow: ellipsis; }
.seg-radios { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg-radio { position: relative; display: inline-flex; }
.seg-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-radio span { display: inline-block; min-width: 52px; text-align: center; padding: 7px 14px; border: 2px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 700; }
.seg-radio input:checked + span { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.seg-radio input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px; }
.rec-card { display: flex; flex-direction: column; gap: 6px; border-left: 5px solid var(--brand); padding: 14px 16px; }
.rec-card h3 { margin: 0; font-size: 1.02rem; }
.rec-card p { margin: 0; flex: 1; }
.rec-card .btn-row { margin-top: 4px; }
.rec-card.k-due, .rec-card.k-mistakes { border-left-color: var(--warn); }
.rec-card.k-weak { border-left-color: var(--bad); }
.rec-card.k-unit, .rec-card.k-new, .rec-card.k-revisit { border-left-color: var(--practical); }
.pill.diff-easy { background: var(--good-soft); color: var(--good); }
.pill.diff-intermediate { background: var(--warn-soft); color: var(--text); }
.pill.diff-advanced { background: var(--beyond-soft); color: var(--beyond); }
.diff-topic { margin-bottom: 10px; padding: 12px 16px; }
.diff-topic summary { cursor: pointer; }
.diff-topic .table-wrap { margin-top: 10px; }
.how-it-works { margin-top: 18px; }
.how-it-works summary { cursor: pointer; }
.how-it-works ol { margin: 10px 0 0; padding-left: 1.3em; }
.how-it-works li { margin-bottom: 6px; }
.filter-card { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin-top: 16px; }
.filter-card .form-row { margin: 0; flex: 0 1 auto; }
.filter-card select.pick { max-width: 100%; }
.filter-card .btn-row { margin: 0; }
.mistake-list { display: grid; gap: 14px; margin-top: 8px; }
.mistake-card { border-left: 5px solid var(--bad); }
.mistake-card.fixed { border-left-color: var(--good); }
.mistake-card .q-text { margin: 8px 0; }
.your-answer { background: var(--bad-soft); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; overflow-wrap: anywhere; }
.mistake-card.fixed .your-answer { background: var(--surface-2); }
.answer-details { margin: 8px 0; }
.answer-box { background: var(--good-soft); border-radius: var(--radius-sm); padding: 8px 14px; margin-top: 6px; overflow-wrap: anywhere; }
.answer-box ul, .answer-box ol { margin: 4px 0 8px; padding-left: 1.3em; }
.answer-box .answer-expl { color: var(--text-2); }
.answer-box .table-wrap { background: var(--surface); }
mark.ans { background: var(--surface); color: var(--good); font-weight: 800; padding: 0 4px; border-radius: 4px; border: 1px solid var(--good); }
.blank { letter-spacing: .05em; color: var(--text-2); }
.try-box { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.empty-state { margin-top: 16px; }
.opts-list { margin: 4px 0 8px; padding-left: 1.2em; color: var(--text-2); }
.opts-list li { margin: 2px 0; }
/* My progress (v3): rewards kept small next to scores */
.compact-rewards { margin-top: 20px; }
.compact-rewards h2 { font-size: 1.15rem; }
.stat-sm { font-size: 1.25rem; font-weight: 800; line-height: 1.2; margin: 2px 0 4px; }
.badge-details summary { cursor: pointer; }
.badge-details .badge-grid { margin-top: 10px; }
.continue-card .rec-grid { margin: 10px 0 12px; }
.continue-card .rec-card { box-shadow: none; }

/* =========================================================
   v3 Stage 6: Practice Exam Mode (practice-exam.html, js/paper.js)
   ========================================================= */
.paper-choices { display: grid; gap: 8px; }
.paper-family { margin: 8px 0 0; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.paper-choice { display: flex; gap: 12px; align-items: center; border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; cursor: pointer; background: var(--surface); }
.paper-choice input { accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.paper-choice > span { display: grid; gap: 2px; min-width: 0; }
.paper-choice strong { color: var(--text); }
.paper-choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.paper-choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.paper-resume { margin-top: 16px; }
.paper-bar { position: sticky; top: var(--hdr-h); z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 0; margin: 4px 0 14px; }
.pb-title { font-weight: 800; }
.pb-count { color: var(--text-2); font-size: .92rem; }
.paper-bar .btn { margin-left: auto; }
.pb-time { font-size: 1.05rem; }
.paper-timeup { border-left: 5px solid var(--bad); margin-bottom: 16px; }
.paper { padding: 24px 28px; }
.paper-front { border-bottom: 2px solid var(--border); padding-bottom: 12px; margin-bottom: 8px; }
.paper-title { margin: 4px 0 4px; }
.paper-meta { font-weight: 700; margin: 0 0 10px; }
.paper-instructions h2 { font-size: 1.05rem; margin: 10px 0 4px; }
.paper-instructions ul { margin: 0 0 8px; padding-left: 1.2em; }
.paper-disclaimer { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; margin: 10px 0 0; }
.paper-q { padding: 14px 0 6px; border-bottom: 1px solid var(--border); }
.pq-head { font-size: 1.2rem; margin: 6px 0 10px; }
.pq-total { text-align: right; font-weight: 700; color: var(--text-2); margin: 6px 0 4px; }
.paper-part { margin: 0 0 18px; }
.pp-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.pp-label { font-weight: 800; color: var(--brand); }
.pp-text { font-weight: 600; }
.pp-text p { margin: 0; }
.pp-marks { font-weight: 700; color: var(--text-2); white-space: nowrap; }
.pp-options { border: 0; padding: 0; margin: 0 0 4px; display: grid; gap: 8px; min-width: 0; }
.pp-opt { display: flex; gap: 10px; align-items: center; border: 2px solid var(--border); border-radius: 10px; padding: 8px 12px; background: var(--surface); cursor: pointer; min-height: 44px; }
.pp-opt input { accent-color: var(--brand); width: 18px; height: 18px; flex: none; margin: 0; }
.pp-opt .key { font-weight: 800; color: var(--text-2); min-width: 1.1em; }
.pp-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pp-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.paper-part textarea.answer { min-height: 0; }
.paper-end { padding-top: 16px; }
.paper-total { font-weight: 800; text-align: right; letter-spacing: .02em; margin: 0 0 6px; }
.paper-finish:empty { display: none; }
.paper-finish .notice p { margin: 4px 0; }
.paper-score { border-left: 5px solid var(--brand); }
.paper-score .result-big { margin: 6px 0 4px; }
.paper-tables { margin-top: 16px; }
.paper-tables table.data th[scope=row] { font-weight: 600; }
.paper-summary .revise-next { margin-top: 16px; }
.revise-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 10px; }
.revise-list li { border-left: 4px solid var(--warn); padding: 2px 0 2px 10px; }
.revise-links { margin-top: 2px; }
.paper-review .paper-q.review { border-bottom: 0; padding-top: 6px; }
.paper-review .paper-q.review > h3 { margin: 18px 0 4px; font-size: 1.1rem; }
.review-head { margin: 0 0 6px; }
.review-head .pp-label { margin-right: 2px; }
.paper-review .your-answer, .paper-self .your-answer { background: var(--surface-2); }
.ya-text { white-space: pre-wrap; margin-top: 4px; }
.ya-text.code { font-family: var(--mono); font-size: .92rem; }
.pp-review-opts { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; }
.pp-review-opts li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; border: 2px solid var(--border); border-radius: 10px; padding: 6px 12px; }
.pp-review-opts li.correct { border-color: var(--good); background: var(--good-soft); }
.pp-review-opts li.wrong { border-color: var(--bad); background: var(--bad-soft); }
.pp-review-opts .key { font-weight: 800; color: var(--text-2); }
.pp-review-opts .opt-note { font-size: .85rem; }
.levels-more summary { margin: 6px 0; }
.paper-self { margin-top: 16px; }
.paper-self h2 { font-size: 1.15rem; }
@media (max-width: 600px) {
  .paper { padding: 16px 14px; }
  .paper-bar { gap: 6px 10px; }
  .pb-title { display: none; }
  .pb-long { display: none; }
  .pb-count { font-size: .85rem; }
  .pp-head { grid-template-columns: auto minmax(0, 1fr); }
  .pp-marks { grid-column: 2; justify-self: end; margin-top: -4px; }
}
@media print {
  .paper-bar, .paper-finish, .paper-timeup { display: none !important; }
  .paper { border: 0; padding: 0; }
}

/* ---------- Contact and support (contact.html, footer links, My progress note) ---------- */
.footer-links a { white-space: nowrap; }
.contact-card { margin: 16px 0; }
.contact-card h2 { margin-top: 0; }
.contact-card .btn-row { align-items: center; }
.contact-email { font-weight: 700; overflow-wrap: anywhere; }
.copy-status:empty { display: none; }
.kofi-btn svg, .kofi-btn .mug-icon { flex: none; }
.with-mug { display: inline-flex; align-items: center; gap: 6px; }
.mug-sm { width: 18px; height: 18px; border-radius: 4px; }
.support-note { margin-top: 18px; }
@media print { .contact-card .btn-row { display: none; } }
/* Ko-fi panel at the end of a completed learning unit (closable) */
.kofi-prompt { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: .92rem; }
.kofi-prompt p { margin: 0; flex: 1; min-width: 0; }
.kofi-prompt .kofi-mug { width: 28px; height: 28px; border-radius: 6px; }
.kofi-link { font-weight: 700; white-space: nowrap; }
.kofi-close { flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; }
.kofi-close:hover { background: var(--surface-2); color: var(--text); }
.kofi-close svg { width: 16px; height: 16px; }
@media print { .kofi-prompt { display: none; } }

/* ---------- v4: marks, first-visit note, messages ---------- */
/* "Estimated mark, not an official Pearson mark" on every mark the site works out (ICT.estLabel in js/app.js). */
.est-label { display: inline-block; font-size: .85rem; font-weight: 700; color: var(--warn); }
.est-label.block { display: block; margin: 2px 0 6px; }
.own-label { display: inline-block; font-size: .85rem; font-weight: 700; color: var(--text-2); }
/* First visit: progress is kept on this device only (js/app.js deviceNote) */
.device-note { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--warn); border-left-width: 5px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: .95rem; }
.device-note p { margin: 0; flex: 1 1 320px; }
.linkish { display: inline; padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkish:hover { text-decoration-thickness: 2px; }
.site-notify { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 10px; background: #1b2030; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: .95rem; line-height: 1.45; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.site-notify.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.site-notify:empty { display: none; }
@media print { .device-note, .site-notify { display: none !important; } }

/* ---------- v4: home page (four numbered sections and the Continue revising bar) ---------- */
.home-title { margin-bottom: .2em; }
.home .lead { margin-top: 0; }
:root { --hc-learn: #2563c9; --hc-learn-bg: #e8f0fd; --hc-practise: #1a7f45; --hc-practise-bg: #e4f5ea; --hc-exam: #6f42c1; --hc-exam-bg: #f0e9fb; --hc-progress: #a3530a; --hc-progress-bg: #fff1e0; }
:root[data-theme="dark"] { --hc-learn-bg: #17243d; --hc-practise-bg: #142c21; --hc-exam-bg: #241c3a; --hc-progress-bg: #33251a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hc-learn-bg: #17243d; --hc-practise-bg: #142c21; --hc-exam-bg: #241c3a; --hc-progress-bg: #33251a; } }
.hc-learn { --hc: var(--hc-learn); --hc-bg: var(--hc-learn-bg); }
.hc-practise { --hc: var(--hc-practise); --hc-bg: var(--hc-practise-bg); }
.hc-exam { --hc: var(--hc-exam); --hc-bg: var(--hc-exam-bg); }
.hc-progress { --hc: var(--hc-progress); --hc-bg: var(--hc-progress-bg); }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 20px 0 26px; }
@media (max-width: 720px) { .home-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; } }
.home-card { position: relative; display: flex; gap: 18px; align-items: flex-start; padding: 22px 22px 20px; border-radius: 16px; background: var(--hc-bg); border: 1px solid color-mix(in srgb, var(--hc) 18%, transparent); transition: box-shadow .15s, transform .15s; }
.home-card:hover { box-shadow: 0 8px 24px rgba(20, 30, 60, .12); transform: translateY(-2px); }
.home-card:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.home-num { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 12px; background: var(--hc); color: #fff; font-size: 1.25rem; font-weight: 800; letter-spacing: .02em; }
.home-body { min-width: 0; }
.home-body h2 { margin: 2px 0 8px; font-size: 1.4rem; }
.home-desc { margin: 0 0 6px; }
.home-sub { margin: 0 0 14px; color: var(--text-2); font-size: .95rem; }
.home-open { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--surface); color: var(--hc); font-weight: 700; font-size: .95rem; text-decoration: none; box-shadow: 0 1px 2px rgba(20, 30, 60, .08); }
.home-open::after { content: ""; position: absolute; inset: 0; border-radius: 16px; }
.home-open:focus-visible { outline: none; }
:root[data-theme="dark"] .home-open { color: color-mix(in srgb, var(--hc) 45%, #fff); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .home-open { color: color-mix(in srgb, var(--hc) 45%, #fff); } }
@media (max-width: 420px) { .home-card { padding: 18px 16px; gap: 14px; } .home-num { width: 44px; height: 44px; font-size: 1.1rem; } .home-body h2 { font-size: 1.25rem; } }
@media (prefers-reduced-motion: reduce) { .home-card { transition: none; } .home-card:hover { transform: none; } }
/* Continue revising: back to the last unfinished learning unit (js/home.js) */
.continue-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; margin: 18px 0 4px; padding: 16px 22px; border-radius: 14px; background: var(--hdr-bg); color: #fff; }
.continue-bar h2 { margin: 0 0 2px; font-size: 1.15rem; color: #fff; }
.continue-bar p { margin: 0; color: #d3dbf6; }
.continue-bar strong { color: #fff; }
.continue-text { flex: 1 1 320px; min-width: 0; }
.continue-btn { background: #2f6fe0; color: #fff; padding: 11px 20px; font-weight: 700; }
.continue-btn:hover { filter: brightness(1.1); }
.continue-btn:focus-visible { outline-color: var(--focus); }
@media (max-width: 520px) { .continue-btn { flex: 1 1 100%; justify-content: center; } }
.home-how h2 { margin-top: 0; font-size: 1.2rem; }
.home-how .steps { margin-bottom: 4px; }
/* Practice overview (practice.html) */
.hub-group { margin: 10px 0 30px; scroll-margin-top: calc(var(--hdr-h) + 12px); }
.hub-group h2 { display: flex; align-items: center; gap: 12px; }
.hub-num { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--hc); color: #fff; font-size: 1rem; font-weight: 800; }
/* About and copyright (about.html) and How to use this site (help.html) */
/* v5.1: "On this page" sits beside the sections on wide screens, as on the subtopic pages, so the page lines up
   with the header; on narrow screens it is a row of links above the sections. */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 28px; align-items: start; }
.doc-toc { margin: 4px 0 4px; font-size: .95rem; }
.doc-toc-title { margin: 0 0 2px; font-weight: 700; color: var(--text); }
.doc-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 18px; line-height: 1.7; }
@media (min-width: 901px) {
  .doc-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .doc-toc { position: sticky; top: calc(var(--hdr-h) + 9px); margin: 16px 0; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; }
  .doc-toc-title { margin-bottom: 6px; }
  .doc-toc ol { display: block; line-height: 1.4; }
  .doc-toc a { display: block; padding: 6px 8px; border-radius: 8px; color: var(--text-2); text-decoration: none; }
  .doc-toc a:hover { background: var(--surface-2); color: var(--brand); text-decoration: underline; }
}
.about-card { margin: 16px 0; scroll-margin-top: calc(var(--hdr-h) + 12px); }
.about-card h2 { margin-top: 0; }
.about-list { padding-left: 1.2em; }
.about-list li { margin: 7px 0; }
.disclaimer { margin: 0 0 12px; padding: 12px 16px; border-left: 4px solid var(--brand); border-radius: 8px; background: var(--surface-2); }
.disclaimer p { margin: 0; }
.credit-group { margin: 1.4em 0 .4em; }
.about-card .credit-item { box-shadow: none; background: var(--surface-2); }
.about-card .credit-item h4 { margin: 0 0 4px; font-size: 1rem; }
.about-teacher { margin-top: 22px; padding-top: 6px; border-top: 1px solid var(--border); }
/* Contact page: the three ways to get in touch side by side on wide screens */
.contact-routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin: 16px 0; }
.contact-routes .contact-card { margin: 0; display: flex; flex-direction: column; border-top: 5px solid var(--hc, var(--brand)); }
.contact-routes .contact-card .btn-row { margin-top: auto; }
.route-report { --hc: #c2352b; }
.route-suggest { --hc: var(--hc-practise); }
.route-enquiry { --hc: var(--hc-learn); }
.contact-pair { margin: 16px 0; }
.contact-pair .contact-card { margin: 0; }
.support-first { border-left: 5px solid #ff9f1c; }
.support-first .btn-row { margin: 4px 0; }
.kofi-btn .mug-icon { width: 24px; height: 24px; }
/* My progress: Save my progress / Restore my progress at the top (js/dashboard.js) */
.backup-card { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; border-left: 5px solid var(--hc-progress); }
.backup-card h2 { margin: 0 0 4px; font-size: 1.2rem; }
.backup-card p { margin: 0 0 4px; }
.backup-text { flex: 1 1 380px; min-width: 0; }
.backup-btns { flex: 0 1 auto; max-width: 100%; }

/* ---------- v5: topic progress cards (ICT.topicCard in js/app.js; Topics, Theory, Practical, My progress) ---------- */
.tc-heading { font-size: 1.2rem; margin: 1.2em 0 .6em; }
.topic-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; margin: 0 0 20px; }
.topic-card { margin: 0; display: flex; flex-direction: column; gap: 8px; border-top: 5px solid var(--theory); padding-top: 14px; }
.topic-card.tc-practical { border-top-color: var(--practical); }
.tc-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.topic-card h3 { margin: 2px 0 0; font-size: 1.15rem; display: flex; flex-direction: column; }
.tc-num { font-size: .8rem; font-weight: 700; color: var(--text-2); text-transform: none; letter-spacing: .02em; }
.tc-main { display: flex; align-items: center; gap: 14px; }
.tc-pct { font-size: 2.1rem; font-weight: 800; line-height: 1; color: var(--theory); min-width: 2.6ch; }
.tc-practical .tc-pct { color: var(--practical); }
.tc-pct-label { line-height: 1.35; }
.tc-pct-label strong { color: var(--text); font-weight: 600; }
.tc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0 0; }
.tc-stats > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
.tc-stats dt { font-size: .74rem; color: var(--text-2); line-height: 1.25; }
.tc-stats dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 800; }
.tc-of { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.tc-stats .tc-warn { background: var(--warn-soft); }
.tc-revisit { margin: 0; }
.tc-links { margin: auto 0 0; padding-top: 4px; }
.topic-block { scroll-margin-top: calc(var(--hdr-h) + 12px); }

/* ---------- v5: home page: Continue revising is the main panel (js/home.js) ---------- */
.continue-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px 32px; align-items: center; margin: 8px 0 8px; padding: 28px 32px; border-radius: 18px; background: var(--hdr-bg); color: #fff; box-shadow: 0 10px 30px rgba(21, 41, 90, .25); }
.ch-eyebrow { margin: 0 0 4px; font-size: .9rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #9fb6ff; }
.ch-title { margin: 0 0 6px; font-size: clamp(1.5rem, 3.4vw, 2.2rem); color: #fff; }
.ch-detail { margin: 0; font-size: 1.1rem; color: #e1e7fb; }
.ch-note { margin: 4px 0 0; color: #b9c6ef; font-size: .97rem; }
.ch-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 18px; }
.continue-hero .continue-btn { font-size: 1.15rem; padding: 14px 30px; border-radius: 12px; }
.ch-alt { color: #d3dbf6; }
.ch-alt:hover { color: #fff; }
.ch-progress { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-width: 150px; }
.ch-progress p { margin: 0; color: #d3dbf6; font-size: .92rem; line-height: 1.35; }
.ch-progress strong { color: #fff; font-size: 1.05rem; }
.ch-progress a { color: #b9c6ef; font-size: .9rem; }
.ch-ring { position: relative; width: 104px; height: 104px; }
.ch-ring svg { width: 100%; height: 100%; }
.ch-ring circle { fill: none; stroke-width: 7; }
.ch-ring-bg { stroke: rgba(255, 255, 255, .16); }
.ch-ring-fg { stroke: #6ea0ff; stroke-linecap: round; }
.ch-ring-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.45rem; font-weight: 800; }
.home-choose { font-size: 1.2rem; margin: 26px 0 0; }
.home .home-grid { margin-top: 12px; }
@media (min-width: 1100px) {
  .home .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .home .home-card { flex-direction: column; gap: 12px; padding: 18px; }
  .home .home-num { width: 44px; height: 44px; font-size: 1.1rem; }
  .home .home-body h2 { font-size: 1.25rem; }
  .home .home-desc { font-size: .95rem; }
}
@media (max-width: 640px) {
  .continue-hero { grid-template-columns: minmax(0, 1fr); padding: 22px 18px; }
  .continue-hero .continue-btn { flex: 1 1 100%; justify-content: center; }
  .ch-progress { flex-direction: row; justify-content: flex-start; text-align: left; gap: 14px; }
  .ch-ring { width: 72px; height: 72px; }
  .ch-ring-pct { font-size: 1.05rem; }
}

/* ---------- v5: Practical exam preparation (practical-exam.html, js/pexam.js) ---------- */
.pexam-top { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin: 16px 0; }
.pexam-top .card { margin: 0; }
@media (max-width: 860px) { .pexam-top { grid-template-columns: minmax(0, 1fr); } }
.pexam-about { border-left: 5px solid var(--practical); }
.pexam-about h2, .pexam-not h2, .pexam-technique h2 { margin-top: 0; font-size: 1.25rem; }
.pexam-facts { padding-left: 1.2em; margin: 0; }
.pexam-facts li { margin: 6px 0; }
.pexam-not { background: var(--warn-soft); border: 1px solid var(--warn); }
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 12px 20px; }
.tech-grid h3 { margin: 4px 0 2px; font-size: 1rem; color: var(--practical); }
.tech-grid p { margin: 0; font-size: .95rem; }
.pexam-papers { display: grid; gap: 16px; }
.ppaper h3 { margin-top: 0; font-size: 1.25rem; }
.psecs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.psec { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.psec h4 { margin: 0 0 2px; font-size: 1.02rem; }
.psec .small { margin: 0 0 6px; }
.psec-tasks { margin: 0 0 10px; padding-left: 1.1em; font-size: .95rem; }
.psec-tasks li { margin: 3px 0; }
.pexam-areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 16px; }
.parea { margin: 0; border-top: 4px solid var(--practical); }
.parea h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.parea-h { margin: 10px 0 2px; font-weight: 700; color: var(--text-2); }
.parea-list { margin: 0; padding-left: 1.1em; font-size: .95rem; }
.parea-list li { margin: 3px 0; }
.parea-links { margin: 12px 0 0; }
.ptask { border-left: 5px solid var(--practical); }
.ptask-title { margin: 8px 0 6px; font-size: 1.35rem; }
.ptask-label { color: var(--practical); }
.ptask-scenario { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.ptask-files { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.ptask-steps { padding-left: 1.4em; }
.ptask-steps li { margin: 8px 0; padding-right: 2.8em; position: relative; }
.ptask-mk { font-weight: 700; color: var(--text-2); white-space: nowrap; }
.ptask-steps .ptask-mk { position: absolute; right: 0; top: 0; }
.ptask-evidence { background: var(--practical-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0; }
.ptask-evidence ul { margin: 4px 0 0; padding-left: 1.2em; }
.ptask-mark { margin-top: 14px; padding-top: 6px; border-top: 1px dashed var(--border); }
.ptask-mark h3 { margin: 10px 0 4px; }
.ptask-mark h3:focus { outline: none; }
.ptask-scheme { list-style: none; padding: 0; margin: 8px 0; }
.ptask-scheme li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 8px; border-radius: 6px; }
.ptask-scheme li:nth-child(odd) { background: var(--surface-2); }
.ptask-scheme label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.ptask-scheme input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.ptask-scheme select { flex: none; font: inherit; font-size: .9rem; }
.ptask-total { font-size: 1.05rem; }
.ptask-model { margin-top: 10px; }
.ptask-model summary, .ptask-tips summary { cursor: pointer; font-weight: 700; }
.ptask-los { margin: 12px 0 0; }
.ptimer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.ptimer-read { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ptimer-face { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ptimer.running { border-color: var(--practical); }
.ptimer.over { border-color: var(--bad); background: var(--bad-soft); }
.ptimer.over .ptimer-face { color: var(--bad); }
.ptimer-btns { display: flex; gap: 8px; }
.ptimer-sticky { position: sticky; top: var(--hdr-h, 68px); z-index: 5; }
.ptimer-sticky .ptimer { box-shadow: var(--shadow); background: var(--surface); }
.ptask-scenario-card h2 { margin-top: 0; font-size: 1.2rem; }
.psec-total { font-size: 1.05rem; }
@media print { .ptimer, .ptask-mark, .btn-row { display: none !important; } }
.hdr-stack .brand small, .hdr-menu .brand small { max-width: none; white-space: nowrap; }
.ptask-steps.lettered { list-style: none; padding-left: .2em; }
.route-copyright { --hc: var(--hc-exam); }
.contact-routes .contact-card { scroll-margin-top: calc(var(--hdr-h) + 12px); }
.about-card h3 { margin: 1.1em 0 .3em; font-size: 1.05rem; }
.footer-version { display: block; margin-top: 4px; font-size: .85rem; }

/* ---------- v5: choose and justify, marks guide, word counter, part-mark example ---------- */
.justify-opts { display: grid; gap: 8px; margin: 6px 0 14px; }
.justify-opt { display: flex; gap: 10px; align-items: center; border: 2px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; }
.justify-opt:hover { border-color: var(--brand); }
.justify-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.justify-opt input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--brand); }
.justify-opt:has(input:disabled) { cursor: default; }
.justify-result > .feedback { margin-bottom: 12px; }
.marks-guide { margin: 6px 0 10px; }
.marks-guide summary { cursor: pointer; font-weight: 700; }
.marks-guide[open] { background: var(--surface-2, var(--surface)); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.word-count { margin: 4px 0 10px; }
.part-example { margin: 10px 0; }
.part-example summary { cursor: pointer; font-weight: 700; }
.part-example q { font-style: italic; }

/* ---------- v5: tool challenges ---------- */
.tool-challenges { margin-top: 12px; border-left: 4px solid var(--practical); }
.tc-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.tc-head h3 { margin: 0; }
.tc-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 8px 0; counter-reset: tc; }
.tc-list li button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer; min-height: 36px; }
.tc-list li.current button { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.tc-list li.done button { border-color: var(--good); }
.tc-task { margin: 8px 0; }
.tc-route { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.tc-route h4 { margin: 0 0 6px; }
.tc-route ol { margin: 0; padding-left: 1.4em; }
.q-item, .tool-challenges { scroll-margin-top: calc(var(--hdr-h, 72px) + 16px); }
.tc-list li button { text-decoration: none; }

/* ---------- v5: display settings ---------- */
html[data-text="large"] { font-size: 112.5%; }
html[data-text="large"] body { font-size: 19px; }
html[data-text="larger"] { font-size: 125%; }
html[data-text="larger"] body { font-size: 21px; }
html[data-contrast="high"] { --text: #000; --text-2: #1b1b1b; --border: #3a3a3a; --surface-2: #f1f1f1; --brand: #2c1fa8; --focus: #b45309; }
html[data-contrast="high"][data-theme="dark"] { --text: #fff; --text-2: #f0f0f0; --border: #cfcfcf; --surface-2: #1d1d1d; --bg: #000; --surface: #0d0d0d; --brand: #a9b4ff; --focus: #ffd34d; }
@media (prefers-color-scheme: dark) { html[data-contrast="high"]:not([data-theme="light"]) { --text: #fff; --text-2: #f0f0f0; --border: #cfcfcf; --surface-2: #1d1d1d; --bg: #000; --surface: #0d0d0d; --brand: #a9b4ff; --focus: #ffd34d; } }
html[data-contrast="high"] main a:not(.btn):not(.card-link):not(.pager-link) { text-decoration: underline; text-underline-offset: 2px; }
html[data-contrast="high"] .muted, html[data-contrast="high"] .small.muted { color: var(--text-2); }
html[data-contrast="high"] .card, html[data-contrast="high"] .q-item { border-color: var(--border); }
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
html[data-focus="strong"] :focus-visible { outline: 4px solid var(--focus) !important; outline-offset: 3px !important; box-shadow: 0 0 0 8px rgba(255, 196, 0, .55) !important; }
.footer-display { margin-bottom: 10px; }
.display-btn { display: inline-flex; align-items: center; gap: 8px; }
.display-settings { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); max-width: min(560px, calc(100vw - 32px)); width: 100%; padding: 20px 22px; box-shadow: var(--shadow); }
.display-settings::backdrop { background: rgba(10, 14, 30, .55); }
.display-settings h2 { margin-top: 0; }
.display-settings fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0 0 14px; padding: 10px 14px 12px; }
.display-settings legend { font-weight: 700; padding: 0 6px; }
.ds-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.ds-opt { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--border); border-radius: 10px; padding: 8px 12px; min-height: 44px; cursor: pointer; }
.ds-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.ds-toggle { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.ds-toggle input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--brand); }
.ds-toggle label { display: flex; flex-direction: column; cursor: pointer; }
:root[data-theme="dark"] .btn.danger { color: #2a0705; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { color: #2a0705; } }

/* ---------- v5: For teachers ---------- */
.teach-top { margin-bottom: 18px; }
.teach-steps li { margin-bottom: 8px; }
.teach-topic h3 { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.teach-table th[scope=row] { font-weight: 600; min-width: 14em; }
.teach-id { font-weight: 800; color: var(--brand); }
.teach-table td.num { text-align: center; }
.teach-ch { white-space: nowrap; }
.scenario-box code, .q-text code, .feedback code, .model-answer code { overflow-wrap: anywhere; word-break: break-word; }
