/* ═══════════════════════════════════════════════════════════════
   INTELLIGENCE N+1 — main stylesheet
   Design system, scene engine styles, chapter layouts
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #04060c;
  --bg-2: #0a0f1c;
  --ink: #e9edf5;
  --ink-2: rgba(233, 237, 245, 0.64);
  --ink-3: rgba(233, 237, 245, 0.4);
  --ink-4: rgba(233, 237, 245, 0.18);
  --line: rgba(233, 237, 245, 0.1);
  --line-2: rgba(233, 237, 245, 0.2);
  --glass: rgba(8, 12, 22, 0.58);
  --glass-2: rgba(8, 12, 22, 0.78);

  --cyan: #86e6ff;
  --cyan-2: #2fb3d3;
  --cyan-rgb: 134, 230, 255;
  --gold: #f3cd93;
  --gold-2: #e39a44;
  --gold-rgb: 243, 205, 147;
  --violet: #ab9dff;
  --violet-rgb: 171, 157, 255;
  --rose: #ff7d8c;
  --rose-rgb: 255, 125, 140;
  --green: #9ef0c0;

  --font-display: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --font-body: 'Manrope', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', ui-monospace, Menlo, monospace;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --pad-x: clamp(20px, 5vw, 72px);
  --pad-top: clamp(84px, 11vh, 132px);
  --nav-h: 60px;
  --pad-bot: calc(clamp(20px, 3.6vh, 44px) + var(--nav-h));
  --radius: 16px;
  --inner-max: 1360px;  /* the widest a chapter's content runs */
  --text-col: 480px;    /* the glass text column of the overlay chapters */
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { overscroll-behavior: none; }

::selection { background: rgba(var(--cyan-rgb), 0.25); color: #fff; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 300; }
strong { font-weight: 500; }
canvas { display: block; }

/* ───────────────────────── Backgrounds ───────────────────────── */

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.nebula {
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.4s ease;
  filter: blur(60px) saturate(1.1);
  animation: nebula-drift 90s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
.nebula--deep {
  background:
    radial-gradient(40% 35% at 25% 30%, rgba(30, 60, 120, 0.42), transparent 70%),
    radial-gradient(35% 40% at 75% 65%, rgba(70, 40, 120, 0.30), transparent 70%),
    radial-gradient(30% 30% at 60% 20%, rgba(20, 90, 110, 0.22), transparent 70%);
}
.nebula--warm {
  background:
    radial-gradient(40% 35% at 30% 65%, rgba(160, 90, 30, 0.30), transparent 70%),
    radial-gradient(35% 40% at 70% 30%, rgba(120, 50, 60, 0.26), transparent 70%),
    radial-gradient(30% 30% at 50% 80%, rgba(180, 130, 40, 0.16), transparent 70%);
  animation-delay: -20s;
}
.nebula--cyan {
  background:
    radial-gradient(45% 40% at 70% 40%, rgba(20, 110, 140, 0.34), transparent 70%),
    radial-gradient(35% 40% at 25% 70%, rgba(30, 60, 130, 0.30), transparent 70%),
    radial-gradient(25% 25% at 50% 15%, rgba(80, 200, 220, 0.12), transparent 70%);
  animation-delay: -40s;
}
.nebula--violet {
  background:
    radial-gradient(45% 40% at 40% 40%, rgba(90, 50, 160, 0.34), transparent 70%),
    radial-gradient(35% 40% at 75% 70%, rgba(40, 30, 110, 0.36), transparent 70%),
    radial-gradient(25% 25% at 20% 80%, rgba(180, 80, 140, 0.14), transparent 70%);
  animation-delay: -60s;
}
body[data-tint="deep"] .nebula--deep,
body[data-tint="warm"] .nebula--warm,
body[data-tint="cyan"] .nebula--cyan,
body[data-tint="violet"] .nebula--violet { opacity: 1; }

@keyframes nebula-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3%, -2%, 0) scale(1.06); }
  100% { transform: translate3d(-2%, 3%, 0) scale(1.02); }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 50%, rgba(2, 4, 10, 0.75) 100%);
}

/* ───────────────────────── Typography ───────────────────────── */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cyan);
}
.eyebrow--dim { color: var(--ink-3); letter-spacing: 0.22em; }
.eyebrow__link {
  text-decoration: underline dotted;
  text-decoration-color: rgba(var(--cyan-rgb), 0.45);
  text-underline-offset: 5px;
  transition: color 0.3s, text-decoration-color 0.3s;
}
.eyebrow__link:hover, .eyebrow__link:focus-visible { color: #fff; text-decoration-color: currentColor; outline: none; }

.title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(56px, 10.5vw, 124px);
  line-height: 0.95;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0.15em 0 0.2em;
  background: linear-gradient(180deg, #ffffff 0%, #dfe6f5 55%, rgba(200, 215, 240, 0.6) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(134, 230, 255, 0.15);
}

.h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(34px, 4.6vw, 62px);
  line-height: 1.05;
  letter-spacing: 0.005em;
  color: #fff;
  text-wrap: balance;
}
.h2--accent {
  font-size: clamp(48px, 8vw, 112px);
  font-style: italic;
  margin: 0.25em 0 0.2em;
  background: linear-gradient(90deg, var(--gold), #fff 50%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(21px, 2.1vw, 29px);
  line-height: 1.38;
  color: #fff;
  text-wrap: balance;
}
.lead em { font-style: normal; color: var(--gold); }
.lead--sm { font-size: clamp(18px, 1.5vw, 22px); color: rgba(255, 255, 255, 0.86); }
.lead--center { text-align: center; }
.lead--em { color: var(--cyan); }

.body {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: clamp(14.5px, 1.05vw, 16.5px);
  line-height: 1.68;
  color: var(--ink-2);
  max-width: 54ch;
  text-wrap: pretty;
}
.body--center { text-align: center; margin-inline: auto; }

.note {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.hint {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  animation: hint-pulse 3s ease-in-out infinite;
}
@keyframes hint-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ───────────────────────── HUD ───────────────────────── */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px var(--pad-x);
  pointer-events: none;
  mix-blend-mode: normal;
}
.hud > * { pointer-events: auto; }

.hud__brand {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  transition: color 0.3s, text-shadow 0.3s;
}
.hud__brand:hover { color: #fff; text-shadow: 0 0 24px rgba(var(--cyan-rgb), 0.6); }

.hud__chapter {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}
.hud__act {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hud__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.8);
  transition: opacity 0.5s;
}

.hud__actions { display: flex; gap: 10px; }

.hud__btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  transition: border-color 0.3s, color 0.3s, box-shadow 0.3s;
}
.hud__btn:hover { border-color: rgba(var(--cyan-rgb), 0.6); color: #fff; box-shadow: 0 0 24px rgba(var(--cyan-rgb), 0.15); }

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 2px; height: 3px; background: currentColor; border-radius: 1px; transition: height 0.3s; }
.hud__btn[aria-pressed="true"] .eq i { animation: eq-bounce 0.9s ease-in-out infinite; }
.hud__btn[aria-pressed="true"] .eq i:nth-child(2) { animation-delay: -0.2s; }
.hud__btn[aria-pressed="true"] .eq i:nth-child(3) { animation-delay: -0.5s; }
.hud__btn[aria-pressed="true"] .eq i:nth-child(4) { animation-delay: -0.7s; }
.hud__btn[aria-pressed="true"] { color: var(--cyan); border-color: rgba(var(--cyan-rgb), 0.4); }
@keyframes eq-bounce { 0%, 100% { height: 3px; } 50% { height: 12px; } }

.burger { display: inline-flex; flex-direction: column; gap: 4px; }
.burger i { width: 16px; height: 1px; background: currentColor; transition: transform 0.4s var(--ease); }
body.menu-open .burger i:first-child { transform: translateY(2.5px) rotate(45deg); }
body.menu-open .burger i:last-child { transform: translateY(-2.5px) rotate(-45deg); }

/* ───────────────────────── Dots ───────────────────────── */

.dots {
  position: fixed;
  right: clamp(14px, 2.2vw, 30px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dot {
  position: relative;
  width: 22px;
  height: 14px;
  display: grid;
  place-items: center;
}
.dot::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-4);
  transition: transform 0.4s var(--ease), background 0.4s, box-shadow 0.4s;
}
.dot--act-start { margin-top: 10px; }
.dot:hover::before { background: var(--ink-2); transform: scale(1.5); }
.dot.is-active::before { background: #fff; transform: scale(1.8); box-shadow: 0 0 12px rgba(255, 255, 255, 0.8); }
.dot__label {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.dot:hover .dot__label { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ───────────────────────── Scroll hint ───────────────────────── */

.scroll-hint {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--nav-h));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
}
.scroll-hint.is-visible { opacity: 1; }
.scroll-hint i {
  width: 1px;
  height: 36px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  background-size: 100% 200%;
  animation: hint-line 2.2s linear infinite;
}
@keyframes hint-line { 0% { background-position: 0 -36px; } 100% { background-position: 0 36px; } }

/* ───────────────────────── Chapter nav ───────────────────────── */

/* a soft scrim so text that scrolls past the bar fades out instead of colliding with it */
.chapnav::before {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + 42px);
  background: linear-gradient(180deg, rgba(4, 6, 12, 0), rgba(4, 6, 12, 0.72) 62%, rgba(4, 6, 12, 0.86));
  pointer-events: none;
  z-index: -1;
}

.chapnav {
  position: fixed;
  left: var(--pad-x);
  right: var(--pad-x);
  bottom: calc((var(--nav-h) - 40px) / 2);
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.chapnav.is-on { opacity: 1; transform: none; }
.chapnav.is-on .chapnav__btn:not(:disabled) { pointer-events: auto; }
body.menu-open .chapnav { opacity: 0; pointer-events: none; }

.chapnav__btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 42vw;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass-2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink-2);
  transition: border-color 0.3s, color 0.3s, box-shadow 0.3s, opacity 0.4s;
}
.chapnav__btn--next { flex-direction: row-reverse; }
.chapnav__btn:hover { border-color: rgba(var(--cyan-rgb), 0.5); color: #fff; box-shadow: 0 0 24px rgba(var(--cyan-rgb), 0.12); }
.chapnav__btn:disabled { opacity: 0; pointer-events: none; }
.chapnav__chev {
  flex: none;
  width: 7px;
  height: 7px;
  border-left: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.35s var(--ease);
}
.chapnav__btn--next .chapnav__chev { transform: rotate(-135deg); }
.chapnav__btn--prev:hover .chapnav__chev { transform: rotate(45deg) translate(2px, -2px); }
.chapnav__btn--next:hover .chapnav__chev { transform: rotate(-135deg) translate(2px, -2px); }
.chapnav__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chapnav__btn--next .chapnav__text { align-items: flex-end; }
.chapnav__k {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1;
}
.chapnav__t {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  line-height: 1.1;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ───────────────────────── Menu ───────────────────────── */

.menu {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(4, 6, 12, 0.86);
  backdrop-filter: blur(30px) saturate(1.2);
  -webkit-backdrop-filter: blur(30px) saturate(1.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s var(--ease), visibility 0s linear 0.6s;
  overflow-y: auto;
}
body.menu-open .menu { opacity: 1; visibility: visible; transition-delay: 0s; }
.menu__inner {
  min-height: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--pad-top) var(--pad-x) var(--pad-bot);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.menu__title {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
}
.menu__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 28px 40px;
}
.menu__act { display: flex; flex-direction: column; gap: 6px; }
.menu__act-name {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 8px;
}
.menu__item {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink-2);
  text-align: left;
  transition: color 0.3s, padding-left 0.4s var(--ease);
  opacity: 0;
  transform: translateY(10px);
}
body.menu-open .menu__item { opacity: 1; transform: none; transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), color 0.3s, padding-left 0.4s var(--ease); transition-delay: calc(var(--i, 0) * 40ms); }
.menu__item:hover, .menu__item.is-active { color: #fff; padding-left: 8px; }
.menu__item i { font-family: var(--font-mono); font-style: normal; font-size: 10px; letter-spacing: 0.2em; color: var(--ink-3); min-width: 20px; }
.menu__foot { margin-top: auto; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; padding-top: 24px; }

/* ───────────────────────── Cursor ───────────────────────── */

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s, width 0.25s var(--ease), height 0.25s var(--ease), margin 0.25s var(--ease), border-color 0.25s, background 0.25s;
  will-change: transform;
}
.cursor.is-on { opacity: 1; }
.cursor.is-hover {
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-color: rgba(var(--cyan-rgb), 0.8);
  background: rgba(var(--cyan-rgb), 0.08);
}
.cursor.is-down { width: 24px; height: 24px; margin: -12px 0 0 -12px; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ───────────────────────── Scenes ───────────────────────── */

#deck { position: relative; z-index: 2; }

.scene {
  position: fixed;
  inset: 0;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.025);
  filter: blur(10px);
  transition: opacity 1s var(--ease), transform 1.1s var(--ease), filter 1s var(--ease), visibility 0s linear 1.05s;
}
.scene.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  filter: none;
  z-index: 3;
  transition-delay: 0s;
}
.scene.is-leaving {
  opacity: 0;
  transform: scale(0.985);
  filter: blur(10px);
  z-index: 2;
  visibility: visible;
  transition: opacity 0.75s var(--ease), transform 0.9s var(--ease), filter 0.75s var(--ease), visibility 0s linear 0.9s;
}

[data-reveal] { opacity: 0; }
.scene.is-active [data-reveal] {
  animation: rise 1.15s var(--ease) both;
  animation-delay: var(--d, 0s);
}
.scene.is-leaving [data-reveal] { opacity: 1; animation: none; }
@keyframes rise {
  0% { opacity: 0; transform: translateY(26px); filter: blur(8px); }
  100% { opacity: 1; transform: none; filter: blur(0); }
}

.scene__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.scene__canvas--interactive { cursor: crosshair; }

.scene__inner {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
  max-width: var(--inner-max);
  margin: 0 auto;
  padding: var(--pad-top) var(--pad-x) var(--pad-bot);
  display: grid;
  align-items: start;
  align-items: safe center;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.scene__inner::-webkit-scrollbar { display: none; }
.scene__inner--pass { pointer-events: none; }
.scene__inner--pass > * { pointer-events: auto; }

.scene--center .scene__inner { justify-items: center; text-align: center; }
.scene--center .body { margin-inline: auto; }

.scene--split .scene__inner {
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(28px, 4.5vw, 80px);
}
.scene__text { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.scene__text .h2 { margin-bottom: 4px; }
.scene__visual { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.scene--overlay .scene__inner { grid-template-columns: minmax(0, var(--text-col)) 1fr; align-items: start; }
.scene__text--glass {
  padding: 26px 28px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.scene--stack .scene__inner { grid-template-rows: auto minmax(auto, 1fr) auto; gap: 20px; align-items: start; }
.scene--stack .scene__inner > .panel { align-self: stretch; }
.scene--stack .scene__inner > .tree { align-self: start; }
.stack__head { display: flex; flex-direction: column; gap: 12px; max-width: 900px; }
.stack__head--center { align-items: center; text-align: center; margin-inline: auto; }
.stack__head .body { max-width: 72ch; }
.stack__foot { max-width: 92ch; }

/* ───────────────────────── Components ───────────────────────── */

.panel {
  position: relative;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(var(--cyan-rgb), 0.35);
  border-style: solid;
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; border-top-left-radius: 4px; }
.panel::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; border-bottom-right-radius: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 50px;
  padding: 0 30px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink);
  transition: transform 0.4s var(--ease-out), border-color 0.3s, box-shadow 0.3s, background 0.3s, color 0.3s, opacity 0.3s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(var(--cyan-rgb), 0.7); box-shadow: 0 0 30px rgba(var(--cyan-rgb), 0.18); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn--primary { background: #fff; color: #05070d; border-color: #fff; }
.btn--primary:hover { background: #fff; box-shadow: 0 0 40px rgba(255, 255, 255, 0.35); }
.btn--ghost { background: transparent; }
.btn--sm { height: 40px; padding: 0 20px; font-size: 10.5px; }
.btn[disabled] { opacity: 0.35; pointer-events: none; }

.actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, rgba(var(--cyan-rgb), 0.9) 0, rgba(var(--cyan-rgb), 0.9) var(--fill, 0%), var(--line-2) var(--fill, 0%), var(--line-2) 100%);
  border-radius: 2px;
}
.range::-moz-range-track { height: 2px; background: var(--line-2); border-radius: 2px; }
.range::-moz-range-progress { height: 2px; background: rgba(var(--cyan-rgb), 0.9); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 18px rgba(var(--cyan-rgb), 0.8);
  transition: transform 0.2s var(--ease);
}
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 18px rgba(var(--cyan-rgb), 0.8);
}
.range:hover::-webkit-slider-thumb, .range:active::-webkit-slider-thumb { transform: scale(1.25); }
.range__ticks { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.08em; color: var(--ink-3); margin-top: -4px; }

.meter { position: relative; height: 3px; width: 100%; background: var(--line); border-radius: 2px; overflow: hidden; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--cyan-2), var(--cyan)); border-radius: 2px; transition: width 0.3s; }

.badges { display: flex; gap: 10px; flex-wrap: wrap; }
.badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(var(--gold-rgb), 0.35);
  color: var(--gold);
  background: rgba(var(--gold-rgb), 0.06);
}

/* ───────────────────────── The opening film ───────────────────────── */

.title__w, .title__n { display: block; }
.title, .hud__brand, .hud__title, .menu__item, .dot__label, .h2--num { font-variant-numeric: lining-nums; }

.scene--title { overflow: hidden; }
.cosmos__gl { z-index: 0; pointer-events: none; }
.cosmos__film { z-index: 1; cursor: crosshair; }
.cosmos__whispers { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }

/* the title sits on the film's focal point (set by the script) and only appears at the end */
.cosmos__title {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 3;
  padding: 0 var(--pad-x);
  transform: translateY(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s var(--ease);
}
.cosmos__title.is-on { opacity: 1; }
.cosmos__title .title { margin: 0; }

/* under the film: the scene controls, the tagline and the way in, always there */
.cosmos__dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px var(--pad-x) calc(clamp(18px, 3.5vh, 40px) + env(safe-area-inset-bottom, 0px));
}
.cosmos__dock::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -70px;
  bottom: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(4, 6, 12, 0), rgba(4, 6, 12, 0.55) 40%, rgba(4, 6, 12, 0.8));
  pointer-events: none;
}
.cosmos__tagline { margin: 0; }
.cosmos__actions { margin-top: 0; }

.cosmos__controls { display: flex; align-items: center; gap: 12px; }
.cosmos__step {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: border-color 0.3s, color 0.3s, box-shadow 0.3s, opacity 0.4s;
}
.cosmos__step:hover { border-color: rgba(var(--cyan-rgb), 0.6); color: #fff; box-shadow: 0 0 24px rgba(var(--cyan-rgb), 0.15); }
.cosmos__step:disabled { opacity: 0.22; pointer-events: none; }
.cosmos__chev { width: 7px; height: 7px; border-left: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateX(2px) rotate(45deg); }
.cosmos__step--next .cosmos__chev { transform: translateX(-2px) rotate(-135deg); }

/* one pip per scene, no names: the current one stretches and fills as the scene plays */
.cosmos__pips { display: flex; align-items: center; gap: 5px; }
.cosmos__pip { height: 24px; width: 10px; display: grid; place-items: center; transition: width 0.5s var(--ease); }
.cosmos__pip i {
  position: relative;
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--ink-4);
  overflow: hidden;
  transition: width 0.5s var(--ease), background 0.4s;
}
.cosmos__pip i::after { content: ''; position: absolute; inset: 0; width: var(--p, 0%); border-radius: 3px; background: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.7); }
.cosmos__pip:hover i { background: var(--ink-2); }
.cosmos__pip.is-done i { background: var(--ink-3); }
.cosmos__pip.is-active { width: 34px; }
.cosmos__pip.is-active i { width: 30px; background: var(--ink-4); }

.cosmos__replay {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, 6px);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(var(--cyan-rgb), 0.45);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0;
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), border-color 0.3s, box-shadow 0.3s;
}
.cosmos__replay.is-on { opacity: 1; transform: translate(-50%, -6px); }
.cosmos__replay:hover { border-color: rgba(var(--cyan-rgb), 0.9); box-shadow: 0 0 28px rgba(var(--cyan-rgb), 0.25); color: #fff; }
.cosmos__replay[hidden] { display: none; }
.cosmos__replay-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }

/* whispers: a line that surfaces beside what was touched, holds, and dissolves */
.whisper { position: absolute; z-index: 2; max-width: min(320px, 78vw); pointer-events: none; --tint: 134, 230, 255; }
.whisper__text {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.3;
  color: #fff;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 0 18px rgba(var(--tint), 0.6), 0 2px 14px rgba(0, 0, 0, 0.9);
}
.whisper__w { display: inline-block; white-space: nowrap; }
.whisper__w span { display: inline-block; opacity: 0; filter: blur(6px); transform: translateY(6px); }
.whisper.is-in .whisper__w span { animation: whisper-in 0.9s var(--ease-out) both; animation-delay: var(--i, 0ms); }
.whisper.is-out .whisper__w span { animation: whisper-out 0.9s var(--ease) both; animation-delay: var(--o, 0ms); }
@keyframes whisper-in { 0% { opacity: 0; filter: blur(8px); transform: translateY(8px); } 100% { opacity: 1; filter: blur(0); transform: none; } }
@keyframes whisper-out { 0% { opacity: 1; filter: blur(0); transform: none; } 100% { opacity: 0; filter: blur(8px); transform: translateY(-14px); } }
.whisper__lead { position: absolute; left: var(--ax, 50%); width: 1px; height: 18px; opacity: 0; transition: opacity 0.6s; }
.whisper.is-above .whisper__lead { top: 100%; margin-top: 4px; background: linear-gradient(180deg, rgba(var(--tint), 0.7), rgba(var(--tint), 0)); }
.whisper.is-below .whisper__lead { bottom: 100%; margin-bottom: 4px; background: linear-gradient(0deg, rgba(var(--tint), 0.7), rgba(var(--tint), 0)); }
.whisper.is-in .whisper__lead { opacity: 1; }
.whisper.is-out .whisper__lead { opacity: 0; }

/* ───────────────────────── You Were Made ───────────────────────── */

.narration { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 820px; }
.narration .lead { font-size: clamp(22px, 2.4vw, 32px); }
.scene--made .scene__canvas { opacity: 0.9; }

/* ───────────────────────── The Laws ───────────────────────── */

.law { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.law__head { display: flex; align-items: baseline; gap: 14px; }
.law__num { font-family: var(--font-display); font-size: 44px; line-height: 1; color: var(--gold); }
.law__name { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-2); }
.law.is-switching .law__head, .law.is-switching .lead, .law.is-switching .body, .law.is-switching .note { animation: rise 0.7s var(--ease) both; }
.law.is-switching .lead { animation-delay: 0.08s; }
.law.is-switching .body { animation-delay: 0.16s; }
.law.is-switching .note { animation-delay: 0.24s; }

.glyph-frame { aspect-ratio: 16 / 10; overflow: hidden; }
.glyph-frame canvas { width: 100%; height: 100%; }

.law-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.law-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 22, 0.35);
  text-align: left;
  transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease);
}
.law-tab i { font-family: var(--font-display); font-style: normal; font-size: 22px; line-height: 1; color: var(--ink-2); transition: color 0.3s; }
.law-tab span { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.law-tab:hover { border-color: var(--line-2); transform: translateY(-2px); }
.law-tab.is-active { border-color: rgba(var(--gold-rgb), 0.5); background: rgba(var(--gold-rgb), 0.07); }
.law-tab.is-active i { color: var(--gold); }
.law-tab.is-active span { color: var(--ink-2); }

/* ───────────────────────── The Journey ───────────────────────── */

.journey-frame { aspect-ratio: 16 / 11; overflow: hidden; display: flex; flex-direction: column; }
.journey-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.journey-caption {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(4, 6, 12, 0.55);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.journey-caption .body { font-size: 13.5px; max-width: none; }
.journey-launch { position: absolute; top: 18px; right: 18px; }

.dose { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 10px; }
.dose__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.dose__years { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); letter-spacing: 0.04em; }
.dose__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dose__grid > div { display: flex; flex-direction: column; gap: 4px; }
.dose__grid strong { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: #fff; }
#dose-verdict[data-level="0"] { color: var(--green); }
#dose-verdict[data-level="1"] { color: var(--gold); }
#dose-verdict[data-level="2"] { color: #ffb070; }
#dose-verdict[data-level="3"] { color: var(--rose); }
.dose__bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.dose__bar i { display: block; height: 100%; width: 10%; border-radius: 2px; background: linear-gradient(90deg, var(--green), var(--gold) 45%, var(--rose)); transition: width 0.25s; }

/* ───────────────────────── The Vent ───────────────────────── */

.vent-hud {
  position: absolute;
  right: var(--pad-x);
  bottom: var(--pad-bot);
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 28px;
}
.vent-hud > div { display: flex; flex-direction: column; gap: 4px; }
.vent-hud strong { font-family: var(--font-mono); font-size: 22px; font-weight: 400; color: #fff; }
.vent-hud .hint { margin-bottom: 4px; }

/* ───────────────────────── The Plan ───────────────────────── */

.plan { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 1fr auto; clip-path: inset(-1px round var(--radius)); }
.plan__toolkit { grid-row: 1 / span 2; display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 14px 0; }
.tool {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 18px;
  transition: background 0.4s;
}
.tool + .tool { border-top: 1px solid var(--line); }
.tool__icon { grid-row: 1 / span 2; width: 44px; height: 44px; }
.tool__icon svg { width: 100%; height: 100%; overflow: visible; }
.tool__icon path, .tool__icon circle, .tool__icon line, .tool__icon polyline { fill: none; stroke: var(--ink-3); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.6s, filter 0.6s; }
.tool__name { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); transition: color 0.4s; }
.tool__state { font-family: var(--font-body); font-size: 12px; color: var(--ink-3); transition: color 0.4s; }
.tool.is-dormant .tool__icon { animation: tool-pulse 3s ease-in-out infinite; }
.tool.is-on { background: rgba(var(--gold-rgb), 0.06); }
.tool.is-on .tool__icon path, .tool.is-on .tool__icon circle, .tool.is-on .tool__icon line, .tool.is-on .tool__icon polyline { stroke: var(--gold); filter: drop-shadow(0 0 6px rgba(var(--gold-rgb), 0.8)); }
.tool.is-on .tool__name { color: #fff; }
.tool.is-on .tool__state { color: var(--gold); }
@keyframes tool-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.plan__stage { position: relative; min-height: 260px; }
.plan__stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.plan__readout { position: absolute; left: 24px; top: 20px; right: 24px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.plan__time { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; color: var(--cyan); }
.plan__readout .lead { max-width: 30ch; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8); }

.plan__timeline { padding: 8px 24px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.plan__marks { position: relative; height: 40px; }
.plan__mark {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.3s;
}
.plan__mark::after { content: ''; width: 1px; height: 22px; background: var(--ink-4); }
.plan__mark--alt::after { height: 8px; }
.plan__mark--first { transform: translateX(0); align-items: flex-start; }
.plan__mark--last { transform: translateX(-100%); align-items: flex-end; }
.plan__mark:hover, .plan__mark.is-past { color: var(--ink-2); }
.plan__mark.is-past::after { background: var(--cyan); }
.plan__foot { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.plan__o2 { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; max-width: 420px; }
.plan__o2 .meter { flex: 1; }
.plan__o2 .meter i { background: linear-gradient(90deg, var(--gold-2), var(--cyan)); }


  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  aspect-ratio: 1;
  max-height: 44vh;
  margin-inline: auto;
  width: 100%;
  max-width: 44vh;
}
  position: relative;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: clamp(7px, 0.75vw, 10px);
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.6);
  background: var(--cell, #555);
  transition: background 0.5s, transform 0.3s var(--ease), box-shadow 0.3s;
  cursor: default;
  user-select: none;
}

/* ───────────────────────── N+1 · Necessity ───────────────────────── */

.body--after { opacity: 0; transform: translateY(10px); transition: opacity 1.2s var(--ease), transform 1.2s var(--ease); color: var(--cyan); }
.body--after.is-on { opacity: 1; transform: none; }
.mind-hud, .necessity-hud {
  position: absolute;
  /* beside the text column, never under it: the controls take the rest of the row, up to 720px, centred in it */
  --gutter: calc(max(0px, (100% - var(--inner-max)) / 2) + var(--pad-x));
  left: calc(var(--gutter) + var(--text-col) + 24px);
  right: var(--gutter);
  max-width: 720px;
  margin: 0 auto;
  bottom: calc(28px + var(--nav-h));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 22px 12px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.mind-hud__row, .necessity-hud__row { display: flex; justify-content: space-between; align-items: baseline; }
.mind-hud__state, .necessity-hud__state { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; color: var(--cyan); }
.mind-hud__marks, .necessity-hud__marks { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-top: -6px; }
.mind-hud__mark--threshold { color: var(--gold); }
/* the time marks sit exactly under the thirds of the slider: 0–1, 1–5 and 5–8 billion years take a third each */
.necessity-hud__marks { display: block; position: relative; height: 12px; }
.necessity-hud__marks span { position: absolute; top: 0; white-space: nowrap; transform: translateX(-50%); }
.necessity-hud__marks span:nth-child(1) { left: 0; transform: none; }
.necessity-hud__marks span:nth-child(2) { left: 33.333%; }
.necessity-hud__marks span:nth-child(3) { left: 66.667%; }
.necessity-hud__marks span:nth-child(4) { left: 100%; transform: translateX(-100%); }
.necessity-hud__marks i { font-style: normal; }
.mind-hud__foot, .necessity-hud__foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 6px; }
.mind-hud__foot .hint, .necessity-hud__foot .hint { text-align: right; }
.necessity-hud { gap: 8px; }
.necessity-hud__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.necessity-hud__stat { display: flex; align-items: baseline; gap: 8px; }
.necessity-hud__stat strong { font-family: var(--font-mono); font-size: 13px; font-weight: 400; color: #fff; font-variant-numeric: tabular-nums; }
.necessity-hud__stat--life strong { color: var(--gold); }
.necessity-hud__stat--mind strong { color: var(--cyan); }
.necessity-hud__stat strong.is-gone { color: var(--ink-3); }
.necessity-hud__stat strong { transition: color 0.6s var(--ease); }

/* ───────────────────────── The Launch ───────────────────────── */

.launch-hud {
  position: absolute;
  right: var(--pad-x);
  bottom: var(--pad-bot);
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 10px 26px;
  align-items: end;
}
.launch-hud__stat { display: flex; flex-direction: column; gap: 4px; }
.launch-hud__stat strong { font-family: var(--font-mono); font-size: 22px; font-weight: 400; color: #fff; font-variant-numeric: tabular-nums; }
.launch-hud__stat--lost strong { color: var(--ink-3); }
.launch-hud__stat--div strong { color: var(--gold); }
.launch-hud__stat--exc strong { color: var(--cyan); }
.launch-hud .hint { grid-column: 1 / -1; }

/* ───────────────────────── The Tree ───────────────────────── */

.tree { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); clip-path: inset(-1px round var(--radius)); }
.tree__chart { position: relative; padding: 26px 26px 20px; border-right: 1px solid var(--line); min-height: 380px; }
.tree__axis { position: absolute; left: 26px; right: 26px; bottom: 26px; height: 1px; background: var(--line-2); }
.tree__tick { position: absolute; bottom: -22px; transform: translateX(-50%); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--ink-3); white-space: nowrap; }
.tree__tick::before { content: ''; position: absolute; left: 50%; top: -10px; width: 1px; height: 6px; background: var(--ink-4); }
.tree__tick:first-child { transform: none; }
.tree__tick:first-child::before { left: 0; }
.tree__tick:last-child { transform: translateX(-100%); }
.tree__tick:last-child::before { left: auto; right: 0; }
.tree__row { position: absolute; left: 26px; right: 26px; height: 40px; }
.tree__life { position: absolute; top: 18px; height: 3px; border-radius: 2px; background: rgba(233, 237, 245, 0.12); }
.tree__life--alive::after { content: ''; position: absolute; right: -3px; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px var(--gold); animation: hint-pulse 2s ease-in-out infinite; }
.tree__era { position: absolute; top: 17px; height: 5px; border-radius: 3px; background: linear-gradient(90deg, rgba(var(--cyan-rgb), 0.9), rgba(var(--cyan-rgb), 0.15)); }
.tree__era--open { background: linear-gradient(90deg, rgba(var(--cyan-rgb), 0.9), rgba(var(--cyan-rgb), 0.35)); }
.tree__node {
  position: absolute;
  top: 8px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: var(--bg);
  display: grid;
  place-items: center;
  transition: transform 0.3s var(--ease), border-color 0.3s, box-shadow 0.3s;
}
.tree__node::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; transition: background 0.3s; }
.tree__node:hover { transform: scale(1.2); }
.tree__node.is-active { border-color: var(--gold); box-shadow: 0 0 18px rgba(var(--gold-rgb), 0.6); }
.tree__node.is-active::before { background: var(--gold); }
.tree__label { position: absolute; top: -8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; pointer-events: none; }
.tree__label small { display: block; letter-spacing: 0.06em; text-transform: none; color: var(--ink-3); font-size: 9.5px; margin-top: 2px; }
.tree__link { position: absolute; width: 1px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05)); }
.tree__legend { position: absolute; right: 26px; top: 18px; display: flex; gap: 16px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--ink-3); }
.tree__legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

.tree__detail { padding: 26px 26px; display: flex; flex-direction: column; gap: 12px; }
.tree__detail .h3 { font-family: var(--font-display); font-size: 34px; line-height: 1; color: #fff; }
.tree__meta { display: flex; gap: 14px; flex-wrap: wrap; }
.tree__theme { font-family: var(--font-display); font-style: italic; font-size: 20px; color: var(--gold); }
.tree__detail.is-switching > * { animation: rise 0.6s var(--ease) both; }
.tree__detail.is-switching > *:nth-child(2) { animation-delay: 0.06s; }
.tree__detail.is-switching > *:nth-child(3) { animation-delay: 0.12s; }
.tree__detail.is-switching > *:nth-child(4) { animation-delay: 0.18s; }

/* ───────────────────────── Humanity's Theorem ───────────────────────── */

.grammar { display: flex; flex-direction: column; overflow: hidden; }
.grammar canvas { width: 100%; aspect-ratio: 16 / 10; }
.grammar__hud { padding: 16px 22px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.grammar__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.grammar__gen { font-family: var(--font-mono); font-size: 14px; color: var(--gold); }
.grammar__row strong { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: #fff; }

/* ───────────────────────── The Federation ───────────────────────── */

.fed-hud {
  position: absolute;
  right: var(--pad-x);
  bottom: calc(28px + var(--nav-h));
  width: min(440px, calc(100% - 2 * var(--pad-x)));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 22px 16px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.fed-hud__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fed-hud__stats > div { display: flex; flex-direction: column; gap: 3px; }
.fed-hud__stats strong { font-family: var(--font-mono); font-size: 18px; font-weight: 400; color: #fff; font-variant-numeric: tabular-nums; }
.fed-hud__ceil { display: flex; flex-direction: column; gap: 3px; padding-top: 10px; border-top: 1px solid var(--line); }
.fed-hud__limit { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--violet); }
.fed-hud__time { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding-top: 6px; }

/* ───────────────────────── Under the Floor ───────────────────────── */

.scene--floor .scene__inner { grid-template-rows: auto auto auto auto; align-content: start; align-content: safe center; gap: 22px; }
.root { position: relative; width: min(860px, 100%); aspect-ratio: 2 / 1; }
.root canvas { display: block; width: 100%; height: 100%; }
.root__hud { position: absolute; left: 0; right: 0; bottom: -22px; display: flex; justify-content: space-between; gap: 12px; }
.root__controls { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.root__controls .hint { margin: 0; }
.floor__after { max-width: 760px; text-align: center; opacity: 0; transform: translateY(12px); transition: opacity 1.4s var(--ease), transform 1.4s var(--ease); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.floor__after.is-on { opacity: 1; transform: none; }
.floor__after [data-reveal] { animation: none !important; opacity: 1; }
.scene--floor .hint { transition: opacity 0.6s; }
.scene--floor .hint.is-hidden { opacity: 0; animation: none; }
.scene--floor .root { margin-bottom: 18px; }

/* ───────────────────────── The Vehicle ───────────────────────── */

.scene--vehicle .scene__inner { grid-template-rows: auto 1fr; align-content: start; }
.vehicle { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 22px; width: 100%; height: 100%; padding-bottom: 8px; }
.vehicle__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 26px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-width: 560px;
  text-align: center;
}
.vehicle__pair { display: flex; gap: 12px; align-items: baseline; font-size: 14px; }
.vehicle__k { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); min-width: 90px; text-align: right; }
.vehicle__pair strong { color: #fff; font-weight: 400; font-size: 15px; }
.vehicle__label.is-switching > * { animation: rise 0.6s var(--ease) both; }
.vehicle__controls { display: flex; gap: 10px; }

/* ───────────────────────── The Ladder ───────────────────────── */

.ladder { display: flex; flex-direction: column-reverse; gap: 10px; padding: 10px 0; }
.rung {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 22, 0.35);
  text-align: left;
  transition: border-color 0.4s, background 0.4s, transform 0.4s var(--ease), opacity 0.4s;
  margin-left: calc(var(--i) * 18px);
}
.rung i { font-family: var(--font-display); font-style: normal; font-size: 26px; color: var(--ink-3); transition: color 0.4s; }
.rung span { font-family: var(--font-display); font-size: 19px; line-height: 1.25; color: var(--ink-2); transition: color 0.4s, text-decoration-color 0.6s; text-decoration: line-through; text-decoration-color: transparent; }
.rung:hover { border-color: var(--line-2); transform: translateX(4px); }
.rung.is-current { border-color: rgba(var(--gold-rgb), 0.55); background: rgba(var(--gold-rgb), 0.07); }
.rung.is-current i, .rung.is-current span { color: #fff; }
.rung.is-passed span { color: var(--ink-3); text-decoration-color: rgba(var(--rose-rgb), 0.7); }
.rung.is-passed i { color: var(--ink-4); }
.rung.is-locked { opacity: 0.4; }
.rung--top { border-style: dashed; border-color: rgba(var(--violet-rgb), 0.4); background: transparent; }
.rung--top i { color: var(--violet); }
.rung--top span { text-decoration: none; }
.rung--top.is-current { border-color: var(--violet); background: rgba(var(--violet-rgb), 0.08); box-shadow: 0 0 40px rgba(var(--violet-rgb), 0.2); }
.ladder__current { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; min-height: 120px; }
.ladder__current .lead { color: var(--gold); }
.ladder__current.is-switching > * { animation: rise 0.6s var(--ease) both; }

/* ───────────────────────── Doubt ───────────────────────── */

.scene--doubt .scene__inner { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.doubt__list { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.doubt__item {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: 19px;
  transition: background 0.3s, color 0.3s, padding-left 0.3s var(--ease);
}
.doubt__item i { font-family: var(--font-mono); font-style: normal; font-size: 10px; letter-spacing: 0.1em; color: var(--ink-3); }
.doubt__item:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.doubt__item.is-active { background: rgba(var(--cyan-rgb), 0.08); color: #fff; padding-left: 18px; }
.doubt__item.is-active i { color: var(--cyan); }
.doubt__panel { padding: 26px 28px; display: flex; flex-direction: column; gap: 14px; min-height: 340px; }
.doubt__claim { color: var(--ink-2); }
.doubt__response { font-size: clamp(14.5px, 1.05vw, 16.5px); line-height: 1.7; color: #fff; min-height: 140px; }
.doubt__response .caret { display: inline-block; width: 8px; height: 1.1em; vertical-align: -0.2em; background: var(--cyan); margin-left: 2px; animation: caret 0.9s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* ───────────────────────── What Stays Open ───────────────────────── */

.scene--questions .scene__inner { grid-template-rows: auto 1fr auto; align-content: space-between; justify-items: center; }
.questions__top { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.questions__card {
  align-self: center;
  width: min(560px, 100%);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0.55;
  transition: opacity 0.5s, transform 0.5s var(--ease);
  text-align: center;
  align-items: center;
}
.questions__card.is-on { opacity: 1; transform: translateY(-4px); }
.questions__title { font-family: var(--font-display); font-size: 28px; line-height: 1.1; color: #fff; min-height: 1em; }
.questions__end { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }

/* ───────────────────────── Theory page ───────────────────────── */

.doc { overflow-y: auto; }

/* ───────────────────────── Responsive ───────────────────────── */

@media (max-width: 1100px) {
  .plan { grid-template-columns: 180px 1fr; }
  .tree { grid-template-columns: 1fr; }
  .tree__chart { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Wide screens: the overlay chapters keep their text on screen and scroll it inside the panel (so it is
   never cut off, and never under the controls), and The Vehicle puts its text left of the rings */
@media (min-width: 901px) {
  .scene--overlay .scene__inner { grid-template-rows: minmax(0, 1fr); }
  .scene--overlay .scene__text--glass { max-height: 100%; overflow-y: auto; scrollbar-width: none; }
  .scene--overlay .scene__text--glass::-webkit-scrollbar { display: none; }
  .scene--vehicle .scene__inner { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-rows: minmax(0, 1fr); gap: clamp(28px, 4.5vw, 80px); align-items: start; justify-items: stretch; text-align: left; }
  .scene--vehicle .stack__head { align-items: flex-start; text-align: left; margin-inline: 0; }
}
/* on tablets in landscape the docked Necessity controls are narrow: the same compaction as on phones */
@media (min-width: 901px) and (max-width: 1120px) {
  .necessity-hud__row { flex-wrap: wrap; gap: 2px 12px; }
  .necessity-hud__marks i { display: none; }
  .necessity-hud__stat { flex-direction: column; gap: 2px; }
}

/* Collapsible text panels for the overlay chapters on small screens */
.glass-toggle { display: none; }

@media (max-width: 900px) {
  :root { --pad-top: 88px; --nav-h: 50px; --pad-bot: calc(14px + var(--nav-h)); }
  .scene--overlay .scene__text--glass { padding: 16px 18px 14px; gap: 8px; }
  .scene--overlay .scene__text--glass .h2 { font-size: clamp(30px, 8.5vw, 42px); margin-bottom: 0; }
  .scene--overlay .scene__text--glass .lead { font-size: 17px; }
  .scene--overlay .scene__text--glass > .body:not(.body--after),
  .scene--overlay .scene__text--glass > .badges,
  .scene--overlay .scene__text--glass > .note { display: none; }
  .scene--overlay .scene__text--glass.is-expanded > .body,
  .scene--overlay .scene__text--glass.is-expanded > .note { display: block; }
  .scene--overlay .scene__text--glass.is-expanded > .badges { display: flex; }
  .scene--overlay .scene__text--glass.is-expanded { max-height: calc(100vh - var(--pad-top) - var(--nav-h) - 16px); max-height: calc(100dvh - var(--pad-top) - var(--nav-h) - 16px); overflow-y: auto; scrollbar-width: none; }
  /* while a panel is open for reading, the chapter's controls step aside so the text is never under them */
  .vent-hud, .mind-hud, .necessity-hud, .launch-hud, .fed-hud { transition: opacity 0.45s var(--ease); }
  .scene.is-reading .vent-hud, .scene.is-reading .mind-hud, .scene.is-reading .necessity-hud, .scene.is-reading .launch-hud, .scene.is-reading .fed-hud { opacity: 0; pointer-events: none; }
  .scene--overlay .scene__text--glass .body--after:not(.is-on) { display: none; }
  .glass-toggle {
    display: inline-flex; align-self: flex-start; align-items: center; height: 32px; padding: 0 14px; margin-top: 2px;
    border: 1px solid var(--line-2); border-radius: 999px; font-family: var(--font-mono); font-size: 10px;
    letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-2);
  }
  .glass-toggle::after { content: ''; width: 5px; height: 5px; margin-left: 10px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform 0.3s var(--ease); }
  .is-expanded .glass-toggle::after { transform: translateY(2px) rotate(-135deg); }
  .vent-hud { flex-wrap: wrap; gap: 10px 24px; }
  .vent-hud .hint { flex-basis: 100%; margin: 0; }
  .hud__chapter { display: none; }
  .hud__btn-label { display: none; }
  .hud__btn { padding: 0 12px; }
  .dots { display: none; }
  .scene__inner { align-items: start; align-content: start; align-content: safe center; }
  .scene--stack .scene__inner { grid-template-rows: auto auto auto; align-content: start; }
  .scene--stack .scene__inner > .panel { align-self: start; }
  .plan__mark { font-size: 0; gap: 0; }
  .plan__mark::after { height: 12px; }
  .plan__mark--alt::after { height: 6px; }
  .plan__marks { height: 16px; }
  .scene--split .scene__inner, .scene--overlay .scene__inner, .scene--doubt .scene__inner { grid-template-columns: 1fr; gap: 24px; }
  .scene--overlay .scene__inner { padding-bottom: calc(250px + var(--nav-h)); }
  .scene__text--glass { padding: 20px; }
  .law-tabs { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .law-tab span { display: none; }
  .law-tab { align-items: center; padding: 10px 6px; }
  .plan { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .plan__toolkit { grid-row: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .tool { grid-template-columns: 32px 1fr; padding: 8px 10px; min-width: 150px; }
  .tool + .tool { border-top: 0; border-left: 1px solid var(--line); }
  .tool__icon { width: 32px; height: 32px; }
  .plan__stage { min-height: 200px; }
  .vent-hud, .launch-hud { left: var(--pad-x); right: var(--pad-x); bottom: calc(20px + var(--nav-h)); justify-content: space-between; }
  .launch-hud { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .launch-hud__stat strong, .vent-hud strong { font-size: 18px; }
  .mind-hud, .necessity-hud { left: var(--pad-x); right: var(--pad-x); max-width: none; bottom: calc(16px + var(--nav-h)); padding: 12px 16px 10px; }
  .mind-hud__marks span:nth-child(even) { display: none; }
  .necessity-hud { gap: 6px; }
  .necessity-hud__row { flex-wrap: wrap; gap: 2px 12px; }
  .necessity-hud__marks i, .necessity-hud__foot .hint { display: none; }
  .necessity-hud__stats { gap: 6px; }
  .necessity-hud__stat { flex-direction: column; gap: 2px; }
  .fed-hud { left: var(--pad-x); right: var(--pad-x); width: auto; bottom: calc(16px + var(--nav-h)); gap: 10px; padding: 14px 16px 12px; }
  .fed-hud__ceil { display: none; }
  .fed-hud__time { grid-template-columns: 1fr; gap: 6px; }
  .ladder { padding: 0; }
  .rung { margin-left: calc(var(--i) * 8px); padding: 12px 14px; }
  .rung span { font-size: 16px; }
  .doubt__list { max-height: none; }
  .doubt__panel { min-height: 0; }
  .questions__card { position: relative; }
  .root__hud { flex-direction: column; gap: 2px; bottom: -54px; }
  .scene--floor .scene__inner { gap: 24px; align-content: start; }
  .scene--floor .root { margin-bottom: 52px; }
  .scene--floor .floor__after:not(.is-on) { display: none; }
  .scene--questions .scene__inner, .scene--vehicle .scene__inner { align-content: start; }
  .vehicle__label { padding: 14px 16px; }
  .vehicle__pair { flex-direction: column; gap: 2px; align-items: center; }
  .vehicle__k { text-align: center; }
}

/* a short, wide screen (a phone on its side): the dock becomes one row so the film keeps its height */
@media (max-height: 520px) and (orientation: landscape) {
  .cosmos__dock { flex-direction: row; justify-content: space-between; gap: 16px; padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .cosmos__dock::before { top: -34px; }
  .cosmos__br { display: none; }
  .cosmos__tagline { font-size: 16px; }
  .cosmos__actions .btn { height: 40px; padding: 0 20px; font-size: 10.5px; }
  .cosmos__step { width: 32px; height: 32px; }
  .cosmos__pip { width: 8px; }
  .cosmos__pip.is-active { width: 26px; }
  .cosmos__pip.is-active i { width: 22px; }
  .cosmos__replay { height: 32px; transform: translate(-50%, 0); }
  .cosmos__replay.is-on { transform: translate(-50%, -6px); }
  .title { font-size: clamp(30px, 7.5vh, 72px); }
}

@media (max-width: 560px) {
  .title { font-size: clamp(34px, 11.5vw, 96px); letter-spacing: 0.06em; }
  .hud__brand { font-size: 15px; letter-spacing: 0.22em; }
  .cosmos__dock { gap: 12px; padding-top: 16px; }
  .cosmos__tagline { font-size: 19px; }
  .cosmos__controls { gap: 10px; }
  .cosmos__step { width: 34px; height: 34px; }
  .cosmos__pips { gap: 4px; }
  .cosmos__pip { width: 8px; }
  .cosmos__pip i { width: 5px; height: 5px; }
  .cosmos__pip.is-active { width: 26px; }
  .cosmos__pip.is-active i { width: 22px; }
  .whisper__text { font-size: 16px; }
  .dose__grid, .fed-hud__stats { grid-template-columns: 1fr 1fr; }
  .law-tabs { gap: 4px; }
  .journey-launch { top: 12px; right: 12px; }
  .journey-caption { left: 12px; right: 12px; bottom: 12px; }
  .questions__end .actions { flex-direction: column; }
  .tree__tick:nth-child(2) { display: none; }
  .tree__label small { display: none; }
}

@media (max-height: 700px) and (min-width: 900px) {
  :root { --pad-top: 72px; --nav-h: 50px; --pad-bot: calc(10px + var(--nav-h)); }
  .scene__text { gap: 12px; }
  .body { font-size: 14px; line-height: 1.55; }
  .lead { font-size: 20px; }
}

/* ───────────────────────── Reduced motion ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.2s !important; }
  .scene { filter: none; transform: none; }
  [data-reveal] { opacity: 1; }
  .nebula { animation: none; }
}
