:root {
  /* Defaults; each quiz's JSON theme overrides these at load. */
  --bg: #F4F1EA;
  --ink: #17181C;
  --muted: #5E5F66;
  --accent: #1F4BFF;
  --accent-ink: #FFFFFF;
  --card: #FFFFFF;
  --tint: color-mix(in srgb, var(--accent) 8%, transparent);
  --tint-strong: color-mix(in srgb, var(--accent) 16%, transparent);
  --line: color-mix(in srgb, var(--accent) 45%, transparent);
  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22, .8, .24, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Progress */
.progress { position: fixed; inset: 0 0 auto; height: 4px; background: var(--tint); z-index: 5; }
.progress-bar { height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }

/* Stage */
.stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 20px 96px;
}
.screen { width: 100%; max-width: 720px; }
.screen.enter { animation: enter .55s var(--ease) both; }
.screen.leave { animation: leave .3s ease-in both; }
.screen.enter-back { animation: enterBack .55s var(--ease) both; }
.screen.leave-back { animation: leaveBack .3s ease-in both; }
@keyframes enter { from { opacity: 0; transform: translateY(48px); } }
@keyframes leave { to { opacity: 0; transform: translateY(-48px); } }
@keyframes enterBack { from { opacity: 0; transform: translateY(-48px); } }
@keyframes leaveBack { to { opacity: 0; transform: translateY(48px); } }

/* Start */
.brand { font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 20px; }
.title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.04;
  letter-spacing: -.025em;
  margin: 0 0 22px;
  text-wrap: balance;
}
.subhead { font-size: clamp(18px, 2.2vw, 21px); margin: 0 0 12px; max-width: 34em; }
.note { color: var(--muted); font-size: 16px; margin: 0 0 32px; max-width: 34em; }

.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 19px;
  padding: 13px 26px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform .15s var(--ease), filter .15s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.press { font-size: 13px; color: var(--muted); }
.press b { font-weight: 600; }
@media (hover: none) { .press { display: none; } }

/* Question */
.q-head { display: flex; gap: 12px; align-items: baseline; }
.q-num {
  flex: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transform: translateY(-2px);
}
.q-num svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.q-text {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(24px, 3.4vw, 32px);
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0;
  text-wrap: pretty;
}
.q-hint { color: var(--muted); margin: 8px 0 0; font-size: 17px; }
.q-body { padding-left: 34px; }
.choices { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 10px; max-width: 560px; }
.choice {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px 10px 10px;
  font-size: 18px;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.choice:hover { background: var(--tint-strong); }
.key {
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  margin-top: 1px;
}
.choice-text { flex: 1; padding-top: 1px; }
.check { flex: none; width: 20px; height: 20px; margin-top: 3px; opacity: 0; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--tint-strong); }
.choice[aria-pressed="true"] .key { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.choice[aria-pressed="true"] .check { opacity: 1; }
.choice.blink { animation: blink .32s steps(2, jump-none) 2; }
@keyframes blink { 50% { background: var(--tint); } }
.q-foot { margin-top: 22px; }

/* Gate */
.field { margin: 0 0 22px; max-width: 520px; }
.field label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.field input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  font-size: clamp(22px, 3vw, 28px);
  padding: 6px 0 8px;
  outline: none;
  border-radius: 0;
  transition: border-color .15s;
}
.field input::placeholder { color: color-mix(in srgb, var(--accent) 40%, var(--bg)); }
.field input:focus { border-bottom-color: var(--accent); }
.error { color: #B3261E; font-size: 15px; min-height: 22px; margin: -8px 0 12px; }
.fineprint { color: var(--muted); font-size: 14px; margin-top: 18px; }

/* Result */
.result { max-width: 680px; }
.eyebrow { font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.band {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(40px, 7.5vw, 72px);
  line-height: 1;
  letter-spacing: -.03em;
  margin: 0 0 18px;
}
.scoreline { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.score { font-size: 20px; font-weight: 600; white-space: nowrap; }
.score b { font-family: var(--display); font-size: 30px; color: var(--accent); }
.meter { display: grid; grid-template-columns: repeat(var(--cells), 1fr); gap: 3px; flex: 1; min-width: 180px; max-width: 320px; }
.meter i { height: 10px; border-radius: 2px; background: var(--tint-strong); transform-origin: left; }
.meter i.on { background: var(--accent); animation: fillIn .4s var(--ease) both; }
@keyframes fillIn { from { transform: scaleX(0); } }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
}
.chip span { opacity: .65; font-weight: 500; }
.meaning { font-size: 19px; font-weight: 500; margin: 14px 0 26px; }
.report-link {
  display: flex; align-items: center; gap: 14px;
  margin: -6px 0 28px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 16px; line-height: 1.45;
  transition: border-color .15s, transform .15s var(--ease);
}
.report-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.report-link b { font-weight: 600; }
.report-go { flex: none; color: var(--accent); display: grid; }
.report-go svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.result p.copy { margin: 0 0 16px; }
.system {
  background: var(--card);
  border-radius: 12px;
  padding: 22px 24px;
  margin: 26px 0;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 28px rgba(0,0,0,.05);
}
.system h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.system p { margin: 0; font-size: 20px; line-height: 1.45; font-weight: 500; }
.cta { margin: 30px 0 0; }
.cta-text { font-family: var(--display); font-weight: 700; font-size: clamp(21px, 2.8vw, 26px); line-height: 1.2; margin: 0 0 16px; letter-spacing: -.01em; }
.quiet { font-size: 15px; color: var(--muted); margin: 12px 0 0; }
.reassure { font-size: 15px; color: var(--muted); margin: 14px 0 0; }
.already { display: inline-block; margin-top: 26px; color: var(--ink); font-size: 16px; text-underline-offset: 4px; }
.retake { display: block; margin-top: 40px; font-size: 14px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Bottom nav */
.nav { position: fixed; right: 20px; bottom: 20px; display: flex; gap: 2px; z-index: 5; }
.nav[hidden] { display: none; }
.nav-btn {
  width: 40px; height: 36px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: grid; place-items: center;
}
.nav-btn:first-child { border-radius: 6px 0 0 6px; }
.nav-btn:last-child { border-radius: 0 6px 6px 0; }
.nav-btn[disabled] { opacity: .4; cursor: default; }
.nav-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 600px) {
  body { font-size: 17px; }
  .stage { align-items: flex-start; padding-top: 56px; }
  .q-head { flex-direction: column; gap: 6px; }
  .q-body { padding-left: 0; }
  .choice { font-size: 17px; }
  .system { padding: 18px; }
  .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.privacy-line { font-size: 13px; color: var(--muted); margin: 22px 0 0; max-width: 520px; }
.privacy-line a { color: var(--muted); text-underline-offset: 3px; }
