:root {
  color-scheme: dark;
  --bg: #05060a;
  --ink: #e9edf5;
  --ink-dim: #9aa3b6;
  --ink-faint: #4a5060;
  --line: rgba(230, 234, 246, 0.10);
  --line-strong: rgba(230, 234, 246, 0.22);

  /* palette — objetd'art tissue, cool + warm, muted, luminous */
  --mind: #7fb2ff;
  --bound: #a5e0ff;
  --committed: #f6d67a;
  --animal: #ffd15c;
  --cream: #f2eee6;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; height: 100dvh; overscroll-behavior: none; }
body {
  background:
    radial-gradient(1200px 800px at 50% 40%, rgba(30, 60, 130, 0.16), transparent 60%),
    radial-gradient(1600px 1000px at 50% 120%, rgba(10, 20, 60, 0.35), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: "Fraunces", "Iowan Old Style", "Georgia", serif;
  font-weight: 400;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
}

.narrator-loci {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.narrator-pin {
  position: absolute;
  transform: translate(-50%, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(260px, 68vw);
  animation: pin-rise 640ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.narrator-pin::before {
  content: "";
  width: 1px;
  height: 16px;
  margin-bottom: 5px;
  background: linear-gradient(180deg, rgba(230, 234, 246, 0), rgba(230, 234, 246, 0.55));
}
.narrator-pin .pin-label {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 13.5px;
  font-variation-settings: "opsz" 36;
  line-height: 1.35;
  color: var(--cream);
  background: linear-gradient(180deg, rgba(14,16,26,0.58), rgba(8,10,18,0.48));
  border: 1px solid rgba(230, 234, 246, 0.16);
  border-radius: 999px;
  padding: 6px 13px;
  text-align: center;
  letter-spacing: 0.01em;
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 10px 28px rgba(0,0,0,0.28), 0 0 18px rgba(150,178,226,0.12);
}
@keyframes pin-rise {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

.field-notice {
  position: fixed;
  top: calc(var(--safe-top) + 62px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--cream);
  background: rgba(10, 12, 22, 0.74);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: min(440px, calc(100vw - 32px));
  text-align: center;
}

.chrome {
  position: fixed;
  z-index: 2;
  pointer-events: none;
  color: var(--ink);
}
.chrome > * { pointer-events: auto; touch-action: auto; }
.chrome.top,
.chrome.legend,
.chrome.telemetry { z-index: 7; }
.chrome.bottom { z-index: 8; }

/* ── Top: brand + epigraph ────────────────────────────────────────────── */
.top {
  top: var(--safe-top);
  left: var(--safe-left); right: var(--safe-right);
  padding: 22px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
}
.mark { display: flex; align-items: baseline; gap: 12px; }
.mark .glyph {
  font-family: "JetBrains Mono", monospace;
  color: var(--bound);
  font-size: 18px;
  transform: translateY(1px);
  text-shadow: 0 0 12px rgba(160, 220, 255, 0.35);
}
.mark .title {
  font-size: 22px;
  letter-spacing: 0.02em;
  font-weight: 400;
  font-variation-settings: "opsz" 144;
}
.top-cluster {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.epigraph {
  color: var(--ink-dim);
  font-size: 13px;
  font-style: italic;
  letter-spacing: 0.02em;
  font-variation-settings: "opsz" 24;
  text-align: right;
  max-width: 480px;
}
.action-cluster {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.action-btn {
  width: 36px;
  height: 36px;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(14,16,26,0.55), rgba(10,12,22,0.55));
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
}
.action-btn:hover { background: rgba(255,255,255,0.07); border-color: rgba(230,234,246,0.45); }
.action-btn:active { transform: scale(0.94); }
.action-btn .icon-play { display: none; }
.action-btn.active .icon-pause { display: none; }
.action-btn.active .icon-play { display: inline-block; }
.action-btn .icon-muted { display: none; }
.action-btn.active .icon-sound { display: none; }
.action-btn.active .icon-muted { display: inline-block; }
#btn-mute.active { color: var(--ink-faint); border-color: var(--line); }
#btn-gap.active { color: var(--bound); border-color: var(--bound); }
#btn-panels.active { color: var(--bound); border-color: var(--bound); }

.legend .row.keys.tappable {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease;
}
.legend .row.keys.tappable:hover { background: rgba(255,255,255,0.04); }
.legend .row.keys.tappable:active { background: rgba(255,255,255,0.08); }

/* ── Legend ──────────────────────────────────────────────────────────── */
.legend {
  left: calc(20px + var(--safe-left));
  bottom: calc(110px + var(--safe-bot));
  /* Never taller than the room between the header and the verse. */
  max-height: calc(100dvh - 110px - 92px - var(--safe-bot) - var(--safe-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
  max-width: 320px;
  background: linear-gradient(180deg, rgba(8,10,18,0.55), rgba(8,10,18,0.35));
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 10px;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  transition: opacity 200ms ease, transform 200ms ease;
}
.legend .section-title {
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
  margin: 2px 0 6px;
}
.legend .row { display: flex; align-items: center; gap: 10px; }
.legend .row b { color: var(--ink); font-weight: 500; }
.legend .row.keys kbd {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
  color: var(--ink);
  font: inherit;
  font-size: 10.5px;
}
.legend .sep {
  height: 1px;
  background: var(--line);
  margin: 10px -14px;
}
.legend .dot {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
  flex: none;
}
.legend .dot.mind      { background: var(--mind);      color: var(--mind); }
.legend .dot.bound     { background: var(--bound);     color: var(--bound); }
.legend .dot.committed { background: var(--committed); color: var(--committed); }
.legend .dot.animal    { background: var(--animal);    color: var(--animal); }
.legend .dot.circuit {
  background: transparent;
  box-shadow: 0 0 0 1.4px rgba(242, 238, 230, 0.55), 0 0 7px rgba(150, 178, 226, 0.4);
}
.legend .dot.wave {
  background: rgba(160, 220, 255, 0.85);
  box-shadow: 0 0 8px rgba(160, 220, 255, 0.55);
}
.legend .dot.channel {
  background:
    radial-gradient(circle at 30% 34%, rgba(134, 186, 168, 0.95) 0 1.6px, transparent 2.2px),
    radial-gradient(circle at 72% 40%, rgba(132, 176, 255, 0.95) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 48% 76%, rgba(226, 140, 108, 0.95) 0 1.4px, transparent 2px);
  box-shadow: 0 0 0 1px rgba(214, 232, 255, 0.35);
}
.legend .dot.jev {
  background: rgba(186, 168, 232, 0.9);
  box-shadow: 0 0 8px rgba(186, 168, 232, 0.5);
}

/* ── Telemetry ───────────────────────────────────────────────────────── */
.telemetry {
  right: calc(20px + var(--safe-right));
  bottom: calc(110px + var(--safe-bot));
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  text-align: right;
  line-height: 1.9;
  background: linear-gradient(180deg, rgba(8,10,18,0.55), rgba(8,10,18,0.35));
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  transition: opacity 200ms ease, transform 200ms ease;
}

body.panels-off .legend,
body.panels-off .telemetry {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}
body.panels-off .legend *,
body.panels-off .telemetry * {
  pointer-events: none;
}
.telemetry .kv { display: flex; justify-content: flex-end; gap: 14px; }
.telemetry .k { color: var(--ink-faint); text-transform: lowercase; }
.telemetry .v { color: var(--ink); min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Objective trial card ─────────────────────────────────────────────── */
.legend .dot.objective {
  background: linear-gradient(135deg, rgba(246, 214, 122, 0.95) 0 48%, rgba(214, 232, 255, 0.95) 52% 100%);
  box-shadow: 0 0 7px rgba(214, 232, 255, 0.35);
}
#btn-objective.active { color: #f6d67a; border-color: rgba(246, 214, 122, 0.7); }
.objective-card {
  position: fixed;
  z-index: 7;
  right: calc(20px + var(--safe-right));
  bottom: calc(110px + var(--safe-bot));
  width: 318px;
  pointer-events: auto;
  touch-action: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, rgba(8,10,18,0.72), rgba(8,10,18,0.56));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px 12px;
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35), 0 0 22px rgba(132,176,255,0.08);
  transition: opacity 200ms ease, transform 200ms ease;
  max-height: calc(100dvh - 110px - 92px - var(--safe-bot) - var(--safe-top));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.legend .row.keys.tappable.phone-only { display: none; }
body.obj-on .telemetry { opacity: 0; transform: translateY(16px); pointer-events: none; }
body.obj-on .telemetry * { pointer-events: none; }
.obj-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.obj-title {
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10px;
}
.obj-mode { color: var(--bound); font-size: 10.5px; flex: 1; }
.obj-x {
  width: 26px; height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font: 15px/1 "JetBrains Mono", monospace;
  cursor: pointer;
}
.obj-x:hover { color: var(--ink); border-color: var(--line-strong); }
.obj-more { display: none; }
.objective-card.behind { opacity: 0; pointer-events: none; }
.objective-card.behind * { pointer-events: none; }
.objective-card.min .obj-spark,
.objective-card.min .obj-legend,
.objective-card.min .obj-conds,
.objective-card.min .obj-modes,
.objective-card.min .obj-model,
.objective-card.min .obj-q { display: none; }
.objective-card.min .obj-nums { margin-bottom: 0; }
.obj-nums { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 8px; }
.obj-num { display: flex; flex-direction: column; line-height: 1.1; }
.obj-num b {
  font-weight: 400;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.obj-num.tau b { color: #f6d67a; }
.obj-num.eps b { color: #d6e8ff; }
.obj-num span { font-size: 10px; color: var(--ink-faint); }
.obj-num span i { font-family: "Fraunces", serif; font-style: italic; font-size: 11px; }
.obj-verdict {
  flex: 1;
  text-align: right;
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--cream);
}
.obj-verdict.bad { color: #f0a58c; }
.obj-verdict.good { color: #bcd6ff; }
.obj-spark { display: block; width: 100%; height: 64px; }
.obj-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px;
  font-size: 9px; color: var(--ink-faint); margin: 4px 0 8px; letter-spacing: 0;
}
.obj-legend > span { white-space: nowrap; }
.obj-legend .sw { display: inline-block; width: 10px; height: 0; border-top: 1.5px solid; margin-right: 4px; vertical-align: middle; }
.obj-legend .sw.tau { border-color: #f6d67a; border-top-style: dashed; }
.obj-legend .sw.eps { border-color: #d6e8ff; }
.obj-legend .sw.gap { height: 7px; border: 0; background: rgba(226, 140, 108, 0.28); }
.obj-legend .sw.mark { width: 0; height: 9px; border-top: 0; border-left: 1.5px dashed #e28c6c; }
.obj-conds { display: grid; gap: 4px; margin-bottom: 9px; }
.obj-cond { display: grid; grid-template-columns: 70px 1fr 32px 92px; align-items: center; gap: 8px; }
.obj-cond .k { color: var(--ink); }
.obj-cond .bar { position: relative; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: visible; }
.obj-cond .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 2px; background: rgb(132, 176, 255); transition: width 160ms linear, background 160ms linear; }
.obj-cond .bar em { position: absolute; top: -3px; width: 1px; height: 10px; background: var(--cream); opacity: 0.75; }
.obj-cond .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.obj-cond .t { color: var(--ink-faint); font-size: 9.5px; white-space: nowrap; }
.obj-cond.low .bar i { background: rgb(226, 140, 108); }
.obj-cond.side { opacity: 0.62; }
.obj-cond.side .bar { background: repeating-linear-gradient(90deg, rgba(132,176,255,0.35) 0 2px, transparent 2px 7px); }
.obj-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.obj-modes button {
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--ink-dim);
  font: 10.5px "JetBrains Mono", monospace;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.obj-modes button:hover { color: var(--ink); border-color: var(--line-strong); }
.obj-modes button[aria-checked="true"] { color: var(--bound); border-color: var(--bound); background: rgba(165,224,255,0.06); }
.obj-model { margin: 8px 0 0; font-size: 9.5px; line-height: 1.45; color: var(--ink-faint); }
.obj-q {
  margin: 7px 0 0;
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--cream);
  opacity: 0.85;
}

/* ── Bottom row: ? + verse-btn + menu ─────────────────────────────────── */
.bottom {
  z-index: 8;
  bottom: var(--safe-bot);
  left: var(--safe-left); right: var(--safe-right);
  padding: 0 28px 22px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
}
.verse-btn {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(10,12,22,0.62), rgba(6,8,16,0.52));
  border: 1px solid var(--line);
  padding: 8px 14px;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  border-radius: 999px;
  transition: background 160ms ease, border-color 160ms ease;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
}
.verse-btn.hearing {
  border-color: rgba(242, 238, 230, 0.32);
  box-shadow: 0 8px 28px rgba(0,0,0,0.28), 0 0 26px rgba(150, 178, 226, 0.22);
}
.verse-btn:hover { background: linear-gradient(180deg, rgba(14,16,26,0.72), rgba(8,10,18,0.62)); border-color: var(--line-strong); }
.verse-btn:focus-visible { outline: 1px solid var(--line-strong); outline-offset: 2px; }
.verse {
  color: var(--cream);
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.02em;
  font-variation-settings: "opsz" 36;
  opacity: 1;
  transition: opacity 140ms ease;
  text-align: center;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: none;
  text-shadow: 0 1px 10px rgba(0,0,0,0.55);
}
.verse-btn .chevron {
  color: var(--ink-dim);
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  transition: color 160ms ease, transform 200ms ease, background 160ms ease;
  flex-shrink: 0;
}
.verse-btn:hover .chevron { color: var(--ink); background: rgba(255,255,255,0.08); }
.verse-btn[aria-expanded="true"] .chevron { color: var(--ink); transform: rotate(180deg); }

.info-btn, .menu-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  font-family: "Fraunces", serif;
  font-size: 18px;
  line-height: 1;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.info-btn:hover, .menu-btn:hover { background: rgba(255,255,255,0.07); border-color: rgba(230,234,246,0.45); }
.info-btn:active, .menu-btn:active { transform: scale(0.96); }
.info-btn { grid-column: 1; justify-self: start; font-style: italic; }
.menu-btn {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}
body.panels-off .menu-btn { color: var(--bound); border-color: var(--bound); }

/* ── Mind hover tooltip ──────────────────────────────────────────────── */
.mind-tooltip {
  position: fixed;
  z-index: 6;
  pointer-events: none;
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(14,16,26,0.94), rgba(10,12,22,0.94));
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  color: var(--ink);
  font-family: "Fraunces", serif;
  font-size: 13px;
  font-variation-settings: "opsz" 24;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 160ms ease;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
}
.mind-tooltip.on { opacity: 1; transform: translateY(0); }
.mind-tooltip .tooltip-species {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.mind-tooltip .tooltip-body em { color: var(--bound); font-style: italic; }

/* ── Narrator drawer ─────────────────────────────────────────────────── */
.narrator-drawer,
.modal-scrim,
.modal {
  touch-action: auto;
}
.drawer-log { touch-action: pan-y; }
.narrator-drawer {
  position: fixed;
  z-index: 5;
  left: 0; right: 0;
  bottom: 0;
  padding: 0 calc(20px + var(--safe-right)) calc(64px + var(--safe-bot)) calc(20px + var(--safe-left));
  pointer-events: none;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 220ms ease;
}
.narrator-drawer.on { transform: translateY(0); opacity: 1; pointer-events: auto; }
.drawer-inner {
  margin: 0 auto;
  max-width: 640px;
  max-height: min(60vh, 520px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(14,16,26,0.92), rgba(10,12,22,0.92));
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(160,200,255,0.05) inset;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 4px;
}
.drawer-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.drawer-close {
  width: 28px; height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: color 120ms ease, border-color 120ms ease;
}
.drawer-close:hover { color: var(--ink); border-color: var(--line-strong); }
.drawer-intro {
  color: var(--ink);
  font-family: "Fraunces", serif;
  font-size: 14.5px;
  line-height: 1.55;
  margin: 6px 18px 8px;
  font-variation-settings: "opsz" 24;
}
.drawer-intro em { color: var(--bound); font-style: italic; }
.drawer-log {
  padding: 4px 6px 14px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.drawer-log-empty {
  color: var(--ink-faint);
  font-style: italic;
  font-size: 13px;
  padding: 12px 0;
}
.morphospace {
  padding: 4px 18px 16px;
  pointer-events: auto;
}
.morphospace .section-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.morph-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.morph-chip {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  color: var(--ink-dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  cursor: pointer;
  pointer-events: auto;
}
.morph-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.morph-chip.on { color: var(--cream); border-color: var(--bound); background: rgba(255,209,92,0.08); }
.morph-chip.in { box-shadow: 0 0 0 1px rgba(132, 176, 255, 0.55) inset; }
.log-entry {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 10px 12px 10px 14px;
  border: 0;
  border-left: 1px solid var(--line);
  margin-bottom: 8px;
  cursor: pointer;
  border-radius: 0 8px 8px 0;
  transition: border-color 300ms ease, background 160ms ease;
}
.log-entry.has-locus:hover,
.log-entry.has-locus:focus-visible {
  background: rgba(150, 178, 226, 0.08);
  border-left-color: var(--bound);
}
.log-entry.fresh { border-left-color: var(--bound); }
.log-entry.chord { border-left-color: var(--committed); }
.log-entry.animal { border-left-color: var(--animal); }
.log-short {
  color: var(--ink);
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 15px;
  font-variation-settings: "opsz" 24;
  line-height: 1.35;
}
.log-long {
  color: var(--ink-dim);
  font-family: "Fraunces", serif;
  font-size: 13.5px;
  line-height: 1.55;
  margin-top: 4px;
  font-variation-settings: "opsz" 24;
}
.log-time {
  color: var(--ink-faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  margin-top: 4px;
}

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bot)) calc(20px + var(--safe-left));
  background: radial-gradient(1200px 800px at 50% 30%, rgba(10,20,50,0.6), rgba(5,6,10,0.85));
  opacity: 0;
  transition: opacity 220ms ease;
}
.modal-scrim.on { opacity: 1; }
.modal {
  max-width: 640px;
  width: 100%;
  max-height: 88dvh;
  overflow: auto;
  background: linear-gradient(180deg, rgba(14,16,26,0.9), rgba(10,12,22,0.9));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 28px 32px 24px;
  color: var(--ink);
  box-shadow: 0 40px 100px rgba(0,0,0,0.6), 0 0 0 1px rgba(160,200,255,0.06) inset;
  position: relative;
  transform: translateY(6px);
  transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.modal-scrim.on .modal { transform: translateY(0); }
.modal h2 {
  margin: 0 0 8px;
  font-weight: 500;
  font-variation-settings: "opsz" 144;
  font-size: 26px;
  letter-spacing: 0.005em;
}
.modal .lede {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.6;
  margin: 0 0 18px;
}
.modal h3 {
  font-size: 12.5px;
  font-family: "JetBrains Mono", monospace;
  color: var(--ink-faint);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 20px 0 8px;
  font-weight: 400;
}
.modal ul {
  margin: 0 0 8px;
  padding-left: 20px;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.6;
}
.modal ul li { margin: 4px 0; }
.modal ul li strong, .modal ul li b { color: var(--ink); font-weight: 500; }
.modal em { color: var(--ink); font-style: italic; }
.modal a { color: var(--bound); text-decoration: none; border-bottom: 1px dotted var(--bound); }
.modal a:hover { border-bottom-style: solid; }
.modal .attribution {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  line-height: 1.6;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); border-color: var(--line-strong); }

/* ── Mobile / small viewports ─────────────────────────────────────────── */
@media (max-width: 780px) {
  .epigraph { display: none; }
  .top { padding: 12px 16px 0; align-items: center; }
  .top-cluster { align-items: flex-end; gap: 0; }
  .action-cluster { gap: 6px; }
  .action-btn { width: 40px; height: 40px; }
  /* ⌇ in the footer is the panels toggle here; the top duplicate would
     push the cluster off a 390 px screen. Chord/arpeggio (look only) moves
     to the legend so the objective trial gets its slot. */
  #btn-panels, #btn-gap { display: none; }
  .legend .row.keys.tappable.phone-only { display: flex; }
  .legend { max-height: calc(100dvh - 90px - 84px - var(--safe-bot) - var(--safe-top)); }
  .objective-card {
    left: calc(12px + var(--safe-left));
    right: calc(12px + var(--safe-right));
    width: auto;
    bottom: calc(84px + var(--safe-bot));
    max-height: 48vh;
    overflow-y: auto;
    padding: 10px 12px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(8,10,18,0.86);
  }
  body.obj-on .legend { opacity: 0; transform: translateY(16px); pointer-events: none; }
  body.obj-on .legend * { pointer-events: none; }
  /* A phone gets the essentials: numbers, verdict, chart, two conditions,
     the three objectives. The long print lives in the ? explainer. */
  .obj-head { margin-bottom: 4px; }
  .obj-nums { margin-bottom: 4px; gap: 12px; }
  .obj-spark { height: 44px; }
  .obj-num b { font-size: 18px; }
  .obj-verdict { font-size: 12px; }
  .obj-legend, .obj-model, .obj-q, .obj-cond.side { display: none; }
  .obj-more {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 999px;
    border: 1px solid var(--line); background: transparent;
    color: var(--ink-dim); font: 13px/1 "JetBrains Mono", monospace; cursor: pointer;
    transition: transform 160ms ease;
  }
  .objective-card.min .obj-more { transform: rotate(180deg); }
  .obj-conds { margin: 6px 0 8px; gap: 2px; }
  .obj-cond { grid-template-columns: 62px 1fr 30px 58px; gap: 6px; font-size: 10px; }
  .bottom { padding: 0 14px 16px; grid-template-columns: 40px 1fr 40px; }
  .menu-btn { display: inline-flex; }
  .legend, .telemetry {
    max-width: min(300px, calc(100vw - 40px));
    font-size: 11px;
    bottom: calc(90px + var(--safe-bot));
  }
  .verse {
    font-size: 13.5px;
    max-width: none;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow: hidden;
    line-height: 1.35;
  }
  .verse-btn { padding: 9px 12px; border-radius: 16px; min-height: 44px; }
  .info-btn, .menu-btn { width: 40px; height: 40px; }
  .mark .title { font-size: 18px; }
  .modal { padding: 22px 20px 20px; border-radius: 14px; }
  .modal h2 { font-size: 22px; }
  .modal ul { font-size: 13px; padding-left: 18px; }
  .modal .lede { font-size: 14px; }
  .narrator-drawer { padding-left: 14px; padding-right: 14px; padding-bottom: calc(60px + var(--safe-bot)); }
  .drawer-inner { max-height: 68vh; }
  .drawer-intro { font-size: 13.5px; }
  .log-short { font-size: 14px; }
  .log-long { font-size: 12.5px; }
}

@media (hover: none) and (pointer: coarse) {
  .verse {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
    max-width: none;
  }
  .verse-btn { min-height: 44px; padding: 9px 14px; }
  .info-btn, .menu-btn, .action-btn { width: 44px; height: 44px; }
  .menu-btn { display: inline-flex; }
  #btn-panels, #btn-gap { display: none; }
  .legend .row.keys.tappable.phone-only { display: flex; }
  .obj-modes button { min-height: 40px; }
  .obj-x { width: 36px; height: 36px; }
  .obj-more {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 999px;
    border: 1px solid var(--line); background: transparent;
    color: var(--ink-dim); font: 13px/1 "JetBrains Mono", monospace; cursor: pointer;
    transition: transform 160ms ease;
  }
  .objective-card.min .obj-more { transform: rotate(180deg); }
  .legend, .telemetry {
    bottom: calc(96px + var(--safe-bot));
  }
}

@media (prefers-reduced-motion: reduce) {
  .objective-card, .obj-cond .bar i { transition: none; }
  .verse { transition: none; }
  .modal-scrim, .modal { transition: none; }
}
