/* BioMetrics: site styles. Plain CSS, no build step.
 *
 * Design: warm paper background, near-black text, one accent (ink blue). Structure comes from type, spacing and thin
 * lines rather than shadows or decoration. Every colour is a variable below, in two themes:
 *   - Light (the default) is the plain :root block. Printing always uses it.
 *   - Dark is the html[data-theme='dark'] block, screen only, chosen from the Display menu in the header.
 * The server writes data-theme on <html> from the visitor's saved choice (see PreferencesController).
 */

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/fonts/PlusJakartaSans-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url('/fonts/PlusJakartaSans-italic.woff2') format('woff2');
}

/* ---------- Light theme (default, and print) ---------- */
:root {
  color-scheme: light;
  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 4px;
  --radius-lg: 6px;
  --header-h: 3.5rem;

  /* Surfaces */
  --bg: #f4f1ea;            /* page: warm paper */
  --surface: #faf8f3;       /* cards, inputs, menus */
  --surface-2: #ebe7dd;     /* subtle fills, hover */
  --surface-3: #e1dcd0;
  --border: #dad4c7;        /* hairlines */
  --border-strong: #bdb6a5; /* control borders, section rules */

  /* Text */
  --ink: #15140f;           /* headings */
  --text: #2a2822;          /* body */
  --muted: #5a564c;         /* secondary text */
  --faint: #6c675b;         /* captions, labels */

  /* Accent: one ink blue */
  --accent: #1f4f8f;        /* links and accent text */
  --accent-hover: #163c70;
  --accent-solid: #1f4f8f;  /* button fills (white text on top) */
  --accent-solid-hover: #163c70;
  --accent-tint: #e3e9f1;
  --accent-border: #b9c7dc;
  --focus: #1f4f8f;

  /* Messages and callouts */
  --danger: #a3302a;
  --danger-bg: #f4e3df;
  --danger-border: #dfb9b3;
  --charcoal: #1c1b18;      /* video posters, code blocks */
  --shadow-menu: 0 10px 28px -14px rgba(21, 20, 15, 0.4);

  --co-key-border: #1f4f8f;      --co-key-bg: #e6ecf4;      --co-key-label: #1f4f8f;
  --co-tip-border: #a8760b;      --co-tip-bg: #f3ead3;      --co-tip-label: #6d4a00;
  --co-mistake-border: #a3302a;  --co-mistake-bg: #f4e3df;  --co-mistake-label: #8a2620;
  --co-hl-border: #4a4a45;       --co-hl-bg: #e9e6de;       --co-hl-label: #3b3a35;
  --co-why-border: #8b8574;      --co-why-bg: #efece4;      --co-why-label: #4a463d;
  --note-bg: #f3ead3;            --note-border: #c9a85a;    --note-text: #5c3f00;
}

/* ---------- Dark theme (optional) ---------- */
@media screen {
  html[data-theme='dark'] {
    color-scheme: dark;
    --bg: #12171e;
    --surface: #181f28;
    --surface-2: #1f2833;
    --surface-3: #27323f;
    --border: #2b3643;
    --border-strong: #3d4a5b;

    --ink: #f2f4f7;
    --text: #d5dbe3;
    --muted: #a3aebc;
    --faint: #8f9aa9;

    --accent: #8fb4e8;
    --accent-hover: #b4cdf0;
    --accent-solid: #2f5f9e;
    --accent-solid-hover: #3a6fb0;
    --accent-tint: rgba(143, 180, 232, 0.12);
    --accent-border: rgba(143, 180, 232, 0.35);
    --focus: #8fb4e8;

    --danger: #f0a8a2;
    --danger-bg: rgba(240, 168, 162, 0.1);
    --danger-border: rgba(240, 168, 162, 0.4);
    --charcoal: #0b0e12;
    --shadow-menu: 0 12px 30px -14px rgba(0, 0, 0, 0.8);

    --co-key-border: #8fb4e8;      --co-key-bg: rgba(143, 180, 232, 0.1);   --co-key-label: #8fb4e8;
    --co-tip-border: #d6a13a;      --co-tip-bg: rgba(214, 161, 58, 0.09);   --co-tip-label: #e6bb62;
    --co-mistake-border: #e08a83;  --co-mistake-bg: rgba(224, 138, 131, 0.09); --co-mistake-label: #f0a8a2;
    --co-hl-border: #a3adba;       --co-hl-bg: rgba(163, 173, 186, 0.1);    --co-hl-label: #c3ccd8;
    --co-why-border: #6f7c8d;      --co-why-bg: rgba(111, 124, 141, 0.08);  --co-why-label: #c3ccd8;
    --note-bg: rgba(214, 161, 58, 0.1); --note-border: #d6a13a; --note-text: #f1d596;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-tint); }

[hidden] { display: none !important; } /* "hidden" always wins over a component's own display */
.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;
}

.page { flex: 1; display: flex; flex-direction: column; }
.page:focus { outline: none; }
.container { width: 100%; max-width: 72rem; margin: 0 auto; padding: 3rem 1.5rem; }
.container.narrow { max-width: 56rem; }
.center { text-align: center; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 60;
  background: var(--accent-solid); color: #fff; padding: 0.5rem 1rem; border-radius: var(--radius); font-weight: 700;
}
.skip-link:focus { top: 0.75rem; }

.site-nav {
  max-width: 80rem; margin: 0 auto; height: var(--header-h); padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }
.brand:hover { color: var(--ink); text-decoration: none; }

.nav-links { display: none; align-items: center; gap: 0.25rem; }
.nav-links a, .mobile-menu a {
  padding: 0.5rem 0.75rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
}
.nav-links a:hover, .mobile-menu a:hover { color: var(--ink); text-decoration: none; }
.nav-links a.is-active, .mobile-menu a.is-active { color: var(--ink); font-weight: 700; }

.menu-toggle {
  margin-left: auto; padding: 0.4rem 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: none; color: var(--ink); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer;
}
.mobile-menu { display: flex; flex-direction: column; padding: 0.75rem 1.5rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg); }
.mobile-menu[hidden] { display: none; }
.mobile-menu a { padding: 0.75rem; }
.mobile-menu-heading { margin: 0.75rem 0.75rem 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.mobile-menu a[aria-current='true'] { font-weight: 700; color: var(--ink); }

@media (min-width: 48rem) {
  .nav-links { display: flex; }
  .menu-toggle, .mobile-menu { display: none !important; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--bg); border-top: 1px solid var(--border-strong); color: var(--muted); font-size: 0.875rem; }
.footer-inner { max-width: 80rem; margin: 0 auto; padding: 3rem 1.5rem 2.5rem; display: grid; gap: 2rem; }
.footer-brand { margin: 0; font-size: 1.125rem; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }
.footer-brand span { color: var(--accent); }
.footer-copy { margin: 0.5rem 0 0; max-width: 24rem; }
.footer-cols { display: grid; gap: 1.5rem 3rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.footer-heading { margin: 0 0 0.6rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.footer-note { margin: 0; font-size: 0.8125rem; color: var(--faint); }
@media (min-width: 48rem) {
  .footer-inner { grid-template-columns: 1.2fr 1.8fr; gap: 4rem; }
  .footer-cols { grid-template-columns: repeat(2, max-content); justify-content: end; }
  .footer-note { grid-column: 1 / -1; padding-top: 1.5rem; border-top: 1px solid var(--border); }
}

/* ---------- Buttons ---------- */
.button {
  display: inline-block; padding: 0.7rem 1.25rem; border-radius: var(--radius);
  background: var(--accent-solid); color: #fff; font-weight: 600; text-decoration: none;
  border: 1px solid var(--accent-solid); cursor: pointer;
}
.button:hover { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); color: #fff; text-decoration: none; }
.button-outline, .button-dark { background: transparent; color: var(--ink); border: 1px solid var(--border-strong); }
.button-outline:hover, .button-dark:hover { background: var(--surface-2); border-color: var(--ink); color: var(--ink); }
.button-small { padding: 0.45rem 0.9rem; font-size: 0.875rem; }
.button-block { display: block; width: 100%; text-align: center; font: inherit; font-weight: 600; }
.button:disabled { opacity: 0.4; cursor: not-allowed; }
.text-link { font-weight: 600; text-decoration: underline; }

/* ---------- Home page ---------- */
.home-hero { padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 5vw, 3.5rem); }
.home-hero h1 { max-width: 15em; font-size: clamp(2.5rem, 6.2vw, 4.5rem); line-height: 1.04; letter-spacing: -0.035em; }
.home-lead { max-width: 38rem; margin: 1.5rem 0 0; font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--muted); }
.choose-h { margin: clamp(2.5rem, 6vw, 4rem) 0 0.75rem; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

.subject-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-strong); }
.subject-row {
  display: grid; gap: 1rem 3rem; grid-template-columns: 1fr; padding: 2rem 0;
  border-bottom: 1px solid var(--border-strong); color: inherit; text-decoration: none;
}
.subject-row:hover { text-decoration: none; color: inherit; }
.subject-name { font-size: clamp(1.75rem, 3.6vw, 2.5rem); letter-spacing: -0.03em; }
.subject-row:hover .subject-name { color: var(--accent); }
.subject-facts { list-style: none; margin: 0.75rem 0 0; padding: 0; font-size: 0.875rem; color: var(--muted); }
.subject-facts li { margin-bottom: 0.15rem; }
.subject-desc { margin: 0 0 0.75rem; color: var(--text); }
.subject-topics { margin: 0; font-size: 0.875rem; color: var(--muted); }
.subject-go { align-self: start; font-weight: 700; color: var(--accent); text-decoration: underline; text-underline-offset: 0.25em; white-space: nowrap; }
@media (min-width: 52rem) {
  .subject-row { grid-template-columns: 1fr 1.25fr auto; padding: 2.25rem 0; }
}

.band { border-top: 1px solid var(--border); padding: clamp(3rem, 7vw, 5.5rem) 0; }
.band-alt { background: var(--surface); }
.split { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 60rem) { .split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 4.5rem; align-items: start; } }
.split-text h2 { font-size: clamp(1.75rem, 3.6vw, 2.6rem); letter-spacing: -0.03em; margin-bottom: 1rem; }
.split-text p { max-width: 30rem; color: var(--muted); }
.split-text .text-link { display: inline-block; margin-top: 0.5rem; }

.product { margin: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg); overflow: hidden; }
.band-alt .product { background: var(--bg); }
.product-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; padding: 0.7rem 1.25rem; border-bottom: 1px solid var(--border); font-size: 0.8125rem; color: var(--muted); }
.product-bar strong { color: var(--ink); }
.product-body { padding: 1.5rem 1.5rem 1.75rem; }
.product-title { font-size: 1.375rem; margin-bottom: 1rem; }
.product figcaption, .product-caption { margin: 0; padding: 0.7rem 1.25rem; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--faint); }
.product .doc-body { font-size: 1rem; margin-top: 1.25rem; }
.demo-question { margin-bottom: 1.25rem; font-size: 1.25rem; line-height: 1.5; color: var(--ink); }

/* ---------- About / generic pages ---------- */
.page-head { margin-bottom: 3rem; }
.page-head h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); letter-spacing: -0.035em; margin-bottom: 1.25rem; }
.lead-quote { font-size: 1.25rem; color: var(--muted); }
.section-title { font-size: 1.75rem; margin-bottom: 1.5rem; }
.stack-lg { margin-bottom: 4rem; }
.card-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 48rem) { .card-grid { grid-template-columns: 1fr 1fr; } }
.muted-italic { color: var(--muted); }
.cta-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }

.message-page { padding-top: 6rem; padding-bottom: 6rem; }
.eyebrow { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.5rem; }
.message-page h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.message-page .button { margin-top: 1rem; }

/* ---------- Legal pages ---------- */
.legal { max-width: 44rem; }
.legal h1 { font-size: clamp(2rem, 4.5vw, 3rem); letter-spacing: -0.035em; margin-bottom: 0.5rem; }
.legal h2 { margin: 2.5rem 0 0.75rem; font-size: 1.375rem; }
.legal p, .legal li { color: var(--text); }
.legal ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.legal li { margin-bottom: 0.4rem; }
.legal-updated { margin: 0 0 1.5rem; font-size: 0.875rem; color: var(--faint); }
.draft-banner { margin: 1.25rem 0 2rem; padding: 1rem 1.25rem; border: 1px solid var(--note-border); border-radius: var(--radius); background: var(--note-bg); color: var(--note-text); font-size: 0.9375rem; }
.draft-banner strong { color: inherit; }
.tbc { padding: 0.05rem 0.35rem; border: 1px solid var(--note-border); border-radius: 2px; background: var(--note-bg); color: var(--note-text); font-weight: 600; }

/* ---------- Header account area ---------- */
.nav-account { display: none; align-items: center; gap: 0.5rem; margin-left: auto; margin-right: 0.25rem; }
@media (min-width: 48rem) { .nav-account { display: flex; } .nav-links { margin-left: 1.5rem; margin-right: auto; } }
.nav-signin { padding: 0.5rem 0.75rem; font-size: 0.875rem; font-weight: 500; color: var(--muted); text-decoration: none; }
.nav-signin:hover { color: var(--ink); text-decoration: none; }

.user-menu, .a11y-menu { position: relative; }
.user-menu summary, .a11y-menu summary {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.6rem;
  border-radius: var(--radius); cursor: pointer; list-style: none; color: var(--muted); font-size: 0.875rem; font-weight: 500;
}
.user-menu summary::-webkit-details-marker, .a11y-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .a11y-menu summary:hover, .a11y-menu[open] summary, .user-menu[open] summary { background: var(--surface-2); color: var(--ink); }
.avatar-sm {
  display: inline-flex; width: 1.75rem; height: 1.75rem; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--accent-solid); color: #fff; font-size: 0.8125rem; font-weight: 700;
}
.user-panel {
  position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 70; min-width: 14rem; padding: 0.75rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-menu);
}
.user-panel p { margin: 0; }
.user-panel-name { font-weight: 700; color: var(--ink); }
.user-panel-email { font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.user-panel-role { margin: 0.25rem 0 0.5rem !important; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.user-panel a, .menu-button {
  display: block; width: 100%; padding: 0.5rem; border: 0; border-radius: var(--radius); background: none;
  font: inherit; font-size: 0.875rem; font-weight: 500; text-align: left; color: var(--text); text-decoration: none; cursor: pointer;
}
.user-panel a:hover, .menu-button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.mobile-menu form { margin: 0; }
.mobile-menu .menu-button { padding: 0.75rem; }
.mobile-who { margin: 0; padding: 0.75rem 0.75rem 0.25rem; font-size: 0.8125rem; color: var(--faint); }

/* Display menu: light or dark */
.a11y-panel { min-width: 15rem; }
.a11y-title { margin: 0 0 0.15rem !important; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.a11y-note { margin: 0 0 0.5rem !important; font-size: 0.8125rem; color: var(--muted); }
.theme-option { display: flex !important; align-items: center; justify-content: space-between; gap: 0.75rem; }
.theme-option .current { visibility: hidden; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.theme-option[aria-current='true'] { font-weight: 700; color: var(--ink); background: var(--surface-2); }
.theme-option[aria-current='true'] .current { visibility: visible; }

.notice-bar { margin: 0; padding: 0.65rem 1.5rem; text-align: center; font-size: 0.875rem; background: var(--surface-2); color: var(--ink); border-bottom: 1px solid var(--border); }

/* ---------- Sign-in / sign-up ---------- */
.auth-container { max-width: 30rem; padding-top: 4rem; padding-bottom: 5rem; }
.auth-card { padding: 2rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.auth-card h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.auth-sub { color: var(--muted); margin-bottom: 1.5rem; }
.auth-alt { margin: 1.5rem 0 0; text-align: center; font-size: 0.9375rem; color: var(--muted); }
.auth-legal { margin: 1rem 0 0; font-size: 0.8125rem; color: var(--faint); }

.field { margin: 0 0 1.25rem; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { display: block; margin-bottom: 0.375rem; padding: 0; font-size: 0.875rem; font-weight: 700; color: var(--ink); }
.field input[type="text"], .field input[type="email"], .field input[type="password"] {
  width: 100%; padding: 0.7rem 0.85rem; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.field input:hover { border-color: var(--muted); }
.field input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--faint); }
.field-error { margin: 0.375rem 0 0; font-size: 0.875rem; font-weight: 600; color: var(--danger); }
.field-error a { color: var(--danger); font-weight: 700; }

.role-choice { display: grid; gap: 0.5rem; }
.role-choice legend { margin-bottom: 0.5rem; }
.choice { display: flex; align-items: flex-start; gap: 0.75rem; margin: 0 0 0.5rem; padding: 0.75rem 0.9rem; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; font-weight: 400 !important; background: var(--bg); }
/* "label.choice" inside a ".field" must beat the general ".field label" rule, so the box/radio sits beside its text. */
.field label.choice { margin-bottom: 0.5rem; display: flex; align-items: flex-start; font-size: 1rem; color: var(--text); }
.field label.quiz-unit { align-items: center; }
.choice:hover { border-color: var(--ink); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.choice input { margin-top: 0.3rem; accent-color: var(--accent-solid); }
.choice strong { display: block; color: var(--ink); }
.choice small { display: block; color: var(--muted); font-size: 0.8125rem; }

.alert { margin: 0 0 1.25rem; padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.9375rem; border: 1px solid; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.alert-success { background: var(--accent-tint); border-color: var(--accent-border); color: var(--ink); }

/* ---------- Dashboard ---------- */
.panel { padding: 1.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.panel h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.panel p:last-child { margin-bottom: 0; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.25rem; margin: 0; }
.details dt { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.details dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Classes (teacher pages, joining, dashboard lists) ---------- */
.head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1.5rem; }
.section-block { margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--border-strong); }
.section-block.first { margin-top: 0; padding-top: 0; border-top: 0; }
.section-block h2 { font-size: 1.375rem; margin-bottom: 0.5rem; }
.section-block .head-row { align-items: center; margin-bottom: 0.75rem; }
.section-block .head-row h2 { margin-bottom: 0; }
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state h2 { font-size: 1.375rem; margin-bottom: 0.5rem; }

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.75rem 0; }
.action-row form, .row-side form, .data-table form { margin: 0; }
a.text-button { display: inline-block; text-decoration: none; }
a.text-button:hover { color: var(--ink); text-decoration: none; }
.spaced { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 1.25rem; }
.stack-buttons { display: grid; gap: 0.6rem; }

.code-display { margin: 0.75rem 0 0; font-size: clamp(2.25rem, 8vw, 3.5rem); font-weight: 800; letter-spacing: 0.14em; line-height: 1.1; color: var(--ink); }
.code-input { text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.copy-row input {
  flex: 1 1 14rem; min-width: 0; padding: 0.6rem 0.75rem; font: inherit; font-size: 0.875rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.copy-row input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }

.table-wrap { margin-top: 1.25rem; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem 0.6rem 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); border-bottom-color: var(--border-strong); }
.data-table td { overflow-wrap: anywhere; }
.data-table .copy-row input { flex-basis: 10rem; }
.data-table button { white-space: nowrap; }

/* On a phone each row becomes a small block with its own labels, instead of four squeezed columns. */
@media (max-width: 560px) {
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
  .data-table td { padding: 0.15rem 0; border: 0; }
  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint);
  }
  .data-table td + td { margin-top: 0.4rem; }
  .data-table td.cell-action { margin-top: 0.6rem; }
}

.row-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-strong); }
.row-list li { border-bottom: 1px solid var(--border); }
.row-link, .row-static { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding: 1rem 0; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--text); text-decoration: none; }
.row-link:hover .row-main strong { color: var(--accent); text-decoration: underline; }
.row-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.row-main strong { font-size: 1.125rem; color: var(--ink); overflow-wrap: anywhere; }
.row-sub { font-size: 0.875rem; color: var(--muted); }
.row-side { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--muted); }
.row-code strong { letter-spacing: 0.1em; color: var(--ink); }

.class-summary { display: flex; flex-direction: column; gap: 0.15rem; margin: 1rem 0 1.25rem; padding: 1rem 1.1rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); font-size: 0.875rem; color: var(--muted); }
.class-summary strong { font-size: 1.125rem; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Video lessons ---------- */
.js .no-js-only { display: none; }

.unit-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 2.5rem; }
.unit-picker label { font-size: 0.875rem; font-weight: 700; color: var(--ink); }
.unit-picker select {
  flex: 1 1 18rem; max-width: 100%; padding: 0.7rem 2.25rem 0.7rem 0.85rem; font: inherit; color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius); background-color: var(--bg); cursor: pointer;
}
.unit-picker select:hover { border-color: var(--muted); }
.unit-picker select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }

.unit-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem; font-size: 1.75rem; margin-bottom: 0.25rem; }
.unit-code {
  padding: 0.1rem 0.55rem; border: 1px solid var(--accent-border); border-radius: var(--radius); background: var(--accent-tint); color: var(--accent);
  font-size: 0.9375rem; font-weight: 700; letter-spacing: 0.02em;
}

.video-grid { display: grid; gap: 2rem 1.5rem; grid-template-columns: 1fr; margin-top: 1.5rem; }
@media (min-width: 48rem) { .video-grid { grid-template-columns: 1fr 1fr; } }
.video-card h3 { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.75rem; font-size: 1rem; line-height: 1.35; letter-spacing: 0; }
.lesson-no { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }

.video-frame {
  position: relative; display: flex; width: 100%; aspect-ratio: 16 / 9; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius); background: var(--charcoal);
  color: #fff; text-decoration: none; overflow: hidden;
}
a.video-frame:hover { text-decoration: none; color: #fff; }
a.video-frame:hover .play-badge { border-color: #fff; background: rgba(255, 255, 255, 0.12); }
video.video-frame { background: #000; object-fit: contain; }
.video-missing { font-size: 0.875rem; color: #d0cdc4; }
.play-badge {
  display: inline-flex; width: 3.75rem; height: 3.75rem; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.8);
}
.play-badge svg { margin-left: 0.2rem; }
.video-hint { position: absolute; bottom: 0.6rem; right: 0.9rem; font-size: 0.75rem; color: #d0cdc4; }
.coming-soon { text-align: center; padding: 3rem 1.5rem; margin-top: 1.5rem; }
.coming-soon h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }

/* ---------- Subject hub ---------- */
html:not(.js) .no-js-hide { display: none; }

.hub-layout { display: flex; flex-direction: column; gap: 2rem; }
@media (min-width: 56rem) { .hub-layout { flex-direction: row; gap: 3.5rem; } .hub-aside { width: 15rem; flex-shrink: 0; position: sticky; top: calc(var(--header-h) + 1.5rem); align-self: flex-start; } }
.hub-aside { display: flex; flex-direction: column; gap: 0.75rem; }
.aside-note { margin: 0; font-size: 0.875rem; color: var(--muted); }
.hub-main { flex: 1; min-width: 0; }
.hub-title { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.035em; margin-bottom: 2rem; }
.accent { color: var(--accent); }

.unit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.unit-card { padding: 1.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.unit-card:hover, .unit-card:focus-within { border-color: var(--ink); }
.unit-card-title { font-size: 1.375rem; margin: 0.5rem 0; }
.unit-card-title a { color: var(--ink); text-decoration: none; }
.unit-card-title a:hover { color: var(--accent); text-decoration: underline; }
.unit-card p { margin-bottom: 0.75rem; }
.unit-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.tag { display: inline-block; padding: 0.1rem 0.5rem; border: 1px solid var(--border-strong); border-radius: 2px; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.tag-level { background: var(--accent-tint); border-color: var(--accent-border); color: var(--accent); }

.unit-sections { margin-top: 0.25rem; }
.unit-sections summary { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.6rem; margin-left: -0.6rem; border-radius: var(--radius); cursor: pointer; font-size: 0.875rem; font-weight: 700; color: var(--accent); list-style: none; }
.unit-sections summary::-webkit-details-marker { display: none; }
.unit-sections summary::after { content: ''; width: 0.45rem; height: 0.45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-bottom: 0.2rem; }
.unit-sections[open] summary::after { transform: rotate(-135deg); margin-bottom: -0.1rem; }
.unit-sections summary:hover { background: var(--surface-2); }
.unit-sections .count { font-weight: 500; color: var(--faint); }
.unit-sections ul { list-style: none; margin: 0.5rem 0 0; padding: 0.75rem 0 0; border-top: 1px solid var(--border); display: grid; gap: 0.15rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .unit-sections ul { grid-template-columns: 1fr 1fr; } }
.unit-sections li a { display: block; padding: 0.4rem 0.6rem; border-radius: var(--radius); font-size: 0.9375rem; font-weight: 500; color: var(--text); text-decoration: none; }
.unit-sections li a:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Unit page ---------- */
.unit-toolbar { position: sticky; top: var(--header-h); z-index: 40; background: var(--bg); border-bottom: 1px solid var(--border); }
@media (max-width: 47.99rem) { .unit-toolbar { position: static; } }
.unit-toolbar-inner { max-width: 80rem; margin: 0 auto; padding: 0.6rem 1.5rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.unit-toolbar-title { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.unit-toolbar-title strong { display: block; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.toolbar-eyebrow { display: block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.back-link { font-size: 0.875rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.unit-toolbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.view-toggle { display: inline-flex; padding: 0.15rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.view-toggle a { padding: 0.35rem 0.75rem; border-radius: 2px; font-size: 0.8125rem; font-weight: 600; text-decoration: none; color: var(--muted); }
.view-toggle a:hover { color: var(--ink); text-decoration: none; }
.view-toggle a.is-active { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--border-strong); }
.text-button { padding: 0.4rem 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: none; color: var(--ink); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.text-button:hover { background: var(--surface-2); }

.unit-main { max-width: 52rem; }
.unit-header { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--border-strong); }
.unit-header h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); letter-spacing: -0.035em; margin-bottom: 1rem; }
.unit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; margin: 1rem 0 0; font-size: 0.875rem; color: var(--muted); }
.unit-next-steps { margin: 3rem 0; padding: 1.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.unit-next-steps h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.unit-pager { display: grid; gap: 1rem; margin: 2.5rem 0 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .unit-pager { grid-template-columns: 1fr 1fr; } }
.unit-pager a { display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 1.25rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); text-decoration: none; color: var(--ink); }
.unit-pager a:hover { border-color: var(--ink); text-decoration: none; }
.unit-pager span { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.pager-next { text-align: right; grid-column: 2; }
.pager-prev + .pager-next { grid-column: 2; }
.pager-next:only-child { grid-column: 2; }
@media (max-width: 39.99rem) { .pager-next, .pager-prev + .pager-next, .pager-next:only-child { grid-column: 1; } }

/* ---------- Notes text (units, and later user notes) ---------- */
.doc-body { font-size: 1.0625rem; line-height: 1.75; color: var(--text); overflow-wrap: break-word; }
.doc-body h2 { font-size: 1.75rem; margin: 3rem 0 1rem; scroll-margin-top: calc(var(--header-h) + 5rem); }
.doc-body h3 { font-size: 1.3rem; margin: 2rem 0 0.75rem; scroll-margin-top: calc(var(--header-h) + 5rem); }
.doc-body h4, .doc-body h5, .doc-body h6 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.doc-body > h2:first-child { margin-top: 0; }
.doc-body strong { color: var(--ink); }
.doc-body a { text-decoration: underline; }
.doc-body ul, .doc-body ol { padding-left: 1.5rem; margin: 0 0 1rem; }
.doc-body li { margin-bottom: 0.35rem; }
.doc-body li > p { margin-bottom: 0.35rem; }
.doc-body blockquote { margin: 1rem 0; padding: 0.25rem 1rem; border-left: 3px solid var(--border-strong); color: var(--muted); }
.doc-body code { padding: 0.1rem 0.35rem; border-radius: 2px; background: var(--surface-2); font-size: 0.9em; }
.doc-body pre { padding: 1rem; border-radius: var(--radius); background: var(--charcoal); color: #e8e6df; overflow-x: auto; }
.doc-body pre code { background: none; padding: 0; color: inherit; }
.doc-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1rem 0; }
.doc-body th, .doc-body td { padding: 0.5rem 0.85rem; border: 1px solid var(--border-strong); text-align: left; }
.doc-body th { background: var(--surface-2); }
.doc-body hr { border: 0; border-top: 1px solid var(--border-strong); margin: 2rem 0; }
.doc-part { display: contents; }
.doc-body > .doc-part:first-child > h2:first-child { margin-top: 0; }
.lesson-video { margin: 1rem 0 1.75rem; }
.video-banner { margin: 0 0 2rem; padding: 0.85rem 1.1rem; border: 1px solid var(--accent-border); border-radius: var(--radius); background: var(--accent-tint); color: var(--ink); font-size: 0.9375rem; }
.tag-video { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.unit-soon { border-style: dashed; background: transparent; }
.unit-soon:hover, .unit-soon:focus-within { border-color: var(--border-strong); }
.unit-soon .unit-card-title { color: var(--muted); font-size: 1.25rem; }

/* ---------- Topics and subtopics (subject hub) ---------- */
.aside-heading { margin: 0.5rem 0 0.4rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.topic-jump ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
.topic-jump a { display: flex; gap: 0.6rem; padding: 0.4rem 0.6rem; margin: 0 -0.6rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; color: var(--text); text-decoration: none; }
.topic-jump a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.jump-no { flex-shrink: 0; width: 1rem; font-weight: 700; color: var(--faint); }
.level-switch .view-toggle { width: 100%; }
.level-switch .view-toggle a { flex: 1; text-align: center; }

.topic { margin: 0 0 3.5rem; scroll-margin-top: calc(var(--header-h) + 1rem); }
.topic-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.9rem; font-size: clamp(1.6rem, 4vw, 2.25rem); letter-spacing: -0.03em; padding-bottom: 0.6rem; border-bottom: 1px solid var(--ink); }
.topic-no { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.topic-meta { margin: 0.6rem 0 1.25rem; font-size: 0.875rem; color: var(--muted); }
.syllabus-h { margin: 2rem 0 0.5rem; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.group-title { margin: 1.25rem 0 0.4rem; font-size: 0.9375rem; font-weight: 700; letter-spacing: 0; color: var(--ink); }
.tag-hl { background: var(--co-hl-bg); border-color: var(--co-hl-border); color: var(--co-hl-label); }
.subtopic-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.subtopic-list li { display: grid; grid-template-columns: 3rem 1fr; gap: 0.15rem 0.75rem; padding: 0.8rem 1rem; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 1rem); }
.subtopic-list li:first-child { border-top: 0; }
.subtopic-list li:target { background: var(--accent-tint); }
.sub-code { font-size: 0.875rem; font-weight: 700; color: var(--accent); }
.sub-text { color: var(--text); }
.sub-notes { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8125rem; font-weight: 600; }
.sub-notes .soon { font-weight: 500; color: var(--faint); }
.unit-list + .syllabus-h { margin-top: 2rem; }
.syllabus-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--muted); }
.syllabus-tags a { padding: 0.05rem 0.5rem; border: 1px solid var(--accent-border); border-radius: 2px; background: var(--accent-tint); color: var(--accent); font-weight: 600; text-decoration: none; }
.syllabus-tags a:hover { border-color: var(--accent); text-decoration: none; }
.notes-link { display: inline-block; margin-top: 0.35rem; font-size: 0.875rem; font-weight: 600; }
.math-display { display: block; margin: 1rem 0; overflow-x: auto; overflow-y: hidden; }
.doc-body .katex-display { margin: 0.5rem 0; }

.callout { padding: 1.1rem 1.4rem; margin: 1.75rem 0; border-left: 3px solid; border-radius: 0 var(--radius) var(--radius) 0; }
.callout > :last-child { margin-bottom: 0; }
.callout::before { display: block; margin-bottom: 0.4rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.callout-key-concept { border-color: var(--co-key-border); background: var(--co-key-bg); }
.callout-key-concept::before { content: 'Key Concept'; color: var(--co-key-label); }
.callout-examiner-tip { border-color: var(--co-tip-border); background: var(--co-tip-bg); }
.callout-examiner-tip::before { content: 'Examiner Tip'; color: var(--co-tip-label); }
.callout-common-mistake { border-color: var(--co-mistake-border); background: var(--co-mistake-bg); }
.callout-common-mistake::before { content: 'Common Mistake'; color: var(--co-mistake-label); }
.callout-hl-only { border-color: var(--co-hl-border); background: var(--co-hl-bg); }
.callout-hl-only::before { content: 'HL Only'; color: var(--co-hl-label); }
.callout-connections { border-color: var(--co-why-border); border-style: dashed; background: var(--co-why-bg); }
.callout-connections::before { content: 'Why This Matters'; color: var(--co-why-label); }

/* ---------- Practice quiz ---------- */
.quiz-container { max-width: 42rem; padding-top: 2.5rem; padding-bottom: 4rem; }
.quiz-container h1 { font-size: 2.25rem; margin: 0.75rem 0 0.5rem; }
.back-link-text { display: inline-block; font-size: 0.875rem; color: var(--muted); }
.quiz-form { margin-top: 2rem; }
.quiz-unit { margin: 0 0 0.5rem; align-items: center; font-weight: 400; }
.quiz-unit span { display: flex; width: 100%; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; }
.quiz-unit small { color: var(--faint); }
.count-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.count-option { margin: 0; font-weight: 600; }
.count-option input { position: absolute; opacity: 0; pointer-events: none; }
.count-option span { display: inline-block; padding: 0.55rem 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); font-size: 0.875rem; cursor: pointer; }
.count-option:hover span { border-color: var(--ink); }
.count-option input:checked + span { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.count-option input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.quiz-status { display: flex; justify-content: space-between; margin-bottom: 0.75rem; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.progress { height: 0.3rem; margin-bottom: 2rem; background: var(--surface-3); overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: var(--accent-solid); }
.quiz-question { margin-bottom: 1.5rem; font-size: 1.25rem; line-height: 1.55; color: var(--ink); }
.quiz-choices { display: grid; gap: 0.6rem; margin-bottom: 1.5rem; }
.quiz-choice { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; padding: 0.9rem 1.1rem; font: inherit; text-align: left; color: var(--ink); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; }
.quiz-choice:hover:not(:disabled) { border-color: var(--ink); }
.quiz-choice:disabled { cursor: default; }
.quiz-choice.is-correct { border-color: var(--accent); background: var(--accent-tint); }
.quiz-choice.is-wrong { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.quiz-choice.is-dim { color: var(--faint); border-color: var(--border); }
.quiz-mark { flex-shrink: 0; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.quiz-explanation { padding: 1rem 1.25rem; margin-bottom: 1.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.quiz-explanation .eyebrow { color: var(--faint); }
.quiz-explanation div > :last-child { margin-bottom: 0; }
.quiz-finished { text-align: center; padding-top: 2rem; }
.quiz-finished:focus, .quiz-finished h1:focus { outline: none; }
.quiz-percent { margin: 0; font-size: 4.5rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; color: var(--ink); }
.quiz-finished .cta-buttons { margin-top: 2rem; }

/* ---------- Search ---------- */
.search-main { padding-top: 3rem; }
.search-main h1 { font-size: 2.5rem; letter-spacing: -0.035em; margin-bottom: 1.5rem; }
.search-form { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; }
.search-form input { flex: 1; min-width: 0; padding: 0.85rem 1.1rem; font: inherit; font-size: 1.125rem; border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--ink); background: var(--bg); }
.search-form input::placeholder { color: var(--faint); }
.search-form input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.search-count { margin-bottom: 1rem; }
.search-results { list-style: none; margin: 0 0 2rem; padding: 0; border-top: 1px solid var(--border-strong); }
.search-hit { display: flex; flex-direction: column; gap: 0.1rem; padding: 1.1rem 0.25rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.search-hit:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.search-hit:hover strong { color: var(--accent); }
.search-hit strong { font-size: 1.2rem; color: var(--ink); }
.hit-meta { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.hit-level { margin-left: 0.5rem; color: var(--muted); }
.search-section-h { margin: 2rem 0 0.75rem; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.search-hit strong .katex { font-size: 1em; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

/* ---------- Admin area ---------- */
.admin-main { padding-top: 1.5rem; }
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.25rem; padding-bottom: 0.75rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border-strong); }
.admin-nav-label { margin: 0 0.75rem 0 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.admin-nav a { padding: 0.4rem 0.7rem; border-radius: var(--radius); color: var(--muted); font-size: 0.9375rem; font-weight: 500; text-decoration: none; }
.admin-nav a:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav a[aria-current='page'] { background: var(--ink); color: var(--bg); }
.admin-head { margin-bottom: 2rem; }
.admin-head h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.admin-sub { color: var(--muted); max-width: 46rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1px; margin: 0 0 2rem; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.stat { margin: 0; padding: 1rem 1.25rem; background: var(--surface); }
.stat dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.stat dd { margin: 0.25rem 0 0; font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.admin-cards { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem; }
.admin-card { display: flex; flex-direction: column; gap: 0.2rem; height: 100%; padding: 1.1rem 1.25rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.admin-card strong { font-size: 1.1rem; color: var(--ink); margin-bottom: 0.2rem; }
.admin-card:hover { border-color: var(--accent); text-decoration: none; color: var(--muted); }
.admin-card:hover strong { color: var(--accent); }
.activity-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.activity-list li { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.9375rem; }
.activity-when { color: var(--faint); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .activity-list li { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; } }
.nowrap { white-space: nowrap; }
.data-table td.num { font-variant-numeric: tabular-nums; }
.tag-draft { background: var(--note-bg); border-color: var(--note-border); color: var(--note-text); }
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; color: var(--muted); }
.search-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; }
.search-row input { flex: 1 1 16rem; min-width: 0; }
.inline-form { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.js .no-js-only { display: none; }
.button-danger { background: var(--danger); border-color: var(--danger); color: var(--bg); } /* light text in light mode, dark text on the pale dark-mode red */
.button-danger:hover { background: var(--danger); color: var(--bg); text-decoration: underline; }
.danger-zone { border-top-color: var(--danger-border); }
.danger-zone h2 { color: var(--danger); }

/* Form controls the admin forms add to the site's set */
.field input[type="search"], .field input[type="date"], .field input[type="number"], .field input[type="file"],
.field select, .field textarea, .search-row input, .inline-form select {
  width: 100%; padding: 0.65rem 0.8rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.inline-form select { width: auto; padding: 0.35rem 0.5rem; font-size: 0.875rem; }
.field input[type="file"] { padding: 0.5rem; }
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .search-row input:focus-visible,
.inline-form select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.field textarea[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.check-group { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; border: 0; padding: 0; }
.check-group legend { margin-bottom: 0.4rem; }
.check { display: inline-flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9375rem; color: var(--text); cursor: pointer; }
.check input { margin-top: 0.25rem; accent-color: var(--accent-solid); }
.check small { display: block; color: var(--muted); }
.check span .katex { font-size: 1em; }
.covers { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 1rem 1.25rem; background: var(--surface); }
.covers legend { padding: 0 0.35rem; }
.covers-topic { border-top: 1px solid var(--border); padding: 0.5rem 0; }
.covers-topic summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 0.25rem 0; }
.covers-topic .check { display: flex; padding: 0.25rem 0 0.25rem 0.5rem; }
.publish-check { display: flex; padding: 1rem 1.25rem; margin: 1.5rem 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.inline-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1rem; }
.inline-fields .field { flex: 0 1 9rem; }
.inline-fields .field.grow, .lesson-fields .field.grow { flex: 1 1 14rem; }
.inline-fields .button { margin-bottom: 1.25rem; }

/* Markdown editor */
.editor { margin-top: 1.5rem; }
.editor-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 0.4rem; }
.editor-label { margin: 0; }
.editor-tabs { display: inline-flex; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.editor-tabs button { padding: 0.3rem 0.85rem; border: 0; border-radius: 2px; background: none; color: var(--muted); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer; }
.editor-tabs button[aria-selected='true'] { background: var(--surface); color: var(--ink); outline: 1px solid var(--border-strong); }
.editor-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.editor-tools button { padding: 0.3rem 0.6rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.8125rem; cursor: pointer; }
.editor-tools button:hover { background: var(--surface-2); }
.editor textarea { min-height: 28rem; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 0.9rem; }
.editor-preview { min-height: 28rem; padding: 1.25rem 1.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.preview-video { padding: 1.5rem; margin: 1.5rem 0; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--charcoal); color: #e8e6df; font-weight: 600; text-align: center; }
.editor-tabs:focus-within, .editor-tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Question and lesson editors */
.question-list { display: grid; gap: 1rem; margin-bottom: 1rem; }
.question-card, .lesson-card { margin: 0; padding: 1.25rem 1.25rem 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); min-width: 0; }
.question-card > legend { padding: 0 0.4rem; font-weight: 700; color: var(--ink); }
.question-card.has-error, .lesson-card.has-error { border-color: var(--danger); }
.choices { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.choices legend { font-weight: 600; font-size: 0.9375rem; color: var(--ink); margin-bottom: 0.4rem; }
.choices legend small, .question-card label small { font-weight: 400; color: var(--muted); }
.choice-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.choice-row input[type="radio"] { accent-color: var(--accent-solid); width: 1.05rem; height: 1.05rem; }
.choice-row input[type="text"] { width: 100%; padding: 0.5rem 0.7rem; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.choice-row input[type="text"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.choice-letter { width: 1.4rem; font-weight: 700; color: var(--muted); }
.choice-row:has(input[type="radio"]:checked) .choice-letter { color: var(--accent); }
.choice-row:has(input[type="radio"]:checked) input[type="text"] { border-color: var(--accent); background: var(--accent-tint); }
.js .slot-extra { display: none; }
.remove-check { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.875rem; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 0.85rem 0; background: var(--bg); border-top: 1px solid var(--border); }
.lesson-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.75rem; counter-reset: lesson; }
.lesson-card { counter-increment: lesson; position: relative; }
.lesson-card::before { content: 'Lesson ' counter(lesson); display: block; margin-bottom: 0.5rem; font-weight: 700; color: var(--ink); }
.lesson-fields { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.lesson-fields .field { flex: 0 1 12rem; min-width: 0; }
.lesson-status { margin: -0.25rem 0 0.5rem; font-size: 0.8125rem; color: var(--muted); }
.upload-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; align-items: end; }
.upload-form .button { margin-bottom: 1.25rem; justify-self: start; }

/* ---------- Saved quiz results ---------- */
.quiz-save { margin-top: 0.75rem; color: var(--muted); font-size: 0.9375rem; }
.results-table th { white-space: normal; min-width: 6rem; vertical-align: bottom; }
.results-table td.num { font-weight: 600; color: var(--ink); }
.muted { color: var(--muted); }

/* ---------- Library ---------- */
.library-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1rem; padding: 1rem 1.25rem 0; margin-bottom: 1.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.library-filters .field { flex: 1 1 12rem; min-width: 0; }
.library-filters .field.grow { flex: 2 1 14rem; }
.library-filters .button { margin-bottom: 1.25rem; }
.doc-list { list-style: none; margin: 0 0 1.5rem; padding: 0; border-top: 1px solid var(--border-strong); }
.doc-row { display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 0.25rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.doc-row:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.doc-row strong { font-size: 1.125rem; color: var(--ink); }
.doc-row:hover strong { color: var(--accent); }
.doc-kind { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.doc-header { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border-strong); }
.doc-header h1 { font-size: clamp(2rem, 4.5vw, 2.75rem); letter-spacing: -0.03em; margin-bottom: 0.75rem; }
.doc-meta { color: var(--muted); font-size: 0.9375rem; }
.alert-note { background: var(--note-bg); border-color: var(--note-border); color: var(--note-text); }
.report-box { margin-top: 3rem; padding: 1rem 1.25rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.report-box summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.report-box form { margin-top: 1rem; }
.report-box .check { display: flex; margin-bottom: 0.35rem; }
.review-note { color: var(--note-text); }
.unit-library { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border-strong); }
.unit-library h2 { font-size: 1.35rem; }
.tab-row { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1.25rem; }
.tab-row a { padding: 0.4rem 0.8rem; border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--muted); font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.tab-row a:hover { background: var(--surface-2); color: var(--ink); }
.tab-row a[aria-current='page'] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 2rem; align-items: start; }
@media (max-width: 860px) { .review-layout { grid-template-columns: minmax(0, 1fr); } }
.review-body { min-width: 0; padding: 1.5rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.review-panel { display: grid; gap: 1.5rem; position: sticky; top: calc(var(--header-h) + 1rem); }
.review-panel section { padding: 1rem 1.1rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.review-panel h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.report-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.6rem; font-size: 0.875rem; }
.report-list li { display: flex; flex-direction: column; gap: 0.1rem; }
.report-list li.resolved { opacity: 0.65; }

/* ---------- Reduced motion: no transitions or smooth scrolling for people who ask for less ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Print: always the light version on white paper ---------- */
@media print {
  .site-header, .site-footer, .unit-toolbar, .unit-next-steps, .unit-pager, .unit-library, .report-box, .alert { display: none !important; }
  body { background: #fff; color: #000; }
  .container, .unit-main { padding: 0 !important; max-width: 100% !important; }
  .doc-body { font-size: 11pt; line-height: 1.5; color: #000; }
  .doc-body h2 { break-after: avoid; }
  .callout { break-inside: avoid; }
  .unit-header { border: 0; margin-bottom: 1rem; padding-bottom: 0; }
  a { color: inherit; text-decoration: none; }
}
