/* ==========================================================================
   app.css — Mind & Behaviour learning app
   Uses the same design tokens, type, colours and components as
   drnasirbhat.com (Academic Website v1.1) so the app feels part of the site.
   Self-contained copy: the app keeps working even if the main site's CSS
   changes. System fonts only; no external requests.
   ========================================================================== */

:root {
  --color-ink-900: #10202a;
  --color-primary-900: #0f2e33;
  --color-primary-700: #1c4a51;
  --color-slate-600: #465563;
  --color-slate-500: #5f6d7b;
  --color-slate-400: #8b97a3;
  --color-line-300: #d5dbdf;
  --color-line-200: #e7ebee;
  --color-paper-100: #f4f6f6;
  --color-paper-050: #fbfcfc;
  --color-white: #ffffff;
  --color-accent-600: #8a5a1c;
  --color-accent-500: #a06a22;
  --color-accent-050: #f6efe3;
  --color-success-700: #1f6f43;
  --color-warning-700: #8a5a00;
  --color-error-700: #a12626;
  --color-info-700: #1d5a8a;

  --c-primary: var(--color-primary-900);
  --c-primary-hover: var(--color-primary-700);
  --c-accent: var(--color-accent-600);
  --c-accent-soft: var(--color-accent-050);
  --c-bg: var(--color-white);
  --c-bg-alt: var(--color-paper-100);
  --c-bg-raised: var(--color-paper-050);
  --c-text: var(--color-ink-900);
  --c-text-muted: var(--color-slate-600);
  --c-text-subtle: var(--color-slate-500);
  --c-text-invert: var(--color-white);
  --c-border: var(--color-line-300);
  --c-border-soft: var(--color-line-200);
  --c-focus: #9a6414;
  --c-focus-on-dark: #e3b877;
  --c-success: var(--color-success-700);
  --c-warning: var(--color-warning-700);
  --c-error: var(--color-error-700);
  --c-info: var(--color-info-700);

  --font-display: Georgia, "Iowan Old Style", "Times New Roman", Times, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --fs-100: 0.833rem;
  --fs-200: 0.9rem;
  --fs-300: 1rem;
  --fs-400: 1.125rem;
  --fs-500: clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
  --fs-600: clamp(1.4rem, 1.2rem + 1vw, 1.8rem);
  --fs-700: clamp(1.7rem, 1.3rem + 1.8vw, 2.4rem);
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.6;

  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4rem;

  --measure: 70ch;
  --container-max: 64rem;
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, 0.06), 0 1px 3px rgba(20, 33, 61, 0.08);
  --shadow-md: 0 2px 6px rgba(20, 33, 61, 0.08), 0 6px 16px rgba(20, 33, 61, 0.08);
  --motion-fast: 120ms; --motion-base: 200ms;
  --motion-ease: cubic-bezier(0.2, 0, 0, 1);
  --focus-ring: 3px solid var(--c-focus);
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.text-large { font-size: 118.75%; }
body {
  font-family: var(--font-body); font-size: var(--fs-300); line-height: var(--lh-normal);
  color: var(--c-text); background: var(--c-bg); min-height: 100vh;
  display: flex; flex-direction: column;
}
html, body { max-width: 100%; overflow-x: clip; }
main { flex: 1 0 auto; outline: none; }
img, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: var(--lh-tight); color: var(--c-primary); font-weight: 700; text-wrap: balance; }
h1 { font-size: var(--fs-700); letter-spacing: -0.01em; outline: none; }
h2 { font-size: var(--fs-600); margin-top: var(--sp-6); margin-bottom: var(--sp-3); }
h3, .h3 { font-size: var(--fs-500); line-height: var(--lh-snug); }
h4, .h4 { font-size: var(--fs-400); }
h2.h3 { font-size: var(--fs-500); }
h2.h4, h3.h4 { font-size: var(--fs-400); margin-top: var(--sp-5); margin-bottom: var(--sp-2); }
p, li { max-width: var(--measure); }
p + p { margin-top: var(--sp-3); }
a { color: var(--c-accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--color-accent-500); }
strong { font-weight: 600; }
ul, ol { padding-left: 1.3rem; }
li + li { margin-top: var(--sp-2); }
:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: 2px; }
[hidden] { display: none !important; }
.container { width: 100%; max-width: var(--container-max); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--sp-6) var(--sp-7); }
.section__lead { color: var(--c-text-muted); font-size: var(--fs-400); margin-top: var(--sp-3); }
.mt-6 { margin-top: var(--sp-6); }
.fine { font-size: var(--fs-200); color: var(--c-text-muted); }
.loading { color: var(--c-text-muted); }
.eyebrow {
  font-family: var(--font-body); font-size: var(--fs-100); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--c-accent); margin-bottom: var(--sp-2);
  display: inline-flex; align-items: center; gap: var(--sp-3);
}
.eyebrow::after { content: ""; width: 2rem; height: 2px; background: var(--c-accent); opacity: 0.5; }
.skip-link { position: absolute; left: var(--sp-2); top: -100px; z-index: 200; background: var(--c-primary); color: #fff; padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--sp-2); color: #fff; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* --- Header (same as main site) --- */
.site-header { position: sticky; top: 0; z-index: 100; background: color-mix(in srgb, var(--c-bg) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--c-border-soft); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); min-height: 4rem; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-400); color: var(--c-primary); text-decoration: none; line-height: 1.2; }
.brand:hover { color: var(--c-primary); }
.brand small { display: block; font-family: var(--font-body); font-size: var(--fs-100); font-weight: 400; color: var(--c-text-subtle); }
.nav-toggle { display: inline-flex; align-items: center; gap: var(--sp-2); background: transparent; border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); cursor: pointer; min-height: 44px; }
.nav-toggle__bars { width: 18px; height: 12px; position: relative; display: inline-block; }
.nav-toggle__bars::before, .nav-toggle__bars::after, .nav-toggle__bars span { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: currentColor; border-radius: 2px; }
.nav-toggle__bars::before { top: 0; } .nav-toggle__bars span { top: 5px; } .nav-toggle__bars::after { bottom: 0; }
.primary-nav ul { list-style: none; display: flex; gap: var(--sp-5); padding: 0; }
.primary-nav li + li { margin-top: 0; }
.primary-nav a { color: var(--c-text); text-decoration: none; font-weight: 500; padding: var(--sp-2) 0; }
.primary-nav a:hover { color: var(--c-accent); }
.primary-nav a[aria-current="page"] { color: var(--c-primary); font-weight: 600; border-bottom: 2px solid var(--c-accent); }

/* --- Footer --- */
.site-footer { background: var(--c-primary); color: var(--c-text-invert); padding-block: var(--sp-7) var(--sp-6); margin-top: var(--sp-7); }
.site-footer a { color: var(--color-accent-050); }
.site-footer :focus-visible { outline-color: var(--c-focus-on-dark); }
.site-footer__grid { display: grid; gap: var(--sp-5); grid-template-columns: 1fr; }
.site-footer nav ul { list-style: none; padding: 0; display: grid; gap: var(--sp-2); }
.site-footer li + li { margin-top: 0; }
.site-footer__meta { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid rgba(255,255,255,0.2); font-size: var(--fs-200); color: rgba(255,255,255,0.82); max-width: none; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); font-weight: 600; padding: var(--sp-3) var(--sp-5); border-radius: var(--radius-sm); border: 2px solid transparent; text-decoration: none; cursor: pointer; min-height: 44px; line-height: 1.25; text-align: center; transition: background var(--motion-base) var(--motion-ease), border-color var(--motion-base) var(--motion-ease); }
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-hover); color: #fff; }
.btn--primary:focus-visible { outline-color: var(--c-focus); }
.btn--ghost { border-color: var(--c-border); color: var(--c-primary); background: var(--c-bg); }
.btn--ghost:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn--danger { background: var(--c-error); color: #fff; }
.btn--small { padding: var(--sp-2) var(--sp-4); font-size: var(--fs-200); min-height: 40px; }
.btn--choice { border-color: var(--c-border); background: var(--c-bg); color: var(--c-text); font-weight: 500; text-align: left; justify-content: flex-start; width: 100%; }
.btn--choice:hover:not(:disabled) { border-color: var(--c-primary); }
.btn--choice.is-picked { border-color: var(--c-primary); background: var(--c-accent-soft); font-weight: 600; }
.btn--choice.is-picked::before { content: "➜ "; }
.btn:disabled { cursor: default; opacity: 0.75; }
.btn-mini { min-width: 44px; min-height: 40px; border: 1px solid var(--c-border); background: var(--c-bg); border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; }
.btn-mini:disabled { opacity: 0.4; cursor: default; }

/* --- Cards & lists --- */
.card { background: var(--c-bg-raised); border: 1px solid var(--c-border-soft); border-radius: var(--radius-md); padding: var(--sp-5); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: var(--sp-2); position: relative; }
.card-grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; list-style: none; padding: 0; }
.card-grid > li + li { margin-top: 0; }
.card__title { font-size: var(--fs-400); }
.card__link { color: var(--c-primary); text-decoration: none; }
.card__link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-md); }
.card:hover { border-color: var(--c-border); box-shadow: var(--shadow-md); }
.card:focus-within { outline: var(--focus-ring); outline-offset: 2px; }
.card__link:focus-visible { outline: none; }
.card__meta { font-size: var(--fs-100); color: var(--c-text-subtle); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; max-width: none; }
.card__body { color: var(--c-text-muted); font-size: var(--fs-200); }
.card__footer { margin-top: auto; padding-top: var(--sp-2); }
.notice { border: 1px dashed var(--c-border); border-radius: var(--radius-md); padding: var(--sp-5); color: var(--c-text-muted); background: var(--c-bg-alt); max-width: none; margin-block: var(--sp-4); }
.chip { display: inline-block; font-size: var(--fs-100); font-weight: 600; padding: 0.1em 0.6em; border-radius: 999px; border: 1px solid var(--c-border); color: var(--c-text-muted); }
.chip--done { color: var(--c-success); border-color: currentColor; }
.chip--seen { color: var(--c-info); border-color: currentColor; }
.chip--mark { color: var(--c-accent); border-color: currentColor; margin-left: var(--sp-1); }
.lesson-list { list-style: none; padding: 0; border-top: 1px solid var(--c-border-soft); }
.lesson-row { padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border-soft); margin: 0 !important; max-width: none; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); align-items: baseline; }
.lesson-row__link { font-weight: 600; flex: 1 1 100%; font-size: var(--fs-400); }
.lesson-row__meta { font-size: var(--fs-200); color: var(--c-text-subtle); }

/* progress bar (always paired with text) */
.pbar { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }
.pbar__track { flex: 1; height: 8px; background: var(--c-border-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--c-border); }
.pbar__fill { height: 100%; background: var(--c-primary); }
.pbar__text { font-size: var(--fs-100); color: var(--c-text-muted); white-space: nowrap; }

/* --- Home --- */
.hero { padding-block: var(--sp-5) var(--sp-6); background: radial-gradient(120% 120% at 100% 0%, var(--c-accent-soft) 0%, transparent 45%); border-radius: var(--radius-lg); }
.hero h1 { max-width: 30ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }
.hero .fine { margin-top: var(--sp-3); }
.searchbar { margin-block: var(--sp-5); display: grid; gap: var(--sp-2); max-width: 40rem; }
.searchbar label { font-weight: 600; }
.searchbar__row { display: flex; gap: var(--sp-2); }
input[type="search"], select, textarea, input[type="file"] { max-width: 100%; border: 1px solid var(--color-slate-400); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); background: var(--c-bg); min-height: 44px; }
input[type="search"] { flex: 1; min-width: 0; width: 100%; }
textarea { width: 100%; max-width: var(--measure); }
.home-panels { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; margin-block: var(--sp-5); }
.panel { border-left: 3px solid var(--c-accent); padding: var(--sp-2) var(--sp-4); background: var(--c-bg-alt); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.panel h2 { margin-top: 0; margin-bottom: var(--sp-2); }
.panel p { font-size: var(--fs-200); color: var(--c-text-muted); }
.home-stats { font-size: var(--fs-200); color: var(--c-text-muted); max-width: none; }

/* --- Page head, crumbs --- */
.page-head { margin-bottom: var(--sp-5); }
.crumbs ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1); font-size: var(--fs-200); margin-bottom: var(--sp-4); }
.crumbs li + li { margin-top: 0; }
.crumbs li + li::before { content: "›"; margin-right: var(--sp-1); color: var(--c-text-subtle); }
.crumbs [aria-current] { color: var(--c-text-muted); }

/* --- Lesson --- */
.lesson__meta { font-size: var(--fs-200); color: var(--c-text-subtle); margin-top: var(--sp-2); }
.lesson__tools { margin-top: var(--sp-3); }
.toc { background: var(--c-bg-alt); border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-5); }
.toc__label { font-size: var(--fs-100); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-subtle); }
.toc ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); margin-top: var(--sp-1); }
.toc li + li { margin-top: 0; }
.toc__link { background: none; border: 0; padding: var(--sp-1) 0; color: var(--c-accent); text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; font-size: var(--fs-200); min-height: 32px; }
.lesson > section { margin-top: var(--sp-6); outline: none; scroll-margin-top: 5rem; }
.lesson > section > h2:first-child, .lesson section > h2:first-child { margin-top: 0; }
.lesson__section p, .lesson__section ul, .lesson__section ol, .lesson__section aside, .lesson__section .table-wrap { margin-top: var(--sp-3); }
.hook { background: var(--c-accent-soft); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); }
.hook p { font-size: var(--fs-400); }
.outcomes li::marker { color: var(--c-accent); }
.note { border-left: 4px solid var(--c-info); background: var(--c-bg-alt); padding: var(--sp-3) var(--sp-4); border-radius: 0 var(--radius-md) var(--radius-md) 0; max-width: var(--measure); }
.note__label { font-size: var(--fs-100); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-info); }
.note p + p { margin-top: var(--sp-1); }
.note--myth { border-color: var(--c-warning); } .note--myth .note__label { color: var(--c-warning); }
.note--myth .note__label::before { content: "⚠ "; }
.note--care { border-color: var(--c-error); } .note--care .note__label { color: var(--c-error); }
.note--culture, .note--india { border-color: var(--c-accent); } .note--culture .note__label, .note--india .note__label { color: var(--c-accent); }
.note--debate .note__label::before { content: "? "; }
.note--fictional { border-color: var(--color-slate-400); } .note--fictional .note__label { color: var(--c-text-muted); }
.note--tip { border-color: var(--c-success); } .note--tip .note__label { color: var(--c-success); }
.terms { display: grid; gap: var(--sp-3); }
.terms > div { border-bottom: 1px solid var(--c-border-soft); padding-bottom: var(--sp-2); }
.terms dt { font-weight: 700; }
.terms dd { margin: 0; color: var(--c-text-muted); max-width: var(--measure); }
.worked { border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); }
.worked__steps { margin-top: var(--sp-3); }
.worked__steps li::marker { font-weight: 700; color: var(--c-primary); }
.worked__take { margin-top: var(--sp-3); background: var(--c-bg-alt); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.term-link { text-decoration-style: dotted; }
.table-wrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-200); }
caption { text-align: left; font-weight: 600; padding-bottom: var(--sp-2); color: var(--c-text-muted); }
th, td { border: 1px solid var(--c-border); padding: var(--sp-2) var(--sp-3); text-align: left; vertical-align: top; }
thead th { background: var(--c-bg-alt); }
tr.total th, tr.total td { font-weight: 700; background: var(--c-bg-alt); }
.flash { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.flash__card { border: 1px solid var(--c-border); border-radius: var(--radius-md); background: var(--c-bg-raised); }
.flash__card summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-weight: 600; min-height: 44px; }
.flash__card p { padding: 0 var(--sp-4) var(--sp-3); color: var(--c-text-muted); }
.flash__card[open] summary { border-bottom: 1px solid var(--c-border-soft); margin-bottom: var(--sp-2); }
.sources-box { border-top: 1px solid var(--c-border); padding-top: var(--sp-5); }
.crosswalk { margin-top: var(--sp-4); }
.meta-list { display: grid; gap: var(--sp-3); margin-top: var(--sp-2); }
.meta-list div { display: grid; gap: 0.1rem; }
.meta-list dt { font-size: var(--fs-100); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-subtle); }
.meta-list dd { margin: 0; max-width: var(--measure); }
.complete-box { margin-top: var(--sp-6); padding: var(--sp-4) var(--sp-5); border: 2px solid var(--c-border); border-radius: var(--radius-md); display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.pager-nav { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; margin-top: var(--sp-5); }
.pager-nav a { display: block; border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); text-decoration: none; }
.pager-nav span { display: block; font-size: var(--fs-100); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-subtle); }
.pager-nav strong { color: var(--c-primary); }
.pager-nav__next { text-align: right; }

/* --- Questions --- */
.q { border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); margin-top: var(--sp-4); background: var(--c-bg); }
.q--embedded { margin-top: 0; border: 0; padding: 0; }
.q__meta { font-size: var(--fs-100); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-subtle); font-weight: 600; max-width: none; }
.q__stem { font-family: var(--font-body); font-size: var(--fs-400); font-weight: 600; color: var(--c-text); margin-top: var(--sp-1); line-height: var(--lh-snug); }
.q__hint { font-size: var(--fs-200); color: var(--c-text-muted); margin-top: var(--sp-1); }
.q__body { margin-top: var(--sp-3); }
.q__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.q__feedback:not(:empty) { margin-top: var(--sp-3); }
.q__explain { background: var(--c-bg-alt); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-2); }
.choices { border: 0; padding: 0; display: grid; gap: var(--sp-2); }
.choices legend { font-weight: 600; margin-bottom: var(--sp-2); }
.choice { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-1) var(--sp-3); align-items: start; border: 1px solid var(--c-border-soft); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); }
.choice input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; accent-color: var(--c-primary); }
.choice label { cursor: pointer; }
.choice:has(input:checked) { border-color: var(--c-primary); background: var(--c-bg-alt); }
.choice__fb { grid-column: 2; font-size: var(--fs-200); }
.is-ok { color: var(--c-success); }
.is-no { color: var(--c-error); }
.choice__fb.is-ok, .choice__fb.is-no, .sort__fb.is-ok, .sort__fb.is-no { color: var(--c-text); padding-left: var(--sp-2); border-left: 3px solid var(--c-success); }
.choice__fb.is-no, .sort__fb.is-no { border-left-color: var(--c-error); border-left-style: dashed; }
.choice__fb strong { color: inherit; }
.verdict { font-weight: 700; display: flex; align-items: center; gap: var(--sp-2); }
.verdict__icon { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid currentColor; font-size: 0.9rem; }
.verdict--ok { color: var(--c-success); }
.verdict--no { color: var(--c-warning); }
.verdict--info { color: var(--c-info); font-weight: 600; }
.match { display: grid; gap: var(--sp-3); }
.match__row { display: grid; gap: var(--sp-1); grid-template-columns: 1fr; border-bottom: 1px solid var(--c-border-soft); padding-bottom: var(--sp-2); }
.match__left { font-weight: 600; }
.match select { width: 100%; }
.match__mark { font-size: var(--fs-200); font-weight: 600; }
.order { padding-left: 1.5rem; display: grid; gap: var(--sp-2); }
.order__item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); margin: 0 !important; max-width: none; background: var(--c-bg-raised); }
.order__btns { display: flex; gap: var(--sp-1); flex-shrink: 0; }
.order-key { padding-left: 1.5rem; }
.open-answer { margin-top: var(--sp-2); }
.model { margin-top: var(--sp-2); }

/* --- Activities --- */
.activity { border: 2px solid var(--c-primary); border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5); margin-top: var(--sp-4); background: var(--c-bg); }
.activity h3 { margin-bottom: var(--sp-2); }
.activity__instr { color: var(--c-text-muted); }
.activity__stage { margin-top: var(--sp-3); }
.activity__tools { margin-top: var(--sp-4); border-top: 1px solid var(--c-border-soft); padding-top: var(--sp-3); }
.activity__about { margin-top: var(--sp-3); font-size: var(--fs-200); }
.activity__about summary { cursor: pointer; font-weight: 600; color: var(--c-primary); min-height: 32px; }
.activity__about p, .activity__about ul { margin-top: var(--sp-2); color: var(--c-text-muted); }
.sort { display: grid; gap: var(--sp-3); }
.sort__row { border-bottom: 1px solid var(--c-border-soft); padding-bottom: var(--sp-3); }
.sort__item { font-weight: 600; }
.sort__fb { margin-top: var(--sp-2); font-size: var(--fs-200); }
.seg { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); border: 0; padding: 0; }
.seg legend { font-weight: 600; margin-bottom: var(--sp-2); }
.seg__opt { position: relative; }
.seg__opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg__opt label { display: inline-flex; align-items: center; min-height: 40px; padding: var(--sp-1) var(--sp-3); border: 1px solid var(--c-border); border-radius: 999px; cursor: pointer; font-size: var(--fs-200); background: var(--c-bg); }
.seg__opt input:checked + label { background: var(--c-primary); color: #fff; border-color: var(--c-primary); font-weight: 600; }
.seg__opt input:checked + label::before { content: "✓ "; }
.seg__opt input:focus-visible + label { outline: var(--focus-ring); outline-offset: 2px; }
.scenario { display: grid; gap: var(--sp-4); }
.scenario__step { border-left: 3px solid var(--c-border); padding-left: var(--sp-4); }
.scenario__step--end { border-left-color: var(--c-accent); }
.scenario__text { outline: none; }
.scenario__choices { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.scenario__fb { margin-top: var(--sp-3); background: var(--c-bg-alt); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.slider { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-1) var(--sp-3); align-items: center; margin-top: var(--sp-3); }
.slider label { grid-column: 1 / -1; font-weight: 600; font-size: var(--fs-200); }
.slider input { width: 100%; accent-color: var(--c-primary); min-height: 32px; }
.slider__val { font-weight: 700; min-width: 5ch; text-align: right; font-variant-numeric: tabular-nums; }
.sim-figure { margin-top: var(--sp-3); background: var(--c-bg-raised); border: 1px solid var(--c-border-soft); border-radius: var(--radius-md); padding: var(--sp-2); max-width: 36rem; }
.sim-svg { width: 100%; height: auto; }
.sim-svg .axis, .sim-svg .grid { stroke: var(--color-slate-400); stroke-width: 1; }
.sim-svg .grid { stroke-dasharray: 2 3; opacity: 0.6; }
.sim-svg .svg-label { font: 10px var(--font-body); fill: var(--c-text-muted); }
.sim-svg .dot { fill: var(--c-primary); opacity: 0.75; }
.sim-svg .trace { fill: none; stroke: var(--c-primary); stroke-width: 2; stroke-linejoin: round; }
.sim-svg .tick { stroke: var(--c-accent); stroke-width: 2; }
.sim-svg .cursor { stroke: var(--c-accent); stroke-width: 2; stroke-dasharray: 4 3; }
.sim-svg .area { fill: var(--c-accent-soft); stroke: none; }
.sim-svg .band { fill: var(--c-accent); }
.sim-svg .meter-bg { fill: var(--c-border-soft); stroke: var(--c-border); }
.sim-svg .meter-fill { fill: var(--color-slate-500); }
.sim-svg .meter-fill--hot { fill: var(--c-primary); }
.sim-svg .threshold { stroke: var(--c-error); stroke-width: 2; stroke-dasharray: 4 2; }
.sim-svg .spike { fill: none; stroke: var(--c-primary); stroke-width: 2.5; }
.sim-svg .spike--flat { stroke: var(--color-slate-400); }
.sim-svg .ml-line, .sim-svg .ml-fin { stroke: var(--c-text); stroke-width: 3; fill: none; stroke-linecap: round; }
.sim-svg .g-tp { fill: var(--c-primary); }
.sim-svg .g-fn { fill: var(--c-bg); stroke: var(--c-primary); stroke-width: 1.4; }
.sim-svg .g-fp { fill: url(#hatch); stroke: var(--c-accent); stroke-width: 1; }
.sim-svg .hatch-line { fill: var(--c-accent); }
.sim-svg .g-tn { fill: var(--c-border-soft); }
.legend { list-style: none; padding: 0; display: grid; gap: var(--sp-1); margin-top: var(--sp-2); font-size: var(--fs-200); }
.legend li + li { margin-top: 0; }
.swatch { display: inline-block; width: 1rem; height: 1rem; vertical-align: -0.15rem; margin-right: var(--sp-2); border: 1px solid var(--c-border); }
.swatch.g-tp { background: var(--c-primary); }
.swatch.g-fn { background: var(--c-bg); border: 2px solid var(--c-primary); }
.swatch.g-fp { background: repeating-linear-gradient(45deg, var(--c-accent) 0 2px, var(--c-bg) 2px 4px); border-color: var(--c-accent); }
.swatch.g-tn { background: var(--c-border-soft); }
.readout { background: var(--c-bg-alt); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-3); font-size: var(--fs-200); }
.readout:empty { display: none; }
.word-list { columns: 2; column-gap: var(--sp-6); margin-top: var(--sp-3); font-size: var(--fs-400); }
.word-list--result { font-size: var(--fs-300); }
.word-list li { break-inside: avoid; }

/* --- Glossary, search, review, misc --- */
.glossary { display: grid; gap: 0; margin-top: var(--sp-4); }
.glossary__item { border-bottom: 1px solid var(--c-border-soft); padding: var(--sp-3) 0; outline: none; scroll-margin-top: 6rem; }
.glossary__item dt { font-weight: 700; font-size: var(--fs-400); font-family: var(--font-display); color: var(--c-primary); }
.glossary__item dd { margin: var(--sp-1) 0 0; }
.glossary__item.is-target { background: var(--c-accent-soft); padding-inline: var(--sp-3); border-radius: var(--radius-sm); }
.say { font-family: var(--font-body); font-size: var(--fs-200); font-weight: 400; color: var(--c-text-subtle); }
.results { list-style: none; padding: 0; }
.results li { border-bottom: 1px solid var(--c-border-soft); padding: var(--sp-3) 0; margin: 0; max-width: none; }
.results__title { font-weight: 600; font-size: var(--fs-400); }
.review-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-4); }
.review-controls label { font-weight: 600; flex-basis: 100%; }
.review-controls select { flex: 1 1 14rem; min-width: 0; width: 100%; max-width: 28rem; }
.tally { position: sticky; top: 4.2rem; z-index: 5; background: var(--c-primary); color: #fff; border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-4); margin-top: var(--sp-4); font-weight: 600; max-width: none; }
.device-box { margin-top: var(--sp-6); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); }
.device-box h2 { margin-top: 0; }
.import-row { display: grid; gap: var(--sp-1); margin-top: var(--sp-3); max-width: 28rem; min-width: 0; }
.import-row input[type="file"] { width: 100%; }
.import-row label { font-weight: 600; }
.check-list li { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--fs-200); }
.source-card { margin-top: var(--sp-4); }
.source-card h2 { margin: 0; }
.teach-unit { border-top: 1px solid var(--c-border); padding-top: var(--sp-4); margin-top: var(--sp-5); }
.teach-unit h2 { margin-top: 0; }
.prose section { margin-top: var(--sp-5); }
.prose section > * + * { margin-top: var(--sp-3); }
.print-lesson { margin-top: var(--sp-5); border-top: 1px solid var(--c-border); padding-top: var(--sp-3); }
.print-qa li p + p { margin-top: var(--sp-1); color: var(--c-text-muted); }

/* --- Responsive --- */
@media (max-width: 47.99rem) {
  .primary-nav { position: fixed; inset: 4rem 0 auto 0; background: var(--c-bg); border-bottom: 1px solid var(--c-border); box-shadow: var(--shadow-md); transform: translateY(-130%); visibility: hidden; transition: transform var(--motion-base) var(--motion-ease), visibility 0s linear var(--motion-base); z-index: 150; }
  .primary-nav[data-open="true"] { transform: translateY(0); visibility: visible; transition: transform var(--motion-base) var(--motion-ease); }
  .primary-nav ul { flex-direction: column; gap: 0; padding: var(--sp-2) var(--gutter); }
  .primary-nav a { display: block; padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border-soft); }
  .brand small { font-size: 0.72rem; }
  .q, .activity { padding: var(--sp-3) var(--sp-4); }
  .word-list { columns: 1; }
}
.no-js .nav-toggle { display: none; }
.no-js .primary-nav { position: static; transform: none; visibility: visible; }
@media (min-width: 48rem) {
  .nav-toggle { display: none; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .home-panels { grid-template-columns: repeat(3, 1fr); }
  .site-footer__grid { grid-template-columns: 1fr 1fr 2fr; }
  .pager-nav { grid-template-columns: 1fr 1fr; }
  .pager-nav__next:only-child { grid-column: 2; }
  .match__row { grid-template-columns: 1fr 1fr; align-items: center; }
  .match__mark { grid-column: 1 / -1; }
}
@media (min-width: 64rem) {
  .card-grid--units { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .skip-link, .btn, .no-print, .toc, .pager-nav, .complete-box, .crumbs, .activity, .lesson__tools { display: none !important; }
  body { color: #000; background: #fff; font-size: 11pt; }
  a { color: #000; }
  h1, h2, h3 { color: #000; break-after: avoid; }
  .section { padding-block: 0; }
  .print-lesson, .teach-unit, .q { break-inside: avoid-page; }
  .eyebrow::after { display: none; }
  .flash__card summary { list-style: none; }
}
