:root {
  --bg-0: #04050b;
  --bg-1: #0a1020;
  --ink: #dfe9ff;
  --ink-dim: #7d8db0;
  --accent-a: #57e6ff;
  --accent-b: #ff5ad1;
  --panel-bg: rgba(8, 12, 26, 0.82);
  --line: rgba(87, 230, 255, 0.22);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --col-w: 380px;
}
html[data-theme="blueprint"] {
  --bg-0: #ece7db;
  --bg-1: #f6f3ea;
  --ink: #1c3350;
  --ink-dim: #6a7891;
  --accent-a: #1d5fd6;
  --accent-b: #c2334d;
  --panel-bg: rgba(250, 248, 241, 0.88);
  --line: rgba(29, 95, 214, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s ease, color 0.5s ease;
}

#stage { position: fixed; inset: 0; }
#space { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#space.dragging { cursor: grabbing; }
#space.hot { cursor: pointer; }
#space.inlens { cursor: move; }
#space.handling { cursor: grabbing; }

.hud { position: fixed; z-index: 20; user-select: none; -webkit-user-select: none; }

.hud-brand { top: max(18px, env(safe-area-inset-top)); left: max(20px, env(safe-area-inset-left)); }
.brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--ink);
  font-family: inherit; text-align: left; cursor: pointer; padding: 4px;
}
.brand-mark {
  border: 1px solid var(--line);
  padding: 7px 9px 5px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.08em;
  color: var(--accent-a);
}
.brand-word {
  font-size: 10px; letter-spacing: 0.34em; line-height: 1.5;
  color: var(--ink-dim);
}
.brand:hover .brand-mark { border-color: var(--accent-a); }

.hud-telemetry {
  left: max(20px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  font-size: 10.5px; line-height: 1.75; letter-spacing: 0.04em;
  color: var(--ink-dim);
}
.tele-row { display: flex; gap: 14px; }
.tele-k { width: 150px; opacity: 0.75; }
.tele-v { color: var(--ink); white-space: nowrap; }

.hud-hints {
  right: max(20px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; gap: 22px;
  font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-dim);
  transition: opacity 0.4s ease;
}
.hud-hints b { color: var(--accent-a); font-weight: 600; margin-right: 6px; }
body.open .hud-hints { opacity: 0; pointer-events: none; }

.theme-toggle {
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--line); color: var(--ink-dim);
  font-family: inherit; font-size: 10px; letter-spacing: 0.2em;
  padding: 8px 12px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent-b); color: var(--ink); }
.tt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-b); }
.tt-label { text-transform: uppercase; }

/* the case file: two columns of marginalia either side of the opened cell, no box, no thumbnail */
.dossier { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.dossier-head, .dossier-body {
  position: absolute; pointer-events: auto;
  width: var(--col-w);
  opacity: 0;
  text-shadow: 0 0 18px var(--bg-0), 0 0 6px var(--bg-0), 0 1px 2px var(--bg-0);
  transition: opacity 0.55s ease 0.3s, transform 0.75s cubic-bezier(0.22, 1, 0.3, 1) 0.3s;
}
.dossier-head { left: max(20px, env(safe-area-inset-left)); top: 96px; transform: translateX(-18px); }
.dossier-body { right: max(20px, env(safe-area-inset-right)); top: 50%; transform: translate(18px, -50%); }
.dossier.open .dossier-head { opacity: 1; transform: translateX(0); }
.dossier.open .dossier-body { opacity: 1; transform: translate(0, -50%); }
.dossier:not(.open) .dossier-head, .dossier:not(.open) .dossier-body { transition-delay: 0s; transition-duration: 0.3s; }
.dossier.swap .dossier-head, .dossier.swap .dossier-body { opacity: 0.12; transition: opacity 0.18s ease; }

.dossier-eyebrow { display: flex; align-items: center; gap: 12px; font-size: 11px; letter-spacing: 0.28em; color: var(--accent-a); }
.dossier-rule { flex: 1; height: 1px; background: var(--line); }
#dossier-year { color: var(--ink-dim); }
.dossier h2 {
  margin-top: 14px;
  font-size: clamp(28px, 3.4vw, 52px);
  letter-spacing: 0.02em; line-height: 1.02;
  font-weight: 700;
}
.dossier-tagline { margin-top: 10px; color: var(--accent-b); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; line-height: 1.6; }

.dossier-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dossier-fig { font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim); }
.dossier-close {
  flex: none;
  background: none; border: 1px solid transparent; color: var(--ink-dim);
  font-size: 22px; line-height: 1; width: 36px; height: 36px; cursor: pointer;
  font-family: inherit;
}
.dossier-close:hover { color: var(--accent-b); border-color: var(--line); }
.dossier-desc { margin-top: 12px; line-height: 1.75; font-size: 13px; color: var(--ink); }
.dossier-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.dossier-tags li {
  border: 1px solid var(--line); color: var(--ink-dim);
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 5px 9px;
  background: color-mix(in srgb, var(--bg-0) 55%, transparent);
}
.dossier-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.meta-k { display: block; font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 5px; }
.meta-v { font-size: 12px; line-height: 1.5; }
.dossier-handle { margin-top: 22px; font-size: 11px; line-height: 1.65; color: var(--ink-dim); }
.dossier-handle b { color: var(--accent-a); font-weight: 600; }
.dossier-foot { margin-top: 10px; font-size: 10px; letter-spacing: 0.06em; line-height: 1.6; color: var(--ink-dim); opacity: 0.8; }

.panel-close {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  background: none; border: 1px solid transparent; color: var(--ink-dim);
  font-size: 22px; line-height: 1; width: 36px; height: 36px; cursor: pointer;
  font-family: inherit;
}
.panel-close:hover { color: var(--accent-b); border-color: var(--line); }

.about {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg-0) 55%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}
.about-card {
  position: relative;
  width: min(620px, 94vw);
  max-height: 86vh; overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  padding: 38px 40px;
}
.about-card h2 { font-size: 22px; letter-spacing: 0.03em; margin-bottom: 18px; }
.about-card p { line-height: 1.8; font-size: 13px; margin-bottom: 14px; }
.about-sig { color: var(--accent-a) !important; }
.about-colophon { font-size: 10px !important; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim) !important; }

.intro {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 42%, color-mix(in srgb, var(--bg-1) 90%, transparent) 0%, color-mix(in srgb, var(--bg-0) 98%, transparent) 72%);
  transition: opacity 0.9s ease;
}
.intro.gone { opacity: 0; pointer-events: none; }
.intro-card { text-align: center; padding: 24px; max-width: 660px; }
.intro-over { font-size: 11px; letter-spacing: 0.5em; color: var(--accent-b); margin-bottom: 22px; }
.intro-card h1 {
  font-size: clamp(44px, 9vw, 84px);
  line-height: 0.98; letter-spacing: 0.04em; font-weight: 800;
  background: linear-gradient(100deg, var(--ink) 30%, var(--accent-a) 65%, var(--accent-b));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.intro-sub { margin: 26px auto 30px; max-width: 520px; line-height: 1.85; font-size: 13px; color: var(--ink-dim); }
.enter-btn {
  font-family: inherit; font-size: 12px; letter-spacing: 0.32em;
  color: var(--bg-0); background: var(--accent-a);
  border: none; padding: 15px 34px 15px 38px; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.enter-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px color-mix(in srgb, var(--accent-a) 40%, transparent); }
.intro-foot { margin-top: 22px; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-dim); }

@media (max-width: 899px) {
  .dossier-head { top: 78px; left: 16px; right: 16px; width: auto; }
  .dossier h2 { font-size: clamp(24px, 7vw, 34px); }
  .dossier-body {
    top: auto; bottom: 0; left: 0; right: 0; width: auto;
    transform: translateY(18px);
    padding: 22px 16px max(16px, env(safe-area-inset-bottom));
    max-height: 36vh; overflow-y: auto;
    background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg-0) 90%, transparent) 22%);
  }
  .dossier.open .dossier-body { transform: none; }
  .dossier-desc { font-size: 12px; line-height: 1.6; }
  .dossier-foot { display: none; }
  body.open .hud-telemetry, body.open .theme-toggle { opacity: 0; pointer-events: none; }
}

@media (max-width: 720px) {
  .hud-telemetry { display: none; }
  .hud-hints { left: 50%; right: auto; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); gap: 14px; font-size: 9px; }
  .theme-toggle { top: auto; bottom: max(44px, calc(env(safe-area-inset-bottom) + 30px)); }
}

@media (prefers-reduced-motion: reduce) {
  .dossier-head, .dossier-body, .intro { transition-duration: 0.01s; transition-delay: 0s; }
}
