:root {
  color-scheme: dark;
  --void: #07090c;
  --panel: #10151b;
  --line: #27313b;
  --ink: #eeeae2;
  --muted: #adb6be;
  --dim: #8f9ca8;
  --accent: #ef4f2f;
  --accent-soft: #ffb68d;
  --data: #4cc9f0;
  --weights: #9aa2ff;
  --kv: #35d39a;
  --heat: #ff8a4c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sidebar: 330px;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button,
select,
input {
  font: inherit;
}
button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}
button,
select {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--data);
  outline-offset: 4px;
}
a {
  color: var(--data);
}
#scene-view {
  position: fixed;
  left: calc(var(--sidebar) + 48px);
  right: 20px;
  top: 142px;
  bottom: 145px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--void);
}
#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#stage.dragging {
  cursor: grabbing;
}
#annotations {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}
.anno {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 11px/1.4 var(--mono);
  white-space: nowrap;
  padding: 5px 8px;
  border-radius: 4px;
  color: var(--ink);
  background: rgba(7, 9, 12, 0.92);
  border: 1px solid var(--line);
  opacity: 0;
}
.anno.visible {
  opacity: 1;
}
.anno b {
  font-weight: 600;
  color: #fff;
}
.anno i {
  font-style: normal;
  color: var(--muted);
}
.anno[data-tone="data"] {
  border-color: var(--data);
}
.anno[data-tone="weights"] {
  border-color: var(--weights);
}
.anno[data-tone="kv"] {
  border-color: var(--kv);
}
.anno[data-tone="compute"] {
  border-color: var(--accent);
}
.anno[data-tone="quiet"] {
  color: var(--muted);
}
#dip {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: var(--void);
}
.boot {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 6vw;
  overflow-y: auto;
  background:
    linear-gradient(
      90deg,
      #07090c 25%,
      rgba(7, 9, 12, 0.95) 42%,
      rgba(7, 9, 12, 0.3) 85%
    ),
    radial-gradient(ellipse at 15% 0%, #153039, transparent 65%);
  transition: opacity 400ms ease;
}
.boot.gone {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.boot-card {
  max-width: 610px;
}
.eyebrow {
  font: 10px/1.5 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--data);
  margin: 0 0 24px;
}
.boot-card h1 {
  font-size: clamp(48px, 6.6vw, 88px);
  line-height: 0.98;
  letter-spacing: -0.065em;
  margin: 0;
  font-weight: 500;
  max-width: 8ch;
}
.tagline {
  font-size: clamp(20px, 2.3vw, 29px);
  color: var(--accent-soft);
  margin: 20px 0;
  letter-spacing: -0.03em;
}
.blurb {
  font-size: 16px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 48ch;
  margin: 0 0 26px;
}
.act-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 26px;
  max-width: 540px;
}
.act-cards > div {
  border-top: 1px solid var(--data);
  padding-top: 12px;
}
.act-cards > div + div {
  border-color: var(--accent);
}
.act-cards span {
  font: 9px var(--mono);
  letter-spacing: 0.09em;
  color: var(--data);
}
.act-cards > div + div span {
  color: var(--accent-soft);
}
.act-cards strong {
  display: block;
  font-size: 15px;
  font-weight: 500;
  margin-top: 12px;
}
.act-cards p {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
  margin: 7px 0 0;
}
#boot-start {
  background: var(--ink);
  color: var(--void);
  border: 0;
  border-radius: 5px;
  padding: 15px 23px;
  font-size: 14px;
  font-weight: 600;
}
#boot-start:hover {
  background: var(--data);
}
.boot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
  color: var(--muted);
  font-size: 12px;
}
.boot-toggle input {
  accent-color: var(--data);
  width: 16px;
  height: 16px;
}
.reading-link {
  border: 0;
  background: none;
  color: var(--muted);
  font: 11px var(--mono);
  padding: 12px 0;
}
.reading-link:hover {
  color: var(--data);
}
.boot-card > .reading-link {
  display: block;
  margin-top: 12px;
}
.boot-note {
  font: 10px/1.6 var(--mono);
  color: var(--dim);
  margin: 12px 0 0;
}
.topbar {
  position: fixed;
  inset: 0 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.home {
  font: 12px var(--mono);
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 12px 10px;
  color: var(--ink);
  text-decoration: none;
}
.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.topbar-title strong {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.topbar-title span {
  font-size: 11px;
  color: var(--dim);
}
.topbar > .reading-link {
  margin-left: auto;
}
.scale-readout {
  text-align: right;
  margin-left: 22px;
  font-family: var(--mono);
}
.scale-label {
  display: block;
  color: var(--dim);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.15em;
}
.scale-value {
  font-size: 13px;
  color: var(--accent-soft);
}
.journey {
  position: fixed;
  top: 91px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.journey-heading {
  display: flex;
  align-items: center;
  gap: 24px;
  font: 10px var(--mono);
  letter-spacing: 0.08em;
}
#act-label {
  color: var(--data);
}
body[data-phase="request"] #act-label {
  color: var(--accent-soft);
}
#world-label {
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 24px;
}
#chapter-select {
  max-width: 380px;
  width: 40%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--panel);
  font: 11px var(--mono);
}
.story-panel {
  position: fixed;
  left: 24px;
  width: var(--sidebar);
  top: 142px;
  bottom: 112px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 8px;
}
.narration {
  padding: 2px 0 22px;
}
.chapter-phase {
  display: none;
}
.chapter-index {
  font: 11px var(--mono);
  color: var(--dim);
  margin: 0 0 15px;
}
#chapter-number {
  color: var(--data);
}
.narration h2 {
  font-size: 31px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.045em;
  margin: 0 0 20px;
}
.plain {
  font-size: 14px;
  line-height: 1.75;
  color: #c6cdd1;
  margin: 0;
}
#chapter-detail-wrap {
  margin-top: 18px;
}
summary {
  cursor: pointer;
  font: 10px var(--mono);
  color: var(--data);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 6px 0;
}
.detail {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0;
  margin: 15px 0 0;
}
.facts li {
  font: 10px/1.5 var(--mono);
  color: var(--accent-soft);
  border: 1px solid #513428;
  padding: 4px 7px;
  border-radius: 3px;
}
.hud {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}
.hud h3 {
  color: var(--dim);
  font: 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  margin: 0 0 16px;
}
.hud dl {
  margin: 0;
  display: grid;
  gap: 10px;
}
.hud .row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 5px 10px;
}
.hud dt {
  color: var(--muted);
  font-size: 12px;
}
.hud dd {
  margin: 0;
  font: 13px var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hud .unit {
  color: var(--dim);
  font-size: 10px;
}
.hud .bar {
  grid-column: 1/-1;
  height: 3px;
  background: #1d252c;
  overflow: hidden;
}
.hud .bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.hud .bar[data-tone="data"] span {
  background: var(--data);
}
.hud .bar[data-tone="weights"] span {
  background: var(--weights);
}
.hud .bar[data-tone="kv"] span {
  background: var(--kv);
}
.hud .bar[data-tone="heat"] span {
  background: var(--heat);
}
.hud-note {
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim);
  margin: 14px 0 0;
}
.hud-note:empty {
  display: none;
}
.scene-caption {
  position: fixed;
  top: 154px;
  left: calc(var(--sidebar) + 64px);
  right: 36px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  font: 9px/1.5 var(--mono);
  color: var(--muted);
  z-index: 4;
  pointer-events: none;
}
.scene-caption > span {
  background: #07090cdd;
  padding: 4px 6px;
  border-radius: 3px;
}
.scene-status {
  color: var(--data);
}
.legend {
  position: fixed;
  left: calc(var(--sidebar) + 48px);
  right: 20px;
  bottom: 118px;
  display: flex;
  gap: 22px;
  justify-content: center;
  font: 10px var(--mono);
  color: var(--muted);
}
.legend span::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--data);
  margin-right: 7px;
}
.legend [data-tone="weights"]::before {
  background: var(--weights);
}
.legend [data-tone="kv"]::before {
  background: var(--kv);
}
.legend [data-tone="compute"]::before {
  background: var(--accent);
}
.transport {
  position: fixed;
  inset: auto 0 0;
  padding: 10px 24px 15px;
  z-index: 5;
  background: var(--void);
  border-top: 1px solid var(--line);
}
.rail {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
}
.rail button {
  flex: 1;
  position: relative;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
}
.rail button::after {
  content: "";
  position: absolute;
  inset: 8px 0 auto;
  height: 3px;
  background: #29323a;
}
.rail button[aria-selected="true"]::after {
  background: var(--accent);
  height: 5px;
}
.rail button.done::after {
  background: #784637;
}
.rail button[data-phase="preparation"][aria-selected="true"]::after {
  background: var(--data);
}
.rail button[data-phase="preparation"].done::after {
  background: #2c687d;
}
.act-break {
  width: 10px;
}
.tip {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font: 10px var(--mono);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.rail button:first-child .tip {
  left: 0;
  transform: none;
}
.rail button:last-child .tip {
  left: auto;
  right: 0;
  transform: none;
}
.rail button:hover .tip,
.rail button:focus-visible .tip {
  opacity: 1;
}
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls button,
#close-reading {
  color: var(--ink);
  background: #111820;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  font: 11px var(--mono);
  min-height: 38px;
}
.controls button:hover {
  border-color: var(--muted);
}
.controls button.primary {
  background: var(--ink);
  color: var(--void);
  min-width: 46px;
}
#recenter {
  color: var(--dim);
}
#recenter.armed {
  color: var(--data);
  border-color: var(--data);
}
#sound[aria-pressed="true"] {
  color: var(--data);
}
#sound:disabled {
  opacity: 0.45;
}
.scrub {
  --progress: 0%;
  flex: 1;
  min-width: 35px;
  width: 100%;
  height: 28px;
  margin: 0 8px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.scrub::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(
    to right,
    var(--data) var(--progress),
    #29323a var(--progress)
  );
}
.scrub::-webkit-slider-thumb {
  appearance: none;
  height: 13px;
  width: 13px;
  border-radius: 50%;
  background: var(--ink);
  margin-top: -5px;
}
.scrub::-moz-range-track {
  height: 3px;
  background: #29323a;
}
.scrub::-moz-range-progress {
  height: 3px;
  background: var(--data);
}
.scrub::-moz-range-thumb {
  height: 13px;
  width: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}
.chapter-time {
  font: 10px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.crash,
.fallback {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--void);
  display: grid;
  place-content: center;
  padding: 30px;
  text-align: center;
}
.crash p,
.fallback p {
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.7;
}
code {
  color: var(--accent-soft);
}
#reading-view {
  max-width: 850px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 32px);
  padding: 32px 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #10151b;
  color: var(--ink);
}
#reading-view::backdrop {
  background: #000c;
  backdrop-filter: blur(10px);
}
.reading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  color: var(--data);
  font: 10px var(--mono);
}
#reading-view h1 {
  font-weight: 500;
  font-size: 42px;
  line-height: 1.06;
  letter-spacing: -0.04em;
  margin: 40px 0 20px;
}
#reading-view p {
  font-size: 15px;
  line-height: 1.8;
  color: var(--muted);
}
#reading-chapters section {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 20px;
}
#reading-chapters h2 {
  font-size: 24px;
  font-weight: 500;
}
@media (min-width: 1500px) {
  :root {
    --sidebar: 380px;
  }
  .narration h2 {
    font-size: 38px;
  }
  .plain {
    font-size: 16px;
  }
}
@media (max-width: 900px) {
  .topbar {
    height: 60px;
    padding: 0 14px;
    gap: 12px;
  }
  .topbar-title strong {
    font-size: 13px;
  }
  .topbar-title span,
  .scale-label,
  .scene-caption > span:last-child {
    display: none;
  }
  .topbar > .reading-link {
    font-size: 9px;
  }
  .scale-readout {
    margin-left: 0;
  }
  .scale-value {
    font-size: 11px;
  }
  .home {
    padding: 8px;
    font-size: 10px;
  }
  .journey {
    top: 73px;
    left: 14px;
    right: 14px;
    gap: 10px;
  }
  .journey-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    font-size: 8px;
  }
  #world-label {
    border: 0;
    padding: 0;
  }
  #chapter-select {
    width: 52%;
    padding: 9px 6px;
    font-size: 10px;
  }
  #scene-view {
    left: 12px;
    right: 12px;
    top: 122px;
    bottom: calc(36dvh + 122px);
    border-radius: 9px;
  }
  .scene-caption {
    top: 130px;
    left: 20px;
    right: 20px;
    font-size: 8px;
  }
  .legend {
    left: 12px;
    right: 12px;
    bottom: calc(36dvh + 101px);
    gap: 12px;
    font-size: 8px;
  }
  .legend span::before {
    width: 5px;
    height: 5px;
    margin-right: 4px;
  }
  .story-panel {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 91px;
    height: 36dvh;
    width: auto;
    padding: 14px 4px 0 0;
    border-top: 1px solid var(--line);
  }
  .narration {
    padding-bottom: 16px;
  }
  .chapter-index {
    font-size: 9px;
    margin-bottom: 8px;
  }
  .narration h2 {
    font-size: 26px;
    margin-bottom: 12px;
  }
  .plain {
    font-size: 13px;
    line-height: 1.65;
  }
  .hud {
    padding-top: 15px;
  }
  .transport {
    padding: 5px 12px max(9px, env(safe-area-inset-bottom));
  }
  .rail {
    margin-bottom: 3px;
    gap: 3px;
  }
  .rail button {
    height: 18px;
  }
  .controls {
    gap: 5px;
  }
  .controls button {
    padding: 9px 8px;
    min-height: 36px;
    font-size: 10px;
  }
  .controls button.primary {
    min-width: 35px;
  }
  .chapter-time {
    display: none;
  }
  #sound-label {
    display: none;
  }
  .scrub {
    margin: 0 4px;
  }
  .anno {
    font-size: 9px;
    white-space: normal;
    max-width: 150px;
    text-align: center;
  }
  .boot {
    padding: 28px;
    background:
      radial-gradient(ellipse at 100% 0%, #16303b, transparent 65%), #07090cf5;
  }
  .boot-card {
    margin: auto;
  }
  .boot-card h1 {
    font-size: clamp(48px, 11vw, 78px);
  }
  .blurb {
    font-size: 14px;
  }
  .act-cards {
    gap: 16px;
  }
  .act-cards strong {
    font-size: 13px;
  }
  .act-cards span {
    font-size: 8px;
  }
  .boot-toggle {
    margin-left: 10px;
    font-size: 11px;
  }
  #boot-start {
    padding: 14px 16px;
    font-size: 12px;
  }
  #reading-view {
    padding: 22px;
  }
  .reading-header {
    font-size: 8px;
  }
  #reading-view h1 {
    font-size: 32px;
  }
}
@media (max-height: 560px) and (min-width: 650px) {
  :root {
    --sidebar: 270px;
  }
  #scene-view {
    left: 305px;
    top: 122px;
    bottom: 105px;
  }
  .story-panel {
    left: 16px;
    top: 122px;
    bottom: 92px;
    width: 270px;
    height: auto;
  }
  .legend {
    left: 305px;
    bottom: 86px;
  }
  .scene-caption {
    left: 315px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@media (max-width: 900px) {
  #recenter {
    font-size: 0;
    padding: 9px;
  }
  #recenter::after {
    content: "↺";
    font-size: 14px;
  }
}
