:root {
  --paper: #F1F4F3;
  --sheet: #FFFFFF;
  --ink: #17222E;
  --muted: #56636F;
  --rule: #CBD3D6;
  --signal: #1F5FA8;
  --signal-soft: #E3ECF7;
  --mark: #E0A800;
  --warn: #9A3B12;
  --font: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Arial Narrow", Arial, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111922; --sheet: #17222D; --ink: #E4EAEE; --muted: #9AA8B4; --rule: #2E3D4A;
    --signal: #7DB0EE; --signal-soft: #1C3149; --mark: #F2C94C; --warn: #F0A07A; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111922; --sheet: #17222D; --ink: #E4EAEE; --muted: #9AA8B4; --rule: #2E3D4A;
  --signal: #7DB0EE; --signal-soft: #1C3149; --mark: #F2C94C; --warn: #F0A07A; color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.5; }
.wrap { max-width: 720px; margin: 0 auto; padding: 28px 20px 64px; }
header.top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.brand { font-family: var(--font-cond); font-weight: 600; font-size: 15px; color: var(--muted); }
.brand strong { color: var(--ink); font-weight: 600; }
.proto { font-size: 13px; color: var(--warn); border: 1px solid currentColor; border-radius: 3px; padding: 1px 8px; }
h1 { font-weight: 700; font-size: 38px; line-height: 1.08; letter-spacing: -0.01em; margin: 8px 0 14px; }
h2 { font-weight: 700; font-size: 26px; line-height: 1.15; margin: 0 0 6px; }
h3 { font-weight: 600; font-size: 19px; margin: 28px 0 8px; }
p { margin: 0 0 12px; }
.lede { font-size: 19px; color: var(--ink); max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
ul.plain { padding-left: 20px; margin: 0 0 14px; }
ul.plain li { margin-bottom: 4px; }

/* progress: a levelling line with one tick per section */
.progress { margin: 6px 0 26px; }
.progress .track { position: relative; height: 18px; }
.progress .line { position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: var(--rule); }
.progress .fill { position: absolute; left: 0; top: 7px; height: 4px; background: var(--signal); transition: width .35s ease; }
.progress .tick { position: absolute; top: 3px; width: 2px; height: 12px; background: var(--rule); }
.progress .tick.done { background: var(--signal); }
.progress .label { display: flex; justify-content: space-between; font-family: var(--font-cond); font-size: 14px; color: var(--muted); margin-top: 4px; }

.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 26px 24px; }
.section-intro { color: var(--muted); margin-bottom: 22px; max-width: 62ch; }
fieldset { border: 0; padding: 0; margin: 0 0 28px; min-width: 0; }
fieldset:last-of-type { margin-bottom: 8px; }
legend { font-weight: 500; font-size: 18px; line-height: 1.35; padding: 0; margin-bottom: 6px; }
legend .qn { font-family: var(--font-cond); color: var(--signal); margin-right: 6px; }
.help { color: var(--muted); font-size: 15px; margin: 0 0 10px; }
.opts { display: grid; gap: 6px; }
/* scored questions read as a ladder: a stile on the left, each option a rung */
.opts.ladder { border-left: 2px solid var(--rule); padding-left: 14px; margin-left: 4px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 4px; cursor: pointer; background: transparent; }
.opt:hover { border-color: var(--signal); }
.opt input { margin: 4px 0 0; accent-color: var(--signal); width: 17px; height: 17px; flex: none; }
.opt.checked { border-color: var(--signal); background: var(--signal-soft); }
.opt.dk { border-style: dashed; }
.opt span { flex: 1; }
legend strong, .opt strong { font-weight: 700; }
legend .qn { font-weight: 700; }
.followup { border-left: 3px solid var(--signal); padding-left: 12px; }
.variant-note { font-size: 13px; color: var(--muted); margin: -2px 0 8px; }
.err { color: var(--warn); font-size: 15px; margin: 10px 0 0; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 500; font-size: 15px; }
.field input[type=text], .field input[type=email] { font: inherit; padding: 9px 10px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); width: 100%; }
.nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
button { font: inherit; cursor: pointer; border-radius: 4px; }
.btn { background: var(--signal); color: var(--sheet); border: 1px solid var(--signal); padding: 10px 18px; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); font-weight: 500; }
.btn:disabled { opacity: .4; cursor: default; }
.linkish { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 4px 0; font-size: 14px; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px; font-weight: 500; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.toast.show { opacity: 1; }

/* result */
.score-head { display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: end; margin: 6px 0 18px; }
.eiq-num { font-weight: 700; font-size: 84px; line-height: .9; letter-spacing: -0.03em; }
.eiq-num small { font-size: 22px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.tier-name { font-family: var(--font-cond); font-weight: 600; font-size: 24px; }
.chart-wrap { overflow-x: auto; margin: 6px 0 4px; }
.chart-wrap svg { display: block; width: 100%; min-width: 440px; height: auto; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0; }
.meta { border-top: 2px solid var(--ink); padding-top: 8px; }
.meta .k { font-family: var(--font-cond); color: var(--muted); font-size: 15px; }
.meta .v { font-weight: 700; font-size: 26px; }
.meta .d { font-size: 14px; color: var(--muted); }
.ref { border-left: 3px solid var(--mark); padding: 6px 0 6px 12px; margin: 10px 0; }
.ref .yours { font-size: 14px; color: var(--muted); margin-top: 2px; }
.ref .src { font-size: 13px; color: var(--muted); }
.note { font-size: 14px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 16px; }
.offer { border: 2px solid var(--signal); border-radius: 6px; padding: 18px; margin-top: 26px; }
.offer h3 { margin-top: 0; }
.restart-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border: 2px solid var(--warn); border-radius: 6px; padding: 12px 14px; margin-bottom: 18px; background: var(--sheet); font-weight: 500; }
.restart-bar .rb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.samples { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0 6px; }
.samples figure { margin: 0; }
.samples img { display: block; width: 100%; max-width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 4px; }
.samples figcaption { font-family: var(--font-cond); font-size: 15px; color: var(--muted); margin-top: 6px; }
@media (max-width: 560px) { .samples { grid-template-columns: 1fr; } }
.proto-box { border: 1px dashed var(--warn); border-radius: 6px; padding: 12px 14px; margin-top: 24px; }
.proto-banner { color: var(--warn); font-size: 14px; border: 1px dashed var(--warn); border-radius: 4px; padding: 6px 10px; }
.facts { font-family: var(--font-cond); font-size: 16px; color: var(--muted); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 8px 0; margin: 18px 0 4px; }
.howto { background: var(--signal-soft); border-radius: 6px; padding: 12px 16px 4px; margin: 0 0 22px; }
.howto p { margin-bottom: 6px; }
footer { margin-top: 26px; font-size: 13px; color: var(--muted); }
.theme-toggle { font-size: 13px; }
@media (max-width: 520px) {
  h1 { font-size: 30px; }
  .sheet { padding: 20px 16px; }
  .eiq-num { font-size: 64px; }
  .score-head { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
