/* Mini Adaptive Quiz Coach - "lab notebook" editorial style.
   System fonts only, so the page also works offline at the defense. */

:root {
  --font-display: "Iowan Old Style", "Charter", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --bg: #f6f3ec;
  --bg-grid: rgba(23, 24, 28, 0.035);
  --surface: #fffdf8;
  --surface-2: #f1ede3;
  --ink: #17181c;
  --ink-2: #3d4049;
  --muted: #6b6f7a;
  --line: #e3ddcf;
  --line-strong: #cfc7b5;
  --shadow: 0 1px 0 rgba(23, 24, 28, 0.04), 0 10px 30px -18px rgba(23, 24, 28, 0.35);

  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --bayes: #2457d6;
  --bayes-soft: rgba(36, 87, 214, 0.1);
  --hmm: #7a3fd1;
  --hmm-soft: rgba(122, 63, 209, 0.1);
  --mdp: #0b8a62;
  --mdp-soft: rgba(11, 138, 98, 0.11);

  --beginner: #c97a06;
  --beginner-soft: rgba(201, 122, 6, 0.14);
  --ready: #0f8f86;
  --ready-soft: rgba(15, 143, 134, 0.14);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.12);
  --bad: #c2362b;
  --bad-soft: rgba(194, 54, 43, 0.11);

  --verdict-ink: #ffffff;

  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 160ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111215;
    --bg-grid: rgba(255, 255, 255, 0.03);
    --surface: #191b20;
    --surface-2: #20232a;
    --ink: #ecebe6;
    --ink-2: #c8c7c1;
    --muted: #979aa3;
    --line: #2b2e36;
    --line-strong: #3a3e48;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 14px 34px -20px rgba(0, 0, 0, 0.8);
    --accent: #8b85ff;
    --accent-ink: #0d0d14;
    --bayes: #7aa2ff;
    --bayes-soft: rgba(122, 162, 255, 0.13);
    --hmm: #b48cff;
    --hmm-soft: rgba(180, 140, 255, 0.13);
    --mdp: #4fd1a5;
    --mdp-soft: rgba(79, 209, 165, 0.13);
    --beginner: #f0a63a;
    --beginner-soft: rgba(240, 166, 58, 0.16);
    --ready: #3fd0c4;
    --ready-soft: rgba(63, 208, 196, 0.15);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.13);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.13);
    --verdict-ink: #0b1414;
  }
}

:root[data-theme="dark"] {
  --bg: #111215;
  --bg-grid: rgba(255, 255, 255, 0.03);
  --surface: #191b20;
  --surface-2: #20232a;
  --ink: #ecebe6;
  --ink-2: #c8c7c1;
  --muted: #979aa3;
  --line: #2b2e36;
  --line-strong: #3a3e48;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 14px 34px -20px rgba(0, 0, 0, 0.8);
  --accent: #8b85ff;
  --accent-ink: #0d0d14;
  --bayes: #7aa2ff;
  --bayes-soft: rgba(122, 162, 255, 0.13);
  --hmm: #b48cff;
  --hmm-soft: rgba(180, 140, 255, 0.13);
  --mdp: #4fd1a5;
  --mdp-soft: rgba(79, 209, 165, 0.13);
  --beginner: #f0a63a;
  --beginner-soft: rgba(240, 166, 58, 0.16);
  --ready: #3fd0c4;
  --ready-soft: rgba(63, 208, 196, 0.15);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.13);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.13);
  --verdict-ink: #0b1414;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 16px/1.6 var(--font-body);
  color: var(--ink);
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  white-space: nowrap;
}

.brand-sub {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.engine {
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  white-space: nowrap;
}

.engine::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
  vertical-align: 1px;
  box-shadow: 0 0 0 3px var(--ok-soft);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: transform var(--fast) var(--ease), background var(--fast), border-color var(--fast), box-shadow var(--fast);
}

.btn:hover {
  border-color: var(--ink-2);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 16px -10px var(--accent);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--fast);
}

.icon-btn:hover {
  border-color: var(--ink-2);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.seg button {
  border: 0;
  background: transparent;
  padding: 0 11px;
  min-height: 36px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- Layout ---------- */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 40px) 40px;
}

.step {
  padding: clamp(28px, 5vw, 56px) 0;
  border-bottom: 1px dashed var(--line-strong);
  scroll-margin-top: 80px;
}

.step:last-child {
  border-bottom: 0;
}

.hero {
  max-width: 760px;
  margin-bottom: 26px;
}

.hero h1 {
  font-size: clamp(32px, 5.4vw, 58px);
  margin: 6px 0 14px;
}

.lead {
  font-size: clamp(16px, 1.6vw, 19px);
  color: var(--ink-2);
  margin: 0;
}

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 24px);
  min-width: 0;
}

.card h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

/* ---------- Input card ---------- */
.input-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
}

.answers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.answer {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 74px;
  padding: 10px 6px 9px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  transition: transform var(--fast) var(--ease), background var(--fast), border-color var(--fast);
}

.answer:hover {
  transform: translateY(-2px);
}

.answer .q {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.answer .mark {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
}

.answer .word {
  font-size: 11.5px;
  font-weight: 600;
}

.answer.C {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.answer.W {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.pill {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}

.pill .seq {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  margin-left: 6px;
  letter-spacing: 0.06em;
}

.pill[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.pill[aria-pressed="true"] .seq {
  color: inherit;
  opacity: 0.7;
}

.quiz-btn {
  width: 100%;
  min-height: 44px;
}

.assumptions {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.assumptions summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-2);
}

.sliders {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-top: 14px;
}

.slider label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.slider output {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink);
}

.slider input {
  width: 100%;
  accent-color: var(--accent);
}

/* ---------- Pipeline strip ---------- */
.pipeline {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
  margin-top: 26px;
}

.pipe-node {
  text-align: left;
  border: 1px solid var(--line);
  border-top: 4px solid var(--c);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform var(--fast) var(--ease);
  min-width: 0;
}

.pipe-node:hover {
  transform: translateY(-2px);
}

.pipe-node .n {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--c);
  font-weight: 700;
}

.pipe-node .name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 2px 0 6px;
}

.pipe-node .val {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-2);
}

.pipe-node.bayes { --c: var(--bayes); }
.pipe-node.hmm { --c: var(--hmm); }
.pipe-node.mdp { --c: var(--mdp); }

.pipe-link {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  padding: 0 10px;
  min-width: 96px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

.pipe-link .arrow {
  font-size: 20px;
  line-height: 1;
  color: var(--ink-2);
}

/* ---------- Algorithm sections ---------- */
.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.big-num {
  font-family: var(--font-display);
  font-size: clamp(56px, 8vw, 92px);
  line-height: 0.8;
  color: var(--c);
  font-weight: 600;
}

.section-head h2 {
  font-size: clamp(26px, 3.6vw, 40px);
  margin-top: 6px;
}

.section-head .kicker {
  color: var(--c);
}

#s-bayes { --c: var(--bayes); --c-soft: var(--bayes-soft); }
#s-hmm { --c: var(--hmm); --c-soft: var(--hmm-soft); }
#s-mdp { --c: var(--mdp); --c-soft: var(--mdp-soft); }
#s-result { --c: var(--accent); --c-soft: rgba(79, 70, 229, 0.1); }

.plain {
  font-size: 16.5px;
  color: var(--ink-2);
  max-width: 820px;
  margin: 0 0 22px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 20px;
}

.grid-2.even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

.io {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--c-soft);
  color: var(--c);
}

.io .text {
  font-size: 15px;
  color: var(--ink-2);
}

.link-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--bayes-soft);
  color: var(--ink);
  border-left: 3px solid var(--bayes);
}

.formula {
  display: grid;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.formula .row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.formula .row .lhs {
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.formula .row .rhs {
  text-align: right;
  overflow-wrap: anywhere;
}

.formula .row.result {
  background: var(--c-soft);
  font-weight: 700;
}

.formula .row.result .rhs {
  color: var(--c);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.table tr:last-child td {
  border-bottom: 0;
}

.table .num {
  text-align: right;
}

.obs {
  font-weight: 700;
}

.obs.C { color: var(--ok); }
.obs.W { color: var(--bad); }

.state-chip {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}

.state-chip.Beginner { background: var(--beginner-soft); color: var(--beginner); }
.state-chip.Ready { background: var(--ready-soft); color: var(--ready); }

.output {
  margin-top: 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  align-items: baseline;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--c);
  box-shadow: var(--shadow);
}

.output .k {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c);
}

.output .v {
  font-size: 17px;
  font-weight: 600;
}

.output .v.why {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink-2);
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart text {
  font-family: var(--font-body);
  fill: var(--muted);
  font-size: 12px;
}

.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { font-size: 11px; }
.chart .area { fill: var(--c-soft); }
.chart .line { fill: none; stroke: var(--c); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--surface); stroke-width: 3; }
.chart .pt.C { fill: var(--ok); }
.chart .pt.W { fill: var(--bad); }
.chart .pt.S { fill: var(--ink-2); }
.chart .pt-label { font-family: var(--font-mono); font-size: 12px; font-weight: 700; fill: var(--ink); }
.chart .x-mark.C { fill: var(--ok); font-weight: 700; }
.chart .x-mark.W { fill: var(--bad); font-weight: 700; }

/* Trellis */
.trellis .edge { stroke: var(--line-strong); stroke-width: 1.4; stroke-dasharray: 4 5; fill: none; }
.trellis .edge.back { stroke: var(--ink-2); stroke-width: 1.8; stroke-dasharray: none; opacity: 0.55; }
.trellis .edge.best { stroke: var(--hmm); stroke-width: 4.5; stroke-dasharray: none; opacity: 1; }
.trellis .node rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.trellis .node.Beginner rect { fill: var(--beginner-soft); stroke: var(--beginner); }
.trellis .node.Ready rect { fill: var(--ready-soft); stroke: var(--ready); }
.trellis .node.on-path rect { stroke: var(--hmm); stroke-width: 3.5; }
.trellis .node .state { font-weight: 700; font-size: 13px; fill: var(--ink); }
.trellis .node .delta { font-family: var(--font-mono); font-size: 13px; fill: var(--ink-2); }
.trellis .col-head { font-weight: 700; fill: var(--ink-2); font-size: 12.5px; }
.trellis .col-head.C { fill: var(--ok); }
.trellis .col-head.W { fill: var(--bad); }
.trellis .arrowhead { fill: var(--hmm); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 0;
  vertical-align: middle;
  margin-right: 6px;
  border-top: 3px solid var(--hmm);
}

.legend .back::before {
  border-top: 2px solid var(--ink-2);
  opacity: 0.55;
}

/* Brute force bars */
.bf {
  display: grid;
  gap: 6px;
}

.bf-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.bf-row.best {
  background: var(--hmm-soft);
  font-weight: 700;
}

.bf-path {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.dot.Beginner { background: var(--beginner); }
.dot.Ready { background: var(--ready); }

.bf-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bf-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--hmm);
  opacity: 0.75;
  transform-origin: left;
}

.bf-row .num {
  font-size: 12.5px;
  min-width: 70px;
  text-align: right;
}

.viterbi-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hmm);
  margin-left: 6px;
}

/* MDP */
.mdp-table td.cell {
  font-family: var(--font-mono);
  font-size: 13px;
}

.mdp-table .p { color: var(--ink); }
.mdp-table .r { color: var(--muted); }
.mdp-table .r.pos { color: var(--ok); }
.mdp-table .r.neg { color: var(--bad); }

.qblock {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.qblock.current {
  border-color: var(--c);
  background: var(--c-soft);
  box-shadow: inset 0 0 0 1px var(--c);
}

.qblock + .qblock {
  margin-top: 12px;
}

.qhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.current-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c);
}

.qrow {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 64px;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
  margin: 6px 0;
}

.qrow .act {
  font-weight: 600;
}

.qtrack {
  position: relative;
  height: 14px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.qzero {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 1.5px;
  background: var(--ink-2);
}

.qbar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 3px;
  background: var(--line-strong);
}

.qbar.Review { background: var(--beginner); }
.qbar.Next { background: var(--ready); }

.qrow .num {
  text-align: right;
  font-weight: 700;
}

.qrow.best .act::after {
  content: " ★";
  color: var(--c);
}

.belief .zone-review { fill: var(--beginner-soft); }
.belief .zone-next { fill: var(--ready-soft); }
.belief .zone-label { font-size: 11.5px; font-weight: 700; }
.belief .zone-label.review { fill: var(--beginner); }
.belief .zone-label.next { fill: var(--ready); }
.belief .axis { stroke: var(--ink-2); stroke-width: 1.5; }
.belief .th { stroke: var(--ink); stroke-width: 2; }
.belief .th.lt { stroke-dasharray: 5 4; }
.belief .marker { fill: var(--bayes); stroke: var(--surface); stroke-width: 3; }
.belief .marker-label { fill: var(--bayes); font-weight: 700; font-family: var(--font-mono); }
.belief .th-label { fill: var(--ink); font-family: var(--font-mono); font-size: 11.5px; }

.note {
  font-size: 14px;
  color: var(--ink-2);
  margin: 12px 0 0;
}

/* Result */
.result-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.verdict {
  border-radius: var(--radius-lg);
  padding: clamp(22px, 4vw, 36px);
  color: var(--verdict-ink);
  background: var(--v);
  box-shadow: 0 20px 40px -24px var(--v);
  position: relative;
  overflow: hidden;
}

.verdict.Next { --v: var(--ready); }
.verdict.Review { --v: var(--beginner); }

.verdict .kicker {
  color: inherit;
  opacity: 0.78;
}

.verdict .action {
  font-family: var(--font-display);
  font-size: clamp(34px, 5.5vw, 60px);
  font-weight: 600;
  line-height: 1.05;
  margin-top: 10px;
}

.verdict .sub {
  margin-top: 14px;
  font-size: 15px;
  opacity: 0.92;
}

.facts {
  display: grid;
  gap: 12px;
  align-content: start;
}

.fact {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.fact .k {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fact .v {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  margin-top: 8px;
  overflow: hidden;
}

.meter > div {
  height: 100%;
  background: var(--bayes);
  border-radius: inherit;
}

.agree {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--ok-soft);
  color: var(--ink);
  border-left: 4px solid var(--ok);
}

.agree.warn {
  background: var(--beginner-soft);
  border-left-color: var(--beginner);
}

/* ---------- Footer ---------- */
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px) 40px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Loader / banners / toast ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: var(--bg);
  transition: opacity 300ms var(--ease);
}

.loader.done {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.loader-text {
  font-family: var(--font-display);
  font-size: 20px;
}

.loader-sub {
  font-size: 13px;
  color: var(--muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.banner {
  max-width: 1120px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

.banner.error {
  background: var(--bad-soft);
  color: var(--ink);
  border-left: 4px solid var(--bad);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
}

/* ---------- Quiz modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 10, 14, 0.5);
  backdrop-filter: blur(4px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
  padding: clamp(18px, 3vw, 28px);
  animation: pop 260ms var(--ease);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.modal-head h3 {
  font-size: 22px;
  margin-top: 4px;
}

.quiz-dots {
  display: flex;
  gap: 6px;
  margin: 16px 0;
}

.quiz-dots span {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
}

.quiz-dots span.C { background: var(--ok); }
.quiz-dots span.W { background: var(--bad); }
.quiz-dots span.now { background: var(--accent); }

.quiz-prompt {
  font-family: var(--font-mono);
  font-size: 16px;
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option {
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 15px;
  transition: border-color var(--fast), background var(--fast), transform var(--fast) var(--ease);
}

.option:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.option .letter {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-2);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}

.option.right {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.option.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option:disabled {
  cursor: default;
}

.quiz-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  min-height: 40px;
}

.feedback {
  font-weight: 700;
}

.feedback.C { color: var(--ok); }
.feedback.W { color: var(--bad); }

/* ---------- Presenter mode ---------- */
.presenter-bar {
  position: sticky;
  top: 63px;
  z-index: 19;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.presenter-bar[hidden] {
  display: none;
}

.dots {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.dots button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.dots button[aria-current="step"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

body.presenting .step {
  display: none;
  border-bottom: 0;
  min-height: calc(100vh - 140px);
}

body.presenting .step.active {
  display: block;
  animation: fade 360ms var(--ease);
}

body.presenting .footer {
  display: none;
}

body.presenting {
  font-size: 17px;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-2,
  .grid-2.even,
  .result-card,
  .input-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .sliders {
    grid-template-columns: 1fr;
  }

  .pipeline {
    grid-template-columns: minmax(0, 1fr);
  }

  .pipe-link {
    padding: 6px 0;
    grid-auto-flow: column;
    gap: 8px;
  }

  .pipe-link .arrow {
    transform: rotate(90deg);
  }
}

@media (max-width: 640px) {
  .brand-sub,
  .engine {
    display: none;
  }

  .brand-title {
    font-size: 15px;
  }

  #presentBtn {
    display: none;
  }

  .options {
    grid-template-columns: 1fr;
  }

  .answers {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .answer {
    width: auto;
  }

  .answer .word {
    font-size: 10px;
  }

  .brand-title {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand > div {
    min-width: 0;
  }

  .formula .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .formula .row .rhs {
    text-align: left;
  }

  .presenter-bar {
    flex-wrap: wrap;
  }
}

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