:root {
  color-scheme: dark;
  --ink: #0a0a0a;
  --panel: #111311;
  --panel-2: #171918;
  --line: #363a37;
  --paper: #f5f4ed;
  --muted: #a6aaa6;
  --yellow: #f4e64c;
  --cyan: #64d8e6;
  --coral: #ff756b;
  --green: #78db8f;
  --focus: #ffffff;
  font-family: "Geist", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--ink);
  color: var(--paper);
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
select,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

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

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--paper);
  color: var(--ink);
}

.skip-link:focus {
  top: 16px;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 10, 10, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.brand,
.nav-actions a {
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.brand-mark {
  width: 15px;
  height: 15px;
  background: conic-gradient(from 45deg, var(--yellow), var(--cyan), var(--coral), var(--yellow));
  transform: rotate(45deg);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

.nav-actions a:hover {
  color: var(--paper);
}

.library-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--yellow);
}

.page-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.arena-shell {
  position: relative;
  min-height: 100svh;
  padding-top: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(330px, 0.86fr);
  grid-template-rows: minmax(560px, calc(100svh - 164px)) 106px;
  background: var(--ink);
}

.scene-panel {
  position: relative;
  min-width: 0;
  min-height: 560px;
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.scene-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 52% 42%, transparent 30%, rgba(0, 0, 0, 0.68) 100%);
}

.scene-host,
.scene-host canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-host canvas {
  display: block;
  touch-action: pan-y;
}

.scene-fallback {
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 180px 32px 32px;
  background: linear-gradient(150deg, #141614, #080808);
  color: var(--muted);
}

.scene-fallback strong {
  display: block;
  max-width: 540px;
  margin-bottom: 8px;
  color: var(--paper);
  font-size: 28px;
}

.arena-heading {
  position: absolute;
  z-index: 5;
  top: clamp(32px, 7vh, 74px);
  left: clamp(20px, 4vw, 64px);
  right: clamp(20px, 5vw, 80px);
  pointer-events: none;
}

.source-line,
.control-kicker {
  margin: 0 0 12px;
  color: var(--yellow);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
}

.arena-heading h1 {
  max-width: 72rem;
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 5rem);
  line-height: 0.95;
  font-weight: 780;
}

.arena-heading > p:last-child {
  max-width: 610px;
  margin: 14px 0 0;
  color: #d1d4d0;
  font-size: clamp(14px, 1.4vw, 19px);
  line-height: 1.45;
}

.gate-legend {
  position: absolute;
  z-index: 5;
  left: clamp(20px, 4vw, 64px);
  right: clamp(20px, 4vw, 64px);
  bottom: 32px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.gate-legend span {
  position: relative;
  padding-top: 10px;
}

.gate-legend span::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  width: 5px;
  height: 5px;
  background: var(--paper);
}

.scene-shortcuts {
  position: absolute;
  z-index: 5;
  right: 20px;
  top: 18px;
  color: rgba(255, 255, 255, 0.42);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.control-rail {
  position: relative;
  z-index: 8;
  min-width: 0;
  min-height: 560px;
  padding: clamp(20px, 3vw, 38px);
  overflow-y: auto;
  background: var(--panel);
}

.control-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.control-heading h2 {
  margin: 0;
  max-width: 290px;
  font-size: 24px;
  line-height: 1.08;
}

.progress-number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.field-label,
.prediction-field legend,
.range-row label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

select {
  width: 100%;
  height: 48px;
  margin-bottom: 20px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--paper);
}

.prediction-field {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

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

.prediction-button {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: transform 280ms ease, border-color 280ms ease, color 280ms ease, background 280ms ease;
}

.prediction-button:hover {
  transform: translateY(-2px);
  border-color: var(--paper);
  color: var(--paper);
}

.prediction-button.selected {
  border-color: var(--yellow);
  background: rgba(244, 230, 76, 0.1);
  color: var(--paper);
}

kbd {
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.range-row {
  display: flex;
  justify-content: space-between;
}

.range-row output,
.transfer-range output {
  color: var(--yellow);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--yellow);
  cursor: pointer;
}

.transport {
  display: grid;
  grid-template-columns: 1fr 48px 48px;
  gap: 8px;
  margin-top: 20px;
}

.primary-button,
.update-button,
.export-button {
  min-height: 48px;
  border: 1px solid var(--paper);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 740;
  cursor: pointer;
  transition: transform 280ms ease, background 280ms ease, color 280ms ease;
}

.primary-button:hover,
.update-button:hover:not(:disabled),
.export-button:hover {
  transform: translateY(-2px);
  background: var(--yellow);
}

.icon-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  transition: transform 280ms ease, border-color 280ms ease, background 280ms ease;
}

.transport .icon-button {
  width: 48px;
  height: 48px;
}

.icon-button:hover {
  transform: translateY(-2px);
  border-color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
}

.update-button {
  width: 100%;
  margin-top: 8px;
  background: var(--yellow);
  border-color: var(--yellow);
}

.update-button:disabled {
  background: transparent;
  border-color: var(--line);
  color: #676a67;
  cursor: not-allowed;
}

.status-box,
.fit-result {
  min-height: 78px;
  margin-top: 14px;
  padding: 13px 14px;
  border-left: 3px solid var(--cyan);
  background: #0c0e0d;
  color: #d7dad6;
  font-size: 13px;
  line-height: 1.45;
}

.status-box.warning,
.fit-result.warning {
  border-color: var(--coral);
}

.status-box.success,
.fit-result.success {
  border-color: var(--green);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  background: var(--line);
  border: 1px solid var(--line);
}

.metric-strip > div {
  min-width: 0;
  padding: 10px;
  background: var(--panel-2);
}

.metric-strip span,
.metric-strip strong {
  display: block;
}

.metric-strip span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.metric-strip strong {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  text-overflow: ellipsis;
}

.telemetry-panel {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  background: #0c0d0c;
  overflow: hidden;
}

.telemetry-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  text-transform: uppercase;
}

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

.trajectory-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.trajectory-dot {
  width: 8px;
  height: 32px;
  background: var(--lane-color);
}

.trajectory-name {
  display: block;
  overflow: hidden;
  color: var(--paper);
  font-size: 11px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trajectory-steps {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trajectory-score {
  min-width: 58px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.trajectory-score strong,
.trajectory-score span {
  display: block;
}

.trajectory-score span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.method-section,
.trap-section,
.transfer-section,
.evidence-section {
  position: relative;
  padding: 160px clamp(22px, 6vw, 92px);
}

.method-section {
  background: var(--paper);
  color: var(--ink);
}

.method-section .source-line,
.trap-section .source-line,
.transfer-section .source-line,
.evidence-section .source-line {
  color: #5f625e;
}

.method-intro {
  max-width: 980px;
  margin-bottom: 100px;
}

.method-intro h2,
.trap-copy h2,
.transfer-copy h2,
.evidence-section h2 {
  max-width: 1100px;
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 6.7rem);
  line-height: 0.96;
  font-weight: 770;
}

.scrub-copy {
  max-width: 980px;
  margin: 48px 0 0;
  font-size: clamp(1.2rem, 2.2vw, 2rem);
  line-height: 1.45;
}

.scrub-copy span {
  opacity: 0.14;
}

.method-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(0, 1.45fr);
  gap: clamp(42px, 8vw, 140px);
  align-items: start;
}

.equation-pin {
  position: sticky;
  top: 98px;
  padding-top: 20px;
  border-top: 2px solid var(--ink);
}

.equation-pin p {
  margin: 20px 0 7px;
  color: #61645f;
  font-size: 12px;
}

.equation-pin code {
  display: block;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(18px, 2vw, 28px);
}

.method-stack {
  min-height: 1250px;
}

.method-card {
  position: sticky;
  top: 100px;
  min-height: 310px;
  margin-bottom: 190px;
  padding: clamp(26px, 4vw, 56px);
  border: 1px solid #a6aaa2;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 16px 0 rgba(10, 10, 10, 0.08);
}

.method-card:nth-child(2) {
  top: 118px;
  background: #e8f5f5;
}

.method-card:nth-child(3) {
  top: 136px;
  background: #fff59d;
}

.method-card span {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.method-card h3 {
  max-width: 650px;
  margin: 62px 0 24px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.method-card p {
  max-width: 650px;
  color: #454844;
  font-size: 17px;
  line-height: 1.55;
}

.trap-section {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: clamp(48px, 8vw, 130px);
  min-height: 860px;
  align-items: center;
  background: var(--coral);
  color: var(--ink);
}

.trap-copy p:last-child,
.transfer-copy p:last-child,
.evidence-section p:last-child {
  max-width: 680px;
  margin-top: 34px;
  font-size: 18px;
  line-height: 1.55;
}

.policy-graph {
  padding: 30px;
  border: 1px solid rgba(10, 10, 10, 0.5);
  background: rgba(245, 244, 237, 0.25);
}

.graph-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 28px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.policy-row {
  margin-bottom: 22px;
}

.policy-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 720;
}

.policy-track {
  height: 18px;
  border: 1px solid rgba(10, 10, 10, 0.45);
}

.policy-fill {
  width: var(--policy-width);
  height: 100%;
  background: var(--lane-color);
  transition: width 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

#trap-status {
  min-height: 62px;
  margin: 30px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(10, 10, 10, 0.35);
  font-size: 14px;
  line-height: 1.45;
}

.transfer-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.78fr);
  gap: clamp(48px, 8vw, 130px);
  min-height: 900px;
  align-items: center;
  background: #dfeff0;
  color: var(--ink);
}

.transfer-controls {
  padding: 28px;
  border: 1px solid #7e8989;
  background: rgba(255, 255, 255, 0.4);
}

.transfer-range {
  margin-bottom: 30px;
}

.transfer-range label,
.transfer-range small {
  display: block;
}

.transfer-range label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 720;
}

.transfer-range output {
  color: #1d646d;
}

.transfer-range input {
  accent-color: #1d646d;
}

.transfer-range small {
  margin-top: 6px;
  color: #596362;
  line-height: 1.35;
}

.transfer-controls .primary-button {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
}

.fit-result {
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}

.evidence-section {
  min-height: 650px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 60px;
  background: var(--yellow);
  color: var(--ink);
}

.evidence-section h2 {
  max-width: 850px;
}

.export-button {
  min-width: 250px;
  padding: 18px 22px;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.export-button span {
  margin-left: 18px;
}

footer {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 42px clamp(22px, 6vw, 92px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

footer div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 22px;
}

footer a:hover {
  color: var(--paper);
}

@media (max-width: 920px) {
  .library-status,
  .nav-actions > a {
    display: none;
  }

  .arena-shell {
    display: block;
    min-height: auto;
    padding-top: 58px;
  }

  .scene-panel {
    height: 55svh;
    min-height: 420px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .arena-heading {
    top: 28px;
  }

  .arena-heading h1 {
    font-size: clamp(2.45rem, 12vw, 4.2rem);
  }

  .arena-heading > p:last-child {
    max-width: 520px;
    font-size: 14px;
  }

  .gate-legend {
    bottom: 20px;
  }

  .scene-shortcuts {
    display: none;
  }

  .control-rail {
    min-height: auto;
    overflow: visible;
  }

  .telemetry-panel {
    min-height: 172px;
  }

  .trajectory-table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .method-section,
  .trap-section,
  .transfer-section,
  .evidence-section {
    padding-top: 110px;
    padding-bottom: 110px;
  }

  .method-layout,
  .trap-section,
  .transfer-section {
    grid-template-columns: 1fr;
  }

  .equation-pin {
    position: relative;
    top: auto;
  }

  .method-stack {
    min-height: 1040px;
  }

  .method-card {
    min-height: 270px;
    margin-bottom: 120px;
  }

  .trap-section,
  .transfer-section {
    min-height: auto;
  }

  .evidence-section {
    min-height: 600px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 14px;
  }

  .brand {
    font-size: 11px;
  }

  .scene-panel {
    height: 54svh;
    min-height: 380px;
  }

  .source-line {
    max-width: 280px;
    font-size: 9px;
  }

  .arena-heading {
    left: 16px;
    right: 16px;
  }

  .arena-heading h1 {
    max-width: 320px;
    font-size: 2.75rem;
  }

  .arena-heading > p:last-child {
    max-width: 320px;
  }

  .gate-legend {
    left: 16px;
    right: 16px;
  }

  .control-rail {
    padding: 24px 16px 28px;
  }

  .control-heading h2 {
    font-size: 21px;
  }

  .prediction-grid {
    gap: 6px;
  }

  .prediction-button {
    min-width: 0;
    padding: 7px 8px;
    font-size: 11px;
  }

  .telemetry-panel {
    padding-inline: 12px;
  }

  .trajectory-table {
    grid-template-columns: 1fr;
  }

  .method-section,
  .trap-section,
  .transfer-section,
  .evidence-section {
    padding-left: 18px;
    padding-right: 18px;
  }

  .method-intro h2,
  .trap-copy h2,
  .transfer-copy h2,
  .evidence-section h2 {
    font-size: 2.65rem;
  }

  .method-card h3 {
    margin-top: 42px;
    font-size: 2.15rem;
  }

  .policy-graph,
  .transfer-controls {
    padding: 20px;
  }

  .export-button {
    width: 100%;
    min-width: 0;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  footer div {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
