:root {
  --ink: #0a0c0f;
  --ink-2: #111418;
  --panel: rgba(14, 17, 20, .92);
  --line: rgba(235, 230, 220, .16);
  --paper: #e8e2d8;
  --muted: #9f9a92;
  --orange: #f05a1a;
  --lime: #b7ff2a;
  --purple: #b026ff;
  --brown: #6b4128;
  --header-h: 68px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--ink); color: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

.masthead {
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: #0a0c0f;
  position: relative;
  z-index: 20;
}

.wordmark { border: 0; background: none; display: flex; align-items: center; gap: 10px; padding: 0; cursor: pointer; justify-self: start; letter-spacing: .12em; font-weight: 750; }
.wordmark small { color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; border-left: 1px solid var(--line); padding-left: 10px; }
.mark { width: 14px; height: 14px; border: 2px solid var(--orange); display: inline-block; position: relative; transform: rotate(45deg); }
.mark::after { content: ""; position: absolute; inset: 3px; background: var(--purple); }

.machine-switcher { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); background: var(--ink-2); }
.machine-switcher button { min-height: 38px; border: 0; background: transparent; color: var(--muted); padding: 7px 10px; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.machine-switcher .machine-kind::before { content: " / "; }
.machine-switcher button.active { color: var(--ink); background: var(--paper); }
.build-status { justify-self: end; display: flex; align-items: center; gap: 8px; color: var(--muted); font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.build-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px rgba(183,255,42,.6); }

.workspace { position: relative; height: calc(100dvh - var(--header-h)); overflow: hidden; }
.stage { position: absolute; inset: 0; background: #101316; }
#viewer { display: block; width: 100%; height: 100%; outline: none; }
.stage::after { content: ""; pointer-events: none; position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.035); }

.stage-copy { position: absolute; left: clamp(28px, 5vw, 78px); top: 12%; max-width: 470px; pointer-events: none; transition: opacity .35s, transform .35s; }
.stage-copy.hidden { opacity: 0; transform: translateY(-12px); visibility: hidden; }
.eyebrow { color: var(--orange); font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; text-transform: uppercase; margin: 0 0 14px; }
.stage-copy h1 { margin: 0; font-size: clamp(46px, 6.2vw, 92px); line-height: .91; letter-spacing: -.06em; font-weight: 620; }
.stage-copy > p:not(.eyebrow) { color: #b8b2a9; max-width: 370px; line-height: 1.55; font-size: 14px; }
.landing-actions { display: flex; gap: 10px; margin-top: 24px; pointer-events: auto; }
.landing-actions button { border: 1px solid var(--line); padding: 12px 17px; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; cursor: pointer; }
.landing-actions .primary { color: var(--ink); background: var(--orange); border-color: var(--orange); }
.landing-actions .secondary { background: rgba(10,12,15,.6); }
.fleet-proof { display: flex; flex-wrap: wrap; gap: 7px 18px; margin-top: 21px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font: 650 8px/1.35 ui-monospace, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; }
.fleet-proof span { padding: 7px 9px; background: rgba(10,12,15,.7); border-left: 2px solid var(--orange); }
.fleet-proof strong { display: block; color: var(--paper); font-size: 13px; letter-spacing: 0; }

.view-hint { position: absolute; left: 26px; bottom: 18px; color: #77736d; font: 500 9px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.view-hint span { color: var(--paper); margin-right: 4px; }
.viewer-toolbar { position: absolute; right: 390px; top: 18px; z-index: 6; display: flex; align-items: center; gap: 10px; color: var(--muted); font: 650 8px/1 ui-monospace, Menlo, monospace; letter-spacing: .11em; text-transform: uppercase; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .25s, transform .25s; }
.workspace:not(.overview-mode) .viewer-toolbar { opacity: 1; transform: none; pointer-events: auto; }
.viewer-toolbar button { border: 1px solid var(--line); background: rgba(10,12,15,.7); padding: 8px 10px; cursor: pointer; text-transform: uppercase; letter-spacing: .08em; font-size: 8px; }
.viewer-toolbar span { padding: 8px 10px; border-left: 2px solid var(--purple); background: rgba(10,12,15,.55); }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; background: #0d1012; color: var(--muted); font: 600 10px/1 ui-monospace, Menlo, monospace; letter-spacing: .14em; text-transform: uppercase; transition: opacity .3s; z-index: 8; }
.loading.done { opacity: 0; pointer-events: none; }
.loading i { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.15); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

.dossier { position: absolute; z-index: 10; top: 20px; right: 20px; width: 350px; max-height: calc(100% - 134px); overflow: auto; padding: 24px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px); transform: translateX(calc(100% + 30px)); transition: transform .35s ease; scrollbar-width: thin; }
.dossier.open { transform: none; }
.dossier-head { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.dossier h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.035em; }
.dossier-head > p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dossier-head > div > p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.fleet-return { border: 1px solid var(--line); background: transparent; padding: 7px 8px; color: var(--muted); font: 650 7px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.dossier-actions { display: flex; gap: 6px; }
.dossier-toggle { display: none; }
.mobile-dossier-tabs { display: none; }
.control-group { padding: 17px 0; border-bottom: 1px solid var(--line); }
.control-label { display: flex; gap: 8px; margin-bottom: 10px; font: 650 9px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.control-label span { color: var(--orange); }
.button-row, .system-row { display: flex; flex-wrap: wrap; gap: 6px; }
.button-row button, .system-row button, .state-list button { border: 1px solid var(--line); background: transparent; color: #bdb7ae; padding: 8px 10px; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.button-row button.active, .system-row button.active, .state-list button.active { border-color: var(--orange); color: var(--paper); background: rgba(240,90,26,.12); }
.state-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.state-list button { text-align: left; line-height: 1.25; min-height: 42px; }
.inspection-row { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 16px 0 10px; }
.inspection-row label { cursor: pointer; color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 6px; }
.inspection-row input { accent-color: var(--orange); }
.inspection-row button { width: 100%; border: 0; background: transparent; padding: 2px 0; color: #7f7a73; font: 650 8px/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-align: left; text-transform: uppercase; cursor: pointer; }
.cutaway-control { padding: 8px 0 17px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.cutaway-control > div { display: flex; justify-content: space-between; gap: 12px; }
.cutaway-control label { color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.cutaway-control output { color: var(--purple); font: 650 8px/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
.cutaway-control input { width: 100%; accent-color: var(--purple); }
.proof { padding-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 13px 18px; }
.proof div { min-width: 0; }
.proof strong { display: block; color: var(--paper); font-size: 18px; font-weight: 620; }
.proof span { display: block; color: var(--muted); font: 600 8px/1.4 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
.proof .wide { grid-column: 1/-1; border-top: 1px solid var(--line); padding-top: 12px; }
.proof .wide strong { font-size: 10px; color: var(--lime); letter-spacing: .08em; }
.scope-note { margin: 15px 0 0; padding-top: 13px; border-top: 1px solid var(--line); color: #77736d; font: 550 8px/1.5 ui-monospace, Menlo, monospace; letter-spacing: .04em; text-transform: uppercase; }

.story { position: absolute; z-index: 9; left: 26px; right: 394px; bottom: 18px; min-height: 94px; display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 18px; padding: 16px 18px; background: rgba(10,12,15,.88); border: 1px solid var(--line); backdrop-filter: blur(14px); transform: translateY(calc(100% + 30px)); transition: transform .35s ease; }
.story[hidden] { display: none; }
.story.open { transform: none; }
.story-index { color: var(--orange); font: 500 13px/1 ui-monospace, Menlo, monospace; }
.story-copy .eyebrow { margin-bottom: 5px; font-size: 8px; }
.story-copy h3 { margin: 0 0 5px; font-size: 16px; }
.story-copy > p:last-child { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; max-width: 680px; }
.story-actions { display: flex; gap: 6px; }
.story-actions button { border: 1px solid var(--line); background: transparent; padding: 9px 11px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; cursor: pointer; }
#story-show { color: var(--ink); background: var(--lime); border-color: var(--lime); }

.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.anatomy-label { position: absolute; transform: translate(-50%, -50%); font: 650 8px/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--paper); background: rgba(10,12,15,.85); border-left: 2px solid var(--lime); padding: 6px 8px; white-space: nowrap; box-shadow: 0 4px 20px rgba(0,0,0,.25); }
.anatomy-label::after { content: ""; position: absolute; left: -5px; top: 50%; width: 4px; height: 4px; border-radius: 50%; background: var(--lime); }

@media (max-width: 800px) {
  :root { --header-h: 64px; }
  .masthead { grid-template-columns: 1fr auto; padding: 0 14px; }
  .wordmark { width: 44px; min-height: 44px; }
  .wordmark > span:not(.mark), .wordmark small, .build-status { display: none; }
  .machine-switcher { width: min(292px, calc(100vw - 76px)); grid-template-columns: repeat(4,minmax(0,1fr)); justify-self: end; display: grid; }
  .machine-switcher button { min-width: 0; min-height: 44px; padding: 7px 4px; font-size: 9px; }
  .machine-switcher .machine-kind { display: none; }
  .machine-switcher .machine-kind::before { content: none; }
  .workspace { height: calc(100dvh - var(--header-h)); }
  .stage { bottom: 0; }
  .workspace.overview-mode .stage { bottom: 0; }
  .stage-copy { left: 20px; right: 20px; top: 9%; }
  .stage-copy h1 { font-size: clamp(42px, 14vw, 62px); }
  .stage-copy > p:not(.eyebrow) {
    width: fit-content;
    max-width: 310px;
    padding: 8px 10px;
    border-left: 2px solid var(--orange);
    background: rgba(10,12,15,.78);
    color: #eee9e0;
    font-size: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
  }
  .landing-actions button { min-height: 44px; padding: 10px 12px; font-size: 10px; }
  .fleet-proof { max-width: 350px; gap: 6px; margin-top: 16px; border-top: 0; padding-top: 0; font-size: 9px; }
  .fleet-proof strong { font-size: 14px; }
  .view-hint { display: none; }
  .viewer-toolbar { top: 10px; right: 10px; }
  .viewer-toolbar button { min-height: 44px; padding: 10px 12px; font-size: 10px; }
  .viewer-toolbar span { display: none; }
  .dossier { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: auto; max-height: calc(100% - 84px); overflow: hidden; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-width: 1px 0 0; transform: translateY(100%); backdrop-filter: none; background: #101316; }
  .dossier.open { transform: none; }
  .dossier.expanded { height: min(52dvh, 440px); overflow: hidden; display: flex; flex-direction: column; }
  .dossier-head { grid-template-columns: minmax(0,1fr) auto; align-items: center; padding-bottom: 0; border-bottom: 0; }
  .dossier.expanded .dossier-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .dossier h2 { margin: 0; font-size: 20px; }
  .dossier-head .eyebrow { margin-bottom: 4px; font-size: 8px; }
  .dossier-head > div > p:last-child { display: none; }
  .dossier-actions { align-items: stretch; }
  .fleet-return, .dossier-toggle { min-height: 44px; border: 1px solid var(--line); background: transparent; padding: 9px 11px; color: var(--muted); font: 650 9px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
  .dossier-toggle { display: block; min-width: 112px; color: var(--ink); background: var(--paper); }
  .dossier.expanded .dossier-toggle { color: var(--paper); background: rgba(240,90,26,.14); border-color: var(--orange); }
  .dossier:not(.expanded) .dossier-controls { display: none; }
  .dossier.expanded .dossier-controls { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  .mobile-dossier-tabs { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: repeat(3,1fr); gap: 3px; margin: 0 -18px; padding: 8px 18px; background: #101316; border-bottom: 1px solid var(--line); }
  .mobile-dossier-tabs button { min-height: 44px; border: 1px solid var(--line); background: transparent; padding: 8px; color: var(--muted); font: 650 10px/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
  .mobile-dossier-tabs button[aria-pressed="true"] { color: var(--ink); background: var(--paper); }
  [data-mobile-panel] { display: none; }
  [data-mobile-panel].mobile-active { display: block; }
  .inspection-row.mobile-active { display: flex; }
  .control-group { padding: 12px 0; }
  .control-label { font-size: 10px; }
  .button-row button, .system-row button, .state-list button { min-height: 44px; padding: 9px 10px; font-size: 10px; }
  .state-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .inspection-row label { min-height: 44px; font-size: 11px; }
  .inspection-row button { min-height: 44px; padding: 9px 0; font-size: 10px; }
  .cutaway-control label { font-size: 10px; }
  .cutaway-control output { font-size: 9px; }
  .cutaway-control input { min-height: 44px; }
  .proof { grid-template-columns: repeat(3, 1fr); }
  .proof span { font-size: 9px; }
  .proof .wide { grid-column: 1/-1; }
  .scope-note { font-size: 9px; }
  .story { left: 10px; right: 10px; bottom: calc(78px + env(safe-area-inset-bottom)); min-height: 76px; grid-template-columns: 36px 1fr auto; gap: 9px; padding: 10px; }
  .workspace.controls-open .story.open { transform: translateY(calc(100% + 120px)); pointer-events: none; }
  .story-actions { display: flex; gap: 4px; }
  .story-actions button { min-width: 44px; min-height: 44px; padding: 7px; font-size: 10px; }
  #story-show { min-width: 78px; padding: 7px 8px; }
  .story-copy > p:last-child { display: none; }
  .story-copy .eyebrow { font-size: 9px; }
  .story-copy h3 { font-size: 15px; }
  .labels { bottom: 80px; }
  .workspace.controls-open .labels { bottom: 52%; }
  .anatomy-label { font-size: 8px; padding: 6px 7px; }
  .workspace.overview-mode .story { display: none; }
}

@media (max-width: 430px) {
  .machine-switcher button { line-height: 1.15; }
  .stage-copy .eyebrow { max-width: 220px; }
  .story { min-height: 64px; grid-template-columns: minmax(0,1fr) auto; }
  .story-index, .story-copy .eyebrow { display: none; }
  .story-copy h3 { margin: 0; font-size: 14px; line-height: 1.15; }
  .inspection-row { flex-wrap: wrap; gap: 10px 16px; }
}

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