:root {
  color-scheme: dark;
  --ink: #070b13;
  --panel: #0c121c;
  --line: #253143;
  --line-soft: #1b2636;
  --text: #f0f3f6;
  --subtle: #a3aebd;
  --muted: #8797ab;
  --gold: #f2bf81;
  --blue: #8ddff1;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --head: 72px;
  --bar: 79px;
  --left: 240px;
  --right: 340px;
  --gutter: clamp(24px, 5.1vw, 84px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--text); }
body { font-family: Inter, system-ui, sans-serif; }
[hidden] { display: none !important; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { color: inherit; }
button { border: 0; font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
button svg, a svg { flex: none; width: 20px; height: 20px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }

#scene { position: absolute; inset: 0; overflow: hidden; background: #060912; }
#scene canvas { display: block; width: 100%; height: 100%; }
[data-mode="arrival"] #scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(5,8,15,.68), rgba(5,8,15,.26) 33%, transparent 67%),
              linear-gradient(0deg, rgba(5,8,15,.99), rgba(5,8,15,.67) 12%, transparent 33%),
              linear-gradient(180deg, rgba(5,8,15,.63), transparent 24%);
}
[data-mode="arrival"]:not([data-title="true"]) #scene::after { background: linear-gradient(0deg, #05080ff7, #05080f86 15%, transparent 35%), linear-gradient(180deg, #05080f91, transparent 23%); }
.scope { z-index: 2; position: absolute; width: 13px; height: 13px; pointer-events: none; border: 1px solid #a8b8d166; }
.scope-tl { top: calc(var(--head) + 29px); left: calc(var(--gutter) - 24px); border-right: 0; border-bottom: 0; }
.scope-tr { top: calc(var(--head) + 29px); right: calc(var(--gutter) - 24px); border-left: 0; border-bottom: 0; }
.scope-bl { bottom: 116px; left: calc(var(--gutter) - 24px); border-right: 0; border-top: 0; }
.scope-br { bottom: 116px; right: calc(var(--gutter) - 24px); border-left: 0; border-top: 0; }

.masthead {
  position: absolute; z-index: 10; top: 0; left: 0; right: 0; height: var(--head);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 33px; border-bottom: 1px solid #b5c3e02b; background: #080c15e8;
}
.brand { display: flex; gap: 10px; align-items: center; width: max-content; text-decoration: none; }
.brand svg { width: 39px; height: 39px; color: var(--gold); }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .145em; font-size: .84rem; }
.brand small { font: 500 .66rem/1 var(--mono); color: var(--muted); letter-spacing: .21em; margin-top: 6px; }
.mode-tabs { height: 100%; display: flex; align-items: stretch; gap: 16px; }
.mode-tabs button { position: relative; display: flex; gap: 9px; align-items: center; margin: 0; padding: 0 20px; font-size: .86rem; font-weight: 600; color: var(--subtle); background: none; }
.mode-tabs button span { font: .67rem var(--mono); color: var(--muted); }
.mode-tabs button[aria-current] { color: var(--text); }
.mode-tabs button[aria-current] span { color: var(--gold); }
.mode-tabs button[aria-current]::after { content: ""; position: absolute; height: 2px; background: var(--gold); left: 0; right: 0; bottom: -1px; box-shadow: 0 0 16px #f2bf8166; }
.mode-tabs button:hover, .sound:hover, .replay:hover, #skip-small:hover { color: var(--gold); }
.sound {
  justify-self: end; display: flex; gap: 9px; align-items: center; min-height: 38px; padding: 0 12px;
  border: 1px solid #334154; border-radius: 4px; color: var(--subtle); background: #111924a3;
  text-transform: uppercase; letter-spacing: .07em; font: 500 .7rem var(--mono);
}
.sound svg { width: 17px; height: 17px; color: var(--gold); }
.sound strong { font-weight: 500; color: var(--text); }
.sound[aria-pressed="true"] svg { color: var(--blue); }
.sound[aria-pressed="false"] { position: relative; }
.sound[aria-pressed="false"]::after { content: ""; position: absolute; inset: 50% auto auto 11px; width: 18px; height: 1px; transform: rotate(-48deg); background: var(--gold); box-shadow: 0 1px #101620; pointer-events: none; }

#arrival { position: relative; height: 100svh; min-height: 530px; pointer-events: none; }
#arrival button, #arrival input { pointer-events: auto; }
.arrival-telemetry { position: absolute; inset: calc(var(--head) + 31px) var(--gutter) auto; display: flex; justify-content: space-between; gap: 20px; color: #bbc6d7; font: 500 .72rem var(--mono); letter-spacing: .13em; }
.arrival-telemetry > :last-child { text-align: right; }
.arrival-telemetry b { font-weight: 500; }
.arrival-telemetry i, .model-label i { display: inline-block; width: 6px; height: 6px; vertical-align: 1px; margin-right: 4px; background: var(--gold); border-radius: 50%; box-shadow: 0 0 9px #f2bf8199; }
.arrival-telemetry small { display: block; margin-top: 7px; color: #8c9db5; font-size: .64rem; }
.hero { position: absolute; top: 48%; transform: translateY(-50%); left: var(--gutter); opacity: 0; visibility: hidden; transition: opacity .55s, visibility .55s; }
[data-title="true"] .hero { opacity: 1; visibility: visible; }
.hero-tag { display: flex; align-items: center; gap: 12px; color: var(--gold); font: 500 .77rem var(--mono); letter-spacing: .17em; }
.hero-tag i { display: inline-block; width: 25px; height: 1px; background: var(--gold); }
.hero h1 { margin: 15px 0 22px -3px; font: 700 clamp(6rem, min(10vw, 15.5vh), 11rem)/.77 var(--display); letter-spacing: -.018em; text-shadow: 0 8px 44px #04060e75; }
.hero h1 span { color: var(--gold); }
.hero p { color: #c1c9d6; margin: 0 0 28px; font-size: 1rem; line-height: 1.5; }
.primary { display: inline-flex; gap: 10px; align-items: center; min-height: 46px; padding: 0 16px; border-radius: 3px; color: #15100c; background: var(--gold); font-size: .84rem; font-weight: 700; box-shadow: 0 6px 28px #0005; }
.primary svg { width: 17px; height: 17px; }
.primary:hover { background: #ffdbad; }
.cinema-caption { position: absolute; bottom: 143px; left: 50%; transform: translateX(-50%); width: min(76%, 620px); text-align: center; }
.cinema-caption p { display: inline; margin: 0; padding: 4px 7px; background: #070b13b3; box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: clamp(.85rem,1.5vw,1.05rem); line-height: 1.75; color: #e7edf5; }
.cinema-caption:has(p:empty) { display: none; }
[data-title="true"] .cinema-caption { left: auto; right: var(--gutter); transform: none; width: min(34%, 390px); text-align: right; }
.film-deck { position: absolute; z-index: 3; left: var(--gutter); right: var(--gutter); bottom: 25px; }
.film-heading, .film-label, .film-right { display: flex; align-items: center; }
.film-heading { justify-content: space-between; gap: 12px; min-height: 38px; }
.film-label, .film-right { gap: 10px; }
.film-icon { font-size: 1.15rem; color: var(--gold); }
#chapter-number, .film-right { font: 500 .72rem var(--mono); white-space: nowrap; }
#chapter-number, .film-duration { color: var(--muted); }
#chapter-title { margin-left: 3px; font-size: .9rem; font-weight: 600; }
#skip-small { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; padding: 5px 0 5px 14px; border-left: 1px solid #344052; color: #d4dcea; background: none; font: 500 .72rem var(--mono); }
#skip-small svg { width: 14px; height: 14px; color: var(--gold); }
.scrub { height: 18px; position: relative; display: flex; align-items: center; }
.scrub-track { width: 100%; height: 2px; background: #536075; }
#scrub-fill { width: 0; height: 100%; background: var(--gold); box-shadow: 0 0 10px #f2bf818c; }
.scrub input { appearance: none; position: absolute; left: 0; width: 100%; margin: 0; height: 18px; cursor: ew-resize; background: transparent; }
.scrub input::-webkit-slider-thumb { appearance: none; width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px #f2bf818c; }
.chapter-marks { display: flex; height: 26px; }
.chapter-marks button { position: relative; padding: 8px 5px 0 0; background: transparent; color: var(--muted); white-space: nowrap; text-align: left; font: 500 .67rem var(--mono); text-transform: uppercase; letter-spacing: .055em; }
.chapter-marks button::before { content: ""; position: absolute; background: #758399; width: 1px; height: 5px; top: 0; left: 0; }
.chapter-marks button.active, .chapter-marks button:hover { color: var(--gold); }

[data-mode="dissection"] #scene { inset: calc(var(--head) + var(--bar)) var(--right) 0 var(--left); }
[data-mode="dissection"] #scene canvas { touch-action: none; cursor: grab; }
[data-mode="dissection"] #scene canvas:active { cursor: grabbing; }
[data-mode="dissection"] .scope-tl, [data-mode="dissection"] .scope-tr { top: 16px; }
[data-mode="dissection"] .scope-bl, [data-mode="dissection"] .scope-br { bottom: 16px; }
[data-mode="dissection"] .scope-tl, [data-mode="dissection"] .scope-bl { left: 16px; }
[data-mode="dissection"] .scope-tr, [data-mode="dissection"] .scope-br { right: 16px; }
#hotspots { display: none; }
[data-mode="dissection"] #hotspots { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.hotspot {
  position: absolute; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 26px; min-width: 26px; padding: 0 5px; transform: translate(-50%, -50%);
  border: 1px solid #9be1f3ae; background: #091424e8; color: #b8ecfa; border-radius: 2px;
  box-shadow: 0 0 0 3px #09142464; white-space: nowrap; font: 500 .66rem var(--mono); pointer-events: auto;
}
.hotspot.active, .hotspot:hover { border-color: var(--gold); background: #211910; color: var(--gold); z-index: 2; }

#dissection { padding-top: var(--head); }
.dissection-bar {
  height: var(--bar); position: relative; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; padding: 0 25px; gap: 12px; background: #0d1420; border-bottom: 1px solid var(--line);
}
.ship-title > span { font: 500 .68rem var(--mono); color: var(--gold); letter-spacing: .1em; }
.ship-title h1 { margin: 0; font: 600 2.3rem/.96 var(--display); text-transform: uppercase; letter-spacing: .01em; white-space: nowrap; }
.view-modes { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 4px; background: #090e17; }
.view-modes button { padding: 8px 12px; color: var(--subtle); font-size: .81rem; font-weight: 600; background: none; border-radius: 2px; white-space: nowrap; }
.view-modes button:hover { color: var(--text); }
.view-modes button[aria-pressed="true"] { color: var(--blue); background: #1b2b3b; }
.replay { display: flex; align-items: center; gap: 7px; justify-self: end; color: var(--subtle); background: none; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.replay svg { color: var(--gold); width: 17px; height: 17px; }
.systems, .dossier { position: absolute; top: calc(var(--head) + var(--bar)); bottom: 0; overflow: auto; scrollbar-color: #394a5f transparent; background: var(--panel); }
.systems { left: 0; width: var(--left); padding: 25px 14px 22px; border-right: 1px solid var(--line); }
.rail-heading { display: flex; gap: 8px; align-items: center; padding: 0 9px; margin-bottom: 17px; color: var(--muted); }
.rail-heading svg { width: 17px; height: 17px; color: var(--blue); }
.rail-heading h2 { margin: 0; font: 500 .73rem var(--mono); letter-spacing: .11em; text-transform: uppercase; }
.overview-button, .system-button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 7px 9px;
  border: 1px solid transparent; border-radius: 3px; text-align: left; color: #c0cad8; background: none; font-size: .81rem; font-weight: 600;
}
.overview-button { margin-bottom: 8px; }
.overview-button span, .system-button span { flex: none; display: grid; place-items: center; width: 25px; height: 23px; background: #141d2b; color: var(--blue); font: 500 .68rem var(--mono); border-radius: 2px; }
.overview-button:hover, .system-button:hover { background: #141e2b; }
.overview-button.active, .system-button.active { border-color: #6b553e; color: var(--text); background: #241e1a; }
.overview-button.active span, .system-button.active span { background: #33271d; color: var(--gold); }
.length-mark { display: flex; align-items: center; gap: 8px; padding: 21px 9px 0; margin-top: 20px; border-top: 1px solid var(--line-soft); font: .65rem var(--mono); color: var(--muted); white-space: nowrap; }
.length-mark span { width: 18px; height: 6px; border: 1px solid var(--muted); border-bottom: 0; }
.model-ui { position: absolute; top: calc(var(--head) + var(--bar)); bottom: 0; left: var(--left); right: var(--right); pointer-events: none; }
.model-label { position: absolute; top: 24px; left: 25px; display: flex; align-items: center; color: var(--blue); font: .68rem var(--mono); letter-spacing: .08em; }
.model-label i { margin-right: 7px; background: var(--blue); box-shadow: 0 0 9px #8ddff177; }
.model-bottom { position: absolute; bottom: 16px; left: 25px; right: 25px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.orbit-help { display: flex; gap: 7px; align-items: center; color: #a6b2c3; font: .68rem var(--mono); white-space: nowrap; }
.orbit-help svg { width: 16px; height: 16px; color: var(--blue); }
.orbit-help b { width: 3px; height: 3px; border-radius: 50%; background: #65809d; }
.model-buttons { display: flex; gap: 5px; }
.model-buttons button { display: grid; place-items: center; width: 34px; height: 34px; background: #101b29; color: var(--blue); border: 1px solid #34465c; border-radius: 3px; pointer-events: auto; }
.model-buttons button:hover { background: #263a51; }
.model-buttons svg { width: 18px; height: 18px; }
.dossier { right: 0; width: var(--right); padding: 25px 22px 30px; border-left: 1px solid var(--line); }
.dossier-kicker { color: var(--gold); font: 500 .72rem var(--mono); letter-spacing: .12em; }
.dossier h2 { margin: 4px 0 12px; font: 600 2.6rem/.97 var(--display); }
.dossier p { margin: 0 0 14px; color: #b6c1cf; font-size: 1rem; line-height: 1.55; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 20px 0; padding: 1px; background: var(--line); border-radius: 3px; }
.specs > div { padding: 10px 9px; background: #111a28; }
.specs dt { color: var(--muted); font: 500 .65rem var(--mono); letter-spacing: .055em; text-transform: uppercase; }
.specs dd { margin: 4px 0 0; color: var(--blue); font: 500 .83rem var(--mono); }
.dossier h3 { margin: 0 0 7px; color: #e1e8f2; font-size: .86rem; }
.dossier .reading { padding-top: 17px; border-top: 1px solid var(--line); }
.dossier .reading p:last-child { margin-bottom: 0; }
.error { position: fixed; z-index: 20; left: 1rem; right: 1rem; bottom: 1rem; padding: 1rem; background: #2b1721; color: #fff4f5; border: 1px solid #a9696d; }

@media (max-width: 1100px) {
  :root { --left: 198px; --right: 295px; }
  .systems { padding-inline: 10px; }
  .dossier { padding-inline: 17px; }
}

@media (max-width: 850px) {
  :root { --head: 62px; --bar: 110px; --gutter: 28px; }
  :root { --mobile-stage: clamp(340px, 53svh, 530px); }
  .masthead { padding-inline: 15px; }
  .mode-tabs { gap: 3px; }
  .mode-tabs button { padding-inline: 12px; }
  [data-mode="dissection"] #scene, .model-ui { left: 0; right: 0; bottom: auto; height: var(--mobile-stage); }
  .dissection-bar { grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 9px 15px; gap: 5px; }
  .view-modes { justify-self: start; grid-row: 2; }
  .replay { grid-row: 1; grid-column: 2; }
  #dissection { display: grid; grid-template-columns: minmax(155px, 31%) minmax(0, 1fr); }
  .dissection-bar { grid-column: 1 / -1; margin-bottom: var(--mobile-stage); }
  .systems, .dossier { position: relative; inset: auto; width: auto; overflow: visible; border-top: 1px solid var(--line); }
  .dossier { border-left: 0; }
}

@media (max-width: 510px) {
  :root { --head: 56px; --gutter: 20px; }
  .brand { gap: 4px; }
  .brand svg { width: 28px; height: 28px; }
  .brand strong { font-size: .65rem; letter-spacing: .08em; }
  .brand small { font-size: .52rem; letter-spacing: .11em; margin-top: 4px; }
  .masthead { padding-inline: 9px; grid-template-columns: 1fr auto auto; gap: 5px; }
  .mode-tabs button { padding: 0 7px; font-size: .72rem; }
  .mode-tabs button span, .sound > span { display: none; }
  .sound { min-height: 32px; padding-inline: 7px; }
  .sound[aria-pressed="false"]::after { left: 7px; }
  .arrival-telemetry { gap: 10px; font-size: .57rem; letter-spacing: .075em; }
  .arrival-telemetry small { font-size: .53rem; }
  .scope-tl, .scope-bl { left: 7px; }
  .scope-tr, .scope-br { right: 7px; }
  .scope { width: 8px; height: 8px; }
  .hero { top: 47%; }
  .hero h1 { font-size: clamp(4.4rem, 17vw, 6rem); }
  .hero-tag { font-size: .63rem; gap: 7px; }
  .hero-tag i { width: 15px; }
  .hero p { max-width: 245px; }
  .film-deck { bottom: 16px; }
  .chapter-marks button { letter-spacing: 0; font-size: .56rem; white-space: normal; line-height: 1; height: 26px; }
  .film-label, .film-right { gap: 6px; }
  #chapter-title { font-size: .72rem; }
  #chapter-number, .film-right, #skip-small { font-size: .62rem; }
  #skip-small { padding-left: 6px; margin-left: 2px; }
  [data-title="true"] .cinema-caption { width: 65%; bottom: 115px; }
  .dossier { padding-inline: 13px; }
  .dossier h2 { font-size: 2rem; }
  .systems { padding-inline: 5px; }
  .rail-heading, .overview-button, .system-button { gap: 6px; padding-inline: 5px; }
  .system-button, .overview-button { font-size: .75rem; }
  .model-bottom { left: 20px; right: 20px; }
}

@media (max-height: 630px) and (min-width: 511px) {
  .hero h1 { font-size: clamp(4.6rem, 13vh, 6.8rem); }
  .hero { top: 50%; }
  .hero p { margin-bottom: 14px; }
  .hero h1 { margin-bottom: 14px; }
  .film-deck { bottom: 13px; }
  .cinema-caption { bottom: 111px; }
}

@media (prefers-reduced-motion: reduce) { .hero { transition: none; } }
