:root {
  --bg: #101310;
  --ink: #ebe6db;
  --muted: #b8b1a4;
  --copper: #d7b48a;
  --line: #2e3832;
  --card: #171c19;
  --alert: #f3d2cb;
  --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(215, 180, 138, 0.1), transparent 58%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.28));
}

::selection {
  background: var(--copper);
  color: #161a17;
}

:focus-visible {
  outline: 2px solid #e7c89a;
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -4rem;
  z-index: 5;
  background: var(--ink);
  color: #161a17;
  padding: 10px 14px;
  text-decoration: none;
}

.skip:focus { top: 12px; }

.shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
}

.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 28px;
  flex-wrap: wrap;
  padding: 26px 0 10px;
  position: relative;
}

.lab {
  margin: 0 0 4px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--copper);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

.protocol {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.rail {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
}

.rail li {
  height: 3px;
  background: #3e4943;
}

.rail li.done { background: #8d7352; }
.rail li.now { background: var(--copper); }

#stage {
  padding: 28px 0 56px;
  position: relative;
}

#stage:focus { outline: none; }

.colophon {
  padding: 0 0 calc(28px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.85rem;
}

.colophon p { margin: 0; }

.sheet { max-width: 52rem; }

.layout {
  display: block;
}

.sidenum {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 2.4rem;
  line-height: 0.9;
  color: var(--copper);
}

.question, .result, .calc, .intro {
  max-width: 40rem;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--copper);
}

.display {
  margin: 8px 0 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.display:focus { outline: none; }

.lede {
  margin: 0 0 8px;
  font-size: 1.12rem;
  max-width: 38rem;
}

.note {
  margin: 0 0 18px;
  color: var(--muted);
}

.facts {
  margin: 16px 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.facts li { margin: 4px 0; }

.dial { margin-top: 20px; }

.dial-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.dial-top label { font-size: 0.98rem; }

.dial-index {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--copper);
  white-space: nowrap;
}

.dial input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2.4rem;
  margin: 2px 0 0;
  background: transparent;
  cursor: pointer;
}

.dial input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--copper) var(--fill, 50%), #343c37 var(--fill, 50%));
}

.dial input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--copper);
  box-shadow: 0 0 0 5px rgba(16, 19, 16, 0.55);
}

.dial input[type="range"]::-moz-range-track {
  height: 2px;
  border: 0;
  background: #343c37;
}

.dial input[type="range"]::-moz-range-progress {
  height: 2px;
  background: var(--copper);
}

.dial input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 2px solid var(--copper);
  border-radius: 50%;
  background: var(--ink);
}

.ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 9px;
  margin-top: -8px;
}

.ticks span {
  width: 1px;
  height: 7px;
  background: #465048;
}

.dial-ends {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.dial-ends span:last-child { text-align: right; }

.dial-read {
  margin: 10px 0 0;
  min-height: 1.5em;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.3;
}

.plane-wrap { margin-top: 22px; }

.axis-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
}

.axis-label.above { margin-bottom: 6px; }
.axis-label.below { margin-top: 6px; }

.axis-x {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.plane {
  position: relative;
  height: 240px;
  border: 1px solid var(--line);
  background:
    linear-gradient(#24302a 1px, transparent 1px) 0 0 / 25% 25%,
    linear-gradient(90deg, #24302a 1px, transparent 1px) 0 0 / 25% 25%,
    radial-gradient(circle at center, rgba(215, 180, 138, 0.05), transparent 68%),
    #141916;
  touch-action: none;
  cursor: crosshair;
}

.plane .hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  pointer-events: none;
  text-align: center;
  padding: 16px;
}

.plane .dot {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--copper);
  box-shadow: 0 0 0 6px rgba(215, 180, 138, 0.16);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.plane-read {
  margin: 8px 0 0;
  color: var(--muted);
  min-height: 1.5em;
}

fieldset.choices {
  margin: 22px 0 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 1rem;
}

.count {
  color: var(--muted);
  margin-left: 8px;
  font-size: 0.85rem;
}

.choice {
  display: block;
  position: relative;
}

.choice + .choice { margin-top: 10px; }

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.choice input:focus-visible { outline: none; }

.choice-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  min-height: 48px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--card);
}

.choice-kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--copper);
  padding-top: 2px;
}

.choice input:checked + .choice-body {
  border-color: var(--copper);
  background: #232b26;
}

.choice input:focus-visible + .choice-body {
  outline: 2px solid #e7c89a;
  outline-offset: 3px;
}

.alert {
  margin: 16px 0 0;
  padding-left: 12px;
  border-left: 2px solid #e7a598;
  color: var(--alert);
}

@keyframes shake {
  20% { transform: translateX(-2px); }
  40% { transform: translateX(2px); }
  60% { transform: translateX(-1px); }
  80% { transform: translateX(1px); }
}

.shake { animation: shake 0.32s ease; }

button {
  font: inherit;
  cursor: pointer;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 26px;
}

.nav:not(:has(.ghost)) .primary {
  margin-left: 0;
}

.primary {
  margin-left: auto;
  background: var(--ink);
  color: #161a17;
  border: 1px solid var(--ink);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.primary:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid #3c463f;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.calc-head { max-width: 40rem; }

.scanner {
  width: 148px;
  height: 148px;
  margin: 8px 0 22px;
  position: relative;
  display: grid;
  place-items: center;
}

.scanner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid #334038;
}

.scanner-ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: conic-gradient(from 20deg, transparent 0 68%, var(--copper) 84%, transparent 96%);
  -webkit-mask: radial-gradient(circle, transparent 63%, #000 64%);
  mask: radial-gradient(circle, transparent 63%, #000 64%);
  animation: spin 1.35s linear infinite;
}

.scanner.is-stalling .scanner-ring { animation-duration: 2.8s; }

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

.scanner-pct {
  position: relative;
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  letter-spacing: 0.03em;
}

.pct-sign {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 1px;
}

.factors {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 36rem;
}

.factor { padding: 9px 0; }

.factor-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
}

.factor-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.82rem;
}

.bar {
  display: block;
  height: 2px;
  margin-top: 7px;
  background: #2a312c;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--copper);
}

.log {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  max-width: 40rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  color: #d9d0c2;
}

.log li {
  padding: 7px 0;
  border-top: 1px solid #24302a;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.seal {
  width: 4.6rem;
  height: 4.6rem;
  margin: 0;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--copper);
  border-radius: 50%;
  color: var(--copper);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.68rem;
  transform: rotate(-8deg);
}

.verdict {
  margin: 12px 0 8px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(4.4rem, 16vw, 7.4rem);
  line-height: 0.84;
  letter-spacing: -0.045em;
}

.verdict:focus { outline: none; }

.verdict .soft {
  font-style: italic;
  font-weight: 450;
}

.metrics {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0 8px;
}

.dossier-wrap { max-width: 40rem; }

.dossier {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.95rem;
}

.dossier caption {
  caption-side: bottom;
  text-align: left;
  color: var(--muted);
  padding-top: 12px;
  font-size: 0.88rem;
}

.dossier th,
.dossier td {
  vertical-align: top;
  text-align: left;
  font-weight: 500;
  padding: 12px 10px 12px 0;
  border-bottom: 1px solid var(--line);
}

.dossier thead th {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.dossier th:nth-child(1),
.dossier td:nth-child(1) { width: 27%; }

.dossier th:nth-child(3),
.dossier td:nth-child(3) { width: 5rem; }

.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.fallback {
  display: block;
  width: min(100%, 40rem);
  margin-top: 12px;
  padding: 12px;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--copper);
}

.copy-note {
  min-height: 1.4em;
  margin: 10px 0 0;
}

@media (min-width: 860px) {
  .layout {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    column-gap: 2.5rem;
    align-items: start;
  }

  .sidenum {
    position: sticky;
    top: 1.25rem;
    margin: 0;
    font-size: 4rem;
  }

  .scanner { margin-left: 0; }
}

@media (max-width: 640px) {
  .shell { width: min(980px, calc(100% - 28px)); }

  .dial-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .protocol { text-align: left; }

  .plane { height: 210px; }

  .nav {
    flex-direction: column;
    align-items: stretch;
  }

  .primary { margin-left: 0; }

  .verdict { font-size: clamp(3.6rem, 20vw, 5.2rem); }

  .dossier th:nth-child(1),
  .dossier td:nth-child(1) { width: 30%; }
}

@media (hover: hover) {
  .primary:hover { background: #fff; }
  .ghost:hover { border-color: var(--copper); }
  .choice:hover .choice-body { border-color: #5c675f; }
}

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

@media print {
  body { background: #fff; color: #161a17; }
  body::before { display: none; }
  .rail, .nav, .skip, .scanner { display: none !important; }
  .verdict, h1, .display { color: #161a17; }
}
