:root {
  --ink: #090a09;
  --ink-soft: #131714;
  --bone: #f1eee3;
  --paper: #d9d6cb;
  --copper: #d5764d;
  --teal: #4eb7aa;
  --sun: #f4d35e;
  --error: #f0523d;
  --line: rgba(241, 238, 227, .27);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: Geist, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
}
a { color: inherit; }

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 10, 9, .91);
  backdrop-filter: blur(14px);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 16px; height: 16px; border: 2px solid var(--copper); transform: rotate(45deg); }
.nav-actions { display: flex; align-items: center; gap: 16px; }
.nav-actions a { color: #c7c8c0; text-decoration: none; }
.library-status { color: var(--teal); font-family: ui-monospace, monospace; }
.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #697069;
  border-radius: 0;
  background: #1b211d;
  color: var(--bone);
  font-size: 20px;
}

.page-shell { width: 100%; max-width: 100%; overflow-x: hidden; }
.instrument {
  position: relative;
  height: 100svh;
  min-height: 630px;
  overflow: hidden;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}
.instrument::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(9,10,9,.85) 0%, rgba(9,10,9,.3) 45%, transparent 72%);
}
.scene-host { position: absolute; z-index: 0; inset: 54px 0 0; }
.scene-host canvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.scene-fallback {
  position: absolute;
  top: 33%;
  right: 8%;
  max-width: 360px;
  padding: 18px;
  border: 1px solid var(--copper);
  background: var(--ink-soft);
}
.scene-fallback span { display: block; margin-top: 7px; color: #c2c4bd; }

.instrument-heading {
  position: absolute;
  z-index: 4;
  top: 13%;
  left: 4.2vw;
  width: min(54vw, 760px);
  pointer-events: none;
  text-shadow: 0 2px 24px rgba(0,0,0,.55);
}
.eyebrow { margin: 0 0 13px; color: var(--copper); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.instrument-heading h1 {
  width: 100%;
  max-width: 1100px;
  margin: 0;
  font-size: clamp(2.75rem, 7vw, 7rem);
  line-height: .86;
  font-weight: 780;
}
.orbital-window {
  display: inline-block;
  width: 1.05em;
  height: .44em;
  vertical-align: .08em;
  margin: 0 .08em;
  border: 1px solid rgba(241,238,227,.72);
  border-radius: 999px;
  background: url("https://pbs.twimg.com/media/HM8-BPjagAARhoI.jpg") center / cover;
  filter: grayscale(1) contrast(1.2);
}
.instrument-heading > p:last-child { max-width: 520px; margin: 17px 0 0; color: #d7d7d0; font-size: clamp(14px, 1.4vw, 18px); line-height: 1.48; }

.live-telemetry {
  position: absolute;
  z-index: 5;
  left: 22px;
  right: 22px;
  bottom: 160px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: rgba(9,10,9,.82);
  backdrop-filter: blur(10px);
}
.live-telemetry > div { min-width: 0; padding: 10px 13px; border-right: 1px solid var(--line); }
.live-telemetry > div:last-child { border-right: 0; }
.live-telemetry span { display: block; color: #aeb2ab; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.live-telemetry strong { display: block; margin-top: 4px; font: 700 clamp(17px, 2vw, 25px)/1 ui-monospace, monospace; }

.workbench {
  position: absolute;
  z-index: 6;
  left: 22px;
  right: 22px;
  bottom: 20px;
  display: grid;
  grid-template-columns: 1.05fr 1.5fr auto;
  min-height: 88px;
  border: 1px solid var(--line);
  background: rgba(15,18,16,.95);
  box-shadow: 0 20px 70px rgba(0,0,0,.45);
}
.prediction-control, .period-control, .transport { min-width: 0; padding: 11px 12px; border-right: 1px solid var(--line); }
.transport { border-right: 0; display: flex; align-items: end; gap: 7px; }
.control-label { display: block; margin-bottom: 8px; color: #aeb2ab; font-size: 10px; font-weight: 800; }
.segmented { display: flex; gap: 6px; }
.segmented button, .primary-action, .claim-actions button, .export-action {
  min-height: 44px;
  border: 1px solid #6b726d;
  border-radius: 0;
  background: #1b211d;
  color: var(--bone);
  padding: 8px 13px;
  font-weight: 740;
}
.segmented button { flex: 1; }
.segmented button[aria-pressed="true"], .primary-action { border-color: var(--copper); background: var(--copper); color: var(--ink); }
.period-control output { color: var(--sun); font-family: ui-monospace, monospace; text-transform: none; }
input[type="range"] { width: 100%; accent-color: var(--copper); }
.status {
  position: absolute;
  z-index: 6;
  left: 34px;
  bottom: 132px;
  color: #d7dbd5;
  font-size: 12px;
}
.first-viewport-hint { position: absolute; z-index: 6; right: 25px; bottom: 132px; color: #a8aca6; font: 700 10px/1 ui-monospace, monospace; }

.orbital-ledger {
  display: grid;
  grid-auto-flow: dense;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bone);
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
}
.orbital-ledger article { min-height: 160px; padding: 28px; border-right: 2px solid var(--ink); }
.orbital-ledger article:last-child { border-right: 0; }
.orbital-ledger span, .orbital-ledger small { display: block; }
.orbital-ledger span { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.orbital-ledger strong { display: block; margin: 26px 0 6px; font: 750 clamp(19px,2.2vw,31px)/1 ui-monospace, monospace; }
.orbital-ledger small { color: #5f655f; }

.derivation {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 8vw;
  padding: 150px 5vw 180px;
  background: var(--paper);
  color: var(--ink);
}
.equation-pin { position: sticky; top: 90px; align-self: start; }
.equation-pin h2, .chapter-heading h2, .misconception h2, .transfer h2, .evidence h2 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 5.4rem);
  line-height: .95;
}
.equation { margin: 35px 0; padding: 18px; border: 2px solid var(--ink); background: var(--ink); color: var(--sun); font: 750 clamp(17px,2vw,26px)/1.4 ui-monospace, monospace; }
.scrub-explanation { font-size: clamp(18px,2vw,27px); line-height: 1.46; }
.derivation-stack { display: flex; min-height: 520px; border: 2px solid var(--ink); overflow: hidden; }
.derivation-panel { flex: 1; min-width: 72px; border-right: 2px solid var(--ink); background: var(--bone); transition: flex .45s ease; }
.derivation-panel:last-child { border-right: 0; }
.derivation-panel.active { flex: 4.2; background: #f7f4e9; }
.accordion-trigger { width: 100%; height: 100%; min-height: 78px; display: flex; justify-content: space-between; padding: 20px; border: 0; background: transparent; font-weight: 800; writing-mode: vertical-rl; }
.derivation-panel.active .accordion-trigger { height: auto; writing-mode: horizontal-tb; border-bottom: 1px solid var(--ink); }
.accordion-body { display: none; padding: 25px; font-size: 17px; line-height: 1.55; }
.derivation-panel.active .accordion-body { display: block; }
.accordion-body strong { display: block; margin-top: 24px; color: #8d3d24; font-family: ui-monospace, monospace; }

.event-chapter { padding: 150px 5vw 170px; background: var(--ink); }
.chapter-heading { max-width: 900px; }
.chapter-heading p:last-child { max-width: 720px; color: #c4c7c1; font-size: 18px; line-height: 1.55; }
.event-strip { display: grid; grid-template-columns: repeat(13, minmax(24px,1fr)); gap: 4px; min-height: 230px; align-items: end; margin: 60px 0 75px; border-bottom: 1px solid var(--line); }
.event-mark { min-height: 18px; position: relative; background: var(--copper); transition: height .5s ease, background .3s; }
.event-mark span { position: absolute; bottom: -27px; left: 50%; transform: translateX(-50%); font: 700 9px/1 ui-monospace, monospace; }
.event-mark.current { background: var(--sun); }
.marquee { overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 15px 0; }
.marquee div { width: max-content; font-weight: 800; word-spacing: 20px; animation: marquee 28s linear infinite; }
@keyframes marquee { to { transform: translateX(-50%); } }

.misconception {
  min-height: 90svh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--copper);
  color: var(--ink);
  overflow: hidden;
}
.misconception-visual { min-height: 580px; display: grid; place-items: center; border-right: 2px solid var(--ink); }
.rose-symbol { position: relative; width: min(62vw, 480px); aspect-ratio: 1; }
.rose-symbol span { position: absolute; inset: 24%; border: 4px solid var(--ink); border-radius: 50% 50% 12% 50%; transform-origin: 50% 100%; }
.rose-symbol span:nth-child(2) { transform: rotate(72deg); }
.rose-symbol span:nth-child(3) { transform: rotate(144deg); }
.rose-symbol span:nth-child(4) { transform: rotate(216deg); }
.rose-symbol span:nth-child(5) { transform: rotate(288deg); }
.misconception-copy { align-self: center; padding: 8vw; }
.misconception-copy .eyebrow { color: #5d2416; }
.misconception-copy > p:not(.eyebrow) { max-width: 620px; font-size: 19px; line-height: 1.55; }
.claim-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.claim-actions button { background: var(--ink); }
.claim-actions .primary-action { background: var(--bone); border-color: var(--bone); }

.transfer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9vw;
  padding: 150px 5vw 170px;
  background: var(--teal);
  color: var(--ink);
}
.transfer-copy > p:not(.eyebrow) { max-width: 650px; font-size: 18px; line-height: 1.55; }
.transfer-result { min-height: 58px; margin-top: 26px; font-weight: 760; }
.transfer-bench { align-self: center; padding: 28px; border: 2px solid var(--ink); background: rgba(241,238,227,.42); }
.transfer-bench label { display: flex; justify-content: space-between; font-weight: 800; }
.transfer-bench input { margin: 32px 0; accent-color: var(--ink); }
.transfer-readout { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 22px; border: 1px solid var(--ink); }
.transfer-readout > div { padding: 16px; border-right: 1px solid var(--ink); }
.transfer-readout > div:last-child { border-right: 0; }
.transfer-readout span { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.transfer-readout strong { display: block; margin-top: 7px; font-family: ui-monospace, monospace; }

.evidence { display: flex; align-items: end; justify-content: space-between; gap: 50px; padding: 140px 5vw; background: var(--bone); color: var(--ink); }
.evidence p { max-width: 650px; font-size: 18px; line-height: 1.5; }
.evidence-actions { display: flex; align-items: center; gap: 20px; }
.mastery-ring { width: 130px; aspect-ratio: 1; display: grid; place-items: center; align-content: center; border: 8px solid var(--copper); border-radius: 50%; }
.mastery-ring strong { font: 800 28px/1 ui-monospace, monospace; }
.mastery-ring span { margin-top: 5px; font-size: 10px; text-transform: uppercase; }
.export-action { min-height: 56px; background: var(--ink); color: var(--bone); }
footer { display: flex; justify-content: space-between; gap: 30px; padding: 23px 5vw; background: var(--ink); color: #afb3ad; font-size: 12px; }

@media (max-width: 900px) {
  .nav-actions a { display: none; }
  .instrument-heading { top: 10%; width: 78vw; }
  .instrument-heading h1 { font-size: clamp(3.2rem, 11vw, 6.2rem); }
  .live-telemetry { grid-template-columns: repeat(2,1fr); bottom: 246px; }
  .live-telemetry > div:nth-child(2) { border-right: 0; }
  .live-telemetry > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workbench { grid-template-columns: 1fr 1fr; }
  .transport { grid-column: span 2; border-top: 1px solid var(--line); }
  .status, .first-viewport-hint { bottom: 218px; }
  .orbital-ledger { grid-template-columns: repeat(2,1fr); }
  .orbital-ledger article:nth-child(2) { border-right: 0; }
  .orbital-ledger article:nth-child(-n+2) { border-bottom: 2px solid var(--ink); }
  .derivation, .transfer { grid-template-columns: 1fr; }
  .equation-pin { position: static; }
  .misconception { grid-template-columns: 1fr; }
  .misconception-visual { min-height: 420px; border-right: 0; border-bottom: 2px solid var(--ink); }
  .evidence { align-items: start; flex-direction: column; }
}

@media (max-width: 600px) {
  .topbar { height: 48px; padding: 0 11px; }
  .brand { font-size: 9px; }
  .library-status { font-size: 8px; }
  .nav-actions { gap: 7px; }
  .scene-host { top: 48px; }
  .instrument { min-height: 844px; }
  .instrument::after { background: linear-gradient(180deg, rgba(9,10,9,.72), transparent 48%, rgba(9,10,9,.76)); }
  .instrument-heading { top: 63px; left: 14px; width: calc(100% - 28px); }
  .instrument-heading .eyebrow { display: none; }
  .instrument-heading h1 { max-width: 520px; font-size: 45px; line-height: .9; }
  .instrument-heading > p:last-child { max-width: 330px; margin-top: 8px; font-size: 12px; }
  .live-telemetry { left: 8px; right: 8px; bottom: 278px; }
  .live-telemetry > div { min-height: 58px; padding: 7px 8px; }
  .live-telemetry strong { font-size: 16px; }
  .workbench { left: 8px; right: 8px; bottom: 8px; grid-template-columns: 1fr; }
  .prediction-control, .period-control, .transport { padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .transport { grid-column: span 1; border-bottom: 0; border-top: 0; }
  .transport .primary-action { flex: 1; }
  .status { left: 13px; bottom: 252px; max-width: calc(100% - 26px); font-size: 10px; }
  .first-viewport-hint { display: none; }
  .orbital-ledger { grid-template-columns: 1fr; }
  .orbital-ledger article { min-height: 125px; border-right: 0; border-bottom: 2px solid var(--ink); }
  .orbital-ledger article:last-child { border-bottom: 0; }
  .derivation, .event-chapter, .transfer { padding: 105px 16px 120px; }
  .derivation-stack { min-height: 410px; }
  .event-strip { grid-template-columns: repeat(13, minmax(10px,1fr)); gap: 2px; }
  .event-mark span { display: none; }
  .misconception-copy { padding: 90px 16px 110px; }
  .evidence { padding: 105px 16px; }
  .evidence-actions { width: 100%; flex-wrap: wrap; }
  footer { flex-direction: column; }
}

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