/* =============================================================================
   Cancer Pathway Navigator — design system
   Calm, accessible, sourced. Four themes are systematic token sets toggled by
   [data-theme] on <html>; text scale is a root font-size multiplier (--user-scale)
   with rem-based sizing throughout, so theme × scale combine freely (spec §2/§8).
   ============================================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Theme tokens — LIGHT (default) ---------- */
:root {
  --user-scale: 1;

  --canvas:        #e7e3da;
  --surface:       #f4f2ec;
  --surface-2:     #fdfcfa;
  --line:          #e3ded6;
  --line-strong:   #d8d2c6;
  --ink:           #23282b;
  --ink-warm:      #1b2421;
  --muted:         #5c6469;
  --faint:         #8a908b;

  --accent:        #1f6f66;
  --accent-ink:    #ffffff;
  --accent-tint:   #e9f1ef;
  --accent-soft:   #f3f8f7;

  --info:          #5566b0;
  --info-ink:      #3f4b8a;
  --info-tint:     #f3f5fb;
  --info-line:     #dde2f2;

  --support:       #b5683f;
  --support-ink:   #a85a32;
  --support-tint:  #fbf6f2;
  --support-line:  #ecdfd5;

  --success:       #4f8a6b;

  --radius-control: 10px;
  --radius-card:    16px;
  --radius-pill:    999px;

  --shadow-card: 0 1px 2px rgba(20,30,28,.04), 0 18px 44px -28px rgba(20,30,28,.38);
  --shadow-soft: 0 1px 2px rgba(20,30,28,.04), 0 10px 26px -22px rgba(20,30,28,.3);
  /* the lift under a primary call-to-action — flat accent colour, never a gradient */
  --accent-shadow: 0 8px 20px -10px rgba(31,111,102,.55);

  --maxw: 1080px;
  --gap:  1rem;

  /* secondary text opacity — Focus mode dims it (spec §8) */
  --secondary-opacity: 1;
  /* decorative chrome visibility — Focus mode hides it */
  --decoration: 1;

  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sans:  'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  font-size: calc(16px * var(--user-scale));
  color-scheme: light;
}

/* ---------- DARK — soft charcoal, accent lightens (spec §2/§8) ---------- */
:root[data-theme="dark"] {
  --canvas:        #161b1e;
  --surface:       #1d2327;
  --surface-2:     #222a2e;
  --line:          #2c3338;
  --line-strong:   #3a4248;
  --ink:           #eef2f0;
  --ink-warm:      #eef2f0;
  --muted:         #9aa4a3;
  --faint:         #7e8a88;

  --accent:        #63b7ab;
  --accent-ink:    #0c1614;
  --accent-tint:   #22302d;
  --accent-soft:   #1b2a27;

  --info:          #97a3df;
  --info-ink:      #b3bdf0;
  --info-tint:     #20242f;
  --info-line:     #343a52;

  --support:       #d59265;
  --support-ink:   #e2a87e;
  --support-tint:  #2a221c;
  --support-line:  #3d3026;

  --success:       #74bd93;

  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -26px rgba(0,0,0,.7);
  --accent-shadow: 0 8px 20px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ---------- FOCUS (ADHD) — lowers stimulation, never adds (spec §8) ---------- */
:root[data-theme="focus"] {
  --canvas:        #f3f1ea;
  --surface:       #ffffff;
  --surface-2:     #ffffff;
  --line:          #e1ddd2;
  --line-strong:   #d6d1c4;
  --ink:           #262b28;
  --ink-warm:      #262b28;
  --muted:         #737a75;
  --faint:         #8a908b;

  --accent:        #2c776c;
  --accent-ink:    #ffffff;
  --accent-tint:   #eaf1ef;
  --accent-soft:   #eef4f2;

  --info:          #5566b0;
  --info-tint:     #f1f3fb;
  --support:       #a85f37;
  --support-tint:  #f7f1ec;

  --shadow-card: 0 1px 2px rgba(20,30,28,.05);
  --secondary-opacity: 0.42;
  --decoration: 0;
}

/* ---------- LARGE PRINT — bigger base, heavier weight, single column (spec §6) ---------- */
:root[data-theme="large-print"] {
  --canvas:        #f1ede4;
  --surface:       #f7f4ee;
  --surface-2:     #ffffff;
  --line:          #ddd7cc;
  --line-strong:   #cfc8bb;
  --ink:           #1c2320;
  --ink-warm:      #151c19;
  --muted:         #4d544f;
  --faint:         #6f756f;

  --accent:        #1c655d;
  --accent-ink:    #ffffff;
  --accent-tint:   #e7efed;
  --accent-soft:   #eef4f2;

  --shadow-card: 0 1px 2px rgba(20,30,28,.06);
  --accent-shadow: none;

  /* base steps up to ~19px; A−/A＋ still stack on top via --user-scale (spec §6) */
  font-size: calc(19px * var(--user-scale));
  color-scheme: light;
}
:root[data-theme="large-print"] body { line-height: 1.75; }
:root[data-theme="large-print"] h1,
:root[data-theme="large-print"] h2,
:root[data-theme="large-print"] h3,
:root[data-theme="large-print"] h4 { font-weight: 600; }
:root[data-theme="large-print"] .btn,
:root[data-theme="large-print"] .option__title,
:root[data-theme="large-print"] .tile__label { font-weight: 700; }
/* single column — never make a large-print reader scan two columns */
:root[data-theme="large-print"] .dash__body { grid-template-columns: 1fr; }
:root[data-theme="large-print"] .side { position: static; }
:root[data-theme="large-print"] .options--2col,
:root[data-theme="large-print"] .tile-grid { grid-template-columns: 1fr; }

/* ---------- Base ---------- */
body {
  font-family: var(--font-sans);
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
:root[data-theme="focus"]      body { line-height: 1.7; }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 500; color: var(--ink-warm); line-height: 1.15; text-wrap: balance; }
h3, h4 { font-weight: 600; }
/* let long body lines wrap evenly rather than leaving orphan words */
p, li { text-wrap: pretty; }
a { color: var(--accent); }
::selection { background: var(--accent-tint); }

/* ---------- Utilities ---------- */
.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;
}
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); }
.eyebrow {
  font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); font-weight: 600;
}
.is-secondary { opacity: var(--secondary-opacity); transition: opacity .25s ease; }

/* ---------- Focus ring — 3px accent, 2px offset, never removed (spec §2/§8) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: fixed; top: .5rem; left: .5rem; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: var(--radius-control);
  font-weight: 600; text-decoration: none; transform: translateY(-150%);
  transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); }

/* =============================================================================
   GLOBAL TOOLBAR
   ============================================================================= */
/* The toolbar uses fixed px sizing (not rem) so it never shifts when the user
   scales body text — only the page content responds to A−/A＋. */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--ink-warm);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 14px;
}
:root[data-theme="dark"] .toolbar { background: #0f1316; }
.toolbar__inner {
  max-width: 1280px; margin-inline: auto; padding: 8px clamp(12px, 3vw, 24px);
  display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
}
.toolbar__brand { display: flex; align-items: center; gap: 8px; margin-inline-end: auto; background: none; border: none; color: inherit; cursor: pointer; padding: 4px 6px; border-radius: 8px; font: inherit; }
.toolbar__brand:hover { background: rgba(255,255,255,.08); }
.toolbar__brand-mark { width: 22px; height: 2px; background: var(--accent); border-radius: 2px; }
.toolbar__brand-text { font-weight: 600; font-size: 14px; white-space: nowrap; }
.toolbar__controls { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.toolbar__group { display: flex; align-items: center; gap: 7px; }
.toolbar__label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: #8c958f;
}
.seg { display: inline-flex; gap: 3px; background: rgba(255,255,255,.06); padding: 3px; border-radius: 9px; }
.seg__btn {
  border: none; cursor: pointer; background: transparent; color: #cdd4d0;
  border-radius: 7px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; min-height: 32px;
}
.seg__btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.seg__btn[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }

/* text sizer — fixed geometry; the A−/A＋ buttons and readout never move */
.sizer { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.06); padding: 3px; border-radius: 9px; }
.sizer__btn {
  border: none; cursor: pointer; background: rgba(255,255,255,.1); color: #fff; border-radius: 7px;
  width: 40px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; padding: 0; flex: none;
}
.sizer__btn:hover { background: rgba(255,255,255,.2); }
.sizer__val { width: 48px; text-align: center; font-family: var(--font-mono); font-size: 12px; color: #cdd4d0; flex: none; }

.toolbar__action {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: rgba(255,255,255,.08); color: #fff; border: none;
  border-radius: 8px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; min-height: 36px;
}
.toolbar__action:hover { background: rgba(255,255,255,.16); }
.toolbar__action[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.toolbar__action[aria-disabled="true"] { opacity: .5; }
.toolbar__group--lang { gap: 6px; }

/* Read-aloud glyph — drawn, not emoji. A solid play triangle that becomes two
   pause bars while speaking. Inherits currentColor (white in the toolbar, accent
   in the per-panel pill), so one rule serves both (polish move 1). */
.ra-glyph {
  display: inline-block; width: 8px; height: 10px; position: relative; flex: none;
}
.ra-glyph::before {
  content: ""; position: absolute; top: 50%; left: 0; transform: translateY(-50%);
  width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent currentColor;
}
.is-playing .ra-glyph::before {
  width: 3px; height: 10px; top: 0; transform: none; border: none; background: currentColor;
}
.is-playing .ra-glyph::after {
  content: ""; position: absolute; top: 0; right: 0; width: 3px; height: 10px; background: currentColor;
}
.lang-select {
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px; padding: 6px 8px; font-size: 12.5px; min-height: 36px; cursor: pointer; max-width: 46vw;
}
.lang-select option { color: #111; }

/* Mobile: hide the group labels (kept for screen readers), tighten spacing. */
@media (max-width: 640px) {
  .toolbar__label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .toolbar__inner { gap: 8px 10px; }
  .toolbar__controls { gap: 8px 12px; }
}

/* =============================================================================
   APP SHELL
   ============================================================================= */
.app { flex: 1 0 auto; width: 100%; outline: none; }
.screen { padding-block: clamp(1.75rem, 5vw, 3.25rem); }
.noscript-note { max-width: 40rem; margin: 3rem auto; padding: 0 1.5rem; }

/* ---------- Buttons / chips / links ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-weight: 600; font-size: 1rem; cursor: pointer;
  border-radius: 9px; padding: .75rem 1.4rem; min-height: 44px; border: 1.5px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: var(--accent-shadow); }
.btn--primary:hover:not([disabled]) { filter: brightness(.95); }
.btn--secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover:not([disabled]) { border-color: var(--accent); }
/* Disabled is visibly muted — a neutral surface, not a pale accent that reads as
   "maybe tappable". A one-line reason sits beside it (.intake-nav__reason). */
.btn[disabled] { background: var(--surface); color: var(--faint); border-color: var(--line); box-shadow: none; cursor: not-allowed; }
:root[data-theme="focus"] .btn--primary,
:root[data-theme="large-print"] .btn--primary { box-shadow: none; }
.btn--block { width: 100%; }
.link-btn {
  background: none; border: none; cursor: pointer; color: var(--accent);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: .4rem .2rem;
}
.text-link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-tint);
  color: var(--accent); font-size: .78rem; font-weight: 600; padding: .3rem .7rem; border-radius: var(--radius-pill);
}

/* ---------- Callouts ---------- */
.callout { border-radius: 0 11px 11px 0; padding: .9rem 1.1rem; border-inline-start: 4px solid; }
.callout--info    { background: var(--info-tint);    border-color: var(--info); }
.callout--support { background: var(--support-tint);  border-color: var(--support); }
.callout--plain   { background: var(--accent-soft);   border-color: var(--accent); }
.callout__title { font-size: .82rem; font-weight: 700; margin-bottom: .35rem; }
.callout--info .callout__title    { color: var(--info-ink); }
.callout--support .callout__title { color: var(--support-ink); }
.callout--plain .callout__title   { color: var(--accent); }

/* =============================================================================
   WELCOME (S1)
   ============================================================================= */
.welcome {
  max-width: 44rem; margin-inline: auto; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 22px; padding: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 5vw, 3.25rem);
  box-shadow: var(--shadow-card);
}
:root[data-theme="focus"] .welcome { box-shadow: none; }
.welcome__title {
  font-size: clamp(2.1rem, 6vw, 3.4rem); line-height: 1.05; letter-spacing: -.01em;
  margin-top: 1rem; max-width: 18ch; margin-inline: auto;
}
.welcome__lead { font-size: 1.0625rem; color: var(--muted); line-height: 1.65; margin: 1.1rem auto 0; max-width: 48ch; }
.welcome__doors { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }
.welcome__rolelabel { display: block; font-size: .9rem; color: var(--muted); margin-top: 1.75rem; margin-bottom: .6rem; }
.welcome__role { display: inline-flex; gap: .35rem; background: var(--surface); border: 1px solid var(--line); padding: .3rem; border-radius: var(--radius-pill); }
.welcome__role-btn { border: none; cursor: pointer; background: none; color: var(--ink); font-weight: 600; font-size: .95rem; padding: .55rem 1.1rem; border-radius: var(--radius-pill); min-height: 40px; }
.welcome__role-btn[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.readaloud-btn[aria-disabled="true"] { opacity: .55; }
.welcome__disclaimer {
  margin: 1.75rem auto 0; max-width: 52ch; text-align: start;
}
.welcome__resume {
  margin: 0 auto 1.5rem; max-width: 40rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 1rem 1.25rem; display: flex; gap: 1rem;
  align-items: center; justify-content: space-between; flex-wrap: wrap;
}

/* =============================================================================
   INTAKE
   ============================================================================= */
.intake { max-width: 44rem; margin-inline: auto; }
.progress { margin-bottom: 1.5rem; }
.progress__track { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .35s ease; }
:root[data-theme="focus"] .progress__fill { transition: none; }
.progress__text { display: block; margin-top: .5rem; font-size: .8rem; color: var(--muted); }

.step__eyebrow { margin-bottom: .35rem; }
.step__q { font-size: clamp(1.4rem, 3.5vw, 1.6rem); line-height: 1.18; margin-bottom: .4rem; }
.step__hint { color: var(--muted); font-size: .95rem; margin-bottom: 1.25rem; max-width: 54ch; }
.optional-tag {
  font-family: var(--font-mono); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface); color: var(--muted); border-radius: 5px; padding: .15rem .45rem; margin-inline-start: .5rem;
}

/* search + grid (cancer type) */
.search {
  position: relative; margin-bottom: 1rem;
}
.search__input {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 9px;
  padding: .8rem 1rem .8rem 2.5rem; font-size: 1rem; background: var(--surface-2); color: var(--ink); min-height: 48px;
}
/* drawn magnifier — no emoji (polish move 1) */
.search__icon {
  position: absolute; inset-inline-start: 1rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; border: 2px solid var(--faint); border-radius: 50%; pointer-events: none;
}
.search__icon::after {
  content: ""; position: absolute; bottom: -3px; inset-inline-end: -4px;
  width: 7px; height: 2px; background: var(--faint); border-radius: 2px; transform: rotate(45deg);
}
[dir="rtl"] .search__icon::after { transform: rotate(-45deg); }
[dir="rtl"] .search__input { padding: .8rem 2.5rem .8rem 1rem; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; }
.tile {
  text-align: start; cursor: pointer; background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; padding: .8rem .9rem; min-height: 56px;
  display: flex; flex-direction: column; gap: .15rem; position: relative; transition: border-color .12s ease;
}
.tile:hover { border-color: var(--accent); }
.tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tile__label { font-weight: 600; font-size: .95rem; padding-inline-end: 1.25rem; }
.tile__sub { font-size: .8rem; color: var(--muted); }
.tile__check {
  position: absolute; top: .55rem; inset-inline-end: .55rem; width: 1.25rem; height: 1.25rem;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: none; align-items: center; justify-content: center; font-size: .7rem;
}
.tile[aria-pressed="true"] .tile__check { display: flex; }
.tile-empty { color: var(--muted); font-size: .9rem; padding: 1rem .2rem; }
.tile-count { font-size: .82rem; color: var(--muted); margin: -.25rem 0 .6rem; }
.tile-actions { display: flex; gap: .5rem 1.25rem; flex-wrap: wrap; align-items: center; margin-top: .9rem; font-size: .9rem; }

/* option cards (single / multi select) */
.options { display: flex; flex-direction: column; gap: .55rem; }
.options--2col { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.option {
  display: flex; gap: .75rem; align-items: flex-start; text-align: start; width: 100%;
  cursor: pointer; background: var(--surface-2); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; padding: .85rem 1rem; min-height: 44px;
  transition: border-color .12s ease;
}
.option:hover { border-color: var(--accent); }
.option[aria-checked="true"], .option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option--muted { opacity: .82; }
.option--muted:hover { opacity: 1; }
.option__box {
  flex: none; width: 1.3rem; height: 1.3rem; border-radius: 6px; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; margin-top: .1rem; color: var(--accent-ink); font-size: .75rem;
}
.option[aria-checked="true"] .option__box, .option[aria-pressed="true"] .option__box { background: var(--accent); border-color: var(--accent); }
.option__box::after { content: "✓"; opacity: 0; }
.option[aria-checked="true"] .option__box::after, .option[aria-pressed="true"] .option__box::after { opacity: 1; }
.option--radio .option__box { border-radius: 50%; }
.option__body { display: flex; flex-direction: column; gap: .15rem; }
.option__title { font-weight: 600; font-size: .98rem; }
.option__desc { font-size: .85rem; color: var(--muted); line-height: 1.5; }

/* about-you fieldsets */
.field { margin-bottom: 1.4rem; }
.field > legend, .field > .field__label { font-weight: 600; font-size: .98rem; margin-bottom: .25rem; padding: 0; }
.field__why { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.pillset { display: flex; gap: .5rem; flex-wrap: wrap; }
.pill {
  cursor: pointer; background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line);
  border-radius: 8px; padding: .55rem .9rem; font-weight: 600; font-size: .9rem; min-height: 40px;
}
.pill:hover { border-color: var(--accent); }
.pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.select-field {
  width: 100%; max-width: 22rem; border: 1.5px solid var(--line-strong); border-radius: 9px;
  padding: .7rem .9rem; background: var(--surface-2); color: var(--ink); min-height: 44px;
}

.intake-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.intake-nav__skip { margin-inline-start: auto; }
/* the "why is Continue disabled" line — sits under the nav, near the button (move 3) */
.intake-nav__reason { margin: .6rem 0 0; text-align: end; font-size: .85rem; color: var(--muted); }
.intake-nav__reason[hidden] { display: none; }

/* =============================================================================
   DASHBOARD (S7)
   ============================================================================= */
.dash { max-width: var(--maxw); margin-inline: auto; }

.profilebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.profilebar__id { display: flex; align-items: center; gap: .8rem; }
.profilebar__eyebrow {
  font-family: var(--font-mono); font-size: .65rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint); margin-bottom: .25rem;
}
.profilebar__title { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 600; color: var(--ink-warm); line-height: 1.2; }
.profilebar__sub { font-size: .85rem; color: var(--muted); margin-top: .2rem; }

/* population opt-in banner */
.popbanner {
  background: var(--info-tint); border: 1px solid var(--info-line); border-radius: var(--radius-card);
  padding: .9rem 1.1rem; margin-bottom: 1rem; display: flex; gap: 1rem; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
}
.popbanner__text { font-size: .9rem; color: var(--ink); }

/* step rail (ARIA tablist) */
.rail { margin-bottom: 1.25rem; }
.rail__track { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .35rem; scrollbar-width: thin; }
.rail__tab {
  flex: 1 1 0; min-width: 7.5rem; text-align: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
  padding: .6rem .5rem; color: var(--muted); min-height: 52px;
}
.rail__tab:hover { border-color: var(--accent); }
.rail__tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); }
.rail__tab[aria-selected="true"] .rail__name,
.rail__tab[aria-selected="true"] .rail__meta { color: var(--accent-ink); }
.rail__name { display: block; font-weight: 600; font-size: .82rem; color: var(--ink); }
.rail__meta { display: block; font-family: var(--font-mono); font-size: .62rem; letter-spacing: .04em; margin-top: .15rem; }
.rail__tab--eol { border-style: dashed; background: var(--canvas); }
.rail__tab--eol .rail__name { color: var(--faint); }
.rail__select { display: none; width: 100%; }

/* layout: sidebar + content */
.dash__body { display: grid; grid-template-columns: 15rem 1fr; gap: 1.25rem; align-items: start; }

.side { display: flex; flex-direction: column; gap: .85rem; position: sticky; top: 4.5rem; }
.sidecard { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; }
.sidecard__title {
  font-family: var(--font-mono); font-size: .65rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); margin-bottom: .6rem;
}
.sidelink { display: block; width: 100%; text-align: start; background: none; border: none; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: .85rem; padding: .25rem 0; }
.sidelink:hover { text-decoration: underline; }
.sidenav { display: flex; flex-direction: column; gap: .3rem; }
.sidenav__item { background: none; border: none; cursor: pointer; text-align: start; color: var(--ink);
  font-size: .85rem; padding: .2rem 0; }
.sidenav__item:hover { color: var(--accent); }
.helpcard { background: var(--info-tint); border-color: var(--info-line); }
.helpcard__title { font-size: .82rem; font-weight: 700; color: var(--info-ink); margin-bottom: .4rem; }
.helpcard__num { font-size: .95rem; font-weight: 700; color: var(--ink); }
.helpcard__det { font-size: .75rem; color: var(--muted); margin-bottom: .5rem; }

/* content panel */
.content { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-card); padding: clamp(1.1rem, 3vw, 1.6rem); box-shadow: var(--shadow-card); }
:root[data-theme="focus"] .content { box-shadow: none; }
.content__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.content__title { font-size: clamp(1.35rem, 3vw, 1.5rem); line-height: 1.15; }
.content__source { font-size: .78rem; color: var(--faint); margin: .3rem 0 1.1rem; }
.content__source em { font-style: italic; }

.readaloud-btn {
  flex: none; display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  background: none; border: 1.5px solid var(--line-strong); color: var(--accent);
  border-radius: var(--radius-pill); padding: .45rem .85rem; font-size: .8rem; font-weight: 600;
  min-height: 36px; white-space: nowrap;
}
.readaloud-btn:hover { border-color: var(--accent); }
.readaloud-btn.is-playing { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* detail expander */
.expander { border: 1px solid var(--line); border-radius: 11px; margin-bottom: .9rem; overflow: hidden; }
.expander__summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .85rem 1.1rem; font-weight: 600; font-size: .95rem; min-height: 44px;
}
.expander__summary::-webkit-details-marker { display: none; }
.expander__summary::after { content: "＋"; color: var(--faint); font-size: 1.1rem; }
.expander[open] .expander__summary::after { content: "−"; }
.expander__body { padding: 0 1.1rem 1.1rem; }

/* questions card */
.questions { margin-top: 1rem; }
.questions__list { margin: .3rem 0 0; padding-inline-start: 1.1rem; font-size: .9rem; color: var(--ink); line-height: 1.6; }

/* prev / next */
.stepnav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap; }
.stepnav__btn { background: none; border: none; cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; padding: .4rem .2rem; }
.stepnav__btn[disabled] { color: var(--faint); cursor: default; }

/* pinned list */
.pinned__item { margin-bottom: .35rem; }
.pinned__badge { font-family: var(--font-mono); font-size: .6rem; color: var(--faint); }

/* =============================================================================
   RENDERED OCP CONTENT (sanitised, re-styled into the system) — spec §7
   ============================================================================= */
.ocp { line-height: 1.66; color: var(--ink); }
.ocp section { margin: 0; }
.ocp h2, .ocp h3, .ocp h4, .ocp h5 { font-family: var(--font-serif); color: var(--ink-warm); margin: 1.2rem 0 .5rem; line-height: 1.25; }
.ocp h3 { font-size: 1.18rem; }
.ocp h4 { font-size: 1.04rem; }
.ocp h5 { font-size: .96rem; }
.ocp p { margin: .5rem 0; }
.ocp ul, .ocp ol { margin: .5rem 0 .8rem; padding-inline-start: 1.3rem; }
.ocp li { margin: .25rem 0; }
.ocp a { color: var(--accent); }
.ocp table { width: 100%; border-collapse: collapse; margin: .8rem 0; font-size: .92rem; }
.ocp th, .ocp td { border: 1px solid var(--line); padding: .5rem .65rem; text-align: start; vertical-align: top; }
.ocp th { background: var(--surface); }
.ocp .sentence.ra-current { background: var(--accent-tint); border-radius: 3px; box-shadow: 0 0 0 2px var(--accent-tint); }
/* read-aloud highlight — sentence spans and whole-element units */
.ra-current { background: var(--accent-tint); border-radius: 4px; box-shadow: 0 0 0 3px var(--accent-tint); }
.sentence { transition: background .15s ease; }

/* "what this step covers" structure list (when body text is absent) */
.structure { list-style: none; margin: .5rem 0; padding: 0; }
.structure li { padding: .4rem .75rem; border-inline-start: 3px solid var(--accent-tint); background: var(--surface); border-radius: 0 6px 6px 0; margin: .3rem 0; font-size: .92rem; }
.structure li.lvl-3 { margin-inline-start: 1.1rem; border-inline-start-color: var(--line); color: var(--muted); font-size: .86rem; }

/* "Available in English" content-language note */
.lang-note { display: flex; gap: .6rem; align-items: flex-start; background: var(--info-tint); border: 1px solid var(--info-line); border-radius: 10px; padding: .7rem .9rem; margin-bottom: .9rem; font-size: .85rem; color: var(--ink); }

/* =============================================================================
   DIAGNOSTICS (corpus & API status)
   ============================================================================= */
.diag { max-width: var(--maxw); margin-inline: auto; }
.diag__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.diag__base { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; margin: .75rem 0 1.25rem; word-break: break-all; }
.diag__summary { background: var(--accent-soft); border: 1px solid var(--accent-tint); border-radius: 12px; padding: .9rem 1.1rem; margin-bottom: 1.25rem; font-size: .95rem; }
.diag__h3 { font-family: var(--font-serif); font-weight: 600; font-size: 1.15rem; margin: 1.25rem 0 .6rem; }
.diag__endpoints { display: grid; gap: .5rem; margin-bottom: .5rem; }
.diag__ep { display: flex; gap: .75rem; align-items: center; justify-content: space-between; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .85rem; font-size: .85rem; flex-wrap: wrap; }
.diag__ep code { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
.diag__wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.diag__grid { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--surface-2); min-width: 40rem; }
.diag__grid th, .diag__grid td { text-align: start; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.diag__grid th { background: var(--surface); font-family: var(--font-mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; }
.diag__grid tr:last-child td { border-bottom: none; }
.diag__slug { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge--ok { background: var(--accent-tint); color: var(--accent); }
.badge--no { background: var(--support-tint); color: var(--support-ink); }
.badge--warn { background: var(--info-tint); color: var(--info-ink); }
.diag__probe { background: none; border: 1.5px solid var(--line-strong); color: var(--accent); border-radius: 8px; padding: .3rem .7rem; font-size: .78rem; font-weight: 600; cursor: pointer; min-height: 32px; }
.diag__probe:hover { border-color: var(--accent); }

/* =============================================================================
   TOASTS
   ============================================================================= */
.toast-region { position: fixed; inset-block-end: 1rem; inset-inline: 0; display: flex; flex-direction: column; gap: .5rem; align-items: center; z-index: 80; pointer-events: none; padding-inline: 1rem; }
.toast {
  pointer-events: auto; background: var(--ink-warm); color: #fff; border-radius: 10px;
  padding: .7rem 1rem; display: flex; gap: .9rem; align-items: center; box-shadow: var(--shadow-card);
  font-size: .9rem; max-width: 32rem;
}
.toast__btn { background: var(--accent); color: var(--accent-ink); border: none; border-radius: 7px; padding: .35rem .75rem; font-weight: 600; cursor: pointer; }

/* =============================================================================
   FOOTER
   ============================================================================= */
.site-footer { flex: none; background: var(--ink-warm); color: #cdd4d0; margin-top: 2.5rem; }
:root[data-theme="dark"] .site-footer { background: #0f1316; }
.site-footer__inner { max-width: var(--maxw); margin-inline: auto; padding: 1.75rem clamp(1rem, 4vw, 2.5rem); display: flex; flex-direction: column; gap: .75rem; }
.site-footer__disclaimer { font-size: .9rem; color: #e7ece9; line-height: 1.55; max-width: 80ch; }
.site-footer__source { font-size: .82rem; }
.site-footer a { color: var(--accent); }
:root[data-theme="dark"] .site-footer a, .site-footer a { color: #9ec3bc; }
.site-footer__row { display: flex; gap: 1rem 2rem; align-items: center; flex-wrap: wrap; padding-top: .5rem; border-top: 1px solid rgba(255,255,255,.12); }
.site-footer .link-btn { color: #fff; }
.site-footer__ack { font-size: .78rem; color: #8c958f; font-style: italic; }
.site-footer__fine { font-size: .72rem; color: #8c958f; }

/* =============================================================================
   FOCUS-MODE specifics — remove decorative chrome, one section in view
   ============================================================================= */
:root[data-theme="focus"] .toast { box-shadow: none; border: 1px solid var(--line); }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 860px) {
  .dash__body { grid-template-columns: 1fr; }
  .side { position: static; order: 2; }
  .rail__track { display: none; }
  .rail__select { display: block; }
  .options--2col { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .toolbar__brand-text { display: none; }
  .toolbar__inner { gap: .6rem .8rem; }
  .welcome__doors .btn { width: 100%; }
}

/* =============================================================================
   MOTION — honour prefers-reduced-motion (spec §8)
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* =============================================================================
   PRINT
   ============================================================================= */
@media print {
  .toolbar, .site-footer, .toast-region, .rail, .side, .skip-link, .readaloud-btn, .stepnav { display: none !important; }
  body { background: #fff; }
  .content { box-shadow: none; border: none; padding: 0; }
}
