/* Layout: a full-bleed render with instruments docked to the corners, like an
   observatory console laid over a film frame. Single deliberate dark look. */
:root {
  --void: #050506;                       /* page ground */
  --ink: #ece6dc;                        /* warm paper white, ~5800 K */
  --ink-2: rgba(236, 230, 220, 0.68);
  --ink-3: rgba(236, 230, 220, 0.42);
  --line: rgba(236, 230, 220, 0.13);
  --glass: rgba(8, 8, 10, 0.76);      /* opaque enough to read without a blur, which is costly over a live render */
  --ember: #ffb46a;                      /* blackbody at ~2900 K */
  --ember-2: #ffd9a8;                    /* ~4000 K */
  --ice: #a9c6ff;                        /* ~20000 K, blueshift */
  --hot: #ff6a45;                        /* captured light */
  --font-display: 'Cormorant Garamond', 'Cormorant', 'Iowan Old Style', Georgia, serif;
  --font-body: 'IBM Plex Sans', 'Helvetica Neue', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --gutter: clamp(16px, 2.2vw, 28px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  outline: none;
}
#view.dragging { cursor: grabbing; }

.label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.mono { font-family: var(--font-mono); }

/* ------------------------------------------------------------------ chrome */
.ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.ui > * { pointer-events: auto; }
.ui.hidden-ui { opacity: 0; }
.ui.hidden-ui > * { pointer-events: none; }
body.intro-open .ui, body.ending-open .ui { opacity: 0; pointer-events: none; }
body.intro-open .ui > *, body.ending-open .ui > * { pointer-events: none; }

.brand {
  position: absolute;
  top: calc(var(--gutter) + var(--safe-t));
  left: var(--gutter);
  pointer-events: none;
}
.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.01em;
}
.tagline {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.tagline .dot { color: var(--ember); }

.toolbar {
  position: absolute;
  top: calc(var(--gutter) + var(--safe-t));
  right: var(--gutter);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
}
.tool {
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 999px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  transition: background 0.2s, color 0.2s;
}
.tool.text { padding: 0 14px; font-size: 13px; letter-spacing: 0.02em; }
.tool.icon { width: 34px; }
.tool:hover { background: rgba(236, 230, 220, 0.08); color: var(--ink); }
.tool[aria-pressed="true"], .tool[aria-expanded="true"], .tool.active { color: var(--ember-2); background: rgba(255, 180, 106, 0.1); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tool .off { display: inline; }
.tool .on { display: none; }
.tool[aria-pressed="true"] .on { display: inline; }
.tool[aria-pressed="true"] .off { display: none; }
.tool .short { display: none; }
.tool.text { white-space: nowrap; }
.sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

:focus-visible { outline: 1.5px solid var(--ember); outline-offset: 2px; }

.panel {
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--glass);
}

/* ------------------------------------------------------------------ instruments */
.instruments {
  left: var(--gutter);
  bottom: calc(var(--gutter) + var(--safe-b));
  width: 316px;
  padding: 14px 16px 12px;
  transition: opacity 0.4s;
}
.ins-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.ins-head strong {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 21px;
  line-height: 1;
  color: var(--ember-2);
}
.readouts { margin: 8px 0 0; display: grid; gap: 5px; }
.readouts > div { display: grid; grid-template-columns: 112px 1fr; align-items: baseline; gap: 8px; }
.readouts dt { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.readouts dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 0;
}
.readouts dd small { display: block; font-size: 11px; color: var(--ink-3); }
.readouts sub { font-size: 0.75em; }
.clocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.clocks > div { display: grid; gap: 2px; }
.clocks output {
  font-family: var(--font-mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
#clock-local { color: var(--ember-2); }
#clock-far { color: var(--ice); }
.playback {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ diagram */
.diagram {
  right: var(--gutter);
  bottom: calc(var(--gutter) + var(--safe-b));
  width: 236px;
  margin: 0;
  padding: 10px 10px 12px;
}
.diagram canvas { display: block; width: 214px; height: 214px; margin: 0 auto; }
.diagram figcaption { display: grid; gap: 6px; padding: 4px 4px 0; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li::before { content: ''; width: 12px; height: 2px; border-radius: 2px; background: currentColor; }
.legend .sky::before { background: var(--ice); }
.legend .disk::before { background: var(--ember); }
.legend .hole::before { background: var(--hot); }

/* ------------------------------------------------------------------ hint, toast */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--gutter) + var(--safe-b) + 6px);
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 1.2s;
}
.hint.gone { opacity: 0; }
.toast {
  position: absolute;
  top: calc(var(--gutter) + var(--safe-t) + 64px);
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s;
  max-width: calc(100vw - 2 * var(--gutter));
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ tour caption */
.caption {
  position: absolute;
  left: 50%;
  bottom: calc(var(--gutter) + var(--safe-b));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 2 * var(--gutter) - 2 * 300px - 40px));
  min-width: 380px;
  padding: 18px 22px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 8, 10, 0.66), rgba(8, 8, 10, 0.86));
  animation: rise 0.7s cubic-bezier(.2, .7, .2, 1);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } }
.cap-head { display: flex; align-items: center; gap: 12px; }
.count { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; color: var(--ember); }
.progress { flex: 1; height: 1px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--ember); }
.caption h2 {
  margin: 10px 0 6px;
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.caption p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); font-weight: 300; text-wrap: pretty; }
.caption p.swap { animation: fadein 0.6s ease; }
@keyframes fadein { from { opacity: 0; } }
.cap-control { margin-top: 12px; }
.cap-control:empty { display: none; }
.cap-nav { display: flex; gap: 8px; margin-top: 14px; }
.cap-nav button, .intro-actions button, .reset {
  border: 1px solid var(--line);
  background: rgba(236, 230, 220, 0.04);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.cap-nav button:hover, .intro-actions button:hover, .reset:hover { color: var(--ink); background: rgba(236, 230, 220, 0.09); }
.cap-nav button:disabled { opacity: 0.35; cursor: default; }
#cap-exit { margin-right: auto; }
.cap-nav .primary, .intro-actions .primary {
  color: #1a1206;
  background: var(--ember-2);
  border-color: var(--ember-2);
  font-weight: 500;
}
.cap-nav .primary:hover, .intro-actions .primary:hover { background: #ffe6c4; color: #1a1206; }

/* ------------------------------------------------------------------ controls */
.drawer {
  position: absolute;
  top: calc(var(--gutter) + var(--safe-t) + 54px);
  right: var(--gutter);
  bottom: calc(var(--gutter) + var(--safe-b));
  width: 320px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 8, 10, 0.9);
  animation: slidein 0.45s cubic-bezier(.2, .7, .2, 1);
  z-index: 3;
}
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 24px; }
.drawer-body { overflow-y: auto; padding: 4px 16px 16px; overscroll-behavior: contain; }
.close {
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
.close:hover { background: rgba(236, 230, 220, 0.08); color: var(--ink); }
.close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; }
.group { padding: 14px 0 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.group h3 { margin: 0; font-family: var(--font-mono); font-weight: 400; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.note { margin: 0; font-size: 12px; color: var(--ink-3); line-height: 1.45; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; }
.seg button {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
#seg-mass { display: grid; grid-template-columns: 1fr 1fr; }
.seg button:hover { color: var(--ink); background: rgba(236, 230, 220, 0.06); }
.seg button[aria-checked="true"] { background: rgba(255, 180, 106, 0.14); color: var(--ember-2); }

.slider { display: grid; gap: 6px; }
.slider .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--ink-2); }
.slider output { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: var(--track, var(--line)); }
input[type="range"]::-moz-range-track { height: 2px; border-radius: 2px; background: var(--track, var(--line)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--void);
  box-shadow: 0 0 0 1px var(--ink-3);
}
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); border: 3px solid var(--void); box-shadow: 0 0 0 1px var(--ink-3); }
.slider.temp input { --track: linear-gradient(90deg, var(--bb-stops)); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 30px; height: 17px; border-radius: 999px; background: rgba(236, 230, 220, 0.14); position: relative; cursor: pointer; flex: none; margin: 0; transition: background 0.2s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--ink-2); transition: transform 0.2s, background 0.2s; }
.switch input:checked { background: rgba(255, 180, 106, 0.45); }
.switch input:checked::after { transform: translateX(13px); background: var(--ember-2); }
.reset { margin-top: 16px; width: 100%; }

/* ------------------------------------------------------------------ intro & ending */
.intro, .ending {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--gutter) + var(--safe-t)) var(--gutter) calc(var(--gutter) + var(--safe-b));
  background: radial-gradient(ellipse at 50% 55%, rgba(5, 5, 6, 0.15), rgba(5, 5, 6, 0.75) 70%);
  z-index: 10;
  transition: opacity 1.1s ease;
}
.intro.leaving, .ending.leaving { opacity: 0; pointer-events: none; }
.intro { place-items: end center; background: linear-gradient(180deg, rgba(5, 5, 6, 0) 30%, rgba(5, 5, 6, 0.7) 78%); }
.intro-inner { max-width: 900px; text-align: center; display: grid; justify-items: center; gap: 18px; margin-bottom: clamp(48px, 9vh, 110px); }
.eyebrow { margin: 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ember); }
.intro-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(54px, 10.5vw, 128px);
  line-height: 0.9;
  white-space: nowrap;
  letter-spacing: -0.02em;
  text-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}
.lede { margin: 0; max-width: 34em; font-size: 16px; line-height: 1.65; font-weight: 300; color: var(--ink-2); text-wrap: balance; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.intro-actions button { padding: 12px 22px; font-size: 14px; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.intro-actions button small { font-size: 11px; font-weight: 400; opacity: 0.7; }
.intro-actions button:disabled { opacity: 0.4; cursor: progress; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-3); cursor: pointer; }
.check input { accent-color: var(--ember); }
.status { margin: 0; min-height: 1.5em; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--ink-3); }
.intro-foot {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--gutter) + var(--safe-b));
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.ending { background: rgba(5, 5, 6, 0.4); align-content: center; gap: 22px; }
.ending p {
  max-width: 30em;
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.35;
  text-wrap: balance;
  animation: fadein 2s ease;
}

/* ------------------------------------------------------------------ modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(var(--gutter) + var(--safe-t)) var(--gutter) calc(var(--gutter) + var(--safe-b));
  background: rgba(3, 3, 4, 0.66);
  animation: fadein 0.35s ease;
}
.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 34px 40px 30px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 10, 12, 0.92);
  overscroll-behavior: contain;
}
.modal-card .close { position: absolute; top: 14px; right: 14px; }
.modal-card h2 { margin: 8px 0 18px; font-family: var(--font-display); font-weight: 300; font-size: 40px; line-height: 1.05; text-wrap: balance; }
.modal-card h3 { margin: 28px 0 8px; font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 24px; color: var(--ember-2); }
.modal-card p, .modal-card li { font-size: 14.5px; line-height: 1.7; color: var(--ink-2); font-weight: 300; max-width: 62ch; }
.modal-card p { margin: 0 0 10px; }
.modal-card em { color: var(--ink); font-style: italic; }
.eq {
  font-family: var(--font-display);
  font-size: 22px !important;
  color: var(--ink) !important;
  text-align: center;
  padding: 10px 0;
  margin: 6px 0 14px !important;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  max-width: none !important;
}
.facts { padding-left: 18px; margin: 0; }
.facts li { margin-bottom: 4px; }
.keys { display: grid; gap: 6px; margin: 0; }
.keys > div { display: grid; grid-template-columns: 180px 1fr; gap: 12px; font-size: 13px; }
.keys dt { font-family: var(--font-mono); font-size: 12px; color: var(--ink); }
.keys dd { margin: 0; color: var(--ink-2); }

.fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: var(--gutter);
  text-align: center;
  background: var(--void);
}
.fallback h2 { margin: 0; font-family: var(--font-display); font-weight: 300; font-size: 40px; }
.fallback p { margin: 0 auto; max-width: 36em; color: var(--ink-2); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .hint { display: none; }
  .caption { width: min(520px, calc(100vw - 2 * var(--gutter))); min-width: 0; bottom: calc(var(--gutter) + var(--safe-b) + 0px); }
  body.touring .instruments, body.touring .diagram { opacity: 0; pointer-events: none; }
}
@media (max-width: 760px) {
  .wordmark { font-size: 24px; }
  .tagline { font-size: 10px; }
  .toolbar { top: auto; bottom: calc(var(--gutter) + var(--safe-b)); left: var(--gutter); right: var(--gutter); justify-content: space-between; }
  .tool.text { padding: 0 10px; font-size: 12.5px; }
  .tool .long { display: none; }
  .tool .short { display: inline; }
  #btn-full { display: none; }
  .eyebrow { font-size: 10px; letter-spacing: 0.14em; }
  .diagram { display: none; }
  .hint { display: none; }
  .instruments {
    top: calc(var(--gutter) + var(--safe-t) + 58px);
    bottom: auto;
    left: var(--gutter);
    right: var(--gutter);
    width: auto;
    padding: 9px 12px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
  }
  .ins-head { grid-column: 1 / -1; padding-bottom: 6px; }
  .readouts { margin-top: 6px; grid-column: 1 / -1; grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .readouts > div { grid-template-columns: 1fr; gap: 0; }
  .instruments .readouts > div:nth-child(n+3), .instruments .playback { display: none; }
  .readouts dd { font-size: 12px; }
  .readouts dd small { display: none; }
  .clocks { grid-column: 1 / -1; margin-top: 8px; padding-top: 6px; }
  body.controls-open .instruments { display: none; }
  .toast { top: auto; bottom: calc(var(--gutter) + var(--safe-b) + 62px); }
  .ins-head strong { font-size: 17px; }
  .clocks output { font-size: 13px; }
  .caption { bottom: calc(var(--gutter) + var(--safe-b) + 54px); padding: 14px 16px 12px; }
  .caption h2 { font-size: 28px; }
  .caption p { font-size: 13.5px; }
  .drawer { top: auto; left: var(--gutter); right: var(--gutter); width: auto; height: 62vh; bottom: calc(var(--gutter) + var(--safe-b) + 54px); }
  .modal-card { padding: 28px 22px 22px; }
  .modal-card h2 { font-size: 30px; }
  .keys > div { grid-template-columns: 1fr; gap: 0; }
  .intro-foot { justify-content: center; text-align: center; }
  body.touring .instruments { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
