:root {
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --text: #16181d;
  --muted: #5f6370;
  --border: #e3dfd6;
  --accent: #0f6b52;
  --accent-soft: #e2efe9;
  --l1: #d9480f; --l2: #e8890c; --l3: #c9a400; --l4: #2f9e44; --l5: #1971c2;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111311; --surface: #191c1a; --text: #ecebe6; --muted: #9c9f98;
    --border: #2c302d; --accent: #5cc9a0; --accent-soft: #1d2f28;
    --l1: #ff7a45; --l2: #ffa940; --l3: #fadb14; --l4: #52c41a; --l5: #4dabf7;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111311; --surface: #191c1a; --text: #ecebe6; --muted: #9c9f98;
  --border: #2c302d; --accent: #5cc9a0; --accent-soft: #1d2f28;
  --l1: #ff7a45; --l2: #ffa940; --l3: #fadb14; --l4: #52c41a; --l5: #4dabf7;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.55 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.15; margin: 8px 0 12px; letter-spacing: -.02em; }
h2 { font-size: 22px; line-height: 1.3; margin: 0 0 20px; }
h3 { font-size: 15px; margin: 0 0 14px; font-weight: 600; }
.lead { font-size: 17px; color: var(--muted); max-width: 680px; margin: 0 0 24px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.wordmark { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-sep { width: 1px; height: 18px; background: var(--border); }
.brand-sub { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: 'IBM Plex Mono', monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

main.wrap { padding-top: 40px; padding-bottom: 40px; }
h1 { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; letter-spacing: -.01em; font-size: clamp(34px, 5vw, 48px); }

/* ---------- Landing ---------- */
.intro { padding-top: 24px; }
.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 56px; align-items: center; padding-bottom: 64px; border-bottom: 1px solid var(--border); }
.kicker { font-family: 'IBM Plex Mono', monospace; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); margin: 0 0 18px; }
.display { font-size: clamp(42px, 6.4vw, 70px); line-height: 1.02; margin: 0 0 22px; }
.display em { font-style: italic; color: var(--accent); }
.hero .lead { font-size: 18px; max-width: 540px; margin-bottom: 32px; }
.start { display: flex; gap: 8px; max-width: 540px; }
.start input {
  flex: 1; min-width: 0; font: inherit; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.start input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.start button { padding: 12px 22px; white-space: nowrap; }
.facts { list-style: none; padding: 0; margin: 28px 0 0; display: flex; gap: 32px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.facts b { display: block; font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; font-size: 30px; line-height: 1.1; color: var(--text); }

.sample { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px 12px; box-shadow: var(--shadow); transform: rotate(1.2deg); }
.sample figcaption { display: flex; justify-content: space-between; font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.sample-score { display: flex; align-items: center; gap: 14px; padding: 14px 0 0; }
.sample-score > span:last-child { display: grid; font-size: 13px; }
.sample-num { font-family: 'Instrument Serif', Georgia, serif; font-size: 52px; line-height: 1; color: var(--l3); }
#sampleRadar { width: 100%; height: auto; display: block; }
.r-grid { fill: none; stroke: var(--border); stroke-width: 1; }
.r-base { fill: none; stroke: var(--muted); stroke-dasharray: 3 4; stroke-width: 1; }
.r-data { fill: var(--accent); fill-opacity: .16; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.r-dot { fill: var(--accent); }
.r-label { font: 600 11px 'IBM Plex Mono', monospace; fill: var(--text); }

.block { display: grid; grid-template-columns: 220px 1fr; gap: 32px; padding: 48px 0; border-bottom: 1px solid var(--border); }
.block:last-child { border-bottom: 0; }
.block > .muted { grid-column: 2; margin: 0; }
.block-title { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; font-size: 30px; line-height: 1.1; margin: 0; }
.block-title span { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--accent); margin-bottom: 8px; }
.domain-list { list-style: none; margin: 0; padding: 0; }
.domain-list li { display: grid; grid-template-columns: 40px 260px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); align-items: baseline; }
.domain-list li:first-child { border-top: 0; padding-top: 4px; }
.dl-num { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted); }
.dl-name { font-weight: 600; }
.dl-topics { color: var(--muted); font-size: 14px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; align-items: end; }
.step { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); align-self: stretch; justify-content: flex-start; }
.step-track { height: 72px; display: flex; align-items: flex-end; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.step-bar { width: 100%; border-radius: 3px 3px 0 0; }
.step b { color: var(--text); font-size: 14px; }
.step b .mono { color: var(--muted); font-weight: 500; margin-right: 4px; }
.step > span { min-height: 80px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; box-shadow: var(--shadow);
}

button {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 18px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.ghost:hover { border-color: var(--accent); }
:root[data-theme="dark"] button.primary, :root:not([data-theme="light"]) button.primary { color: #fff; }

.form { max-width: 480px; display: grid; gap: 10px; }
.form label { font-weight: 600; font-size: 14px; }
.form input {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }


.form.wide { max-width: 720px; gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row2 > div { display: grid; gap: 6px; }
.consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 400 !important; font-size: 14px !important; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); cursor: pointer; }
.consent input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.error { color: var(--l1); font-size: 14px; margin: 0; font-weight: 600; }
.form .nav { margin-top: 4px; }
@media (max-width: 760px) { .row2 { grid-template-columns: 1fr; } }

/* Quiz */
.progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 14px; }
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 20px; }
#progressBar { height: 100%; background: var(--accent); width: 0; transition: width .25s ease; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; font-weight: 400;
  padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg);
}
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option .num {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: var(--accent); background: var(--accent-soft);
}
.option.selected .num { background: var(--accent); color: #fff; }
.option .lvl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 12px; }

/* Results */
.results-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.actions { display: flex; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; }
.stat strong { font-size: 32px; line-height: 1.2; letter-spacing: -.02em; }
.stat strong.smaller { font-size: 18px; line-height: 1.3; margin: 6px 0 4px; }

.ladder-card { margin-bottom: 14px; }
.ladder { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding-top: 30px; }
.rung { height: 12px; border-radius: 4px; opacity: .35; }
.rung.on { opacity: 1; }
.rung-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rung-label b { display: block; color: var(--text); font-size: 13px; }
.marker {
  position: absolute; top: 0; transform: translateX(-50%); font-size: 12px; font-weight: 700;
  background: var(--text); color: var(--surface); padding: 2px 8px; border-radius: 6px; white-space: nowrap;
}
.marker::after { content: ""; position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%); border: 4px solid transparent; border-top-color: var(--text); border-bottom: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-box { position: relative; height: 340px; }
.section-title { margin-top: 40px; margin-bottom: 12px; }

.domain-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.dcard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dcard-head h3 { margin: 0; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; color: #fff; white-space: nowrap; }
.meter { height: 8px; background: var(--border); border-radius: 99px; margin: 12px 0; overflow: hidden; }
.meter div { height: 100%; border-radius: 99px; }
.dcard p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.qlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; }
.qlist li { display: flex; justify-content: space-between; gap: 10px; }
.qlist .dots { display: flex; gap: 3px; flex: none; padding-top: 5px; }
.qlist .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }

.recs { padding-left: 22px; display: grid; gap: 10px; }
.recs li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.recs li b { display: block; font-size: 14px; margin-bottom: 2px; }
.recs .tag { font-size: 12px; color: var(--muted); }

.footer { padding-top: 8px; padding-bottom: 32px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-bottom: 48px; }
  .sample { transform: none; max-width: 440px; }
  .block { grid-template-columns: 1fr; gap: 20px; padding: 40px 0; }
  .block > .muted { grid-column: 1; }
  .domain-list li { grid-template-columns: 32px 1fr; }
  .dl-topics { grid-column: 2; }
}
@media (max-width: 760px) {
  .brand-sub { display: none; }
  .brand-sep { display: none; }
  .start { flex-direction: column; }
  .facts { gap: 24px; }
  .scale { grid-template-columns: 1fr; gap: 0; }
  .step { display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
  .step-track { grid-row: span 2; width: 48px; height: 28px; margin: 0; }
  .step-bar { border-radius: 2px 2px 0 0; }
  .step > span { min-height: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .hint { display: none; }
  .rung-label span { display: none; }
  .card { padding: 18px; }
}
@media print {
  .topbar, .no-print, .footer { display: none; }
  body { background: #fff; }
  .card, .recs li { break-inside: avoid; box-shadow: none; }
}
