:root {
  --ink: #171714;
  --paper: #f2eee3;
  --paper-deep: #ded7c8;
  --vermilion: #ef5b3f;
  --lime: #c8f35b;
  --brass: #caa35d;
  --muted: #777164;
  --line: rgba(23, 23, 20, .18);
  --focus: #fff6b0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Geist, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}
button, input { font: inherit; }
button { letter-spacing: 0; }
a { color: inherit; }
main { width: 100%; max-width: 100%; overflow-x: hidden; }

.nav {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  width: 65%;
  height: 58px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  color: var(--paper);
  border-bottom: 1px solid rgba(242, 238, 227, .2);
}
.wordmark {
  text-transform: uppercase;
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
}
.engine {
  color: rgba(242, 238, 227, .64);
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}
.nav-link {
  justify-self: end;
  font-size: 11px;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.court {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 65%) minmax(410px, 35%);
  background: var(--ink);
}
.world {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background: #171714;
}
#scene, #fallbackCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.webgl-fallback { position: absolute; inset: 0; }
.world::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(23,23,20,.26) 0%, transparent 28%, transparent 65%, rgba(23,23,20,.76) 100%);
}
.court-copy {
  position: absolute;
  z-index: 5;
  top: 100px;
  left: 28px;
  width: min(760px, calc(100% - 56px));
  color: var(--paper);
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}
.court-copy .eyebrow { color: var(--lime); }
h1, h2, h3, p { letter-spacing: 0; }
h1 {
  max-width: 920px;
  margin: 0;
  font-size: 68px;
  line-height: .96;
  font-weight: 780;
}
.lede {
  max-width: 520px;
  margin: 18px 0 0;
  color: rgba(242,238,227,.75);
  font-size: 16px;
}
.scene-telemetry {
  position: absolute;
  z-index: 5;
  left: 28px;
  right: 28px;
  bottom: 22px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: rgba(242,238,227,.66);
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}
.scene-telemetry b { color: var(--paper); font-weight: 760; }

.control-rail {
  position: relative;
  z-index: 10;
  min-height: 100svh;
  padding: 24px 26px 20px;
  background: var(--paper);
  border-left: 1px solid var(--paper-deep);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 11px;
}
.chapter-line {
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.chapter-name, .chapter-progress { display: block; }
.chapter-name { font-size: 17px; font-weight: 820; }
.chapter-progress { margin-top: 2px; color: var(--muted); font-size: 10px; }
.plain-button {
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: none;
  color: var(--ink);
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
}
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend, .range-row > span {
  width: 100%;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}
.prediction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.prediction-button {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
}
.prediction-button:hover, .prediction-button:focus-visible, .prediction-button.active {
  background: var(--ink);
  color: var(--paper);
}
.parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.range-row { display: block; }
.range-row > span { display: flex; justify-content: space-between; }
.range-row output { color: var(--ink); }
.range-row > span > span { display: inline-flex; align-items: center; gap: 4px; }
.number-input {
  width: 42px;
  height: 22px;
  padding: 1px 3px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--vermilion);
  cursor: ew-resize;
}
.segmented > div { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.segmented button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-right: 0;
  background: transparent;
  color: var(--ink);
  font-size: 10px;
  font-weight: 760;
  cursor: pointer;
}
.segmented button:last-child { border-right: 1px solid var(--line); }
.segmented button.active { background: var(--brass); border-color: var(--ink); }
.quorum button { font-size: 9px; }
.metric-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}
.metric-strip > div {
  min-width: 0;
  padding: 7px 8px;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.metric-strip span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.metric-strip strong { display: block; margin-top: 1px; font-size: 18px; font-variant-numeric: tabular-nums; }
.run-row { display: grid; grid-template-columns: 1fr 38px 38px; gap: 6px; }
.run-button, .icon-button, .export-button {
  min-height: 40px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 820;
  cursor: pointer;
}
.run-button:disabled { cursor: not-allowed; opacity: .38; }
.icon-button { background: transparent; color: var(--ink); }
.explanation {
  min-height: 64px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
.explanation-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--vermilion);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}
.explanation p { margin: 0; font-size: 11px; line-height: 1.45; }
.transfer-status { color: var(--muted); font-size: 9px; }

.reasoning {
  min-height: 160vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(0, 58%);
  gap: 8%;
  padding: 160px 7vw;
  background: var(--ink);
  color: var(--paper);
}
.reasoning-title { align-self: start; max-width: 520px; }
.reasoning-title .eyebrow { color: var(--lime); }
.reasoning-title h2 { margin: 0; font-size: 48px; line-height: 1.03; }
.reasoning-cases { display: grid; gap: 180px; padding-bottom: 220px; }
.reasoning-cases article { max-width: 520px; }
.reasoning-cases h3 { margin: 22px 0 12px; font-size: 28px; }
.reasoning-cases p { margin: 0; color: rgba(242,238,227,.67); font-size: 16px; line-height: 1.65; }
.case-symbol { width: 110px; height: 54px; display: block; position: relative; }
.case-symbol::before, .case-symbol::after { content: ""; position: absolute; }
.independent-symbol::before { inset: 20px 0 auto; height: 2px; background: var(--lime); box-shadow: 0 -14px var(--lime), 0 14px var(--lime); }
.independent-symbol::after { right: 0; top: 9px; width: 28px; height: 28px; border: 2px solid var(--lime); border-radius: 50%; }
.linked-symbol::before { inset: 6px auto auto 0; width: 40px; height: 40px; border: 2px solid var(--vermilion); border-radius: 50%; box-shadow: 28px 0 0 -2px var(--ink), 28px 0 0 0 var(--vermilion), 56px 0 0 -2px var(--ink), 56px 0 0 0 var(--vermilion); }
.gate-symbol::before { left: 0; top: 5px; width: 42px; height: 42px; border: 6px solid var(--brass); border-radius: 50%; }
.gate-symbol::after { left: 70px; top: 25px; width: 40px; height: 2px; background: var(--brass); }

.worked {
  min-height: 90vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  background: var(--paper);
}
.worked-formula {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vw;
  background: var(--brass);
}
.worked-formula span { font-size: 13px; font-weight: 800; }
.worked-formula strong { margin: 8px 0; font-size: 92px; line-height: 1; font-variant-numeric: tabular-nums; }
.worked-formula small { color: rgba(23,23,20,.65); }
.worked-copy { align-self: center; max-width: 620px; padding: 8vw; }
.worked-copy h2 { margin: 0 0 20px; font-size: 50px; line-height: 1; }
.worked-copy p:not(.eyebrow) { color: var(--muted); font-size: 17px; line-height: 1.65; }
.export-button { margin-top: 24px; padding: 0 18px; background: var(--vermilion); color: #fff; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding: 34px 7vw;
  background: var(--ink);
  color: rgba(242,238,227,.68);
  font-size: 11px;
}
footer p { max-width: 640px; margin: 0; }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

@media (max-height: 700px) and (min-width: 801px) {
  .control-rail { gap: 7px; padding-top: 16px; padding-bottom: 12px; }
  .court-copy { top: 82px; }
  h1 { font-size: 56px; }
  .lede { margin-top: 12px; }
  .metric-strip strong { font-size: 15px; }
  .explanation { min-height: 52px; }
}

@media (max-width: 800px) {
  .nav {
    position: absolute;
    width: 100%;
    height: 50px;
    grid-template-columns: 1fr auto;
    padding: 0 15px;
  }
  .nav-link { display: none; }
  .engine { text-align: right; font-size: 8px; }
  .court { display: block; min-height: 100svh; }
  .world { min-height: 42svh; height: 42svh; }
  .court-copy { top: 68px; left: 15px; width: calc(100% - 30px); }
  .court-copy .eyebrow { margin-bottom: 7px; font-size: 9px; }
  h1 { max-width: 540px; font-size: 42px; line-height: .98; }
  .lede { display: none; }
  .scene-telemetry { left: 15px; right: 15px; bottom: 10px; font-size: 8px; }
  .scene-telemetry span:nth-child(2) { display: none; }
  .control-rail {
    min-height: 58svh;
    padding: 15px;
    gap: 9px;
    border-left: 0;
  }
  .prediction-button { min-height: 42px; }
  .segmented button { min-height: 38px; }
  .run-button, .icon-button { min-height: 44px; }
  .reasoning { min-height: auto; display: block; padding: 110px 20px; }
  .reasoning-title { position: static !important; }
  .reasoning-title h2 { font-size: 38px; }
  .reasoning-cases { gap: 90px; padding: 100px 0 0; }
  .worked { grid-template-columns: 1fr; }
  .worked-formula { min-height: 48vh; padding: 60px 20px; }
  .worked-formula strong { font-size: 76px; }
  .worked-copy { padding: 80px 20px; }
  .worked-copy h2 { font-size: 40px; }
  footer { display: block; padding: 30px 20px; }
  footer a { display: inline-block; margin-top: 20px; }
}

@media (max-width: 620px) and (max-height: 420px) {
  .world { width: 58%; height: 100svh; min-height: 100svh; }
  .control-rail { position: absolute; top: 0; right: 0; width: 42%; min-height: 100svh; padding: 8px; gap: 4px; overflow: hidden; }
  .nav { width: 58%; height: 34px; padding: 0 8px; }
  .engine { display: none; }
  .court-copy { top: 48px; left: 10px; width: calc(100% - 20px); }
  .court-copy .eyebrow { font-size: 7px; }
  h1 { font-size: 25px; max-width: 300px; }
  .scene-telemetry { left: 10px; right: 10px; font-size: 6px; }
  .chapter-name { font-size: 11px; }
  .chapter-progress, .plain-button, legend, .range-row > span, .transfer-status { font-size: 7px; }
  .prediction-button { min-height: 25px; padding: 3px; font-size: 7px; }
  .parameter-grid { gap: 5px; }
  input[type="range"] { height: 10px; }
  .number-input { width: 30px; height: 15px; padding: 0 2px; font-size: 6px; }
  .segmented button { min-height: 22px; font-size: 7px; }
  .metric-strip > div { padding: 3px; }
  .metric-strip span { font-size: 6px; }
  .metric-strip strong { font-size: 10px; }
  .run-row { grid-template-columns: 1fr 25px 25px; gap: 3px; }
  .run-button, .icon-button { min-height: 26px; font-size: 7px; }
  .explanation { min-height: 36px; grid-template-columns: 16px 1fr; gap: 4px; padding-top: 3px; }
  .explanation-mark { width: 14px; height: 14px; font-size: 7px; }
  .explanation p { font-size: 7px; line-height: 1.2; }
}

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