/* ============================================================
   Claude Architect Quiz — stylesheet
   Warm dark base, amber-gold accent ("certification stamp"),
   editorial typography, layered surfaces.
   ============================================================ */

@layer reset, tokens, base, layout, components, modes, motion, responsive;

/* ============================================================
   RESET
   ============================================================ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
  body { min-height: 100vh; min-height: 100dvh; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  ol, ul, dl, dd { margin: 0; padding: 0; }
  ol, ul { list-style: none; }
  h1, h2, h3, h4, h5, h6, p { margin: 0; }
  a { color: inherit; }
  img, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; }
  :focus { outline: none; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
  [hidden] { display: none !important; }
}

/* ============================================================
   TOKENS
   ============================================================ */
@layer tokens {
  :root {
    /* core palette — OKLCH, all neutrals tinted warm */
    --ink-0:   oklch(0.18 0.012 60);  /* page */
    --ink-1:   oklch(0.22 0.012 60);  /* raised surface */
    --ink-2:   oklch(0.26 0.012 60);  /* card */
    --ink-3:   oklch(0.30 0.010 60);  /* card hover / sunken */
    --line:    oklch(0.34 0.010 60);  /* border */
    --line-soft: oklch(0.28 0.008 60);

    --text:    oklch(0.96 0.008 75);
    --text-2:  oklch(0.78 0.010 75);
    --text-3:  oklch(0.62 0.012 75);
    --text-4:  oklch(0.48 0.012 75);

    --accent:        oklch(0.82 0.16 78);  /* amber-gold */
    --accent-hi:     oklch(0.88 0.14 80);
    --accent-lo:     oklch(0.70 0.16 75);
    --accent-ink:    oklch(0.22 0.05 70); /* text on accent surfaces */
    --accent-soft:   oklch(0.82 0.16 78 / 0.14);

    --ok:      oklch(0.74 0.13 150);
    --ok-soft: oklch(0.74 0.13 150 / 0.16);
    --warn:    oklch(0.72 0.16 30);
    --warn-soft: oklch(0.72 0.16 30 / 0.16);
    --bad:     oklch(0.68 0.18 28);
    --bad-soft: oklch(0.68 0.18 28 / 0.16);
    --review:  oklch(0.76 0.13 60);

    /* spacing scale (rem) — varied, not uniform */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-7: 3rem;
    --s-8: 4rem;
    --s-9: 6rem;

    /* type */
    --f-sans: "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    /* shape */
    --r-1: 4px;
    --r-2: 8px;
    --r-3: 12px;
    --r-4: 18px;

    /* depth */
    --shadow-1: 0 1px 0 oklch(1 0 0 / 0.04) inset, 0 1px 2px oklch(0 0 0 / 0.4);
    --shadow-2: 0 1px 0 oklch(1 0 0 / 0.06) inset, 0 8px 24px -8px oklch(0 0 0 / 0.55);
    --shadow-3: 0 1px 0 oklch(1 0 0 / 0.08) inset, 0 24px 60px -16px oklch(0 0 0 / 0.65);

    /* motion */
    --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
    --d-1: 130ms;
    --d-2: 200ms;
    --d-3: 320ms;
  }

  /* light theme — used when user toggles or prefers-color-scheme: light + no override */
  :root[data-theme="light"] {
    --ink-0:   oklch(0.985 0.008 75);
    --ink-1:   oklch(0.97 0.010 75);
    --ink-2:   oklch(1 0 0);
    --ink-3:   oklch(0.95 0.010 75);
    --line:    oklch(0.86 0.010 75);
    --line-soft: oklch(0.91 0.008 75);

    --text:    oklch(0.18 0.012 60);
    --text-2:  oklch(0.32 0.012 60);
    --text-3:  oklch(0.46 0.012 60);
    --text-4:  oklch(0.58 0.012 60);

    --accent:        oklch(0.66 0.16 55);
    --accent-hi:     oklch(0.58 0.16 50);
    --accent-lo:     oklch(0.74 0.14 60);
    --accent-ink:    oklch(0.99 0 0);
    --accent-soft:   oklch(0.66 0.16 55 / 0.14);

    --ok:      oklch(0.55 0.14 150);
    --ok-soft: oklch(0.55 0.14 150 / 0.14);
    --warn:    oklch(0.62 0.16 30);
    --warn-soft: oklch(0.62 0.16 30 / 0.14);
    --bad:     oklch(0.55 0.20 28);
    --bad-soft: oklch(0.55 0.20 28 / 0.14);
    --review:  oklch(0.62 0.14 50);

    --shadow-1: 0 1px 2px oklch(0.18 0.012 60 / 0.08);
    --shadow-2: 0 8px 24px -8px oklch(0.18 0.012 60 / 0.15);
    --shadow-3: 0 24px 60px -16px oklch(0.18 0.012 60 / 0.2);
  }
}

/* ============================================================
   BASE
   ============================================================ */
@layer base {
  html { font-family: var(--f-sans); font-feature-settings: "ss01", "cv11"; }
  @supports (font-variation-settings: normal) {
    html { font-family: "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
  }

  body {
    background: var(--ink-0);
    color: var(--text);
    line-height: 1.5;
    font-size: 16px;
    overflow-x: hidden;
    /* subtle warmth — a single radial wash, not a SaaS-cliché gradient */
    background-image:
      radial-gradient(ellipse 80% 50% at 78% -10%, var(--accent-soft), transparent 60%),
      radial-gradient(ellipse 60% 40% at 0% 100%, oklch(0.34 0.04 50 / 0.18), transparent 60%);
    background-attachment: fixed;
  }

  ::selection { background: var(--accent-soft); color: var(--text); }

  .skip {
    position: absolute;
    top: -100px; left: 0;
    background: var(--accent);
    color: var(--accent-ink);
    padding: var(--s-3) var(--s-4);
    border-radius: 0 0 var(--r-2) 0;
    font-weight: 600;
    z-index: 100;
  }
  .skip:focus-visible { top: 0; }

  .kbd {
    display: inline-block;
    font-family: var(--f-mono);
    font-size: 0.72em;
    line-height: 1;
    padding: 0.32em 0.5em;
    background: var(--ink-1);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: var(--r-1);
    color: var(--text-2);
    font-weight: 500;
    min-width: 1.6em;
    text-align: center;
  }

  code, pre {
    font-family: var(--f-mono);
    font-size: 0.92em;
  }
  pre {
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-2);
    padding: var(--s-4);
    overflow-x: auto;
    line-height: 1.55;
  }
  :not(pre) > code {
    background: var(--ink-1);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--line-soft);
    color: var(--accent-hi);
  }
  [data-theme="light"] :not(pre) > code { color: var(--accent); }
}

/* ============================================================
   LAYOUT — top bar, main shell
   ============================================================ */
@layer layout {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-5);
    padding: var(--s-3) var(--s-6);
    background: color-mix(in oklch, var(--ink-0) 88%, transparent);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-bottom: 1px solid var(--line-soft);
  }

  .brand-link {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3) var(--s-2) var(--s-2);
    border-radius: var(--r-2);
    transition: background var(--d-1) var(--ease);
  }
  .brand-link:hover { background: var(--ink-1); }

  .brand-mark {
    display: inline-flex;
    width: 32px; height: 32px;
    align-items: center; justify-content: center;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: var(--r-2);
    box-shadow: var(--shadow-1);
  }

  .brand-name {
    font-weight: 600;
    font-size: 0.94rem;
    letter-spacing: -0.015em;
    color: var(--text);
  }
  .brand-name-sub {
    color: var(--text-3);
    font-weight: 400;
    margin-left: 0.15em;
  }

  .modes {
    display: flex;
    gap: var(--s-1);
    justify-self: center;
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    padding: 4px;
    border-radius: 999px;
  }
  .mode {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    border-radius: 999px;
    color: var(--text-2);
    font-size: 0.88rem;
    font-weight: 500;
    transition: color var(--d-1) var(--ease), background var(--d-1) var(--ease);
  }
  .mode:hover { color: var(--text); }
  .mode[aria-current="true"] {
    background: var(--ink-2);
    color: var(--text);
    box-shadow: var(--shadow-1);
  }
  .mode-key {
    display: inline-flex;
    width: 18px; height: 18px;
    align-items: center; justify-content: center;
    font-family: var(--f-mono);
    font-size: 0.66rem;
    font-weight: 700;
    background: var(--ink-0);
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    color: var(--text-3);
  }
  .mode[aria-current="true"] .mode-key { color: var(--accent); border-color: var(--accent-soft); }

  .topbar-right {
    display: inline-flex;
    gap: var(--s-1);
    align-items: center;
  }

  .iconbtn {
    display: inline-flex;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border-radius: var(--r-2);
    color: var(--text-2);
    transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease);
  }
  .iconbtn:hover { background: var(--ink-1); color: var(--text); }

  .theme-icon-light { display: none; }
  [data-theme="light"] .theme-icon-dark { display: none; }
  [data-theme="light"] .theme-icon-light { display: block; }

  .main {
    padding: var(--s-7) var(--s-6) var(--s-9);
    max-width: 1280px;
    margin: 0 auto;
    min-height: calc(100vh - 64px);
    min-height: calc(100dvh - 64px);
  }
  .main:focus { outline: none; }

  .view { animation: viewIn var(--d-3) var(--ease); }
  @keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ============================================================
   COMPONENTS — buttons, pills, chips, dialog
   ============================================================ */
@layer components {
  .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-2);
    font-weight: 500;
    font-size: 0.92rem;
    line-height: 1;
    transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease), transform var(--d-1) var(--ease), border-color var(--d-1) var(--ease);
    border: 1px solid transparent;
    white-space: nowrap;
  }
  .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
  }
  .btn-primary:hover:not(:disabled) { background: var(--accent-hi); }

  .btn-ghost {
    background: var(--ink-1);
    border-color: var(--line-soft);
    color: var(--text);
  }
  .btn-ghost:hover { background: var(--ink-2); border-color: var(--line); }

  .btn-large { padding: var(--s-4) var(--s-5); font-size: 1rem; }

  .btn-known {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: color-mix(in oklch, var(--ok) 30%, transparent);
  }
  .btn-known:hover { background: color-mix(in oklch, var(--ok) 22%, transparent); }

  .btn-review {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: color-mix(in oklch, var(--warn) 30%, transparent);
  }
  .btn-review:hover { background: color-mix(in oklch, var(--warn) 20%, transparent); }

  .btn-danger {
    background: var(--bad-soft);
    color: var(--bad);
    border-color: color-mix(in oklch, var(--bad) 35%, transparent);
  }
  .btn-danger:hover { background: color-mix(in oklch, var(--bad) 22%, transparent); }

  .btn .kbd { background: transparent; border-color: color-mix(in oklch, currentColor 30%, transparent); color: inherit; opacity: 0.7; }

  .link {
    background: none;
    color: var(--text-3);
    font-size: 0.85rem;
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 3px;
    transition: color var(--d-1) var(--ease);
  }
  .link:hover { color: var(--accent); text-decoration-color: var(--accent); }

  .check {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    cursor: pointer;
    user-select: none;
    color: var(--text-2);
    font-size: 0.9rem;
  }
  .check input {
    appearance: none;
    width: 16px; height: 16px;
    border: 1px solid var(--line);
    background: var(--ink-1);
    border-radius: 4px;
    display: inline-grid; place-items: center;
    cursor: pointer;
    transition: background var(--d-1) var(--ease), border-color var(--d-1) var(--ease);
  }
  .check input:checked { background: var(--accent); border-color: var(--accent); }
  .check input:checked::after {
    content: "";
    width: 10px; height: 6px;
    border-left: 2px solid var(--accent-ink);
    border-bottom: 2px solid var(--accent-ink);
    transform: rotate(-45deg) translate(1px, -1px);
  }
  .check:hover { color: var(--text); }

  /* segmented control */
  .seg {
    display: inline-flex;
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-2);
    padding: 3px;
    gap: 2px;
  }
  .seg-wrap { flex-wrap: wrap; }
  .seg-opt {
    padding: var(--s-2) var(--s-4);
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-2);
    transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease);
  }
  .seg-opt:hover { color: var(--text); }
  .seg-opt[aria-pressed="true"] {
    background: var(--ink-2);
    color: var(--text);
    box-shadow: var(--shadow-1);
  }

  /* help dialog */
  dialog.help {
    border: 1px solid var(--line);
    background: var(--ink-1);
    color: var(--text);
    border-radius: var(--r-3);
    padding: 0;
    max-width: 560px;
    width: calc(100% - 2rem);
    box-shadow: var(--shadow-3);
  }
  dialog.help::backdrop {
    background: oklch(0.1 0 0 / 0.6);
    backdrop-filter: blur(4px);
  }
  .help-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--line-soft);
  }
  .help-head h2 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
  .help-body { padding: var(--s-5); display: grid; gap: var(--s-5); }
  .help-body section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: var(--s-3);
  }
  .help-body dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--s-2) var(--s-5);
    align-items: center;
  }
  .help-body dt { display: flex; gap: var(--s-1); }
  .help-body dd { color: var(--text-2); font-size: 0.92rem; }
}

/* ============================================================
   MODES — view-specific styles
   ============================================================ */
@layer modes {

  /* -------------------- HOME -------------------- */
  .view-home { padding-top: var(--s-5); }
  .home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    grid-template-areas:
      "eyebrow eyebrow"
      "headline meter"
      "lede meter"
      "cta meter"
      "domains tip";
    gap: var(--s-6) var(--s-8);
    align-items: start;
  }

  .home-eyebrow {
    grid-area: eyebrow;
    display: inline-flex; gap: var(--s-3); align-items: center;
    font-size: 0.82rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
  }
  .home-eyebrow .dot {
    width: 7px; height: 7px;
    background: var(--accent);
    border-radius: 999px;
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
  .home-eyebrow-sep { color: var(--text-4); }

  .home-headline {
    grid-area: headline;
    font-size: clamp(2.4rem, 5.6vw, 4.6rem);
    line-height: 0.98;
    letter-spacing: -0.035em;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    color: var(--text);
  }
  .home-headline-name {
    color: var(--accent);
    font-style: italic;
    font-weight: 500;
    letter-spacing: -0.04em;
    font-feature-settings: "ss01";
  }

  .home-lede {
    grid-area: lede;
    color: var(--text-2);
    font-size: 1.06rem;
    max-width: 56ch;
    line-height: 1.55;
  }
  .home-lede strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

  .home-cta {
    grid-area: cta;
    display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center;
  }
  .home-cta-meta {
    color: var(--text-3);
    font-size: 0.85rem;
    margin-left: var(--s-3);
  }

  .home-meter {
    grid-area: meter;
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
    padding: var(--s-5);
    display: grid; gap: var(--s-3);
    box-shadow: var(--shadow-1);
  }
  .home-meter-row {
    display: flex; justify-content: space-between; align-items: baseline;
  }
  .home-meter-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
  }
  .home-meter-value {
    font-family: var(--f-mono);
    font-size: 2.2rem;
    color: var(--accent);
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  .home-meter-track {
    height: 8px;
    background: var(--ink-2);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
  }
  .home-meter-fill {
    height: 100%;
    width: calc(var(--p, 0) * 1%);
    background: linear-gradient(90deg, var(--accent-lo), var(--accent));
    border-radius: 999px;
    transition: width var(--d-3) var(--ease);
  }
  .home-meter-detail {
    color: var(--text-3);
    font-size: 0.86rem;
    gap: var(--s-4);
    flex-wrap: wrap;
  }
  .home-meter-detail strong { color: var(--text); font-variant-numeric: tabular-nums; }

  .home-domains { grid-area: domains; }
  .home-domains-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: var(--s-4);
  }
  .home-domains-head h2 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
  }

  .domain-list {
    display: grid;
    gap: var(--s-2);
    counter-reset: dom;
  }
  .domain-row {
    counter-increment: dom;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-4) var(--s-5);
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-2);
    transition: border-color var(--d-1) var(--ease), background var(--d-1) var(--ease), transform var(--d-1) var(--ease);
    cursor: pointer;
    text-align: left;
    width: 100%;
  }
  .domain-row:hover { border-color: var(--line); background: var(--ink-2); }
  .domain-row .num {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--text-4);
    font-variant-numeric: tabular-nums;
  }
  .domain-row .num::before { content: counter(dom, decimal-leading-zero); }
  .domain-row .body {
    display: grid; gap: 2px;
  }
  .domain-row .name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .domain-row .summary {
    font-size: 0.84rem;
    color: var(--text-3);
    line-height: 1.4;
  }
  .domain-row .pct {
    font-family: var(--f-mono);
    font-size: 0.88rem;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    text-align: right;
    min-width: 5ch;
  }
  .domain-row .pct .pct-track {
    display: block;
    width: 80px;
    height: 4px;
    background: var(--ink-3);
    margin-top: 6px;
    border-radius: 999px;
    overflow: hidden;
  }
  .domain-row .pct .pct-fill {
    height: 100%;
    background: var(--accent);
    width: calc(var(--p, 0) * 1%);
    border-radius: 999px;
    transition: width var(--d-3) var(--ease);
  }

  .home-tip {
    grid-area: tip;
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
    padding: var(--s-5);
  }
  .home-tip h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
    margin-bottom: var(--s-4);
  }
  .home-tip ol {
    display: grid; gap: var(--s-3);
    counter-reset: tip;
  }
  .home-tip li {
    counter-increment: tip;
    position: relative;
    padding-left: var(--s-6);
    color: var(--text-2);
    font-size: 0.94rem;
    line-height: 1.5;
  }
  .home-tip li::before {
    content: counter(tip);
    position: absolute;
    left: 0; top: 0;
    width: 22px; height: 22px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    font-family: var(--f-mono);
    font-size: 0.72rem;
    font-weight: 700;
  }
  .home-tip li strong { color: var(--text); font-weight: 600; }
  .home-tip li em { color: var(--accent); font-style: italic; }
  .home-tip-fine {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px dashed var(--line-soft);
    color: var(--text-4);
    font-size: 0.82rem;
  }

  /* -------------------- CARDS -------------------- */
  .view-cards {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--s-6);
    align-items: start;
  }

  .study-side {
    position: sticky;
    top: calc(64px + var(--s-4));
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
    padding: var(--s-5);
  }
  .study-side-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: var(--s-4);
  }
  .study-side-head h2 {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
  }
  .domain-pills {
    display: grid; gap: var(--s-1);
  }
  .domain-pills li button {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--s-2);
    width: 100%;
    text-align: left;
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-1);
    color: var(--text-2);
    font-size: 0.88rem;
    transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease);
  }
  .domain-pills li button:hover { background: var(--ink-2); color: var(--text); }
  .domain-pills li button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .domain-pills li button .count {
    font-family: var(--f-mono);
    font-size: 0.76rem;
    color: var(--text-4);
    font-variant-numeric: tabular-nums;
  }
  .domain-pills li button[aria-pressed="true"] .count { color: var(--accent); opacity: 0.8; }
  .study-side-foot {
    display: grid; gap: var(--s-2);
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px dashed var(--line-soft);
  }

  .study-stage { display: grid; gap: var(--s-4); }
  .study-stage-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-4);
  }
  .study-pos {
    font-family: var(--f-mono);
    font-size: 0.88rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
  }
  .study-pos-current { color: var(--accent); font-weight: 700; }
  .study-pos-sep { color: var(--text-4); margin: 0 0.3em; }
  .study-tags {
    display: flex; flex-wrap: wrap; gap: var(--s-1);
    justify-self: center;
  }
  .study-tags .chip {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.3em 0.6em;
    border-radius: var(--r-1);
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    color: var(--text-3);
  }
  .study-tags .chip-type {
    color: var(--accent);
    border-color: var(--accent-soft);
  }
  .card-options { margin: 0; padding: 0; list-style: none; }
  .study-controls { display: flex; gap: var(--s-1); }

  .card {
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-4);
    padding: var(--s-6) var(--s-6) var(--s-5);
    min-height: 360px;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: var(--s-4);
    box-shadow: var(--shadow-2);
    position: relative;
    overflow: hidden;
  }
  .card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0.6;
  }
  .card-meta {
    display: flex; justify-content: space-between; align-items: center;
  }
  .card-domain {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 500;
  }
  .card-difficulty {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    padding: 0.3em 0.6em;
    border-radius: var(--r-1);
    background: var(--ink-2);
    border: 1px solid var(--line-soft);
  }
  .card-difficulty[data-d="easy"] { color: var(--ok); }
  .card-difficulty[data-d="medium"] { color: var(--review); }
  .card-difficulty[data-d="hard"] { color: var(--bad); }
  .card-q {
    font-size: clamp(1.1rem, 1.6vw, 1.3rem);
    line-height: 1.55;
    color: var(--text);
    letter-spacing: -0.005em;
    align-self: center;
    max-width: 70ch;
  }
  .card-q strong { color: var(--accent); font-weight: 600; }
  .card-q ul, .card-q ol { padding-left: 1.4em; }
  .card-q li { margin: 0.3em 0; }
  .card-q p + p { margin-top: 0.7em; }
  .card-q pre { margin-top: var(--s-3); }

  .card-a {
    display: grid; gap: var(--s-3);
    padding: var(--s-4) var(--s-5);
    background: var(--ink-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
    border-left: none;
    position: relative;
    animation: revealA var(--d-3) var(--ease);
  }
  .card-a::before {
    content: "";
    position: absolute;
    top: -1px; left: 0;
    width: 56px; height: 2px;
    background: var(--accent);
    border-radius: 0;
  }
  @keyframes revealA {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
  }
  .card-a h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
  }
  .card-a-body, .card-a-explanation {
    color: var(--text);
    font-size: 0.96rem;
    line-height: 1.55;
  }
  .card-a-explanation { color: var(--text-2); }

  .card-foot {
    display: flex; justify-content: flex-end;
  }

  .card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-3);
    animation: revealA var(--d-2) var(--ease) 100ms backwards;
  }
  .card-actions .btn { justify-content: center; padding: var(--s-4); }

  .study-empty {
    text-align: center;
    padding: var(--s-9) var(--s-5);
    background: var(--ink-1);
    border: 1px dashed var(--line);
    border-radius: var(--r-3);
    display: grid; gap: var(--s-3);
    justify-items: center;
  }
  .study-empty h3 { font-size: 1.1rem; }
  .study-empty p { color: var(--text-3); max-width: 40ch; }

  /* -------------------- QUIZ -------------------- */
  .view-quiz { max-width: 760px; margin: 0 auto; }

  .quiz-config {
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-4);
    padding: var(--s-7) var(--s-6);
    display: grid; gap: var(--s-5);
    box-shadow: var(--shadow-1);
  }
  .quiz-config h2 {
    font-size: 1.8rem;
    letter-spacing: -0.02em;
    font-weight: 600;
  }
  .quiz-config-lede { color: var(--text-2); font-size: 0.96rem; }
  .quiz-config-row {
    border: none; padding: 0; margin: 0;
    display: grid; gap: var(--s-3);
  }
  .quiz-config-row legend {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
    padding: 0;
    margin-bottom: var(--s-1);
  }
  .quiz-config-toggles { display: flex; gap: var(--s-5); flex-wrap: wrap; }

  .quiz-run-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--s-5);
    align-items: center;
    margin-bottom: var(--s-5);
  }
  .quiz-progress { display: grid; gap: var(--s-2); }
  .quiz-progress-pos {
    font-family: var(--f-mono);
    font-size: 0.82rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
  }
  .quiz-progress-pos #quiz-pos { color: var(--accent); font-weight: 700; }
  .quiz-progress-track {
    height: 6px;
    background: var(--ink-1);
    border-radius: 999px;
    overflow: hidden;
  }
  .quiz-progress-fill {
    height: 100%;
    background: var(--accent);
    width: calc(var(--p, 0) * 1%);
    transition: width var(--d-2) var(--ease);
  }
  .quiz-score {
    font-family: var(--f-mono);
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
  }
  .quiz-score-correct { color: var(--ok); font-weight: 700; }
  .quiz-score-sep { color: var(--text-4); margin: 0 0.2em; }
  .quiz-timer { display: inline-flex; align-items: center; gap: var(--s-2); position: relative; }
  .quiz-timer #quiz-timer-text {
    position: absolute;
    inset: 0;
    display: grid; place-items: center;
    font-family: var(--f-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    pointer-events: none;
  }

  .quiz-card {
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-4);
    padding: var(--s-6);
    display: grid; gap: var(--s-5);
    box-shadow: var(--shadow-2);
  }
  .quiz-card-domain {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 500;
  }
  .quiz-card-q {
    font-size: 1.16rem;
    line-height: 1.5;
    color: var(--text);
    letter-spacing: -0.005em;
  }
  .quiz-options { display: grid; gap: var(--s-2); }
  .quiz-options li { margin: 0; }
  .quiz-option {
    width: 100%;
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-4);
    background: var(--ink-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-2);
    color: var(--text);
    font-size: 0.96rem;
    transition: background var(--d-1) var(--ease), border-color var(--d-1) var(--ease), transform var(--d-1) var(--ease);
  }
  .quiz-option:hover:not([disabled]) { border-color: var(--text-3); background: var(--ink-3); }
  .quiz-option .letter {
    width: 26px; height: 26px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    font-family: var(--f-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-3);
    background: var(--ink-1);
  }
  .quiz-option[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .quiz-option[aria-pressed="true"] .letter {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
  }
  .quiz-option[data-state="correct"] {
    border-color: var(--ok);
    background: var(--ok-soft);
  }
  .quiz-option[data-state="correct"] .letter { background: var(--ok); color: oklch(0.1 0 0); border-color: var(--ok); }
  .quiz-option[data-state="wrong"] {
    border-color: var(--bad);
    background: var(--bad-soft);
  }
  .quiz-option[data-state="wrong"] .letter { background: var(--bad); color: oklch(0.99 0 0); border-color: var(--bad); }
  .quiz-option[disabled] { cursor: default; }
  .quiz-option .mark {
    font-family: var(--f-mono);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    opacity: 0;
    transition: opacity var(--d-1) var(--ease);
  }
  .quiz-option[data-state="correct"] .mark { opacity: 1; color: var(--ok); }
  .quiz-option[data-state="wrong"] .mark { opacity: 1; color: var(--bad); }

  .quiz-explain {
    padding: var(--s-4) var(--s-5);
    background: var(--ink-2);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--r-2) var(--r-2) 0;
    animation: revealA var(--d-2) var(--ease);
  }
  .quiz-explain h4 {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: var(--s-2);
    letter-spacing: -0.01em;
  }
  .quiz-explain h4[data-verdict="correct"] { color: var(--ok); }
  .quiz-explain h4[data-verdict="wrong"] { color: var(--bad); }
  .quiz-explain p { color: var(--text-2); font-size: 0.94rem; line-height: 1.55; }

  .quiz-card-foot {
    display: flex; gap: var(--s-3); justify-content: flex-end;
  }

  .quiz-result {
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-4);
    padding: var(--s-7) var(--s-6);
    display: grid; gap: var(--s-5);
    box-shadow: var(--shadow-2);
  }
  .quiz-result h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
  .quiz-result-score {
    display: flex; align-items: baseline; gap: var(--s-4);
    padding: var(--s-4) 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .quiz-result-pct {
    font-family: var(--f-mono);
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
  }
  .quiz-result-fraction {
    font-family: var(--f-mono);
    font-size: 1rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
  }
  .quiz-result-verdict {
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--text-2);
  }
  .quiz-result-breakdown {
    display: grid; gap: var(--s-3);
  }
  .quiz-result-breakdown .row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--s-3);
    align-items: center;
    padding: var(--s-3);
    border-radius: var(--r-2);
    background: var(--ink-2);
    border: 1px solid var(--line-soft);
    font-size: 0.92rem;
  }
  .quiz-result-breakdown .row .name { color: var(--text); }
  .quiz-result-breakdown .row .fraction { font-family: var(--f-mono); color: var(--text-3); font-variant-numeric: tabular-nums; }
  .quiz-result-breakdown .row .bar {
    width: 80px; height: 6px;
    background: var(--ink-3); border-radius: 999px; overflow: hidden;
  }
  .quiz-result-breakdown .row .bar > span {
    display: block; height: 100%;
    background: var(--accent);
    width: calc(var(--p, 0) * 1%);
    border-radius: 999px;
  }
  .quiz-result-misses {
    display: grid; gap: var(--s-3);
    counter-reset: miss;
  }
  .quiz-result-misses li {
    counter-increment: miss;
    padding: var(--s-4);
    background: var(--ink-2);
    border: 1px solid var(--line-soft);
    border-left: 2px solid var(--bad);
    border-radius: 0 var(--r-2) var(--r-2) 0;
    display: grid; gap: var(--s-2);
  }
  .quiz-result-misses li::before {
    content: "Q" counter(miss, decimal-leading-zero);
    font-family: var(--f-mono);
    font-size: 0.74rem;
    color: var(--text-4);
    letter-spacing: 0.08em;
  }
  .quiz-result-misses .q { color: var(--text); font-size: 0.96rem; line-height: 1.5; }
  .quiz-result-misses .your { font-size: 0.86rem; color: var(--bad); }
  .quiz-result-misses .correct { font-size: 0.86rem; color: var(--ok); }
  .quiz-result-misses .why { color: var(--text-2); font-size: 0.9rem; line-height: 1.5; }
  .quiz-result-cta { display: flex; gap: var(--s-3); }

  /* -------------------- CRAM -------------------- */
  .view-cram { max-width: 880px; margin: 0 auto; }
  .cram-shell { display: grid; gap: var(--s-4); }
  .cram-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--s-3) var(--s-5);
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
  }
  .cram-status {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-3);
  }
  .cram-controls { display: flex; align-items: center; gap: var(--s-4); }
  .cram-speed {
    display: inline-flex; align-items: center; gap: var(--s-2);
    font-size: 0.84rem;
    color: var(--text-3);
  }
  .cram-speed input[type="range"] {
    accent-color: var(--accent);
    width: 120px;
  }
  .cram-speed-val {
    font-family: var(--f-mono);
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 3ch;
  }
  .cram-stage {
    min-height: 380px;
    display: grid; place-items: center;
  }
  .cram-card {
    width: 100%;
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-4);
    padding: var(--s-7) var(--s-6);
    display: grid; gap: var(--s-4);
    box-shadow: var(--shadow-2);
    position: relative;
    overflow: hidden;
  }
  .cram-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    height: 100%; width: 3px;
    background: var(--accent);
    transform-origin: top;
    animation: cramProgress var(--cram-duration, 7s) linear forwards;
  }
  .cram-card.paused::before { animation-play-state: paused; }
  @keyframes cramProgress {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
  }
  .cram-card-domain {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 500;
  }
  .cram-card-q {
    font-size: 1.5rem;
    line-height: 1.4;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .cram-card-a {
    padding-top: var(--s-3);
    border-top: 1px dashed var(--line-soft);
    color: var(--text-2);
    font-size: 1rem;
    line-height: 1.5;
    animation: revealA var(--d-2) var(--ease);
  }
  .cram-foot { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
  .cram-foot .btn { justify-content: center; padding: var(--s-4); }

  /* -------------------- STATS -------------------- */
  .view-stats { max-width: 880px; margin: 0 auto; }
  .stats-head { margin-bottom: var(--s-5); }
  .stats-head h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
  .stats-lede { color: var(--text-3); font-size: 0.92rem; margin-top: var(--s-1); }
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--s-3);
    margin-bottom: var(--s-6);
  }
  .stats-tile {
    padding: var(--s-5);
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
    display: grid; gap: var(--s-1);
  }
  .stats-tile-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
  }
  .stats-tile-value {
    font-family: var(--f-mono);
    font-size: 2.4rem;
    color: var(--accent);
    line-height: 1;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
  }
  .stats-tile-of {
    font-size: 0.84rem;
    color: var(--text-4);
    font-variant-numeric: tabular-nums;
  }
  .stats-tile-of strong { color: var(--text-2); }

  .stats-section { margin-top: var(--s-6); display: grid; gap: var(--s-3); }
  .stats-section h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    font-weight: 500;
  }
  .stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--ink-1);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-3);
    overflow: hidden;
  }
  .stats-table th, .stats-table td {
    padding: var(--s-3) var(--s-4);
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.9rem;
  }
  .stats-table thead th {
    background: var(--ink-2);
    font-weight: 500;
    color: var(--text-3);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .stats-table tbody tr:last-child td { border-bottom: 0; }
  .stats-table td:not(:first-child) {
    font-family: var(--f-mono);
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
  }
  .stats-section-danger p { color: var(--text-3); font-size: 0.9rem; }
}

/* ============================================================
   MOTION — reduced motion
   ============================================================ */
@layer motion {
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* ============================================================
   FOOTER
   ============================================================ */
.sitefoot {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-6) var(--s-7);
  border-top: 1px solid var(--line-soft);
  color: var(--text-4);
  font-size: 0.84rem;
}
.sitefoot a { color: var(--text-3); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.sitefoot a:hover { color: var(--accent); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@layer responsive {
  @media (max-width: 880px) {
    .topbar { padding: var(--s-3) var(--s-4); grid-template-columns: auto 1fr auto; gap: var(--s-3); }
    .brand-name { display: none; }
    .modes { font-size: 0.84rem; }
    .mode { padding: var(--s-2) var(--s-3); }
    .mode-key { display: none; }
    .main { padding: var(--s-5) var(--s-4) var(--s-9); }

    .home-grid {
      grid-template-columns: 1fr;
      grid-template-areas:
        "eyebrow"
        "headline"
        "lede"
        "cta"
        "meter"
        "domains"
        "tip";
      gap: var(--s-5);
    }
    .view-cards {
      grid-template-columns: 1fr;
    }
    .study-side {
      position: static;
    }
    .card { padding: var(--s-5); min-height: 320px; }
    .quiz-card { padding: var(--s-5); }
    .quiz-result-score { flex-wrap: wrap; }
    .quiz-result-pct { font-size: 3rem; }
    .stats-table { font-size: 0.84rem; }
    .stats-table th, .stats-table td { padding: var(--s-2) var(--s-3); }
  }

  @media (max-width: 520px) {
    .home-headline { font-size: clamp(2rem, 9vw, 2.8rem); }
    .home-cta-meta { display: none; }
    .quiz-card-foot { flex-direction: column-reverse; align-items: stretch; }
    .quiz-card-foot .btn { justify-content: center; }
    .card-actions { grid-template-columns: 1fr; }
  }
}
