/* ===========================
   DESIGN TOKENS
   iqtify design system v2 — "instrument"
   Rules:
     · Colour is data. Chrome is neutral.
     · --accent = "you / your position". green/red/amber = one answer's outcome.
     · Never hand-type a colour. If it isn't a token, it doesn't ship.
   =========================== */
:root {
  color-scheme: light dark;              /* audit #10 */

  /* ── Surfaces (promoted clean landing palette) ── */
  --bg:             #ffffff;
  --surface:        #ffffff;
  --surface-2:      #f5f7ff;
  --surface-3:      #edf1f6;   /* meter tracks / inset fills — NOT a text bed */
  --border:         #e7ecf3;   /* decorative separators */
  --border-strong:  #8490a4;   /* control edges — meets 3:1 non-text (WCAG 1.4.11) */

  /* ── Ink ── */
  --text:           #0c1b3a;   /* promoted landing ink */
  --text-muted:     #667085;   /* secondary text */
  --text-subtle:    #8490a4;   /* tertiary; ALWAYS less prominent than muted */

  /* ── Accent: "you / your position" ── */
  --accent:          #6847f5;
  --accent-contrast: #ffffff;
  --accent-dim:      #edf2ff;
  --accent-mid:      #8b6ff7;

  /* ── Semantic: outcome of one answer ── */
  --green:      #146c4a;  --green-dim: #dff0e7;   /* correct */
  --red:        #a52320;  --red-dim:   #fbe4e2;   /* wrong   */
  --amber:      #7a4d09;  --amber-dim: #f8ecd4;   /* skipped / provisional */

  /* ── Type scale — 8 steps, ratio ≈1.2, replaces 23 ad-hoc sizes (audit #6) ── */
  --text-2xs: 0.6875rem;  /* 11px — uppercase micro-labels ONLY */
  --text-xs:  0.8125rem;  /* 13px — meta, captions, counts */
  --text-sm:  0.9375rem;  /* 15px — secondary body, buttons, inputs */
  --text-md:  1.0625rem;  /* 17px — body, question text */
  --text-lg:  1.25rem;    /* 20px — card question, modal title */
  --text-xl:  1.5rem;     /* 24px — screen headings */
  --text-2xl: 1.875rem;   /* 30px — dashboard title */
  --text-3xl: 2.375rem;   /* 38px — the single largest numeral (level readout). Nothing bigger. */

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;     /* 800 is retired — it was doing gradient-headline work */

  --lh-tight:   1.2;
  --lh-snug:    1.35;
  --lh-normal:  1.55;
  --lh-relaxed: 1.7;

  --ls-tight:  -0.01em;
  --ls-normal: 0;
  --ls-wide:   0.06em;    /* uppercase micro-labels only */

  /* ── Spacing — 4px base (audit #7) ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── Radii — by ROLE, not by vibe (audit #33) ── */
  --radius-sm:   6px;    /* notices, small inset chips */
  --radius-md:   12px;   /* interactive controls: buttons, inputs, mcq options */
  --radius-lg:   18px;   /* containers: cards, rows, banners, panels */
  --radius-xl:   24px;   /* primary focus surfaces ONLY: the quiz card + the modal */
  --radius-full: 100px;  /* pills & badges */

  /* ── Borders — ONE weight. Emphasis comes from colour, never from 1px→1.5px ── */
  --border-w: 1px;

  /* ── Elevation (audit #5) ── */
  --shadow-sm: 0 1px 2px rgba(20,40,80,.05), 0 1px 3px rgba(20,40,80,.04);
  --shadow-md: 0 4px 12px rgba(20,40,80,.07), 0 2px 4px rgba(20,40,80,.05);
  --shadow-lg: 0 10px 34px rgba(20,40,70,.08), 0 4px 12px rgba(20,40,80,.06);
  --shadow-xl: 0 14px 40px rgba(20,40,80,.12), 0 4px 12px rgba(20,40,80,.08);

  /* ── Scrims (modal backdrop, card loading overlay) ── */
  --scrim:         rgba(24,24,20,.5);
  --scrim-surface: rgba(255,255,255,.85);

  /* ── Motion ── */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --ease-out:    cubic-bezier(.2,.8,.2,1);
  --ease-in-out: cubic-bezier(.4,0,.2,1);

  /* ── Fonts ── */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;

  /* ── Layout ── */
  --topbar-h:       56px;
  --panel-w:        272px;
  --width-content:  720px;  /* scanning/reading surfaces: goals, dashboard, topics */
  --width-card:     640px;  /* single-question focus: the quiz card */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #111312;
    --surface:       #1a1c1c;
    --surface-2:     #232626;
    --surface-3:     #2f3332;
    --border:        #343837;
    --border-strong: #787d7c;   /* 4.09:1 on surface */

    --text:          #ececeb;
    --text-muted:    #b3b1a8;   /* 7.96:1 — still MORE prominent than subtle (audit #18) */
    --text-subtle:   #9a978e;   /* 5.86:1 */

    --accent:          #9db8f0;
    --accent-contrast: #111312;  /* ← CRITICAL: dark text on a light accent. white would be 1.99:1 */
    --accent-dim:      #1b2540;
    --accent-mid:      #7590c4;

    --green: #5fcfa0;  --green-dim: #0d2a20;
    --red:   #f0908c;  --red-dim:   #331615;
    --amber: #e0ac4e;  --amber-dim: #302209;

    --scrim:         rgba(0,0,0,.6);
    --scrim-surface: rgba(26,28,28,.88);

    /* Elevation must be re-specified for dark — 7%-black on #111 is invisible (audit #5) */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
    --shadow-md: 0 2px 6px rgba(0,0,0,.55), 0 6px 16px rgba(0,0,0,.45);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.6),  0 3px 8px rgba(0,0,0,.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,.7),  0 6px 16px rgba(0,0,0,.55);
  }
}

/* ===========================
   RESET & BASE
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* 16px root — the rem scale above assumes this, and it respects user font settings.
   NOTE (deviation from direction §2.4): the spec put `font-size: var(--text-sm)` on
   `html, body`. Because --text-sm is a rem value, that resolves the ROOT to 15px and then
   compounds on body to 14.06px — the opposite of the intended 16px root. The size belongs
   on body only. */
html {
  font-size: 100%;
  height: 100%;
}

body {
  height: 100%;
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: var(--lh-normal);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

/* Focus — audit #4. app.js moves focus ~6× per question; this is the primary flow. */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.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;
}

/* ===========================
   LAYOUT SHELL
   =========================== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ===========================
   TOP BAR
   =========================== */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: var(--border-w) solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  gap: var(--space-3);
  z-index: 10;
  flex-shrink: 0;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.app-logo {
  font-size: var(--text-md);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  color: var(--text);
}

/* audit #15: the badge leaked the LLM provider and model to end users, and "Live" is
   not news — a working product is the expected state. It now shows ONLY when it carries
   a real warning (Mock / Offline, both .badge--mock). Live and the loading placeholder
   render nothing. app.js keeps setting all of them; CSS decides visibility. */
.badge {
  display: none;
  align-items: center;
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  text-transform: uppercase;
}
.badge--mock {
  display: inline-flex;
  background: var(--amber-dim);
  color: var(--amber);
}

.topic-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: var(--space-1) var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-full);
  border: var(--border-w) solid var(--border);
}

/* ===========================
   MAIN LAYOUT
   =========================== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===========================
   CARD COLUMN
   =========================== */
/* audit #20: `justify-content: center` on a scroll container makes content taller than
   the viewport unreachable — the overflow escapes past the scrollable top. `margin-block:
   auto` on the view (below) centres short content while letting tall content scroll. */
.card-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: var(--space-8) var(--space-5) var(--space-12);
  min-width: 0;
}

/* Only one of these is ever visible ([hidden] => display:none), so the auto margins
   never compete. */
.goals-screen,
.start-screen,
.goal-dash,
.quiz-area { margin-block: auto; }

/* ===========================
   START SCREEN
   =========================== */
.start-screen {
  width: 100%;
  max-width: var(--width-content);
  animation: fade-up var(--dur-base) var(--ease-out);
}

.start-hero {
  text-align: center;
  margin-bottom: var(--space-8);
}

.start-heading {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: var(--space-2);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
}

.start-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--lh-normal);
}

.topic-grid {
  --grid-min: 180px;                                              /* audit #13 */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr));
  gap: var(--space-3);
  text-align: left;
}

/* .topic-grid-loading is no longer a loading state (skeletons replaced it, audit #26) —
   app.js still writes empty/failure text into the grids through it. */
.topic-grid-loading {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--text-xs);
  padding: var(--space-2) 0;
  text-align: center;
}

/* Review section */
.review-section {
  margin: var(--space-4) 0 var(--space-3);
  text-align: center;
}

.review-stats {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.topic-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast),
              transform var(--dur-fast), background var(--dur-fast);
  font-family: var(--font);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.topic-card:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), var(--shadow-sm);
  transform: translateY(-2px);
}

.topic-card:active:not(:disabled) {
  transform: translateY(0);
}

.topic-card:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.topic-card--selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.topic-card-emoji {
  font-size: var(--text-xl);
  line-height: var(--lh-tight);
  margin-bottom: 2px;
}

.topic-card-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-snug);
}

/* audit #13 — a 160-char description used to wrap to ~10 lines and inflate the grid row */
.topic-card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--lh-snug);
}

.topic-card-count {
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  margin-top: auto;
  padding-top: var(--space-1);
  font-weight: var(--fw-medium);
}

/* ===========================
   NOTICES (§3.7)
   Audit #24: success used to render through a function named showError, into an
   element classed .start-error — a red box recoloured green. One box now, with the
   variant carrying the meaning. showError()/hideError() (app.js) toggle
   .notice--error / .notice--success; .start-error / .start-error--status are gone.
   =========================== */
.notice {
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  border: var(--border-w) solid transparent;
  line-height: var(--lh-snug);
  text-align: left;
}

/* Stacking helpers — the notice box itself carries no margin, so it can sit in a
   gap-spaced flex column (#quiz-error) without paying for it twice. */
.notice-top    { margin-top: var(--space-3); }
.notice-bottom { margin-bottom: var(--space-3); }

.notice--error,
.article-status--error {
  color: var(--red);
  background: var(--red-dim);
  border-color: var(--red);
}

.notice--success,
.article-status--ok {
  color: var(--green);
  background: var(--green-dim);
  border-color: var(--green);
}

.notice--info,
.notice--pending,
.article-status--pending {
  color: var(--text-muted);
  background: var(--surface-2);
  border-color: var(--border);
}

/* A load failure renders one message, where the user is looking — in the grid it
   replaces — rather than one in the grid and a second one below the fold (audit #24). */
.grid-notice { grid-column: 1 / -1; }

/* ===========================
   QUIZ AREA
   =========================== */
.quiz-area {
  width: 100%;
  max-width: var(--width-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ===========================
   CARD DECK
   audit #23: the ghost-card ::before/::after are DELETED — they read as a rendering
   artifact, carried no information (the deck implied a history it never rendered),
   and their z-index:-1 was fragile. .card-deck stays as the card's positioning
   context; updateDeck() and the has-history-* classes are left alone — dead classes
   are harmless and touching that JS isn't worth the risk.
   =========================== */
.card-deck { position: relative; }

/* ===========================
   QUESTION CARD
   =========================== */
.card {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
  position: relative;
  overflow: hidden;
  z-index: 1;
}


.card--enter {
  animation: card-in var(--dur-base) var(--ease-out);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Question state ─── */
.card-tag {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-question {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--text);
  margin-bottom: var(--space-6);
  letter-spacing: var(--ls-tight);
}

.answer-row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

/* ─── MCQ options ─── */
.mcq-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-1) 0;
}

.mcq-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 44px;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
  font-size: var(--text-sm);
  color: var(--text);
  user-select: none;
}

.mcq-option:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.mcq-option--selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.mcq-option input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.mcq-label { flex: 1; }

.mcq-submit {
  margin-top: var(--space-2);
  align-self: flex-end;
}

.secondary-actions {
  margin-top: var(--space-3);
  display: flex;
  justify-content: flex-end;
}

/* ─── Feedback state ─── */
/* .feedback-status is a .pill variant — the outcome of one answer is the one place
   saturated colour is licensed (§1 rule 2). */
.feedback-status {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: var(--border-w) solid transparent;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  white-space: nowrap;
}

.fb-status--correct {
  background: var(--green-dim);
  color: var(--green);
  border-color: var(--green);
}
.fb-status--wrong {
  background: var(--red-dim);
  color: var(--red);
  border-color: var(--red);
}
.fb-status--hedged {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: var(--amber);
}

.fb-explanation {
  font-size: var(--text-md);
  line-height: var(--lh-relaxed);
  color: var(--text);
  margin-bottom: var(--space-4);
  white-space: pre-wrap;
}

.fb-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-left: 3px solid var(--accent-mid);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  font-style: italic;
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.fb-hedge-note {
  font-size: var(--text-xs);
  color: var(--amber);
  background: var(--amber-dim);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.fb-concept-row {
  margin-bottom: var(--space-5);
}

.feedback-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

/* JS-applied (app.js:1646) — keep the class name (guardrail §6.3) */
.learn-prominent {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-mid);
}
.learn-prominent:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* ─── Done state ─── */
.done-header {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: var(--space-2);
  letter-spacing: var(--ls-tight);
}

/* .done-grade / .done-grade-label are DELETED — the letter grade is cut entirely
   (audit #1). #done-grade-block stays in the DOM and is written empty. */

.done-concepts { margin-bottom: var(--space-6); }

.done-concept-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
  border-bottom: var(--border-w) solid var(--border);
}
.done-concept-row:last-child { border-bottom: none; }

.done-concept-rating {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;   /* gives --mono's job to the numerals (audit #33) */
}
.done-concept-samples {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

/* ─── Card loading overlay ─── */
.card-loading {
  position: absolute;
  inset: 0;
  background: var(--scrim-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  backdrop-filter: blur(4px);
  z-index: 10;
}

/* ===========================
   INPUTS & BUTTONS
   =========================== */
.text-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: var(--border-w) solid var(--border-strong);  /* a control edge must be seen */
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-sm);
  min-height: 44px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  /* `outline: none` REMOVED — :focus-visible must survive (audit #4) */
}
.text-input::placeholder { color: var(--text-subtle); }
.text-input:focus-visible {
  outline: none;                       /* replaced by the ring below */
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  border: var(--border-w) solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  min-height: 44px;                      /* audit #34 — was 40px on mobile */
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }   /* reduced-motion-guarded globally */

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);         /* NOT #fff — white on the dark accent is 1.99:1 */
  border-color: var(--accent);
  /* NO box-shadow glow — the rgba(79,94,247,.35) halo was a light-mode literal that
     stayed indigo in dark mode. Deleted, not fixed (audit #8). */
}
.btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, black);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn--sm {
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
}
@media (max-width: 640px) { .btn--sm { min-height: 44px; } }

/* ===========================
   TYPING DOTS (shared)
   =========================== */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-subtle);
  animation: dot-bounce .9s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ===========================
   SIDE PANEL
   =========================== */
/* audit #2: the panel only ever has content during a quiz. The ≤640px rule below
   already hid it off-quiz; it was never applied above 640px, so a permanently empty
   272px box greeted every desktop visitor. Hoisted to base — one rule, both breakpoints. */
.side-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  border-left: var(--border-w) solid var(--border);
  background: var(--surface);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--dur-base) var(--ease-out), min-width var(--dur-base) var(--ease-out);
  flex-shrink: 0;
}

.quiz-active .side-panel { display: flex; }

.side-panel.collapsed {
  width: 44px;
  min-width: 44px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-w) solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.side-panel.collapsed .panel-title { opacity: 0; }

.panel-toggle {
  flex-shrink: 0;
  font-size: var(--text-sm);
  border: none !important;
  min-height: 32px;
  padding: var(--space-1) var(--space-2) !important;
  transition: transform var(--dur-base) var(--ease-out);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
}

.side-panel.collapsed .panel-body { display: none; }

/* ─── Empty states (§3.10) ─── */
.empty-state { text-align: center; padding: var(--space-10) var(--space-4); }
.empty-state-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin-bottom: var(--space-1);
}
.empty-state-body {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--lh-normal);
}

/* #panel-empty now renders .empty-state's title/body structure (app.js only toggles its
   `hidden`, never its classes). Since Stage 3 the panel is only shown inside a quiz, so
   this empty state is a true statement rather than an indictment. */

/* .topic-grade-block's .tg-name / .tg-grade are DELETED — the letter grade is cut
   (audit #1). #topic-grade-block stays in the DOM; nothing is written to it. */

/* Concept rows */
.concept-item { margin-bottom: var(--space-4); }

.concept-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.concept-name {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}

/* the level, in the same unit as everywhere else — was a raw Elo number + a ±Elo delta */
.concept-meta {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* .concept-delta (±Elo) and .rating-bar-* (the 4px bar) are DELETED — replaced by
   .level-meter--sm, which speaks levels (audit #1, #28). */

.concept-samples {
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  margin-top: 3px;
}

.hedge-panel-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  text-align: center;
}

/* ===========================
   LEVEL METER (§3.1)
   The one data visualisation in the product — and the only place the accent is
   allowed to mean something. 5 segments -> 142x10px (audit #28: was 72x6px).
   Stage 4 wires app.js's gapBar() -> levelMeter() to emit this and deletes
   .gap-bar / .rating-bar-*.
   =========================== */
.level-meter {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.level-meter-seg {
  width: 26px;
  height: 10px;
  border-radius: 2px;
  background: var(--surface-3);
  transition: background var(--dur-slow) var(--ease-out);
}

.level-meter-seg--filled { background: var(--accent); }       /* 5.61:1 on track */

/* between current and target — a 2px ring on a 10px box is legible; the old
   1.5px ring on a 6px box was half the element's height */
.level-meter-seg--target {
  background: var(--surface-3);
  box-shadow: inset 0 0 0 2px var(--accent-mid);              /* 3.35:1 on track */
}

.level-meter--sm .level-meter-seg { width: 16px; height: 8px; }   /* ratings panel */

/* ===========================
   SKELETONS (§3.8)
   The global prefers-reduced-motion block neutralises the shimmer for free.
   Skeletons must reserve the real height of what they replace.
   =========================== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shimmer 1.4s ease infinite;
}
@keyframes skeleton-shimmer {
  from { background-position: 100% 50%; }
  to   { background-position: 0 50%; }
}
.skeleton-card { height: 132px; border-radius: var(--radius-lg); }
.skeleton-row  { height: 64px;  border-radius: var(--radius-lg); }

/* Skeleton containers. --grid-min is inherited from the .topic-grid / .goal-grid these
   sit inside, so the placeholders lay out on the same tracks as the cards they stand in
   for — the grid can't reflow when the real content lands. */
.grid-skeletons {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 180px), 1fr));
  gap: var(--space-3);
}

.dash-skeletons {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ===========================
   PROGRESS PANEL (§3.9)
   For "Build my map" (90s) and "Preparing your first questions…" (60s).
   Reuses .typing-dots verbatim.
   =========================== */
.progress-panel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-2);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
}
.progress-panel-text { min-width: 0; }
.progress-panel-label {
  font-size: var(--text-sm);
  color: var(--text);
  font-weight: var(--fw-medium);
}
.progress-panel-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
/* The elapsed count is the honest part: it is the one signal in the panel that is
   measured rather than asserted. Tabular figures so it doesn't jitter as it ticks. */
.progress-panel-elapsed { font-variant-numeric: tabular-nums; }

/* ===========================
   SCROLLBAR STYLING
   =========================== */
.card-column::-webkit-scrollbar,
.modal-box::-webkit-scrollbar,
.panel-body::-webkit-scrollbar { width: 5px; }
.card-column::-webkit-scrollbar-thumb,
.modal-box::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

/* ===========================
   LEARN MODAL
   =========================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-5);
  animation: fade-in var(--dur-fast) var(--ease-out);
  backdrop-filter: blur(3px);
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Dark elevation rule (§3.3): lift is carried by surface lightness first, shadow
   second. A raised element steps up one surface token. */
.modal-box {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 82dvh;
  overflow-y: auto;
  padding: var(--space-8);
  position: relative;
  animation: modal-slide var(--dur-base) var(--ease-out);
}
@media (prefers-color-scheme: dark) {
  .modal-box { background: var(--surface-2); }
}

@keyframes modal-slide {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 44x44px — was ~22x27px (audit #17b) */
.modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface-2);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  line-height: var(--lh-tight);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }

.modal-loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--space-3) 0;
}

.modal-concept {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: var(--space-4);
  padding-right: var(--space-10);
  letter-spacing: var(--ls-tight);
}

.modal-lesson {
  font-size: var(--text-md);
  line-height: var(--lh-relaxed);
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: var(--space-6);
}

.modal-links-heading {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.modal-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.modal-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
}
.modal-links a:hover { text-decoration: underline; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 640px) {
  .topbar { padding: 0 var(--space-3); }
  .card-column { padding: var(--space-6) var(--space-3) var(--space-8); }
  /* mobile keeps top-aligned views (the pre-existing `justify-content: flex-start`) */
  .goals-screen,
  .start-screen,
  .goal-dash,
  .quiz-area { margin-block: 0; }
  /* audit #16: the fixed ratings pill sits bottom-right and covered "Next question" */
  .quiz-active .card-column {
    padding-bottom: var(--space-16);
    scroll-padding-bottom: var(--space-16);
  }
  .card { padding: var(--space-6) var(--space-5); }
  .card-question { font-size: var(--text-md); }
  .start-heading { font-size: var(--text-lg); }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-sub { font-size: var(--text-sm); }
  .landing-ask { flex-direction: column; }
  [data-landing-variant="v2"] .landing-chips { grid-template-columns: 1fr; max-width: 100%; }
  [data-landing-variant="v2"] .landing-chip { min-height: 56px; }
  .feedback-actions { flex-direction: column; align-items: stretch; }
  .modal-box { padding: var(--space-6) var(--space-5); max-height: 90dvh; }
  .article-form { flex-direction: column; align-items: stretch; }
  .article-topic-input { max-width: none; }

  .quiz-active .topbar-nav,
  .quiz-active .badge { display: none; }
  .quiz-active .topbar-left { min-width: 0; }
  .quiz-active .topbar-right { min-width: 0; flex: 1; justify-content: flex-end; }
  .quiz-active .topic-label { max-width: min(48vw, 180px); }

  /* display:none / .quiz-active override now live at base — see .side-panel above */
  .side-panel {
    position: fixed;
    z-index: 20;
    right: var(--space-3);
    bottom: var(--space-3);
    width: min(340px, calc(100vw - 24px));
    min-width: 0;
    max-height: 62dvh;
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }
  .side-panel.collapsed {
    width: 128px;
    min-width: 128px;
  }
  .side-panel.collapsed .panel-title { opacity: 1; }
  .side-panel.collapsed .panel-header { border-bottom: none; }
  .panel-toggle { min-width: 36px; min-height: 36px; }
}

/* ─────────────────────────────────────────
   ADD YOUR OWN SOURCE MATERIAL (article ingest)
   audit #30: a power/dev feature that occupied the main topic screen. It is now
   automatically demoted — it lives on #topics, which is itself a secondary surface —
   and restyled as a quiet disclosure rather than a section heading. Kept, not deleted:
   it is dogfooded.
───────────────────────────────────────── */
.article-section {
  margin: var(--space-8) auto 0;
  max-width: var(--width-content);
  width: 100%;
  border-top: var(--border-w) solid var(--border);
  padding-top: var(--space-2);
}

.article-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-1);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--text-subtle);
  transition: color var(--dur-fast);
}

.article-toggle:hover { color: var(--accent); }

.article-toggle-chevron { font-size: var(--text-xs); }

.article-panel {
  margin-top: var(--space-2);
  animation: fade-in var(--dur-fast) var(--ease-out);
}

.article-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
  line-height: var(--lh-normal);
}

.article-form {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.article-topic-input { max-width: 180px; }

/* .article-status colour variants are defined with the .notice system above —
   app.js toggles article-status--{pending|ok|error} (guardrail §6.3). */
.article-status { margin-top: var(--space-2); }

.article-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.article-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
}

.article-item-title {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-item-title:hover { text-decoration: underline; }

.article-item-meta {
  font-size: var(--text-2xs);
  color: var(--text-subtle);
}

/* Goals */

/* ─── Topbar nav ─── */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-2);
}

.nav-link {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link--active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ─── Goals home ─── */
.goals-screen {
  width: 100%;
  max-width: var(--width-content);
  animation: fade-up var(--dur-base) var(--ease-out);
}

/* ===========================
   LANDING (goals home) — "aurora console"
   Deliberately OUTSIDE the instrument system: the goals-home view is an
   always-dark, glass-and-glow stage that has to feel like a 2026 AI product and
   earn a click. Everything else in the app keeps the paper/instrument look.
   Scoped by .landing on #goals-screen + a :has() hook that darkens the shell
   only while this view is showing. All hand-typed colour is confined here.
   =========================== */
.landing {
  --ln-ink:        #f4f7ff;
  --ln-ink-soft:   rgba(228, 234, 250, 0.72);
  --ln-ink-faint:  rgba(228, 234, 250, 0.45);
  --ln-glass:      rgba(255, 255, 255, 0.055);
  --ln-glass-2:    rgba(255, 255, 255, 0.09);
  --ln-hair:       rgba(255, 255, 255, 0.12);
  --ln-hair-lit:   rgba(125, 235, 255, 0.55);
  --ln-violet:     #8b5cf6;
  --ln-indigo:     #6366f1;
  --ln-teal:       #5eead4;
  --ln-sky:        #38bdf8;
}

/* The dark stage — painted on the scroll column only while goals-home shows,
   so the quiz/dashboard surfaces are untouched. */
.app-shell:has(#goals-screen:not([hidden])) .card-column {
  background-color: #05060d;
  background-image:
    radial-gradient(58% 46% at 12% 6%,  rgba(99, 102, 241, 0.30), transparent 72%),
    radial-gradient(52% 42% at 88% 10%, rgba(56, 189, 248, 0.22), transparent 72%),
    radial-gradient(46% 52% at 78% 92%, rgba(217, 70, 239, 0.18), transparent 72%),
    radial-gradient(40% 40% at 22% 88%, rgba(45, 212, 191, 0.14), transparent 72%);
  background-attachment: local;
}

.app-shell:has(#goals-screen:not([hidden])) .topbar {
  background: #080a14;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
.app-shell:has(#goals-screen:not([hidden])) .app-logo { color: #f4f7ff; }
.app-shell:has(#goals-screen:not([hidden])) .nav-link { color: rgba(228, 234, 250, 0.66); }
.app-shell:has(#goals-screen:not([hidden])) .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f4f7ff;
}
.app-shell:has(#goals-screen:not([hidden])) .nav-link--active {
  background: rgba(139, 92, 246, 0.22);
  color: #d6ccff;
}

/* ── Hero: a floating glass console ── */
.landing-hero {
  position: relative;
  isolation: isolate;
  text-align: center;
  padding: clamp(2.25rem, 6vw, 4rem) clamp(1.25rem, 5vw, 3.5rem) clamp(2rem, 5vw, 3rem);
  border-radius: 28px;
  border: 1px solid var(--ln-hair);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 40px 120px -46px rgba(56, 189, 248, 0.40),
    0 24px 70px -34px rgba(139, 92, 246, 0.45);
}

/* Glow bloom behind the panel. */
.landing-hero::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from 140deg, var(--ln-indigo), var(--ln-sky), var(--ln-violet), var(--ln-teal), var(--ln-indigo));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
}

/* Two slow drifting light orbs sitting just OUTSIDE the panel so they frame it
   rather than tint the controls. Motion-gated. */
.landing-hero::after {
  content: "";
  position: absolute;
  inset: -12%;
  z-index: -2;
  border-radius: inherit;
  background:
    radial-gradient(30% 32% at 6% 4%, rgba(99, 102, 241, 0.5), transparent 70%),
    radial-gradient(28% 30% at 96% 96%, rgba(45, 212, 191, 0.34), transparent 70%);
  filter: blur(48px);
}

.landing-title {
  margin-bottom: var(--space-3);
  font-family: "Space Grotesk", var(--font);
  font-size: clamp(2rem, 5.4vw, 3.35rem);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.06;
  text-wrap: balance;
  color: var(--ln-ink);
  background: linear-gradient(104deg, #eef2ff 18%, #b7c0ff 40%, #7ff0dd 56%, #eef2ff 78%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ln-sheen 9s linear infinite;
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .landing-title { -webkit-text-fill-color: var(--ln-ink); color: var(--ln-ink); }
}

.landing-sub {
  max-width: 44ch;
  margin: 0 auto var(--space-6);
  font-size: var(--text-md);
  line-height: var(--lh-normal);
  color: var(--ln-ink-soft);
  text-wrap: pretty;
}

.landing-ask {
  display: flex;
  gap: var(--space-2);
  max-width: 540px;
  margin: 0 auto var(--space-5);
}

.landing .landing-ask-input {
  flex: 1;
  min-height: 54px;
  padding: 0 var(--space-4);
  font-size: var(--text-md);
  color: var(--ln-ink);
  background: var(--ln-glass);
  border: 1px solid var(--ln-hair);
  border-radius: 14px;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.landing .landing-ask-input::placeholder { color: var(--ln-ink-faint); }
.landing .landing-ask-input:focus {
  outline: none;
  background: var(--ln-glass-2);
  border-color: var(--ln-hair-lit);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.14), 0 0 30px -4px rgba(94, 234, 212, 0.30);
}

.landing .landing-ask-btn {
  min-height: 54px;
  padding: 0 var(--space-5);
  white-space: nowrap;
  font-weight: 700;
  color: #fff;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ln-indigo), var(--ln-violet));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 10px 30px -8px rgba(99, 102, 241, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              filter var(--dur-fast) var(--ease-out);
}
.landing .landing-ask-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 16px 40px -8px rgba(99, 102, 241, 0.85),
    0 0 40px -6px rgba(56, 189, 248, 0.55);
}
.landing .landing-ask-btn:active:not(:disabled) { transform: translateY(0); }

.landing-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  max-width: 580px;
  margin: 0 auto;
}

.landing-chip {
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--ln-ink-soft);
  cursor: pointer;
  background: rgba(12, 16, 28, 0.55);
  border: 1px solid var(--ln-hair);
  border-radius: var(--radius-full);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.landing-chip:hover:not(:disabled) {
  transform: translateY(-1px);
  color: #ecfeff;
  background: rgba(94, 234, 212, 0.1);
  border-color: var(--ln-hair-lit);
  box-shadow: 0 0 22px -3px rgba(94, 234, 212, 0.4);
}
.landing-chip:active:not(:disabled) { transform: translateY(0); }
.landing-chip:disabled { opacity: 0.45; cursor: default; }

.landing-context {
  max-width: 540px;
  margin: var(--space-5) auto 0;
  text-align: left;
}
.landing-context > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 32px;
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--ln-ink-faint);
  list-style-position: inside;
}
.landing-context > summary:hover { color: var(--ln-ink-soft); }
.landing-context > summary span { font-weight: var(--fw-medium); }
.landing-context[open] > summary { margin-bottom: var(--space-2); }
.landing-context .goal-desc-input {
  width: 100%;
  color: var(--ln-ink);
  background: var(--ln-glass);
  border: 1px solid var(--ln-hair);
  border-radius: 12px;
}
.landing-context .goal-desc-input::placeholder { color: var(--ln-ink-faint); }
.landing-context .goal-desc-input:focus {
  outline: none;
  border-color: var(--ln-hair-lit);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}

/* ── Variant v2 — "pick your move": no visible input, chips become tiles ── */
.landing-typeown {
  display: none;
  margin: var(--space-4) auto 0;
  padding: var(--space-2);
  background: none;
  border: 0;
  color: var(--ln-teal);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}
.landing-typeown:hover { text-decoration: underline; }

[data-landing-variant="v2"] .landing-ask { display: none; }
[data-landing-variant="v2"] .landing-typeown { display: block; }
[data-landing-variant="v2"].landing--askopen .landing-ask { display: flex; }
[data-landing-variant="v2"].landing--askopen .landing-typeown { display: none; }

[data-landing-variant="v2"] .landing-chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  max-width: 480px;
}
[data-landing-variant="v2"] .landing-chip {
  position: relative;
  min-height: 64px;
  padding: var(--space-3) var(--space-6) var(--space-3) var(--space-4);
  border-radius: 16px;
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  color: var(--ln-ink);
  text-align: left;
}
[data-landing-variant="v2"] .landing-chip::after {
  content: "→";
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ln-ink-faint);
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
[data-landing-variant="v2"] .landing-chip:hover:not(:disabled) {
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 28px -6px rgba(139, 92, 246, 0.5);
}
[data-landing-variant="v2"] .landing-chip:hover:not(:disabled)::after {
  transform: translate(3px, -50%);
  color: var(--ln-teal);
}

/* ── Ready-made goals, below the fold, on the same dark stage ── */
.landing-templates { margin-top: clamp(2.5rem, 7vw, 4rem); }

.landing-section-label {
  margin-bottom: var(--space-4);
  text-align: center;
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--ln-ink-faint);
}

.landing .goal-card {
  background: rgba(12, 16, 28, 0.55);
  border: 1px solid var(--ln-hair);
  color: var(--ln-ink-soft);
  box-shadow: none;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.landing .goal-card:hover:not(:disabled) {
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 34px -10px rgba(139, 92, 246, 0.45);
  transform: translateY(-3px);
}
.landing .goal-card .topic-card-label { color: var(--ln-ink); }
.landing .goal-card .topic-card-desc { color: var(--ln-ink-faint); }
.landing .goal-card .topic-card-count { color: var(--ln-ink-faint); }
.landing .goal-card .goal-card-cta { color: var(--ln-teal); }

.landing .my-goals-heading { color: var(--ln-ink-faint); }
.landing .my-goal-row {
  background: rgba(12, 16, 28, 0.55);
  border: 1px solid var(--ln-hair);
  color: var(--ln-ink-soft);
}
.landing .my-goal-row:hover { border-color: var(--ln-hair-lit); background: var(--ln-glass-2); }
.landing .my-goal-title { color: var(--ln-ink); }

.landing .goals-footer { border-top-color: rgba(255, 255, 255, 0.1); }
.landing .secondary-link { color: var(--ln-ink-faint); }
.landing .secondary-link:hover { color: var(--ln-teal); }

@keyframes ln-sheen {
  from { background-position: 220% 0; }
  to   { background-position: -20% 0; }
}
@keyframes ln-orb {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(14px, -18px, 0) scale(1.08); }
}
@media (prefers-reduced-motion: no-preference) {
  .landing-hero::after { animation: ln-orb 16s var(--ease-in-out) infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .landing-title { animation: none; background-position: 0 0; }
}

.goal-grid {
  --grid-min: 280px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr));
  gap: var(--space-3);
  text-align: left;
}

.goal-card { gap: var(--space-2); padding: var(--space-4); }

.goal-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: auto;
  padding-top: var(--space-2);
  width: 100%;
}

.goal-card-cta {
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--accent);
}

/* #goals-status is now only ever a .progress-panel host (audit #3) — the panel brings
   its own box, so this is a bare positioning wrapper. */
.goals-status { margin-top: var(--space-3); }

.goal-create {
  margin-top: var(--space-8);
  border-top: var(--border-w) solid var(--border);
  padding-top: var(--space-5);
}

.goal-create-heading,
.my-goals-heading {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.goal-create-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  margin-bottom: -3px;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
}

.field-label span { font-weight: var(--fw-medium); color: var(--text-subtle); }

.goal-desc-input {
  resize: vertical;
  min-height: 44px;
  font-family: var(--font);
}

.goal-create-btn { align-self: flex-end; }

.goal-create-status { margin-top: var(--space-2); }

.my-goals { margin-top: var(--space-8); }

/* audit #31 — Goals is the product. The topic quiz keeps its element and its id
   (#nav-topics; route() toggles its class wherever it lives) but moves out of the
   topbar to a quiet footer link: reachable, not advertised. */
.goals-footer {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: var(--border-w) solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  text-decoration: none;
}
.secondary-link:hover { color: var(--accent); text-decoration: underline; }

.my-goals-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* §3.3: rows sit on --surface-2 in dark (lift by surface lightness first) */
.my-goal-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
@media (prefers-color-scheme: dark) {
  .my-goal-row { background: var(--surface-2); }
}
.my-goal-row:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), var(--shadow-sm);
  transform: translateY(-1px);
}

.my-goal-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: var(--ls-tight);
}

.my-goal-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.my-goal-pct {
  font-weight: var(--fw-bold);
  color: var(--accent);
}

/* ─── Goal dashboard ─── */
/* the `align-self: flex-start; margin: 0 auto` patch is gone — it existed only to work
   around .card-column's `justify-content: center` (audit #20), which is now removed */
.goal-dash {
  width: 100%;
  max-width: var(--width-content);
  animation: fade-up var(--dur-base) var(--ease-out);
}

.dash-nav { margin-bottom: var(--space-4); }

.dash-back-link {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-decoration: none;
}
.dash-back-link:hover { color: var(--accent); }

.dash-header { margin-bottom: var(--space-5); }

.dash-title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  color: var(--text);
  line-height: var(--lh-tight);
  margin-bottom: var(--space-1);
}

.dash-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

/* audit #1/#28: readiness was a 34px gradient hero shouting a number the estimate can't
   justify. It is now a sentence — "3 of 13 skills at target level" — with the % as a
   trailing note. The old .dash-readiness / -pct / -label / -note rules are deleted. */
.dash-standing {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text);
}

.dash-standing-note {
  font-size: var(--text-xs);
  font-weight: var(--fw-regular);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Next step banner */
.next-banner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--accent-dim);
  border: var(--border-w) solid var(--accent-mid);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}

/* audit #32: `writing-mode: vertical-rl` + rotate(180deg) is DELETED — a sideways
   label is unreadable and was the CTA's only affordance. */
.next-banner-tag {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.next-banner-body { flex: 1; min-width: 0; }

.next-banner-skill {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: var(--ls-tight);
}

.next-banner-reason {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  margin-top: 2px;
}

.next-banner-why {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.next-banner > .btn { flex-shrink: 0; }

/* Status groups & skill rows (§4.3)
   The map is grouped by STATUS, not by area: area is taxonomy, status is the answer to
   "where do I stand and what next". "At target" is a <details>, collapsed — nothing to
   do there — which removes roughly a third of the wall (audit #12). The old
   .dash-area* rules are deleted with the area grouping. */
.dash-group { margin-bottom: var(--space-6); }

.dash-group-name {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.dash-group--collapsible > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.dash-group--collapsible > summary:hover { color: var(--text); }
.dash-group--collapsible[open] > summary { margin-bottom: var(--space-2); }

.dash-group-skills {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skill-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
}
@media (prefers-color-scheme: dark) {
  .skill-row { background: var(--surface-2); }
}

.skill-main { flex: 1; min-width: 0; }

.skill-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: var(--ls-tight);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Stage 4 adds this caption — area demotes from a grouping header to a row label */
.skill-area {
  font-size: var(--text-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 2px;
}

.skill-why {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  line-height: var(--lh-snug);
}

/* One unit. One visualisation. One target reference. (audit #12: was 4 indicators.) */
.skill-levels {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

.skill-gap-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===========================
   PILLS & CHIPS (§3.5)
   The smallest type in the product is --text-2xs (11px), and only for uppercase
   micro-labels. .mini-badge's 9.5px at 4.33:1 is retired (audit #9).
   =========================== */
/* .mini-badge is retired — app.js now emits .pill. .lvl-pill survives only for
   #sr-provisional in index.html; its --current / --target / --none variants went with
   levelPill(), which the .level-meter + "L3 → target L4" label replaced (§4.3). */
.pill,
.lvl-pill,
.concept-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);          /* 13px — was 11px at 4.33:1 */
  font-weight: var(--fw-semibold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: var(--border-w) solid transparent;
  white-space: nowrap;
}

.lvl-pill--provisional,
.pill--provisional {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: var(--amber);
}

.pill--history {
  background: var(--green-dim);
  color: var(--green);
  border-color: var(--green);
}

.concept-chip {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent-mid);
}

/* .gap-bar / .gap-seg* are DELETED — replaced by .level-meter (§3.1), which is
   142x10px instead of 72x6px (audit #28). gapBar() is now levelMeter(). */

/* audit #29 (partial): separated from Practice and given a real 44x44px target */
.skill-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.skill-hide-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: var(--text-xs);
  cursor: pointer;
  border-radius: var(--radius-md);
  line-height: var(--lh-tight);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.skill-hide-btn:hover { background: var(--red-dim); color: var(--red); }
.skill-hide-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Non-assessable strip */
.nonassess-strip {
  margin-top: var(--space-2);
  background: var(--surface-2);
  border: var(--border-w) dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.nonassess-title {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.nonassess-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--space-2) 0;
  border-bottom: var(--border-w) solid var(--border);
}
.nonassess-row:last-child { border-bottom: none; }

.nonassess-name {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
}

/* --text-subtle on --surface-2 is fine; the §2.3 rule only bars it on --surface-3 */
.nonassess-why {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.hidden-skills {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: var(--border-w) dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  background: var(--surface-2);
}

.hidden-skills summary {
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
}

.hidden-skills-list { margin-top: var(--space-2); }

.hidden-skill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: var(--border-w) solid var(--border);
  font-size: var(--text-xs);
}

/* Level legend — Stage 4 adds the <details> to the dashboard (audit #25) */
.level-legend {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.level-legend summary {
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
}
.level-legend-list {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--lh-normal);
}

/* ─── Calibration result card state ─── */
.skill-result-eyebrow {
  font-size: var(--text-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* The single licensed use of --text-3xl: the calibration level readout (audit #28). */
.skill-result-level {
  font-size: var(--text-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  color: var(--accent);
  line-height: var(--lh-tight);
  margin-bottom: var(--space-2);
}

.skill-result-label {
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin-bottom: var(--space-3);
}

.skill-result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.skill-result-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Goals responsive */
@media (max-width: 640px) {
  .topbar-nav { margin-left: 2px; }
  .goal-grid,
  .goal-grid .grid-skeletons { grid-template-columns: 1fr; }
  .skill-row { flex-wrap: wrap; }
  /* the meter drops to its own full-width line, reading left-to-right beside its label */
  .skill-levels {
    width: 100%;
    order: 3;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .next-banner { flex-wrap: wrap; }
  .nav-link { min-height: 44px; display: inline-flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
