:root {
  color-scheme: dark;
  --bg: #0a1628;
  --bg-secondary: #0f2047;
  --ink: #e8e4d8;
  --muted: #b9ad98;
  --soft: #8f9aae;
  --line: rgba(212, 168, 85, 0.24);
  --line-strong: rgba(212, 168, 85, 0.44);
  --panel: #132847;
  --panel-2: #0f2047;
  --chart-bg: #0f2047;
  --chart-grid: rgba(232, 228, 216, 0.10);
  --chart-axis: rgba(232, 228, 216, 0.34);
  --accent: #d4a855;
  --accent-hover: #e0bc72;
  --accent-2: #f08030;
  --accent-3: #60a8e0;
  --bad: #f87171;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  font-family: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(212, 168, 85, 0.10), transparent 32%),
    radial-gradient(circle at 88% 8%, rgba(80, 144, 248, 0.14), transparent 24%),
    var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; }

a { color: var(--accent-hover); }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: white;
  padding: .7rem 1rem;
  border-radius: .4rem;
  z-index: 20;
}

.skip-link:focus { top: 1rem; }

.shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 36px;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(15, 32, 71, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand:hover .brand-name { color: var(--accent-hover); }

.brand-logo {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}

.brand-section {
  color: var(--soft);
  font-size: .72rem;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.stepper {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 2px;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reset-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.28);
  color: var(--muted);
  padding: .45rem .75rem;
  font-weight: 800;
  cursor: pointer;
}

.reset-button:hover,
.reset-button:focus-visible {
  color: var(--ink);
  border-color: var(--line-strong);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(232, 228, 216, 0.28);
  flex: 0 0 auto;
}

.dot.active { width: 30px; background: var(--accent); }

.hero, .screen {
  background: rgba(19, 40, 71, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

.hero-grid, .screen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1, h2, h3 { line-height: 1.05; letter-spacing: 0; }
h1 { margin: 0 0 18px; font-size: clamp(2.4rem, 7vw, 5.4rem); max-width: 9ch; }
h2 { margin: 0 0 14px; font-size: clamp(1.8rem, 4vw, 3.15rem); max-width: 13ch; }
h3 { margin: 0 0 8px; font-size: 1rem; }
p { line-height: 1.58; color: var(--muted); }
.lead { font-size: clamp(1.04rem, 2vw, 1.25rem); max-width: 68ch; }

.stat-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 24px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-2);
}

.stat b { display: block; font-size: 1.25rem; }
.stat span { color: var(--muted); font-size: .86rem; }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(10, 22, 40, 0.38);
  overflow: hidden;
}

.choices {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(10, 22, 40, 0.28);
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.choice:hover, .choice:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212, 168, 85, 0.14); }
.choice input { position: absolute; opacity: 0; }
.choice.selected { border-color: var(--accent); background: rgba(212, 168, 85, 0.12); }
.choice-title { font-weight: 800; color: var(--ink); }
.choice-text { color: var(--muted); font-size: .94rem; line-height: 1.45; }
.choice-formula {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(212, 168, 85, 0.22);
  border-radius: 6px;
  background: rgba(10, 22, 40, 0.44);
  color: var(--accent-hover);
  padding: 3px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  white-space: normal;
}

.split-preview {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.28);
  padding: 12px;
  color: var(--muted);
}

.milestones {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.24);
  padding: 12px;
}

.milestones p {
  margin: 0 0 8px;
  color: var(--soft);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.milestones div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.milestones span {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  border: 1px solid rgba(212, 168, 85, 0.20);
  border-radius: 999px;
  background: rgba(15, 32, 71, 0.7);
  color: var(--muted);
  padding: 5px 9px;
  font-size: .78rem;
  line-height: 1.2;
}

.milestones b {
  color: var(--accent-hover);
}

.split-preview.muted {
  color: var(--soft);
  font-size: .92rem;
}

.split-bar {
  display: flex;
  overflow: hidden;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(240, 128, 48, 0.14);
}

.split-segment {
  display: grid;
  place-items: center;
  min-width: 56px;
  color: var(--bg);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.split-segment.train {
  background: rgba(80, 144, 248, 0.84);
}

.split-segment.test {
  flex: 1;
  background: rgba(240, 128, 48, 0.76);
}

.split-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
  font-size: .9rem;
}

.split-summary span {
  display: grid;
  gap: 2px;
}

.split-summary b {
  color: var(--ink);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.split-warning {
  margin: 12px 0 0;
  border-left: 3px solid var(--accent-2);
  border-radius: 0 6px 6px 0;
  background: rgba(240, 128, 48, 0.10);
  padding: 10px 12px;
  color: #f0d5bc;
  font-size: .9rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
}

label.control {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }
select, input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem .8rem;
  background: #0a1628;
  color: var(--ink);
}

.actions {
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(10, 22, 40, 0.38);
  border-top: 1px solid var(--line);
}

.next-action {
  display: grid;
  gap: 8px;
}

.action-hint {
  margin: 0;
  color: var(--accent-hover);
  font-size: .9rem;
  line-height: 1.35;
}

.button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .85rem 1.05rem;
  min-height: 44px;
  font-weight: 800;
  cursor: pointer;
  background: var(--accent);
  color: #0a1628;
  width: 100%;
}

.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .48;
  background: rgba(232, 228, 216, 0.28);
  color: var(--muted);
}

.button:focus-visible, .choice:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(79, 70, 229, .35);
  outline-offset: 2px;
}

.chart-wrap {
  min-height: 0;
  overflow-x: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
}

svg.chart {
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  background: var(--chart-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(10, 22, 40, 0.45);
}

.panel svg.chart {
  min-width: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: .82rem;
}

.chart-title {
  margin: 0 0 10px;
  color: var(--soft);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  width: 22px;
  height: 3px;
  display: inline-block;
  background: currentColor;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(10, 22, 40, 0.28);
}

.metric span { color: var(--muted); font-size: .82rem; display: block; }
.metric b { font-size: clamp(1.05rem, 5vw, 1.35rem); line-height: 1.1; }

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(10, 22, 40, 0.28);
  margin-top: 16px;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

.notes, .sources {
  display: grid;
  gap: 8px;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.5;
}

.callout {
  border-left: 4px solid var(--accent-2);
  background: rgba(240, 128, 48, 0.12);
  padding: 12px 14px;
  border-radius: 6px;
  color: #f0d5bc;
}

.info-box {
  border-left: 4px solid var(--accent);
  background: rgba(212, 168, 85, 0.08);
  padding: 12px 14px;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
}

.info-box.green {
  border-color: #30c880;
  background: rgba(48, 200, 128, 0.08);
}

.info-box.orange {
  border-color: var(--accent-2);
  background: rgba(240, 128, 48, 0.10);
}

.math-box {
  margin: 16px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.48);
  padding: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  line-height: 1.65;
}

.math-box strong {
  color: var(--accent-hover);
}

.math-box .comment {
  color: var(--soft);
}

.sharebox {
  overflow-wrap: anywhere;
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
}

.guidance {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.guidance p {
  margin: 0;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: rgba(212, 168, 85, 0.08);
  padding: 10px 12px;
  color: var(--muted);
}

.hypothesis-section {
  display: grid;
  gap: 14px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.22);
  padding: 14px;
}

.hypothesis-section > h3 {
  color: var(--ink);
  margin: 0;
}

.hypothesis-section > p {
  margin: 0;
}

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

.attribution-grid div {
  border: 1px solid rgba(212, 168, 85, 0.20);
  border-radius: 8px;
  background: rgba(15, 32, 71, 0.72);
  padding: 12px;
}

.attribution-grid span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
}

.attribution-grid b {
  display: block;
  color: var(--accent-hover);
  font-size: 1.28rem;
  line-height: 1.2;
  margin-top: 3px;
}

.projection-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.30);
  padding: 14px;
  margin: 14px 0;
}

.projection-box h3 {
  margin-bottom: 8px;
}

.projection-box p {
  margin: 0 0 12px;
}

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

.projection-grid div {
  border: 1px solid rgba(212, 168, 85, 0.20);
  border-radius: 8px;
  background: rgba(15, 32, 71, 0.72);
  padding: 12px;
}

.projection-grid span,
.projection-grid small {
  display: block;
  color: var(--muted);
  font-size: .82rem;
}

.projection-grid b {
  display: block;
  color: var(--accent-hover);
  font-size: 1.28rem;
  line-height: 1.2;
  margin: 3px 0;
}

.projection-note {
  margin-top: 12px !important;
  color: var(--soft);
  font-size: .88rem;
}

.score-section {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.30);
  padding: 14px;
  scroll-margin-top: 16px;
}

.score-section h3 {
  margin-bottom: 12px;
}

.score-scroll-footer {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
  font-weight: 900;
  cursor: pointer;
}

.score-scroll-footer.hidden {
  display: none;
}

.noscript {
  max-width: 680px;
  margin: 3rem auto;
  background: var(--panel);
  padding: 2rem;
  border-radius: 8px;
}

@media (min-width: 680px) {
  .shell {
    width: min(1180px, calc(100% - 32px));
    padding: 24px 0 48px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .stat-strip, .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .score-scroll-footer {
    left: 50%;
    right: auto;
    width: min(460px, calc(100% - 32px));
    transform: translateX(-50%);
  }

  .actions {
    flex-direction: row;
    padding: 18px clamp(22px, 4vw, 44px);
  }

  .button {
    width: auto;
  }
}

@media (min-width: 900px) {
  .hero-grid, .screen-grid {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 470px);
    gap: 26px;
    padding: clamp(28px, 4vw, 44px);
  }

  .stat-strip {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .chart-wrap {
    min-height: 360px;
    overflow-x: auto;
    padding: 16px;
  }

  svg.chart {
    min-width: 620px;
    min-height: 340px;
  }
}
