:root {
  --bg:           #0a0d14;
  --bg-soft:      #11162a;
  --panel:        rgba(16, 19, 28, 0.78);
  --border:       rgba(167, 139, 250, 0.30);
  --text:         #e9eef7;
  --text-muted:   #9bb6ea;
  --muted:        #9bb6ea;
  --dim:          #6e87b8;
  --accent:       #a78bfa;
  --accent-bright:#c4b5fd;
  --warm:         #ffa276;
  --good:         #6ee7b7;
  --bad:          #f57b8a;
  --orbit-fg:     rgba(155, 182, 234, 0.12);
  --font-mono:    ui-monospace, SFMono-Regular, Menlo, monospace;

  /* ── DESIGN SYSTEM (canonical tokens — see /design-system) ───────── */
  --bg-deep:      #06080f;
  --bg-card:      rgba(18, 23, 36, 0.7);
  --bg-code:      #0f1220;
  --border-2:     rgba(148, 163, 184, 0.22);
  --border-violet: rgba(167, 139, 250, 0.35);
  --text-faint:   #5d6778;
  --accent-d:     #8b5cf6;
  --accent-2:     #10b981;
  --astro:        #38bdf8;
  --pink:         #f472b6;
  --font-body:    'Inter', -apple-system, system-ui, sans-serif;

  --bg-page:
    radial-gradient(1400px 700px at 80% -10%, #1c1845 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 30%, #0e2233 0%, transparent 60%),
    linear-gradient(180deg, #0a0d14, #06080f);

  --neon-violet: #a78bfa;
  --neon-cyan:   #38bdf8;
  --neon-mint:   #10b981;
  --neon-pink:   #f472b6;
  --glow-violet: rgba(167, 139, 250, 0.55);
  --glow-cyan:   rgba(56, 189, 248, 0.45);

  --class-planet: #7dd3fc; --class-moon: #cbd5e1; --class-trojan: #c4b5fd;
  --class-asteroid: #fcd34d; --class-comet: #f9a8d4; --class-irregular: #d8b4fe;

  --system-forge: #f97316; --system-signal: #38bdf8; --system-mind: #a78bfa;

  --grad-hero:  linear-gradient(90deg, #a78bfa, #38bdf8 60%, #10b981);
  --grad-btn:   linear-gradient(180deg, #a78bfa, #8b5cf6);
  --grad-price: linear-gradient(180deg, #ddd6fe, #a78bfa 70%, #8b5cf6);

  --shadow-card:       0 0 18px rgba(167, 139, 250, 0.06);
  --shadow-card-hover: 0 0 0 1px rgba(167, 139, 250, 0.35), 0 0 28px rgba(167, 139, 250, 0.20);
  --shadow-btn:        0 0 0 1px rgba(167, 139, 250, 0.45), 0 0 14px 2px rgba(167, 139, 250, 0.35), 0 0 28px 6px rgba(167, 139, 250, 0.18);
  --shadow-panel:     -8px 0 40px rgba(0, 0, 0, 0.5), -1px 0 24px rgba(167, 139, 250, 0.18);

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;
  --section-y: clamp(48px, 8vw, 96px);

  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-pill: 999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.15s; --dur-base: 0.25s; --dur-slow: 0.5s;

  --fs-display: clamp(36px, 6vw, 60px);
  --fs-h1: clamp(28px, 5vw, 40px);
  --fs-h2: clamp(22px, 3.5vw, 32px);
  --fs-h3: 17px; --fs-lead: 17px; --fs-body: 15px;
  --fs-small: 13.5px; --fs-caption: 12px; --fs-eyebrow: 11.5px; --fs-code: 13.5px;

  --lh-tight: 1.05; --lh-snug: 1.15; --lh-base: 1.65; --lh-mono: 1.7;

  --tracking-tight: -0.025em; --tracking-tight-2: -0.02em;
  --tracking-eyebrow: 0.18em; --tracking-section: 0.12em;
}

/* Semantic type classes — mirror /design-system/tokens.css */
.t-display { font-family: var(--font-body); font-size: var(--fs-display); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); font-weight: 700; text-wrap: balance; }
.t-h1      { font-family: var(--font-body); font-size: var(--fs-h1); line-height: var(--lh-snug); letter-spacing: var(--tracking-tight-2); font-weight: 700; text-wrap: balance; }
.t-h2      { font-family: var(--font-body); font-size: var(--fs-h2); line-height: 1.2; letter-spacing: var(--tracking-tight-2); font-weight: 700; text-wrap: balance; }
.t-h3      { font-family: var(--font-body); font-size: var(--fs-h3); line-height: 1.3; letter-spacing: -0.01em; font-weight: 600; }
.t-lead    { font-family: var(--font-body); font-size: var(--fs-lead); line-height: var(--lh-base); color: var(--text-muted); text-wrap: pretty; }
.t-body    { font-family: var(--font-body); font-size: var(--fs-body); line-height: var(--lh-base); color: var(--text); }
.t-small   { font-family: var(--font-body); font-size: var(--fs-small); line-height: 1.55; color: var(--text-muted); }
.t-mono    { font-family: var(--font-mono); font-size: var(--fs-code); line-height: var(--lh-mono); color: #a5b4fc; }
.t-eyebrow { font-family: var(--font-mono); font-size: var(--fs-eyebrow); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; font-weight: 600; color: var(--accent); }
.t-grad    { background: var(--grad-hero); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* Shared keyframes */
@property --neon-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes neonRotate { to { --neon-angle: 360deg; } }
@keyframes gradShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes liveDotPing {
  0%   { box-shadow: 0 0 0 0  rgba(16,185,129,0.65); transform: scale(0.92); }
  60%  { box-shadow: 0 0 0 10px rgba(16,185,129,0); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0  rgba(16,185,129,0); transform: scale(0.92); }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background:
    radial-gradient(ellipse 100% 60% at 50% 0%, rgba(124,58,237,0.10), transparent 70%),
    var(--bg);
  color: var(--text); overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text-muted); text-decoration: none; }
a:hover { color: #fff; }

/* ── Nav (mirrors ask-meridian.uk landing) ──────────────────────────── */
.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 32px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; backdrop-filter: blur(12px);
  background: rgba(10,13,20,0.85); z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; color: var(--accent); }

.burger {
  position: relative;
  display: inline-flex;
  width: 40px; height: 40px;
  background: rgba(167,139,250,0.06);
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  isolation: isolate;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.burger:hover { background: rgba(167,139,250,0.12); border-color: var(--accent); box-shadow: 0 0 14px rgba(167,139,250,0.25); }
.burger span {
  position: absolute;
  left: 10px; right: 10px; height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.28s ease, opacity 0.2s ease, top 0.28s ease;
}
.burger span:nth-child(1) { top: 13px; }
.burger span:nth-child(2) { top: 19px; }
.burger span:nth-child(3) { top: 25px; }
.burger.open { background: rgba(167,139,250,0.18); border-color: var(--accent); }
.burger.open span:nth-child(1) { top: 19px; transform: rotate(45deg);  }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { top: 19px; transform: rotate(-45deg); }

.nav-menu {
  position: fixed;
  top: 64px;
  right: clamp(12px, 3vw, 24px);
  width: min(320px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 14px;
  background: rgba(10, 13, 20, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(167,139,250,0.1);
  transform-origin: top right;
  transform: translateY(-12px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.16,1,0.3,1), opacity 0.2s ease;
  z-index: 11;
}
.nav-menu.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
.nav-menu a {
  display: block;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14.5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-menu a:hover, .nav-menu .current {
  background: rgba(167,139,250,0.08);
  color: var(--text);
}
.nav-menu .nav-group {
  border-top: 1px solid rgba(167, 139, 250, 0.10);
  margin-top: 6px; padding-top: 4px;
}
.nav-menu .nav-group:first-of-type { border-top: 0; margin-top: 4px; padding-top: 0; }
.nav-menu .nav-group > summary { cursor: pointer; list-style: none; user-select: none; }
.nav-menu .nav-group > summary::-webkit-details-marker { display: none; }
.nav-menu .nav-section {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(167, 139, 250, 0.75);
  padding: 12px 14px 6px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-menu .nav-section::after {
  content: '+'; font-size: 14px; color: rgba(167, 139, 250, 0.55);
  transition: transform 0.18s ease, color 0.18s;
}
.nav-menu .nav-group[open] > summary .nav-section::after { transform: rotate(45deg); color: var(--accent); }
.nav-menu .nav-group > summary:hover .nav-section { color: var(--text); }
.nav-menu a.nav-app {
  display: block; padding: 10px 14px; border-radius: 10px;
  background: rgba(167, 139, 250, 0.04); border: 1px solid rgba(167, 139, 250, 0.10);
  margin: 4px 0; line-height: 1.3;
}
.nav-menu a.nav-app:hover { background: rgba(167, 139, 250, 0.12); border-color: rgba(167, 139, 250, 0.32); }
.nav-menu .nav-app-name { display: block; font-size: 14px; color: var(--text); font-weight: 500; }
.nav-menu .nav-app-tag { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.nav-menu .nav-app .nav-app-emoji { margin-right: 6px; }
.nav-menu .nav-app[data-status="live"] .nav-app-name::after {
  content: '·'; margin-left: 8px; color: var(--good);
}
@media (max-width: 520px) {
  .nav { padding: 16px 20px; }
  .nav-menu { right: 12px; left: 12px; width: auto; }
}

/* ── Stage ────────────────────────────────────────────────────── */
.stage { position: fixed; inset: 76px 0 0 0; }

/* Vertical scroll of star-system cards. One protein per row, big
   enough that the structure dominates and the metadata reads
   comfortably. */
.universe {
  position: absolute; inset: 12px 0 200px 0;
  display: flex; flex-direction: column; gap: 28px;
  align-items: center;
  padding: 24px 32px 40px;
  overflow-y: auto; overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: thin;
}
.universe::-webkit-scrollbar { width: 6px; }
.universe::-webkit-scrollbar-thumb { background: rgba(155,182,234,0.2); border-radius: 3px; }

.universe-empty {
  margin: auto;
  max-width: 520px;
  text-align: center;
  color: var(--dim);
  font-size: 14px; line-height: 1.6;
}

/* One star-system card per recommended protein. */
.system {
  position: relative;
  flex: 0 0 auto;
  width: min(720px, calc(100vw - 64px));
  height: min(560px, calc(100vh - 280px));
  scroll-snap-align: center;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 38%, rgba(124,58,237,0.18), rgba(6,8,15,0.92) 70%),
    rgba(16,19,28,0.5);
  border: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.03);
  overflow: hidden;
  cursor: pointer;
  transition: transform 240ms, box-shadow 240ms, border-color 240ms;
}
.system:hover {
  transform: translateY(-4px);
  border-color: rgba(34,211,238,0.4);
  box-shadow: 0 18px 60px rgba(0,0,0,0.5), 0 0 30px rgba(34,211,238,0.18);
}
.system.focused { transform: scale(1.02); border-color: var(--accent); }

.system-header {
  position: absolute; top: 12px; left: 16px; right: 16px;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; z-index: 4;
}
.system-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.35);
  font-size: 11px; color: var(--accent); font-weight: 700;
}
.system-name { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; flex: 1; }
.system-uniprot { font-size: 11px; color: var(--dim); }

/* Central protein structure — Mol* mounts here. Filled box with
   top/left/right/bottom anchors so we always sit between the header
   and footer regardless of card dimensions (no aspect-ratio
   overflow). Mol*'s WebGL canvas fits the box; the box's gradient
   shows through because the Mol* canvas is set transparent. */
.system-center {
  position: absolute;
  top: 54px; left: 7%; right: 7%; bottom: 102px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(124,58,237,0.30), rgba(34,211,238,0.05) 55%, rgba(6,8,15,0) 80%),
    radial-gradient(ellipse at 50% 60%, rgba(167,139,250,0.10), transparent 75%);
  box-shadow:
    0 0 40px rgba(124,58,237,0.20),
    0 0 80px rgba(34,211,238,0.10),
    inset 0 0 0 1px rgba(167,139,250,0.16);
  z-index: 3;
}
.system-center.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--dim); text-align: center; padding: 0 20px;
}
/* Mol* mounts inside .system-viewport (sibling of the fullscreen
   button), so when it wipes its host's children on init it can't
   take the button with it. */
.system-viewport {
  position: absolute; inset: 0;
  border-radius: inherit;
  overflow: hidden;
}
/* Keep Mol*'s internal CSS bg transparent so our gradient on
   .system-center is the visible background; the setProps call sets
   renderer transparency on the WebGL side. */
.system-viewport .msp-plugin,
.system-viewport .msp-plugin-content,
.system-viewport .msp-viewport,
.system-viewport canvas {
  background: transparent !important;
}

/* ── Viewport tools (overlay buttons on the Mol* canvas) ───────────── */
/* z-index bumped high so it sits above every layer Mol* mounts. */
.viewer-tool {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px;
  background: rgba(10, 13, 20, 0.82);
  border: 1px solid rgba(167, 139, 250, 0.45);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0.85;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: opacity 0.15s, background 0.15s, border-color 0.15s, transform 0.12s;
}
.system-center:hover .viewer-tool,
.viewer-tool:focus-visible { opacity: 1; }
.viewer-tool:hover {
  background: rgba(167, 139, 250, 0.28);
  border-color: var(--accent);
  transform: scale(1.06);
}
.viewer-tool:active { transform: scale(0.96); }
.viewer-tool .ico-collapse { display: none; }

/* Fullscreen state: viewport fills the whole screen, button stays
   visible, expand icon swaps to collapse icon. */
.system-center:fullscreen {
  width: 100vw !important; height: 100vh !important;
  border-radius: 0;
  background:
    radial-gradient(ellipse 100% 60% at 50% 50%, rgba(124,58,237,0.18), transparent 70%),
    var(--bg);
  box-shadow: none;
  transform: none;
  top: 0; left: 0;
}
.system-center:fullscreen .viewer-tool {
  opacity: 1; top: 16px; right: 16px;
  width: 38px; height: 38px;
}
.system-center:fullscreen .viewer-tool .ico-expand   { display: none; }
.system-center:fullscreen .viewer-tool .ico-collapse { display: block; }
/* WebKit prefix for Safari */
.system-center:-webkit-full-screen {
  width: 100vw !important; height: 100vh !important;
  border-radius: 0; transform: none; top: 0; left: 0;
}
.system-center:-webkit-full-screen .viewer-tool .ico-expand   { display: none; }
.system-center:-webkit-full-screen .viewer-tool .ico-collapse { display: block; }

/* In-viewport HUD — a side panel inside the fullscreen viewport
   showing the full detail card (the side panel is outside the
   fullscreen tree and gets hidden by the browser). Carries protein
   name + meta + scores + rationale, plus a click-to-select block
   with a 2D molecular render of whatever the user just tapped. */
.system-hud {
  position: absolute; top: 16px; right: 16px; bottom: 16px;
  width: min(360px, 40vw);
  padding: 20px 22px;
  background: rgba(10, 13, 20, 0.88);
  border: 1px solid rgba(167, 139, 250, 0.40);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5), 0 0 0 1px rgba(167,139,250,0.08);
  backdrop-filter: blur(10px);
  color: var(--text);
  z-index: 1100;
  display: none;
  overflow-y: auto;
}
.system-center:fullscreen .system-hud         { display: block; }
.system-center:-webkit-full-screen .system-hud { display: block; }

.system-hud .hud-name {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin-bottom: 4px;
}
.system-hud .hud-meta {
  font-size: 12px; color: var(--muted); margin-bottom: 14px;
}
.system-hud .hud-scores {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
}
.system-hud .hud-rationale {
  font-size: 13.5px; color: var(--text-muted); line-height: 1.55;
  margin-bottom: 18px;
}
.system-hud .hud-selection {
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.28);
  border-radius: 10px;
  padding: 10px 12px 12px;
}
.system-hud .hud-selection[hidden] { display: none; }
.system-hud .hud-kind {
  font-size: 10.5px; letter-spacing: 0.10em; text-transform: uppercase;
  color: rgba(167, 139, 250, 0.90); font-weight: 600;
  margin-bottom: 3px;
}
.system-hud .hud-comp {
  font-size: 14.5px; line-height: 1.4; color: var(--text);
}
.system-hud .hud-atom {
  margin-top: 3px;
  font-size: 11.5px; color: var(--muted);
  font-family: var(--font-mono);
}
.system-hud canvas.hud-molecule {
  display: block; width: 100%; height: 140px; margin-top: 10px;
  background: rgba(6,8,15,0.6);
  border-radius: 8px;
  border: 1px solid rgba(167,139,250,0.15);
}
.system-hud .hud-sel-explanation {
  margin-top: 10px;
  font-size: 12px; line-height: 1.55;
  color: var(--text);
}
.system-hud .hud-sel-explanation.loading { color: var(--dim); font-style: italic; }
.system-hud .hud-sel-explanation.failed  { color: var(--bad);  font-size: 11.5px; }

/* Footer with scores + rationale snippet */
.system-footer {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 12px 16px 14px;
  background: linear-gradient(to top, rgba(6,8,15,0.95), transparent);
  z-index: 4;
}
.system-scores { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.score-pill {
  background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.32);
  border-radius: 999px; padding: 2px 8px; font-size: 10.5px; color: var(--accent);
  letter-spacing: 0.02em;
}
.score-pill.warm { background: rgba(255,162,118,0.10); border-color: rgba(255,162,118,0.35); color: var(--warm); }
.score-pill.dim  { background: rgba(155,182,234,0.06); border-color: rgba(155,182,234,0.2); color: var(--muted); }
.system-rationale {
  font-size: 11.5px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Input card ───────────────────────────────────────────────── */
.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
}
.input-card {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 24px;
  width: min(640px, calc(100vw - 32px));
  padding: 14px;
  z-index: 30;
}
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row.controls { margin-top: 10px; flex-wrap: wrap; }
textarea {
  width: 100%; min-height: 60px; max-height: 140px; resize: vertical;
  background: rgba(12, 15, 23, 0.7); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px;
  font: inherit; font-size: 14px; line-height: 1.5;
}
textarea:focus { outline: none; border-color: rgba(34,211,238,0.55); }

.btn {
  border: 0; border-radius: 10px; padding: 9px 14px;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: transform 120ms, box-shadow 200ms;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: #062028; box-shadow: 0 4px 18px rgba(34,211,238,0.35); }
.btn.ghost   { background: transparent; color: var(--accent); border: 1px solid rgba(34,211,238,0.4); }

#img-preview { display: none; height: 32px; width: 32px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
#img-preview.shown { display: inline-block; }

.status { font-size: 12px; color: var(--dim); flex: 1; min-width: 140px; text-align: right; }
.status.busy { color: var(--accent); }
.status.error { color: var(--bad); }

/* ── Detail panel — full-height slider from the right edge ───── */
.detail {
  position: fixed; top: 76px; right: 0; bottom: 0;
  width: min(440px, calc(100vw - 24px));
  padding: 22px 24px 200px;        /* bottom padding clears the input card */
  border-radius: 16px 0 0 16px;
  z-index: 40;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
  overflow-y: auto;
}
.detail:not([hidden]) { transform: translateX(0); pointer-events: auto; }
.detail h2 { margin: 0 0 6px; font-size: 19px; }
.detail-meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

/* Selection block — appears when user clicks an atom/residue inside
   the protein viewport. Includes a 2D ball-and-stick render of the
   selected residue/ligand parsed live from the cached PDB. */
.detail-selection {
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 10px;
  padding: 10px 12px 12px;
  margin-bottom: 14px;
}
.detail-selection .sel-molecule {
  display: block; width: 100%; height: 160px;
  margin-top: 10px;
  background: rgba(6,8,15,0.6);
  border-radius: 8px;
  border: 1px solid rgba(167,139,250,0.15);
}
.detail-selection .sel-explanation {
  margin-top: 10px;
  font-size: 12.5px; line-height: 1.55;
  color: var(--text);
}
.detail-selection .sel-explanation.loading { color: var(--dim); font-style: italic; }
.detail-selection .sel-explanation.failed  { color: var(--bad);  font-size: 12px; }
.detail-selection .sel-kind {
  font-size: 10.5px; letter-spacing: 0.10em; text-transform: uppercase;
  color: rgba(167, 139, 250, 0.85); font-weight: 600;
  margin-bottom: 4px;
}
.detail-selection .sel-comp {
  font-size: 15px; color: var(--text); line-height: 1.4;
}
.detail-selection .sel-num {
  color: var(--accent); font-weight: 600;
}
.detail-selection .sel-meta {
  color: var(--muted); font-size: 13px;
}
.detail-selection .sel-atom {
  margin-top: 6px;
  font-size: 12px; color: var(--muted);
  font-family: var(--font-mono);
}
.detail-selection .sel-atom strong { color: var(--text); font-weight: 600; }
.detail-rationale { margin: 0 0 14px; font-size: 14px; line-height: 1.55; }
.detail-scores { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.detail-scores .pill {
  background: rgba(34,211,238,0.1); border: 1px solid rgba(34,211,238,0.3);
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; color: var(--accent);
}
.detail-scores .pill.warm { background: rgba(255,162,118,0.08); border-color: rgba(255,162,118,0.32); color: var(--warm); }
.detail-notes { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.detail-notes .concern { color: var(--warm); margin-top: 8px; }
.detail-close {
  position: absolute; top: 8px; right: 10px;
  width: 28px; height: 28px;
  background: transparent; border: 0; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; border-radius: 6px;
}
.detail-close:hover { background: rgba(155,182,234,0.08); color: #fff; }

/* ── Debug ────────────────────────────────────────────────────── */
.debug {
  position: absolute; left: 16px; bottom: 16px;
  max-width: 280px; max-height: 240px; overflow: auto;
  padding: 8px 12px;
  font-size: 11px; color: var(--dim);
  z-index: 20;
}
.debug summary { cursor: pointer; }
.debug pre { color: var(--muted); font: 11px/1.4 ui-monospace, Menlo, monospace; margin: 6px 0 0; }

/* ── Mobile (≤ 720 px) ────────────────────────────────────────── */
@media (max-width: 720px) {
  .brand-sub { display: none; }
  .nav { padding: 14px 16px; }
  .brand { font-size: 16px; }

  /* Stage: trim the bottom reservation so cards get more vertical
     space; input card is shorter on mobile anyway. */
  .stage { inset: 70px 0 0 0; }

  /* Universe: tighter side padding, full-width cards. */
  .universe {
    inset: 8px 0 180px 0;
    padding: 16px 12px 28px;
    gap: 20px;
  }
  .system {
    width: calc(100vw - 24px);
    height: min(620px, calc(100vh - 220px));
    border-radius: 18px;
  }
  .system-header { top: 10px; left: 14px; right: 14px; }
  .system-name { font-size: 16px; }
  .system-uniprot { font-size: 10.5px; }
  .system-center { top: 48px; left: 5%; right: 5%; bottom: 96px; }
  .system-footer { padding: 10px 14px 12px; }
  .score-pill { font-size: 10px; padding: 2px 7px; }
  .system-rationale { font-size: 11px; -webkit-line-clamp: 2; }

  /* Viewer tool button: smaller, still tappable */
  .viewer-tool { top: 8px; right: 8px; width: 36px; height: 36px; }

  /* Detail panel: full-width drawer sliding from the right.
     Bottom margin clears the input card. */
  .detail {
    top: 64px; right: 0; bottom: 0;
    width: 100vw;
    border-radius: 16px 0 0 0;
    padding: 18px 18px 160px;
  }
  .detail h2 { font-size: 17px; }

  /* Input card: tighter and lower */
  .input-card {
    bottom: 12px;
    padding: 12px;
    width: calc(100vw - 16px);
  }
  textarea { min-height: 56px; font-size: 13.5px; }
  .input-row.controls { gap: 8px; }
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .status { font-size: 11px; min-width: 0; }

  /* Fullscreen HUD: docks to the bottom as a sheet on phones so the
     protein stays visible above it. Right-side panel is unreadable
     in portrait. */
  .system-hud {
    top: auto;
    left: 12px; right: 12px; bottom: 12px;
    width: auto;
    max-height: 45vh;
    padding: 14px 16px;
    border-radius: 14px;
  }
  .system-hud .hud-name { font-size: 15px; }
  .system-hud .hud-rationale { font-size: 12.5px; margin-bottom: 12px; }
  .system-hud canvas.hud-molecule { height: 110px; }

  /* Debug card: tighter, doesn't overlap input */
  .debug { bottom: auto; top: 70px; left: 12px; max-width: 200px; max-height: 160px; }
}

/* ── Extra-small phones (≤ 420 px) ──────────────────────────────── */
@media (max-width: 420px) {
  .system { width: calc(100vw - 16px); border-radius: 14px; }
  .system-center { left: 4%; right: 4%; }
  .input-card { width: calc(100vw - 12px); bottom: 8px; }
  .detail { padding: 16px 16px 160px; }
}
