:root {
  --bg-deep: #0a0a14;
  --bg-panel: #14162a;
  --bg-sidebar: #12131f;
  --text-primary: #e8eaf2;
  --text-secondary: #8b8fa8;
  --text-muted: #5a5e78;
  --border-soft: rgba(255,255,255,0.08);
  --glass: rgba(255,255,255,0.04);

  --c-analyst: #a78bfa;
  --c-summarizer: #22d3ee;
  --c-writer: #60a5fa;
  --c-visualizer: #4ade80;
  --c-chat: #c084fc;
  --c-verifier: #d4a24e;

  --scrollbar-width: 8px;
  --scrollbar-track: rgba(255,255,255,0.03);
  --scrollbar-thumb-start: #a78bfa;
  --scrollbar-thumb-end: #22d3ee;
}

/* Scrollbar personnalisée des zones défilantes (fiche-panel, story-feed) —
   dégradé violet→cyan cohérent avec l'identité Orion, plus fine que le style navigateur par défaut. */
.fiche-panel, .story-feed {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-start) var(--scrollbar-track);
}
.fiche-panel::-webkit-scrollbar, .story-feed::-webkit-scrollbar {
  width: var(--scrollbar-width);
}
.fiche-panel::-webkit-scrollbar-track, .story-feed::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}
.fiche-panel::-webkit-scrollbar-thumb, .story-feed::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scrollbar-thumb-start), var(--scrollbar-thumb-end));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.fiche-panel::-webkit-scrollbar-thumb:hover, .story-feed::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #b8a3fc, #4de8ff);
  background-clip: content-box;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: radial-gradient(ellipse at center, #16182e 0%, #0a0a14 70%);
  color: var(--text-primary);
  font-family: "Inter", "Poppins", -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

#starfield {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}

/* ===== AUTH GATE (magic-link) ===== */
.auth-gate {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  position: relative;
  width: 100%; max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  padding: 40px 32px 32px;
  text-align: center;
  backdrop-filter: blur(12px);
}
.auth-ring {
  width: 56px; height: 56px; margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid var(--c-analyst);
  box-shadow: 0 0 24px rgba(167,139,250,0.5);
}
.auth-title {
  font-size: 1.6rem; font-weight: 700; letter-spacing: 0.08em;
  color: #fff; margin-bottom: 6px;
}
.auth-sub {
  font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 26px;
}
#authForm { display: flex; flex-direction: column; gap: 12px; }
#authForm input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}
#authForm input:focus { border-color: var(--c-analyst); }
#authForm button {
  background: linear-gradient(135deg, var(--c-analyst), var(--c-summarizer));
  border: none; border-radius: 10px;
  padding: 12px 14px;
  color: #0a0a14; font-weight: 600; font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
#authForm button:hover { opacity: 0.9; }
#authForm button:disabled { opacity: 0.5; cursor: default; }
.auth-message {
  margin-top: 18px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.auth-message.success { color: #4ade80; }
.auth-message.error { color: #f87171; }

.app {
  position: relative; z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
/* Titre + logo animé centrés en haut de la page (plus de sidebar à gérer autour). */
.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 22px 36px 10px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-ring {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid #6b7cff;
  border-top-color: transparent;
  box-shadow: 0 0 18px rgba(107,124,255,0.5);
  animation: spin 6s linear infinite;
}
.brand-name {
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.35em;
  color: #fff;
}
.brand-tagline {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

/* ===== BODY ROW ===== */
/* Fiche panel (1/3, collé à gauche) + stage central (cercles centrés dans l'espace
   restant) + story panel (1/3, collé à droite). Plus de sidebar d'icônes. */
.body-row {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ===== STAGE / CONSTELLATION ===== */
.stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  min-width: 0;
}

.constellation {
  position: relative;
  width: min(64vh, 46vw, 640px);
  height: min(64vh, 46vw, 640px);
  transition: width .45s ease, height .45s ease;
}

/* Compact mode: once a document is analyzed, the parcours (story-panel)
   becomes the main focus and the constellation shrinks to a small,
   glanceable hub instead of competing for space with 6 big orbiting cards. */
.stage.compact { padding: 10px; }
.constellation.compact {
  width: min(34vh, 300px);
  height: min(34vh, 300px);
}
.constellation.compact .node {
  width: 20%; height: 20%;
  min-width: 64px; min-height: 64px;
  padding: 6px;
}
.constellation.compact .node .node-desc { display: none; }
.constellation.compact .node .node-name { font-size: 0.62rem; }
.constellation.compact .node svg { width: 16px; height: 16px; margin-bottom: 2px; }
.constellation.compact .center-node { width: 40%; height: 40%; min-width: 120px; min-height: 120px; }
.constellation.compact .center-sub { display: none; }
.constellation.compact .center-title { font-size: 0.72rem; }
.constellation.compact .orbit-ring { opacity: 0.5; }

.orbits { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.orbit-ring { fill: none; stroke: rgba(255,255,255,0.05); stroke-width: 1; }

.center-node {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 34%; height: 34%;
  min-width: 210px; min-height: 210px;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.center-glow {
  position: absolute; inset: -20%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120,130,255,0.28), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}
.center-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 0deg, #4f6ef7, #a78bfa, #22d3ee, #4f6ef7);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 8s linear infinite;
  box-shadow: 0 0 60px rgba(120,130,255,0.35);
}
.center-inner {
  position: relative;
  width: calc(100% - 14px); height: calc(100% - 14px);
  border-radius: 50%;
  background: #0d0e1c;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  cursor: pointer;
  padding: 20px;
  text-align: center;
  transition: box-shadow .2s;
}
.center-inner.dragover { box-shadow: 0 0 0 3px rgba(167,139,250,0.5) inset; }
.upload-icon { width: 40px; height: 40px; stroke: #a5b4fc; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.center-title {
  font-size: 1rem; font-weight: 600; letter-spacing: 0.06em;
  color: #fff; text-transform: uppercase; line-height: 1.4;
}
.center-sub { font-size: 0.78rem; color: var(--text-secondary); max-width: 200px; }
.center-plus {
  position: absolute; bottom: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-soft);
  color: #e8eaf2; font-size: 1.2rem;
  cursor: pointer;
  display: none;
}
.center-inner.has-doc .center-plus { display: block; }
.center-inner.has-doc .upload-icon,
.center-inner.has-doc .center-sub { display: none; }
.center-inner.loading .center-title { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Satellite nodes */
.nodes { position: absolute; inset: 0; pointer-events: none; }
.node {
  position: absolute;
  width: 26%; height: 26%;
  min-width: 130px; min-height: 130px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 12px;
  cursor: pointer;
  pointer-events: auto;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.03), transparent 70%);
  border: 1.5px solid var(--node-color, #888);
  box-shadow: 0 0 40px -14px var(--node-color, #888), inset 0 0 30px -22px var(--node-color, #888);
  transition: transform .2s, box-shadow .2s;
}
.node:hover {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 0 0 55px -8px var(--node-color, #888), inset 0 0 30px -18px var(--node-color, #888);
}
.node svg {
  width: 24px; height: 24px;
  stroke: var(--node-color, #888);
  fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  margin-bottom: 6px;
}
.node .node-name { font-size: 0.86rem; font-weight: 600; color: #fff; }
.node .node-desc { font-size: 0.68rem; color: var(--text-secondary); margin-top: 3px; line-height: 1.25; }
.node.disabled { opacity: 0.35; cursor: not-allowed; }
.node.disabled:hover { transform: translate(-50%, -50%); }
.node.dimmed { opacity: 0.28; }
.node.dimmed:hover { transform: translate(-50%, -50%); opacity: 0.45; }
.node.suggested {
  animation: node-pulse 2.2s ease-in-out infinite;
}
.node.suggested .node-name { color: #fff; text-shadow: 0 0 10px var(--node-color, #fff); }
@keyframes node-pulse {
  0%, 100% { box-shadow: 0 0 40px -14px var(--node-color, #888), inset 0 0 30px -22px var(--node-color, #888); }
  50% { box-shadow: 0 0 60px -6px var(--node-color, #888), inset 0 0 30px -14px var(--node-color, #888); }
}

.conn-line { fill: none; stroke-width: 1; opacity: 0.35; }
.conn-dot { opacity: 0.9; }


/* Fiche panel */
.fiche-panel {
  flex: 0 0 420px;
  max-width: 420px;
  min-width: 260px;
  margin: 10px 0 10px 26px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  padding: 20px;
  backdrop-filter: blur(12px);
  display: none;
}
@media (min-width: 900px) { .fiche-panel:not(.hidden) { display: block; } }
.fiche-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 600; color: #fff;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); margin-bottom: 10px;
}
.fiche-close {
  margin-left: auto; background: none; border: none; color: var(--text-secondary);
  font-size: 1.1rem; cursor: pointer;
}
.fiche-item { margin-bottom: 10px; }
.fiche-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.fiche-value { font-size: 0.8rem; color: var(--text-primary); margin-top: 2px; line-height: 1.35; }
.fiche-hint { font-size: 0.72rem; color: var(--text-secondary); margin-top: 12px; font-style: italic; }

/* ===== STORY PANEL (conversational journey, right side) ===== */
.story-panel {
  flex: 0 0 420px;
  max-width: 420px;
  min-width: 300px;
  margin: 10px 26px 10px 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.story-header {
  display: flex; align-items: center; gap: 8px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.85rem; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.story-icon { font-size: 1rem; }
.story-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.story-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 14px 16px;
}
.story-card.loading { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 0.85rem; }
.story-card.error { font-size: 0.85rem; }
.story-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.story-agent-badge {
  font-size: 0.78rem; font-weight: 600;
  color: var(--badge-color, #fff);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--badge-color, var(--border-soft));
  background: rgba(255,255,255,0.03);
}
.story-card-actions { display: flex; align-items: center; gap: 6px; }
.copy-mini-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.85rem; opacity: 0.6; padding: 2px 4px;
}
.copy-mini-btn:hover { opacity: 1; }
.export-mini-btn {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-soft); cursor: pointer;
  font-size: 0.7rem; opacity: 0.75; padding: 3px 8px; border-radius: 999px;
  color: var(--text-secondary);
}
.export-mini-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.export-mini-btn.enrich-btn {
  border-color: rgba(167,139,250,0.5); color: #c4b5fd;
}
.export-mini-btn.enrich-btn:hover { background: rgba(167,139,250,0.12); }
.story-trace {
  font-family: ui-monospace, "SF Mono", "Fira Code", monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.5;
}
.trace-line { white-space: pre-wrap; word-break: break-word; }
.story-output {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
}
.story-output h4 { font-size: 0.85rem; color: #fff; margin: 10px 0 4px; }
.story-output p { margin: 4px 0; }
.story-output ul { margin: 4px 0; padding-left: 18px; }
.story-output li { margin-bottom: 3px; }
.story-output pre {
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, monospace; font-size: 0.75rem;
  background: rgba(0,0,0,0.2); padding: 10px; border-radius: 8px;
}
.story-narration {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  line-height: 1.5;
}
.story-card > .story-narration:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* Orion Visualizer — rendu visuel des données chiffrées (au lieu du JSON brut) */
.viz-summary { font-size: 0.85rem; margin: 0 0 12px; color: var(--text-primary); }
.viz-series-block { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.viz-series-group { display: flex; flex-direction: column; gap: 8px; }
.viz-bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; }
.viz-bar-label { font-size: 0.78rem; color: var(--text-secondary); }
.viz-bar-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.viz-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4ade80, #22d3ee); min-width: 3px; }
.viz-bar-value { font-size: 0.78rem; font-weight: 600; color: #fff; white-space: nowrap; }
.viz-timeline { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 12px; padding-left: 2px; }
.viz-timeline-item { display: flex; align-items: flex-start; gap: 10px; }
.viz-timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-top: 5px; flex-shrink: 0; }
.viz-timeline-date { font-size: 0.72rem; color: var(--text-muted); }
.viz-timeline-label { font-size: 0.82rem; color: var(--text-primary); }
.viz-insight {
  font-size: 0.82rem; color: #4ade80; background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.25); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.viz-empty { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }

/* Orion Pivot — tableau croisé dynamique (données calculées exactement par pandas côté serveur) */
.pivot-table-wrap { overflow-x: auto; margin-bottom: 12px; border-radius: 10px; border: 1px solid var(--border-soft); }
.pivot-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.pivot-table thead th {
  background: rgba(251,146,60,0.14); color: #fff; font-weight: 600; text-align: left;
  padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--border-soft);
}
.pivot-table tbody td { padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); white-space: nowrap; }
.pivot-row-label { color: var(--text-secondary); font-weight: 500; }
.pivot-cell { position: relative; min-width: 90px; }
.pivot-cell-bar {
  position: absolute; inset: 3px auto 3px 0; height: auto; border-radius: 4px;
  background: linear-gradient(90deg, rgba(251,146,60,0.35), rgba(251,146,60,0.12)); z-index: 0;
}
.pivot-cell span { position: relative; z-index: 1; color: #fff; font-weight: 500; }
.viz-raw-toggle {
  background: none; border: 1px solid var(--border-soft); color: var(--text-muted);
  font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; margin-top: 4px;
}
.viz-raw-toggle:hover { color: #fff; border-color: var(--text-muted); }
.viz-raw-json.hidden { display: none; }
.viz-raw-json {
  margin-top: 8px; font-family: ui-monospace, monospace; font-size: 0.72rem;
  background: rgba(0,0,0,0.25); padding: 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-word;
}
.story-user-bubble {
  align-self: flex-end;
  max-width: 85%;
  background: linear-gradient(120deg, rgba(124,92,255,0.25), rgba(79,209,255,0.15));
  border: 1px solid rgba(124,92,255,0.35);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #fff;
}
.story-choices-wrap { margin-top: 4px; }
.story-choices-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.story-choices-row { display: flex; flex-direction: column; gap: 7px; }
.choice-btn {
  display: flex; align-items: center; gap: 8px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--choice-color, var(--border-soft));
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.choice-btn:hover { background: rgba(255,255,255,0.08); transform: translateX(2px); }
.choice-btn .dot { width: 7px; height: 7px; min-width: 7px; border-radius: 50%; background: var(--choice-color, #888); }
.format-choice-inline { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.format-choice-inline .format-btn {
  flex: 0 0 auto; padding: 7px 12px; font-size: 0.78rem;
  border-radius: 8px; border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.04); color: var(--text-primary); cursor: pointer;
}
.format-choice-inline .format-btn.active { background: var(--c-writer); border-color: var(--c-writer); color: #0a0a14; font-weight: 600; }
.btn-run-inline {
  background: linear-gradient(120deg, #7c5cff, #4fd1ff);
  border: none; color: #fff; font-weight: 600;
  border-radius: 8px; padding: 7px 14px; font-size: 0.78rem; cursor: pointer;
}
.story-free {
  border-top: 1px solid var(--border-soft);
  padding: 14px 18px;
  flex-shrink: 0;
}
.story-free-row { display: flex; gap: 8px; }
#storyFreeInput {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-size: 0.85rem;
}
#storyFreeInput:focus { outline: 1px solid var(--c-chat); }
#storyFreeSend {
  background: linear-gradient(120deg, #7c5cff, #4fd1ff);
  border: none; color: #fff; font-weight: 700;
  border-radius: 10px; width: 42px; cursor: pointer; font-size: 1rem;
}

.hidden { display: none !important; }

/* ===== FOOTER ===== */
.bottombar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 36px 22px;
  flex-shrink: 0;
}
.security-pill, .help-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 8px 16px;
  cursor: default;
}
.shield-icon { color: #4ade80; }
.security-title { font-size: 0.78rem; color: #fff; }
.security-sub { font-size: 0.68rem; color: var(--text-secondary); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.project-label { font-size: 0.72rem; letter-spacing: 0.12em; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Format inline choice + spinner + toast (utilisés dans le panneau de parcours) */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(255,80,80,0.15);
  border: 1px solid rgba(255,80,80,0.4);
  color: #ffb4b4;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 100;
}

/* Small screens fallback: stack, allow scroll */
@media (max-width: 1100px) {
  .story-panel { max-width: none; min-width: 0; margin: 10px 26px; }
}
@media (max-width: 860px) {
  html, body { overflow-y: auto; height: auto; }
  .app { height: auto; min-height: 100vh; }
  .body-row { flex-direction: column; }
  .sidebar { flex-direction: row; width: auto; margin: 10px 20px; }
  .stage { padding: 20px; }
  .constellation { width: 92vw; height: 92vw; }
  .node { width: 30%; height: 30%; min-width: 100px; min-height: 100px; }
  .story-panel { max-height: 60vh; }
}
