/* Theoria shared shell: layout, type and controls used by every concept page. */
@font-face {
  font-family: Inter;
  src: url('../fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #070b12;
  --glass: rgba(11, 17, 28, .72);
  --glass-border: rgba(255, 255, 255, .09);
  --ink: #eef3f8;
  --ink-2: #bccad7;
  --ink-3: #8b9cae;
  --ink-4: #66788b;
  --line: rgba(255, 255, 255, .14);
  --accent: #a9dfee;
  --gutter: 32px;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.55 Inter, system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
[hidden] { display: none !important; }

.stage { position: relative; height: 100svh; min-height: 520px; isolation: isolate; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; outline: 0; display: block; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }

/* Top bar */
.topbar {
  position: absolute; z-index: 5;
  top: max(20px, env(safe-area-inset-top)); left: var(--gutter); right: var(--gutter);
  display: flex; align-items: center; gap: 20px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.wordmark { color: inherit; text-decoration: none; display: flex; align-items: baseline; gap: 14px; }
.wordmark b { font-size: 16px; letter-spacing: .3em; font-weight: 600; }
.wordmark span { font-size: 13px; color: var(--ink-3); }
.view-switch {
  margin-left: auto; display: flex; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(7, 11, 18, .5);
}
.view-switch button { padding: 7px 16px; border-radius: 999px; font-size: 13px; color: var(--ink-3); transition: background .25s, color .25s; }
.view-switch button.active { background: rgba(255, 255, 255, .12); color: var(--ink); }
.icon-button {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--ink-2); font-size: 15px;
}
.icon-button:hover { border-color: rgba(255, 255, 255, .45); color: #fff; }
.icon-button svg { width: 16px; height: 16px; }

/* Guided tour card */
.story {
  position: absolute; z-index: 4;
  top: 84px; left: var(--gutter); width: 360px;
  padding: 20px 22px 18px;
  max-height: calc(100svh - 84px - 150px); overflow-y: auto;
}
.story-head { display: flex; align-items: center; justify-content: space-between; }
.story-collapse { width: 30px; height: 30px; display: grid; place-items: center; color: var(--ink-3); border-radius: 50%; margin: -6px -8px -6px 0; }
.story-collapse svg { width: 14px; height: 14px; transition: transform .25s; }
.story.collapsed .story-collapse svg { transform: rotate(180deg); }
.story.collapsed .story-body { display: none; }
.story h1 { font-size: 26px; font-weight: 400; letter-spacing: -.03em; line-height: 1.18; margin: 12px 0 10px; }
.story-text p { margin: 0 0 10px; color: var(--ink-2); font-size: 14.5px; }
.story-text b { color: var(--ink); font-weight: 550; }
.notice, .maths { margin: 12px 0 0; font-size: 13px; color: var(--ink-2); }
.notice span, .maths span { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 3px; }
.maths { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14px; }
.story-nav { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.more-toggle { display: none; font-size: 13px; color: var(--accent); padding: 2px 0; }
.dots { display: flex; gap: 6px; margin: 0 auto; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .18); transition: background .3s; }
.dots i.on { background: var(--accent); }
.primary-button {
  padding: 9px 18px; border-radius: 999px; background: #e6f2f7; color: #08111b; font-weight: 550; font-size: 13.5px;
}
.primary-button:hover { background: #fff; }
.text-button { padding: 9px 4px; color: var(--ink-2); font-size: 13.5px; }
.text-button:hover { color: #fff; }

/* Swatches used in text and chips */
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); vertical-align: 0; margin: 0 2px; }

/* Live readings, top right */
.readout {
  position: absolute; z-index: 4;
  top: 84px; right: var(--gutter); width: 320px;
  padding: 10px 16px;
}
.readout-row {
  display: grid; grid-template-columns: 14px 1fr auto; column-gap: 8px; align-items: baseline;
  padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, .07);
}
.readout-row:first-child { border-top: 0; }
.readout-row .swatch { align-self: center; }
.readout-row .who { font-size: 13.5px; color: var(--ink); }
.readout-row .who small { display: block; font-size: 12px; color: var(--ink-3); }
.readout-row strong { font-size: 22px; font-weight: 400; letter-spacing: -.02em; font-variant-numeric: tabular-nums; align-self: center; }
.readout-row .sub { grid-column: 2 / 4; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
#row-far strong { font-size: 17px; color: var(--ink-2); }

/* Segmented control inside the readout, e.g. "Seen from" */
.frame-switch { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 4px 0 10px; }
.frame-switch > span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); margin-right: 6px; }
.frame-switch button {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--ink-3);
  transition: background .2s, color .2s;
}
.frame-switch button.active { background: rgba(255, 255, 255, .12); color: var(--ink); border-color: rgba(255, 255, 255, .3); }
.frame-switch + .readout-row { border-top: 1px solid rgba(255, 255, 255, .07); }
.settings .toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 10px 0 4px; cursor: pointer; }
.settings .toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Layers & settings panel */
.panel {
  position: absolute; z-index: 4;
  right: var(--gutter); bottom: 104px; width: 290px;
  padding: 16px 18px;
  max-height: calc(100svh - 180px); overflow-y: auto;
}
.panel.sheet-closed { display: none; }
#panel-toggle { display: inline-flex; align-items: center; gap: 6px; }
#panel-toggle[aria-expanded="true"] { color: #fff; }
.panel .eyebrow { display: block; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-3); transition: all .2s;
}
.chip .swatch { opacity: .35; box-shadow: none; }
.chip.active { color: var(--ink); border-color: rgba(255, 255, 255, .32); background: rgba(255, 255, 255, .07); }
.chip.active .swatch { opacity: 1; box-shadow: 0 0 8px var(--c); }
.settings { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 4px; }
.settings summary { cursor: pointer; padding: 8px 0; font-size: 13px; color: var(--ink-2); list-style: none; display: flex; justify-content: space-between; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: '+'; color: var(--ink-3); }
.settings[open] summary::after { content: '−'; }
.settings label { display: block; margin: 6px 0 2px; }
.settings label > span { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.settings output { margin-left: auto; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.settings .hint { font-size: 12px; color: var(--ink-4); margin: 8px 0 2px; }

/* Transport */
.transport {
  position: absolute; z-index: 5;
  left: var(--gutter); right: var(--gutter); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 18px;
  padding: 12px 18px;
}
.round-button {
  width: 42px; height: 42px; flex: none; border-radius: 50%; background: #e6f2f7; color: #08111b;
  display: grid; place-items: center;
}
.round-button svg { width: 15px; height: 15px; }
.timeline { flex: 1; min-width: 0; }
.timeline-label { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--ink-3); }
.timeline-label b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 14px; margin: 0 3px 0 6px; }
.timeline-label .note { color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0;
  background: transparent; cursor: pointer; touch-action: pan-y; --progress: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--progress), rgba(255, 255, 255, .16) var(--progress));
}
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .16); }
input[type=range]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%;
  background: #eef7fb; box-shadow: 0 0 0 4px rgba(169, 223, 238, .18);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #eef7fb; }

/* Labels pinned to 3D points */
.labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.scene-label { position: absolute; left: 0; top: 0; visibility: hidden; will-change: transform; }
.scene-label .tag {
  transform: translate(16px, -50%); white-space: nowrap;
  text-shadow: 0 1px 10px var(--bg), 0 0 4px var(--bg), 0 0 2px var(--bg);
}
.scene-label .name { display: flex; align-items: center; gap: 7px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); font-weight: 600; }
.scene-label .name small { letter-spacing: 0; text-transform: none; color: var(--ink-3); font-size: 12px; }
.scene-label strong { display: block; font-size: 24px; font-weight: 400; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 2px 0 0; }
.scene-label .detail { display: block; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.scene-label.flip:not(.landmark) .tag { transform: translate(calc(-100% - 16px), -50%); text-align: right; }
.scene-label.flip:not(.landmark) .name { justify-content: flex-end; }
.scene-label.landmark .tag { transform: translate(-50%, 10px); text-align: center; }
.scene-label.landmark .name { font-size: 10.5px; color: var(--ink-3); justify-content: center; }

/* Toast */
#toast {
  position: absolute; z-index: 6; top: 70px; left: 50%; transform: translate(-50%, -6px);
  padding: 8px 16px; border-radius: 999px; background: rgba(11, 17, 28, .85); border: 1px solid var(--glass-border);
  font-size: 13px; color: var(--ink-2); opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Notes dialog */
dialog.notes {
  background: rgba(10, 15, 24, .96); color: var(--ink-2); border: 1px solid var(--glass-border); border-radius: 18px;
  padding: 36px 40px; width: min(640px, calc(100vw - 32px)); max-height: 86svh; font-size: 14px; line-height: 1.65;
}
dialog.notes::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); }
dialog.notes h2 { font-size: 28px; font-weight: 400; letter-spacing: -.03em; line-height: 1.2; color: var(--ink); margin: 10px 0 16px; }
dialog.notes h3 { font-size: 15px; font-weight: 550; color: var(--ink); margin: 24px 0 6px; }
dialog.notes p { margin: 0 0 10px; }
dialog.notes .eq { display: block; margin: 6px 0 10px; padding: 8px 12px; border-radius: 8px; background: rgba(255, 255, 255, .05); color: var(--ink); font-variant-numeric: tabular-nums; }
dialog.notes .honest { border-left: 2px solid var(--accent); padding-left: 14px; color: var(--ink-3); }
dialog.notes a { color: var(--accent); text-underline-offset: 3px; }
dialog.notes .close { position: absolute; right: 16px; top: 16px; }
dialog.notes .version { display: block; margin-top: 22px; font-size: 11px; letter-spacing: .12em; color: var(--ink-4); text-transform: uppercase; }

#fallback { position: absolute; inset: 30% 10%; z-index: 10; text-align: center; color: var(--ink-2); }
#fallback h2 { font-weight: 400; color: var(--ink); }

/* Tablet and narrower */
@media (max-width: 1080px) {
  .story { width: 320px; }
  .story h1 { font-size: 23px; }
  .panel { width: 250px; }
}

/* Phones and narrow windows: tour card on top, settings in a sheet */
@media (max-width: 720px) {
  :root { --gutter: 12px; }
  .wordmark span { display: none; }
  .wordmark b { font-size: 14px; }
  .view-switch button { padding: 6px 12px; }
  .story { top: 64px; left: 12px; right: 12px; width: auto; padding: 14px 16px; max-height: 44svh; }
  .story h1 { font-size: 20px; margin: 8px 0 6px; }
  .story-text p { font-size: 14px; margin-bottom: 6px; }
  .notice, .maths { font-size: 13px; margin-top: 8px; }
  .story:not(.more) .notice, .story:not(.more) .maths { display: none; }
  .more-toggle { display: inline-block; }
  .story-nav { margin-top: 12px; }
  .panel { left: 12px; right: 12px; width: auto; bottom: 86px; }
  .readout {
    top: auto; bottom: 98px; left: 12px; right: 12px; width: auto; padding: 6px 12px;
    display: flex; flex-wrap: wrap; gap: 4px 14px;
  }
  .readout-row { display: flex; gap: 6px; align-items: center; border: 0; padding: 2px 0; }
  .readout-row .who small, .readout-row .sub { display: none; }
  .readout-row .who { font-size: 12px; color: var(--ink-3); }
  .readout-row strong, #row-far strong { font-size: 15px; color: var(--ink); }
  .transport { gap: 10px; padding: 10px 12px; }
  .timeline-label .note { display: none; }
  .scene-label strong { font-size: 19px; }
  .scene-label .detail { font-size: 11px; }
  dialog.notes { padding: 28px 22px; }
  dialog.notes h2 { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Long text values in the readout (e.g. "back first, by 1.50 s") use a smaller size. */
.readout-row strong.text-value { font-size: 15px; letter-spacing: 0; text-align: right; }

/* ---------------------------------------------------------------- v2 controls (dock, markers, tooltip) */
.dock { gap: 22px; padding: 10px 14px 10px 12px; }
.dock .timeline { min-width: 200px; }
.track { position: relative; }
.markers { position: absolute; left: 8px; right: 8px; top: 0; bottom: 0; pointer-events: none; }
.marker { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.marker i { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(7, 11, 18, .9), 0 0 10px var(--c); }
.marker b {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 10.5px; font-weight: 500; color: var(--ink-2); letter-spacing: .02em;
  text-shadow: 0 0 6px var(--bg), 0 0 3px var(--bg);
}
.dock-group { display: flex; flex-direction: column; gap: 5px; flex: none; }
.dock-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); white-space: nowrap; }
.dock-label output { color: var(--ink); letter-spacing: 0; text-transform: none; font-size: 13px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.dock-group.speed { width: 190px; }
.dock-group.speed input[type=range] { height: 22px; }
.dock-actions { display: flex; gap: 14px; flex: none; }
.segmented { display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.segmented button { padding: 5px 13px; border-radius: 999px; font-size: 13px; color: var(--ink-3); transition: background .25s, color .25s; white-space: nowrap; }
.segmented button.active { background: #e6f2f7; color: #08111b; font-weight: 550; }
.segmented button:not(.active):hover { color: var(--ink); }

#tip {
  position: absolute; z-index: 7; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .15s;
  padding: 10px 14px; border-radius: 12px; background: rgba(10, 15, 24, .94); border: 1px solid var(--glass-border);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.5; max-width: 300px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
#tip.visible { opacity: 1; }
#tip h4 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
#tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
#tip .row span:first-child { color: var(--ink-3); }
#tip .note { margin-top: 6px; color: var(--ink-3); font-size: 12px; }

.v2 .scene-label.tick .name { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.v2 .scene-label.tick .tag { transform: translate(10px, -50%); }
.v2 .scene-label.axis .name { font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: none; color: var(--ink-3); }
.v2 .scene-label.axis .tag { transform: translate(-100%, -50%); padding-right: 8px; }
.v2 .scene-label.curve .name { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.v2 .scene-label.curve .tag { transform: translate(-50%, -140%); }
.v2 .readout { width: 300px; }
.v2 .panel { bottom: 96px; }
.v2 #scene { cursor: grab; }
.v2 #scene:active { cursor: grabbing; }
.v2 #scene.pointing { cursor: pointer; }

@media (max-width: 1080px) {
  .dock { gap: 14px; }
  .dock-group.speed { width: 150px; }
}
@media (max-width: 860px) {
  .dock { flex-wrap: wrap; row-gap: 8px; }
  .dock .timeline { flex: 1 1 calc(100% - 60px); order: 0; }
  .dock-group, .dock-actions { order: 1; }
  .dock-group.speed { flex: 1; width: auto; }
}
@media (max-width: 720px) {
  .dock-label { font-size: 10px; }
  .segmented button { padding: 4px 9px; font-size: 12px; }
  .dock-actions { gap: 8px; }
  .dock-actions #replay { display: none; }
  .dock-group.speed { flex: 1 1 110px; min-width: 0; }
  .dock-actions { margin-left: auto; }
  .dock-label output { font-size: 12px; }
  .v2 .readout, .v2 .panel { bottom: calc(var(--dock-h, 140px) + 26px); }
  .marker b { display: none; }
}
.marker.below b { bottom: auto; top: 12px; }
.marker.end b { left: auto; right: -4px; transform: none; }
@media (max-width: 720px) {
  .wide-only { display: none; }
  .dock-group.experiment { order: 0; }
  .dock-group.experiment .dock-label { display: none; }
  .dock-group.experiment + .dock-group.speed { flex-basis: 100%; }
}

/* Small live chart inside the readout (entropy over time) */
.readout .chart { padding: 8px 0 4px; border-top: 1px solid rgba(255, 255, 255, .07); }
.readout .chart canvas { display: block; width: 100%; height: 84px; }
.chart-key { display: flex; gap: 14px; font-size: 11px; color: var(--ink-4); margin-top: 4px; }
.chart-key .key { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 5px; background: var(--accent); }
.chart-key .key.back { background: #c9b8ff; }
.chart-key .key.max { background: repeating-linear-gradient(90deg, #8b9cae 0 3px, transparent 3px 6px); }
.readout-row sup, .readout-row small sup { font-size: .62em; vertical-align: .55em; line-height: 0; }
.dock-group.clock { width: 96px; }
.dock-group.clock .direction { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.dock-group.clock .direction.back { color: #c9b8ff; }
.reverse-button { display: inline-flex; align-items: center; gap: 6px; }
.reverse-button svg { width: 15px; height: 15px; }
.reverse-button.active { color: #c9b8ff; }
@media (max-width: 720px) {
  .readout .chart { flex-basis: 100%; padding: 2px 0 0; border: 0; }
  .readout .chart canvas { height: 40px; }
  .chart-key { display: none; }
  .dock-group.clock { width: auto; flex-direction: row; align-items: baseline; gap: 8px; }
}

/* Phones: the tour card shows its first paragraph; "Read more" opens the rest, the notice and the maths. */
.narrow-only { display: none; }
@media (max-width: 720px) {
  .narrow-only { display: inline; }
  .story:not(.more) .story-text p + p { display: none; }
  .story-text p:last-child { margin-bottom: 2px; }
}

/* Readout: a little wider on desktop so two-word labels do not wrap; full width on phones. */
.v2 .readout { width: 320px; }
@media (max-width: 720px) {
  .v2 .readout { width: auto; }
  /* Long slider labels (e.g. "Ship speed 0.60 c · γ 1.25") wrap instead of running into the buttons. */
  .dock-group.speed .dock-label { white-space: normal; line-height: 1.35; }
}

/* Link to the next concept, at the end of each tour */
.next-concept {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13.5px;
  transition: border-color .2s, background .2s;
}
.next-concept small { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); }
.next-concept:hover { border-color: rgba(169, 223, 238, .5); background: rgba(255, 255, 255, .04); }
.next-concept .arrow { color: var(--accent); font-size: 16px; }

/* Thin bars under readout rows, e.g. time lived by each clock */
.readout-row .bar { grid-column: 2 / 4; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .07); margin-top: 7px; overflow: hidden; }
.readout-row .bar i { display: block; height: 100%; width: 0; background: var(--c); border-radius: 2px; box-shadow: 0 0 8px var(--c); transition: width .15s linear; }
.readout-row .sub .swatch { width: 8px; height: 8px; vertical-align: -1px; }
.v2 .scene-label.axis-tick .name, .v2 .scene-label.axis-title .name { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.v2 .scene-label.axis-tick .tag { transform: translate(10px, -50%); }
.v2 .scene-label.axis-title .tag { transform: translate(-50%, -100%); }
@media (max-width: 720px) { .readout-row .bar { display: none; } }

/* Phones: messages appear just above the dock, not over the tour card. */
@media (max-width: 720px) {
  #toast { top: auto; bottom: calc(var(--dock-h, 140px) + 30px); transform: translate(-50%, 6px); border-radius: 14px; }
  #toast.visible { transform: translate(-50%, 0); }
}

/* A badge over the scene, e.g. while time runs backwards */
.time-badge {
  white-space: nowrap;
  position: absolute; z-index: 5; top: 74px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 999px;
  background: rgba(201, 184, 255, .14); border: 1px solid rgba(201, 184, 255, .45); color: #e3daff;
  font-size: 13px; letter-spacing: .04em; pointer-events: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: badge-pulse 2.4s ease-in-out infinite;
}
.time-badge svg { width: 15px; height: 15px; }
@keyframes badge-pulse { 50% { box-shadow: 0 0 22px rgba(201, 184, 255, .35); } }
@media (max-width: 720px) { .time-badge { top: auto; bottom: calc(var(--dock-h, 140px) + 30px); white-space: nowrap; font-size: 12px; padding: 5px 12px; background: rgba(28, 22, 48, .92); } }

/* A key under the readout: what colour (and height) mean in the current view */
.legend { padding: 10px 0 4px; border-top: 1px solid rgba(255, 255, 255, .07); }
.legend-bar { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #2f6cf0, #0b1220 50%, #ee9a3f); }
.legend.bright .legend-bar { background: linear-gradient(90deg, #05050c, #4d1f94 35%, #f6765a 72%, #fff2d2); }
.legend-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.legend-caption { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.45; }
@media (max-width: 720px) {
  .legend { flex-basis: 100%; padding: 4px 0 0; border: 0; }
  .legend-caption { display: none; }
}

/* ================================================================ Paper (risograph) theme
   Two inks on oat paper: olive for lines and text, burnt orange as the second ink. Flat and printed:
   no glow, no blur, square corners, thick ink rules, Space Mono for labels and numbers. */
@font-face { font-family: 'Space Mono'; src: url('../fonts/SpaceMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('../fonts/SpaceMono-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
body.riso {
  --paper: #ece4d2; --paper-2: #f4eee0; --olive: #56612a; --olive-dark: #3b4419; --spot: #c8541f; --spot-tint: #e9b99a; --olive-tint: #c9c9a3;
  --bg: var(--paper); --glass: var(--paper); --glass-border: var(--olive);
  --ink: #2f3614; --ink-2: #454d22; --ink-3: #6a6f45; --ink-4: #8a8c68; --line: rgba(86, 97, 42, .4); --accent: var(--spot);
  --mono: 'Space Mono', ui-monospace, Menlo, monospace;
  background: var(--paper); color: var(--ink); color-scheme: light;
}
/* Print grain over the scene (behind the panels). */
.riso .stage::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: .32; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35 0 0 0 0 .32 0 0 0 0 .22 0 0 0 .55 0'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
}
.riso .glass { background: var(--paper-2); border: 2px solid var(--olive); border-radius: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.riso :focus-visible { outline-color: var(--spot); }
.riso .eyebrow, .riso .dock-label, .riso .readout-row .who, .riso .wordmark, .riso .marker b { font-family: var(--mono); letter-spacing: .04em; }
.riso .readout-row strong, .riso .dock-label output, .riso .timeline-label b { font-family: var(--mono); color: var(--olive-dark); letter-spacing: 0; }
.riso .swatch { box-shadow: none; border-radius: 0; }

/* Top bar */
.riso .wordmark b { color: var(--olive-dark); }
.riso .wordmark span { color: var(--ink-3); }
.riso .view-switch { border: 2px solid var(--olive); border-radius: 0; background: var(--paper-2); padding: 2px; }
.riso .view-switch button { border-radius: 0; font-family: var(--mono); color: var(--ink-3); }
.riso .view-switch button.active { background: var(--olive); color: var(--paper-2); }
.riso .icon-button { border: 2px solid var(--olive); border-radius: 0; color: var(--olive-dark); background: var(--paper-2); font-family: var(--mono); }
.riso .icon-button:hover { background: var(--olive); color: var(--paper-2); border-color: var(--olive); }

/* Tour card: a block of solid olive ink */
.riso .story { background: var(--olive); border-color: var(--olive); color: var(--paper-2); }
.riso .story .eyebrow { color: #d9d3b6; }
.riso .story h1 { font-family: var(--mono); font-weight: 700; letter-spacing: -.02em; color: var(--paper-2); }
.riso .story-text p { color: #ece6d2; }
.riso .story-text b { color: #fff8e8; font-weight: 600; }
.riso .story .notice, .riso .story .maths { color: #e4ddc6; }
.riso .story .notice span, .riso .story .maths span { color: #c9c2a3; font-family: var(--mono); }
.riso .story .maths { font-family: var(--mono); }
.riso .story-collapse, .riso .story .text-button { color: #e4ddc6; }
.riso .more-toggle { color: #ffc9a8; }
.riso .dots i { background: rgba(244, 238, 224, .3); border-radius: 0; }
.riso .dots i.on { background: var(--spot); }
.riso .primary-button { background: var(--spot); color: var(--paper-2); border-radius: 0; font-family: var(--mono); white-space: nowrap; }
.riso .primary-button:hover { background: #b0461a; }
.riso .story .swatch { outline: 1.5px solid rgba(244, 238, 224, .6); }
.riso .next-concept { border: 2px solid rgba(244, 238, 224, .5); border-radius: 0; color: var(--paper-2); }
.riso .next-concept small { color: #c9c2a3; }
.riso .next-concept .arrow { color: #ffc9a8; }

/* Readout, panel, dock */
.riso .readout-row { border-top-color: var(--line); }
.riso .readout-row .who { color: var(--ink); font-size: 12.5px; }
.riso .readout-row .who small { font-family: Inter, system-ui, sans-serif; letter-spacing: 0; color: var(--ink-3); }
.riso .chip { border: 2px solid var(--olive); border-radius: 0; color: var(--ink-3); font-family: var(--mono); font-size: 12px; }
.riso .chip.active { background: var(--olive); color: var(--paper-2); border-color: var(--olive); }
.riso .chip .swatch { opacity: 1; }
.riso .settings { border-top: 2px solid var(--line); }
.riso .settings summary, .riso .settings label > span { color: var(--ink-2); }
.riso .settings .hint { color: var(--ink-3); }
.riso .round-button { background: var(--olive); color: var(--paper-2); border-radius: 0; }
.riso .segmented { border: 2px solid var(--olive); border-radius: 0; background: transparent; padding: 2px; }
.riso .segmented button { border-radius: 0; font-family: var(--mono); color: var(--ink-3); }
.riso .segmented button.active { background: var(--spot); color: var(--paper-2); font-weight: 400; }
.riso .segmented button:not(.active):hover { color: var(--olive-dark); }
.riso .text-button { color: var(--olive-dark); font-family: var(--mono); }
.riso .text-button:hover { color: var(--spot); }
.riso input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 0; background: linear-gradient(90deg, var(--spot) var(--progress), var(--olive-tint) var(--progress)); }
.riso input[type=range]::-moz-range-track { height: 4px; border-radius: 0; background: var(--olive-tint); }
.riso input[type=range]::-moz-range-progress { height: 4px; border-radius: 0; background: var(--spot); }
.riso input[type=range]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; border-radius: 0; background: var(--olive); box-shadow: none; }
.riso input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 0; background: var(--olive); }

/* Labels in the scene: ink on a paper halo */
.riso .scene-label .tag { text-shadow: 0 0 4px var(--paper), 0 0 2px var(--paper), 0 0 1px var(--paper); }
.riso .scene-label .name { color: var(--olive-dark); font-family: var(--mono); letter-spacing: .02em; }
.riso .scene-label.landmark .name, .riso .v2 .scene-label.curve .name { color: var(--ink-2); }

/* Tooltip, toast, notes */
.riso #tip { background: var(--paper-2); border: 2px solid var(--olive); border-radius: 0; color: var(--ink-2); box-shadow: none; }
.riso #tip h4 { color: var(--olive-dark); font-family: var(--mono); }
.riso #toast { background: var(--olive); color: var(--paper-2); border: 0; border-radius: 0; font-family: var(--mono); font-size: 12px; }
.riso dialog.notes { background: var(--paper-2); color: var(--ink-2); border: 2px solid var(--olive); border-radius: 0; }
.riso dialog.notes::backdrop { background: rgba(59, 68, 25, .35); backdrop-filter: none; }
.riso dialog.notes h2 { color: var(--olive-dark); font-family: var(--mono); font-weight: 700; letter-spacing: -.02em; }
.riso dialog.notes h3 { color: var(--olive-dark); font-family: var(--mono); }
.riso dialog.notes .eq { background: var(--paper); border: 1.5px solid var(--olive); border-radius: 0; color: var(--olive-dark); font-family: var(--mono); }
.riso dialog.notes .honest { border-left: 3px solid var(--spot); color: var(--ink-3); }
.riso dialog.notes a { color: var(--spot); }
.riso dialog.notes .version { color: var(--ink-4); font-family: var(--mono); }
.riso #fallback, .riso #fallback h2 { color: var(--ink); }
/* Space Mono is wide: in mid-width windows the secondary part of slider values steps aside. */
@media (max-width: 1080px) { .riso .dock-label output .wide-only { display: none; } }

/* Light-as-a-wave key, in the paper palette */
.riso .legend { border-top-color: var(--line); }
.riso .legend-bar { border-radius: 0; height: 9px; background: linear-gradient(90deg, #56612a, #ece4d2 50%, #c8541f); border: 1.5px solid var(--olive); }
.riso .legend.bright .legend-bar { background: linear-gradient(90deg, #ece4d2, #e8a680 40%, #c8541f 75%, #66290f); }
.riso .legend-labels, .riso .legend-caption { color: var(--ink-3); }
.riso .legend-labels { font-family: var(--mono); }

/* Entropy chart key and the backwards badge, in the paper palette */
.riso .chart-key { color: var(--ink-3); font-family: var(--mono); }
.riso .chart-key .key { background: var(--olive); height: 3px; }
.riso .chart-key .key.back { background: var(--spot); }
.riso .chart-key .key.max { background: repeating-linear-gradient(90deg, #8a8c68 0 3px, transparent 3px 6px); }
.riso .dock-group.clock .direction { color: var(--ink-2); font-family: var(--mono); }
.riso .dock-group.clock .direction.back, .riso .reverse-button.active { color: var(--spot); }
.riso .time-badge { background: var(--spot); border: 0; border-radius: 0; color: var(--paper-2); font-family: var(--mono); animation: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.riso .readout .chart { border-top-color: var(--line); }
