/* ============================================================================
   Knowledge Fabric · Command Center — dual-theme mission control
   ============================================================================ */

:root {
  /* ===== Client brand accents (theme-invariant, set per engagement) ===== */
  --qz-blue: #4D7CFF;
  --qz-blue-deep: #2E5DDB;
  --qz-blue-soft: rgba(77, 124, 255, 0.16);
  --qz-pink: #EE1C5C;
  --qz-pink-deep: #C81550;
  --qz-pink-soft: rgba(238, 28, 92, 0.16);
  --qz-violet: #7B5BFF;
  --qz-cyan: #4DD0E8;

  /* ===== Navbar (consistent across themes — mirrors the client's own site) ===== */
  --nav-bg: #F8F9FB;
  --nav-text: #1A1F36;
  --nav-text-dim: #5C6788;
  --nav-border: #E5E8EE;

  /* ===== DARK THEME (default) — vibrant navy ===== */
  --bg: #0E1A45;
  --bg-1: #142158;
  --bg-2: #1A2A6E;
  --bg-3: #213388;
  --bg-4: #2A3FA2;
  --border: #2A3680;
  --border-soft: #1F2860;
  --border-strong: #3D4DA8;

  --text: #E9EEF8;
  --text-dim: #A5ADC8;
  --text-mute: #6E78A0;

  /* Digital texture */
  --grid-color: rgba(77, 124, 255, 0.09);
  --grid-size: 28px;
  --aurora-opacity: 0.5;
  --aurora-blur: 90px;

  /* Semantic brand mapping */
  --brand: var(--qz-blue);
  --brand-soft: var(--qz-blue-soft);
  --accent: var(--qz-pink);
  --accent-soft: var(--qz-pink-soft);
  --warn: #ffb74a;
  --danger: var(--qz-pink);
  --magenta: var(--qz-pink);

  /* Galaxy node colors */
  --node-base: #4A5694;
  --node-related: var(--qz-blue);
  --node-active: var(--qz-pink);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.55);
  --shadow-glow-brand: 0 0 28px rgba(77, 124, 255, 0.45);
  --shadow-glow-accent: 0 0 28px rgba(238, 28, 92, 0.45);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-snap: cubic-bezier(0.45, 0, 0.15, 1);
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg: #EFF3FB;
  --bg-1: #FFFFFF;
  --bg-2: #F6F8FD;
  --bg-3: #E6ECF7;
  --bg-4: #D5DEEF;
  --border: #D6DEEC;
  --border-soft: #E8EDF7;
  --border-strong: #B8C5DE;

  --text: #0E1A45;
  --text-dim: #4F5B7D;
  --text-mute: #8B95B3;

  --grid-color: rgba(77, 124, 255, 0.07);
  --aurora-opacity: 0.18;
  --aurora-blur: 120px;

  --node-base: #B8C5DE;

  --shadow-sm: 0 1px 3px rgba(15, 26, 69, 0.06);
  --shadow-md: 0 8px 32px rgba(15, 26, 69, 0.10);
  --shadow-glow-brand: 0 0 24px rgba(77, 124, 255, 0.25);
  --shadow-glow-accent: 0 0 24px rgba(238, 28, 92, 0.25);
}

/* Smooth theme crossfade across surfaces, text, borders */
html { transition: background-color 0.45s var(--ease); }
body, .pane, .cmd-bar, .cmd-tile, .composer input, .composer button,
.chip, .pill, .cite, .lineage-entry, .heatmap-bar, .answer-card,
.explain-overlay, .explain-card, .empty-state, .qz-context-title,
.qz-context-eyebrow, .cmd-eyebrow, .cmd-title, .pane-title,
.pane-subtitle, .pane-head, .copilot, .galaxy, .lineage, .insights {
  transition: background-color 0.4s var(--ease),
              border-color 0.4s var(--ease),
              color 0.35s var(--ease),
              box-shadow 0.4s var(--ease);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html { overflow-x: hidden; }
body {
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}
/* Narrative scroll mode (the storytelling layout uses <body class="narrative">):
   the body becomes a normal scrollable document. Aurora background and sections
   stack vertically. This replaces the old fit-the-viewport flex column behavior. */
body.narrative {
  display: block;
  height: auto;
}

/* ============================================================================
   AURORA + DIGITAL GRID — vibrant texture layers behind content
   ============================================================================ */
.aurora-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(var(--aurora-blur));
  opacity: var(--aurora-opacity);
  will-change: transform;
  transition: opacity 0.5s var(--ease), filter 0.5s var(--ease);
}
.aurora-1 {
  width: 55vw; height: 55vw;
  top: -18%; left: -12%;
  background: radial-gradient(circle, var(--qz-blue) 0%, transparent 65%);
  animation: aurora-drift-1 22s var(--ease) infinite;
}
.aurora-2 {
  width: 60vw; height: 60vw;
  top: 20%; right: -22%;
  background: radial-gradient(circle, var(--qz-pink) 0%, transparent 65%);
  animation: aurora-drift-2 26s var(--ease) infinite;
}
.aurora-3 {
  width: 50vw; height: 50vw;
  bottom: -22%; left: 28%;
  background: radial-gradient(circle, var(--qz-violet) 0%, transparent 65%);
  animation: aurora-drift-3 30s var(--ease) infinite;
}
.aurora-4 {
  width: 35vw; height: 35vw;
  top: 45%; left: 40%;
  background: radial-gradient(circle, var(--qz-cyan) 0%, transparent 70%);
  opacity: calc(var(--aurora-opacity) * 0.6);
  animation: aurora-drift-4 34s var(--ease) infinite;
}

@keyframes aurora-drift-1 {
  0%, 100% { transform: translate(0%, 0%) scale(1); }
  33%      { transform: translate(15%, 10%) scale(1.18); }
  66%      { transform: translate(-8%, 22%) scale(0.92); }
}
@keyframes aurora-drift-2 {
  0%, 100% { transform: translate(0%, 0%) scale(1); }
  33%      { transform: translate(-12%, -10%) scale(1.12); }
  66%      { transform: translate(10%, 14%) scale(0.88); }
}
@keyframes aurora-drift-3 {
  0%, 100% { transform: translate(0%, 0%) scale(1); }
  50%      { transform: translate(-18%, -25%) scale(1.22); }
}
@keyframes aurora-drift-4 {
  0%, 100% { transform: translate(0%, 0%) scale(1); }
  25%      { transform: translate(20%, -10%) scale(0.85); }
  50%      { transform: translate(-15%, 15%) scale(1.15); }
  75%      { transform: translate(10%, 8%) scale(1.05); }
}

/* Digital dot grid — fixed, vignetted to fade at edges */
.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: radial-gradient(circle, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: 0 0;
  mask-image: radial-gradient(ellipse 90% 80% at center, black 30%, transparent 95%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at center, black 30%, transparent 95%);
}

/* Stacking: content above aurora + grid */
.qz-navbar { z-index: 20; }
.cmd-bar, main, .explain-overlay { position: relative; z-index: 2; }

@media (prefers-reduced-motion: reduce) {
  .aurora { animation: none !important; }
}

/* ============================================================================
   GLOBAL ENTRANCE ANIMATIONS — staggered pane + tile reveal
   ============================================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes glowBreath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(77, 124, 255, 0); }
  50%      { box-shadow: 0 0 30px 4px rgba(77, 124, 255, 0.35); }
}
@keyframes ripple-pink {
  0%   { box-shadow: 0 0 0 0 rgba(238, 28, 92, 0.6); }
  100% { box-shadow: 0 0 0 28px rgba(238, 28, 92, 0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes barFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ============================================================================
   CLIENT NAVBAR — slim white strip: client wordmark, product, demonstrator credit
   ============================================================================ */
.qz-navbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
/* Narrative mode: make sure first section accounts for navbar's sticky height */
body.narrative .story-section:first-of-type { margin-top: 0; }
.qz-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.qz-wordmark {
  height: 32px;
  width: auto;
  display: block;
}
.qz-wordmark-text {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--nav-text);
}
.qz-wordmark-text > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--nav-text-dim);
}
.qz-context {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  padding-left: 16px;
  border-left: 1px solid var(--nav-border);
  margin-left: 4px;
}
.qz-context-eyebrow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--qz-pink);
}
.qz-context-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--nav-text);
  margin-top: 2px;
  letter-spacing: -0.005em;
}
.qz-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
}
.qz-nav a {
  color: var(--nav-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s;
  position: relative;
}
.qz-nav a:not(.qz-cta):hover { color: var(--qz-blue); }
.qz-nav a:not(.qz-cta)::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--qz-blue);
  border-radius: 1px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s;
}
.qz-nav a:not(.qz-cta):hover::after { transform: scaleX(1); }
.qz-cta {
  background: var(--qz-pink);
  color: white !important;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.qz-cta:hover {
  background: var(--qz-pink-deep);
  box-shadow: 0 4px 16px rgba(238, 28, 92, 0.35);
}
.qz-cta:active { transform: scale(0.97); }

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  padding: 0;
  margin-left: -6px;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
              transform 0.15s var(--ease-spring);
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover {
  background: var(--qz-blue-soft);
  border-color: var(--qz-blue);
  transform: translateY(-1px);
}
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.55s var(--ease-spring), opacity 0.3s var(--ease);
}
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
.theme-toggle:hover svg { transform: rotate(-25deg) scale(1.1); }

@media (max-width: 980px) {
  .qz-navbar { padding: 8px 14px; gap: 12px; }
  .qz-wordmark { height: 26px; }
  .qz-context { padding-left: 10px; }
  .qz-context-eyebrow { font-size: 9px; }
  .qz-context-title { font-size: 12.5px; }
  .qz-nav { gap: 14px; }
  .qz-nav a:not(.qz-cta) { display: none; }  /* Hide secondary links on small screens, keep CTA */
}
@media (max-width: 600px) {
  .qz-context { display: none; }
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-family: var(--font-serif); font-weight: 400; font-size: 22px; letter-spacing: -0.005em; }
h3 { font-size: 13.5px; }
h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); font-weight: 600; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================================
   COMMAND BAR — top header with brand + stat tiles + LIVE status
   ============================================================================ */
.cmd-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--bg-1) 92%, transparent),
    color-mix(in oklab, var(--bg) 88%, transparent));
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeUp 0.5s var(--ease) backwards;
  animation-delay: 0.1s;
}
.cmd-bar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand) 30%, var(--accent) 70%, transparent);
  background-size: 200% 100%;
  opacity: 0.7;
  animation: shimmer 8s linear infinite;
}

.cmd-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.cmd-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-glow-accent);
  position: relative;
}
.cmd-logo::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 7px;
  background: var(--bg);
}
.cmd-logo-pulse {
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
  position: relative;
  z-index: 1;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.65; }
}

.cmd-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.cmd-eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 600;
}
.cmd-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 1px;
}

.cmd-tiles {
  display: flex;
  gap: 1px;
  margin-left: 16px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--border-soft);
  border-radius: 10px;
  padding: 1px;
}
.tile {
  flex: 1;
  min-width: 0;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.6s var(--ease) backwards;
  transition: transform 0.25s var(--ease), background 0.4s var(--ease);
}
.tile:nth-child(1) { animation-delay: 0.05s; }
.tile:nth-child(2) { animation-delay: 0.12s; }
.tile:nth-child(3) { animation-delay: 0.19s; }
.tile:nth-child(4) { animation-delay: 0.26s; }
.tile:nth-child(5) { animation-delay: 0.33s; }
.tile:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
}
.tile:first-child { border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
.tile:last-child { border-top-right-radius: 9px; border-bottom-right-radius: 9px; }
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(140px 60px at 50% -10%, var(--brand-soft), transparent);
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.3s var(--ease);
}
.tile:hover::before { opacity: 1.2; }
.tile-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  font-weight: 600;
}
.tile-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.tile-delta {
  font-size: 10px;
  color: var(--text-mute);
}

.cmd-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  flex-shrink: 0;
}
.status-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
.status-text {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* ============================================================================
   GRID — 4-pane mission control layout
   ============================================================================ */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  grid-template-rows: 1.25fr 1fr;
  gap: 1px;
  background: var(--border-soft);
  min-height: 0;
  overflow: hidden;
}

.pane {
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
  animation: fadeUp 0.7s var(--ease) backwards;
}
.pane-galaxy   { grid-column: 1; grid-row: 1; animation-delay: 0.20s; }
.pane-copilot  { grid-column: 2; grid-row: 1; animation-delay: 0.30s; }
.pane-lineage  { grid-column: 1; grid-row: 2; animation-delay: 0.40s; }
.pane-insights { grid-column: 2; grid-row: 2; animation-delay: 0.50s; }

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, color-mix(in oklab, var(--bg-2) 35%, transparent), transparent);
  flex-shrink: 0;
}
.pane-head h2 { font-size: 18px; }
.pane-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============================================================================
   KNOWLEDGE GALAXY (pane 1)
   ============================================================================ */
.legend {
  display: flex;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-dim);
  align-items: center;
}
.lg-item { display: inline-flex; align-items: center; gap: 4px; }
.lg-dot { width: 7px; height: 7px; border-radius: 50%; }
.lg-active { background: var(--node-active); box-shadow: 0 0 6px var(--node-active); }
.lg-related { background: var(--node-related); }
.lg-base { background: var(--node-base); }

.galaxy-canvas {
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(77, 124, 255, 0.05), transparent 65%),
    radial-gradient(circle at 30% 70%, rgba(238, 28, 92, 0.04), transparent 60%);
  position: relative;
}
.galaxy-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.1), transparent),
    radial-gradient(1px 1px at 80% 20%, rgba(255,255,255,0.12), transparent),
    radial-gradient(1px 1px at 35% 85%, rgba(255,255,255,0.08), transparent);
  pointer-events: none;
}
.vis-network:focus { outline: none; }

/* Floating ask launcher (mobile only) */
.ask-launcher {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}
.ask-launcher button {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: var(--bg);
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-glow-brand);
}

/* Galaxy floating detail card */
.galaxy-detail {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  max-height: 55%;
  background: rgba(13, 19, 36, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  z-index: 5;
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.detail-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-mute);
  font-size: 20px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  line-height: 1;
}
.detail-close:hover { color: var(--text); background: var(--bg-3); }

/* ===== Premium entity cards ===== */
.entity-card-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 6px;
}
.entity-card-eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
}
.entity-card-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 12px;
}
.entity-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin-bottom: 14px;
}
.entity-card-meta .kv {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.entity-card-meta .k {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  font-weight: 600;
}
.entity-card-meta .v {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.entity-card-section { margin-top: 14px; }
.entity-card-section h4 { margin-bottom: 8px; }
.entity-card-pills { display: flex; flex-wrap: wrap; gap: 5px; }

.pill {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--brand); background: rgba(77, 124, 255, 0.18); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-accent:hover { border-color: var(--accent); background: rgba(238, 28, 92, 0.16); }

.evidence {
  background: var(--bg-1);
  border-left: 2px solid var(--brand);
  padding: 9px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 6px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.evidence:hover { background: var(--bg-2); }
.evidence-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  margin-bottom: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.evidence-meta .doc { color: var(--accent); }
.evidence-meta .sep { color: var(--border-strong); }
.evidence-text {
  color: var(--text-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================================
   AI COPILOT (pane 2)
   ============================================================================ */
.copilot-metrics {
  display: flex;
  gap: 12px;
}
.metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}
.m-k {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  font-weight: 600;
}
.m-v {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin-top: 2px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.copilot-empty {
  margin: auto;
  text-align: center;
  max-width: 320px;
}
.copilot-orb {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(77, 124, 255, 0.65), transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(238, 28, 92, 0.55), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--border-strong);
  position: relative;
  box-shadow: var(--shadow-glow-brand);
  animation: orb-float 4s ease-in-out infinite;
}
.copilot-orb::after {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 0 18px rgba(238, 28, 92, 0.6);
  animation: orb-inner 4s ease-in-out infinite;
}
@keyframes orb-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes orb-inner {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.85; }
}
.copilot-hint {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.chip {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  text-align: left;
  transition: all 0.15s;
}
.chip:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--brand);
  transform: translateY(-1px);
}

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-bubble {
  max-width: 92%;
  padding: 12px 15px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.55;
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, var(--brand), #2E5DDB);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-assistant .msg-bubble {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 4px;
}
.answer-text { white-space: pre-wrap; }
.answer-text .cite-ref {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 0 1px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease-spring),
              box-shadow 0.25s var(--ease), background 0.2s var(--ease);
}
.answer-text .cite-ref:hover {
  border-color: var(--brand);
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 6px 18px rgba(77, 124, 255, 0.35);
  background: color-mix(in oklab, var(--qz-blue) 22%, transparent);
}

.answer-actions {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.action-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.action-btn:hover {
  background: var(--bg-3);
  color: var(--accent);
  border-color: var(--accent-soft);
}
.answer-confidence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ac-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); font-weight: 600; }
.ac-bar {
  width: 60px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.ac-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent), var(--brand));
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
  box-shadow: 0 0 10px rgba(77, 124, 255, 0.4);
}
.ac-value { font-family: var(--font-mono); font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

.composer {
  display: flex;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(0deg, rgba(13, 19, 36, 0.4), transparent);
  flex-shrink: 0;
}
.composer input {
  flex: 1;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer input::placeholder { color: var(--text-mute); }
.composer input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(77, 124, 255, 0.15);
}
.composer button {
  background: linear-gradient(135deg, var(--brand), #2E5DDB);
  color: white;
  border: none;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.1s, box-shadow 0.15s;
}
.composer button:hover { box-shadow: 0 4px 14px rgba(77, 124, 255, 0.35); }
.composer button:active { transform: scale(0.97); }
.composer button:disabled { opacity: 0.5; cursor: wait; }

/* ============================================================================
   SOURCE LINEAGE (pane 3)
   ============================================================================ */
.ghost-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.ghost-btn:hover {
  background: rgba(238, 28, 92, 0.08);
  border-color: var(--accent-soft);
  box-shadow: 0 0 14px rgba(238, 28, 92, 0.18);
}

.lineage-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  font-size: 12.5px;
}
.lineage-empty {
  margin: auto;
  padding-top: 40px;
  text-align: center;
  color: var(--text-mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.lineage-empty svg { color: var(--text-mute); opacity: 0.5; }
.lineage-empty p { font-size: 12px; line-height: 1.6; }

/* Lineage tree */
.lineage-root {
  position: relative;
  padding-left: 0;
}
.lineage-answer {
  background: linear-gradient(135deg, rgba(238, 28, 92, 0.08), rgba(77, 124, 255, 0.06));
  border: 1px solid var(--accent-soft);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 14px;
  position: relative;
}
.lineage-answer .lineage-eyebrow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
}
.lineage-answer-text {
  margin-top: 4px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lineage-tree { padding-left: 14px; }
.lineage-doc {
  position: relative;
  padding-left: 22px;
  margin-bottom: 12px;
}
.lineage-doc::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 14px;
  height: 1px;
  background: var(--border-strong);
}
.lineage-doc::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-strong);
}
.lineage-doc:last-child::after { height: 12px; }
.lineage-doc-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.lineage-doc-name {
  font-weight: 600;
  color: var(--accent);
  font-size: 12.5px;
}
.lineage-doc-stat {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
}
.lineage-page {
  padding-left: 14px;
  margin-bottom: 4px;
  position: relative;
}
.lineage-page::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--text-mute);
  font-weight: 600;
}
.lineage-page-info {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
  font-weight: 500;
}
.lineage-section {
  color: var(--text-dim);
  font-style: italic;
  font-size: 12px;
  margin-top: 2px;
}
.lineage-paragraph {
  margin-top: 6px;
  padding: 8px 11px;
  background: var(--bg-1);
  border-left: 2px solid var(--brand);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: background 0.15s;
}
.lineage-paragraph:hover { background: var(--bg-2); }
.lineage-para-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  margin-bottom: 3px;
}
.lineage-para-text {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================================
   INSIGHTS DASHBOARD (pane 4)
   ============================================================================ */
.tabs {
  display: inline-flex;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
}
.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.12s;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--bg-3);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.insights-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  min-height: 0;
}
.insight-panel { display: none; }
.insight-panel.is-active { display: block; }

/* ===== Heatmap ===== */
.heatmap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.heatmap-intro {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.hm-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hm-label {
  font-size: 11.5px;
  color: var(--text-dim);
  flex: 0 0 38%;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.hm-track {
  flex: 1;
  height: 22px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.hm-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  transition: width 0.6s var(--ease);
  position: relative;
  transform-origin: left center;
  animation: barFill 1.1s var(--ease) backwards;
  box-shadow: 0 0 16px rgba(77, 124, 255, 0.25);
}
.hm-row:nth-child(2) .hm-fill { animation-delay: 0.55s; }
.hm-row:nth-child(3) .hm-fill { animation-delay: 0.65s; }
.hm-row:nth-child(4) .hm-fill { animation-delay: 0.75s; }
.hm-row:nth-child(5) .hm-fill { animation-delay: 0.85s; }
.hm-row:nth-child(6) .hm-fill { animation-delay: 0.95s; }
.hm-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22) 50%, transparent);
  background-size: 200% 100%;
  border-radius: 5px;
  animation: shimmer 3.5s linear infinite;
}
.hm-value {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #FFFFFF;
  font-weight: 700;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== Word Cloud ===== */
.wordcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: center;
  padding: 14px 4px;
  line-height: 1.4;
}
.wc-word {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: all 0.18s;
  color: var(--text-dim);
}
.wc-word:hover { color: var(--accent); transform: translateY(-1px); text-shadow: 0 0 14px rgba(238, 28, 92, 0.5); }

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding: 8px 0;
}
.tl-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  margin-bottom: 6px;
  padding: 0 4px;
}
.tl-bars {
  display: flex;
  align-items: flex-end;
  height: 90px;
  gap: 3px;
  border-bottom: 1px solid var(--border-soft);
  padding: 0 4px 0;
  margin-bottom: 12px;
}
.tl-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent), var(--brand));
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  opacity: 0.55;
  transition: opacity 0.15s, transform 0.15s;
  cursor: pointer;
}
.tl-bar:hover { opacity: 1; transform: scaleY(1.05); transform-origin: bottom; }
.tl-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tl-event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 11.5px;
}
.tl-event-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 70px;
}
.tl-event-text { color: var(--text-dim); flex: 1; min-width: 0; }
.tl-event-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
  flex-shrink: 0;
}

/* ============================================================================
   EXPLAIN OVERLAY — Why Did AI Say This?
   ============================================================================ */
.explain-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 15, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.explain-modal {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}
.explain-head {
  padding: 20px 26px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(77, 124, 255, 0.08), transparent);
}
.explain-eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  font-weight: 600;
}
.explain-head h2 { font-size: 22px; margin-top: 3px; }
.explain-flow {
  flex: 1;
  overflow-y: auto;
  padding: 20px 26px 28px;
}

.flow-step {
  position: relative;
  padding: 14px 18px 14px 56px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  margin-bottom: 10px;
}
.flow-step::before {
  content: attr(data-step);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 1px solid var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.flow-connector {
  width: 1px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  margin: 0 auto 4px 28px;
}
.flow-step h3 { font-size: 13px; color: var(--text); margin-bottom: 6px; }
.flow-step-body { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.flow-step-question {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  font-style: italic;
}
.flow-doc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.flow-doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg-1);
  border-radius: 6px;
  font-size: 11.5px;
}
.flow-doc-rank {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  width: 22px;
}
.flow-doc-name { color: var(--accent); font-weight: 500; flex-shrink: 0; }
.flow-doc-section { color: var(--text-dim); font-style: italic; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-doc-score { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-mute); font-variant-numeric: tabular-nums; }

.flow-graph-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.flow-entity {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
}
.flow-stats {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
}
.flow-stats strong { color: var(--text); font-weight: 600; }

.flow-context-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.flow-context-row {
  padding: 7px 10px;
  background: var(--bg-1);
  border-left: 2px solid var(--brand);
  border-radius: 0 6px 6px 0;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.55;
}

.flow-answer {
  background: linear-gradient(135deg, rgba(238, 28, 92, 0.08), rgba(77, 124, 255, 0.06));
  border-color: var(--accent-soft);
}
.flow-answer-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-top: 4px;
}

/* ============================================================================
   RESPONSIVE — tablet & phone
   ============================================================================ */
@media (max-width: 1100px) {
  html, body { overflow: auto; }
  body { height: auto; min-height: 100vh; }
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, minmax(380px, auto));
    overflow: visible;
  }
  .pane-galaxy   { grid-column: 1; grid-row: 1; }
  .pane-copilot  { grid-column: 1; grid-row: 2; }
  .pane-lineage  { grid-column: 1; grid-row: 3; }
  .pane-insights { grid-column: 1; grid-row: 4; }
  .pane { min-height: 380px; }
  .cmd-tiles { overflow-x: auto; }
  .tile { min-width: 110px; }
}

@media (max-width: 720px) {
  .cmd-bar { padding: 10px 14px; gap: 12px; flex-wrap: wrap; }
  .cmd-tiles { order: 3; flex-basis: 100%; margin-left: 0; }
  .cmd-status { margin-left: auto; }
  .cmd-brand-text .cmd-eyebrow { font-size: 9px; }
  .cmd-title { font-size: 16px; }
  .pane-head { padding: 14px 16px; }
  .pane-head h2 { font-size: 16px; }
  .messages, .composer, .lineage-body, .insights-body { padding-left: 14px; padding-right: 14px; }
  .explain-overlay { padding: 12px; }
  .explain-head { padding: 16px 18px; }
  .explain-flow { padding: 16px 18px 22px; }
  .legend { display: none; }
  .copilot-metrics { gap: 8px; }
  .m-v { font-size: 11.5px; }
}

/* ============================================================================
   Phase 4 enhancements — semantic palette, bigger graph, maturity score,
   knowledge risk, animated copilot, lineage demo state
   ============================================================================ */

:root {
  /* Semantic accent palette — each color carries a specific meaning */
  --sem-pink:    #EE1C5C;   /* activated / answer */
  --sem-blue:    #4D7CFF;   /* relationships / graph edges */
  --sem-amber:   #F5A623;   /* citations / sources */
  --sem-green:   #16C784;   /* confidence / health-positive */
  --sem-pink-glow:  rgba(238, 28, 92, 0.30);
  --sem-blue-glow:  rgba(77, 124, 255, 0.30);
  --sem-amber-glow: rgba(245, 166, 35, 0.30);
  --sem-green-glow: rgba(22, 199, 132, 0.30);
}

[data-theme="light"] {
  --sem-pink:    #D11051;
  --sem-blue:    #3060E0;
  --sem-amber:   #C87900;
  --sem-green:   #119265;
}

/* ===== Grid restructure — hero graph, sidecar copilot/lineage, bottom strip ===== */
.grid {
  grid-template-columns: 1.55fr 1fr;
  grid-template-rows: 1.5fr 0.95fr 0.7fr;
}
.pane-galaxy   { grid-column: 1; grid-row: 1 / 3; }   /* hero — spans both top rows */
.pane-copilot  { grid-column: 2; grid-row: 1; }
.pane-lineage  { grid-column: 2; grid-row: 2; }
.pane-risk     { grid-column: 1; grid-row: 3; animation-delay: 0.45s; }
.pane-insights { grid-column: 2; grid-row: 3; animation-delay: 0.55s; }

/* Galaxy canvas should fill its now-taller container */
.pane-galaxy .galaxy-canvas { min-height: 0; flex: 1; }

/* ===== Citations get amber — they are the trust signal ===== */
.cite-ref,
sup.cite-ref {
  color: var(--sem-amber) !important;
  font-weight: 600;
  background: color-mix(in oklab, var(--sem-amber) 14%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
  margin: 0 1px;
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
}
.cite-ref:hover {
  background: color-mix(in oklab, var(--sem-amber) 24%, transparent);
  box-shadow: 0 0 10px var(--sem-amber-glow);
}

/* ===== Confidence bar goes green ===== */
.ac-fill,
.answer-confidence .ac-fill {
  background: linear-gradient(90deg, var(--sem-green), color-mix(in oklab, var(--sem-green) 65%, var(--sem-blue))) !important;
  box-shadow: 0 0 8px var(--sem-green-glow);
}
.ac-value { color: var(--sem-green); font-weight: 600; }

/* Confidence indicator in copilot metrics tile */
#m-conf { color: var(--sem-green); }
#m-sources { color: var(--sem-amber); }
#m-rels { color: var(--sem-blue); }
#m-paths { color: var(--sem-pink); }

/* ===== Maturity Score card (top-right) ===== */
.cmd-status-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
.maturity-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 14px 8px 10px;
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--sem-pink) 10%, transparent),
    color-mix(in oklab, var(--sem-blue) 10%, transparent));
  border: 1px solid color-mix(in oklab, var(--sem-pink) 30%, var(--border-soft));
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: all 180ms ease;
  font: inherit;
}
.maturity-card:hover {
  border-color: var(--sem-pink);
  box-shadow: 0 0 22px var(--sem-pink-glow);
  transform: translateY(-1px);
}
.maturity-label {
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}
.maturity-score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.maturity-ring {
  width: 26px;
  height: 26px;
  margin-right: 2px;
  align-self: center;
  flex-shrink: 0;
}
.ring-track {
  fill: none;
  stroke: var(--border-soft);
  stroke-width: 4;
}
.ring-fill {
  fill: none;
  stroke: var(--sem-green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transform: rotate(-90deg);
  transform-origin: 22px 22px;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.2,0.9,0.3,1.1), stroke 400ms ease;
}
.maturity-value {
  font: 600 22px/1 var(--font-serif, 'Instrument Serif'), Georgia, serif;
  color: var(--text);
  font-feature-settings: "tnum";
}
.maturity-suffix {
  font-size: 11px;
  color: var(--text-mute);
}

.maturity-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: color-mix(in oklab, var(--bg-1) 96%, transparent);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.55), 0 0 1px var(--sem-pink-glow);
  padding: 0;
  z-index: 50;
  animation: fadeUp 0.22s var(--ease);
}
.mp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
.mp-eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sem-pink);
  font-weight: 700;
}
.mp-body {
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mp-row {
  display: grid;
  grid-template-columns: 95px 1fr 36px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.mp-row-label { color: var(--text-dim); font-weight: 500; }
.mp-row-bar {
  height: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.mp-row-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--w, 0%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sem-blue), var(--sem-green));
  box-shadow: 0 0 6px var(--sem-blue-glow);
  transition: width 1.2s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.mp-row-bar[data-tone="warn"]::after { background: linear-gradient(90deg, var(--sem-amber), var(--sem-pink)); box-shadow: 0 0 6px var(--sem-amber-glow); }
.mp-row-bar[data-tone="risk"]::after { background: var(--sem-pink); box-shadow: 0 0 6px var(--sem-pink-glow); }
.mp-row-val {
  font: 600 13px/1 'JetBrains Mono', monospace;
  color: var(--text);
  text-align: right;
  font-feature-settings: "tnum";
}

/* ===== Animated Copilot suggestion chips ===== */
.copilot-empty .suggestions { gap: 8px; }
.copilot-empty .suggestions .chip {
  animation: chipIn 0.5s var(--ease) backwards;
  border-color: color-mix(in oklab, var(--sem-pink) 28%, var(--border));
}
.copilot-empty .suggestions .chip:nth-child(1) { animation-delay: 0.1s; }
.copilot-empty .suggestions .chip:nth-child(2) { animation-delay: 0.2s; }
.copilot-empty .suggestions .chip:nth-child(3) { animation-delay: 0.3s; }
.copilot-empty .suggestions .chip:nth-child(4) { animation-delay: 0.4s; }
.copilot-empty .suggestions .chip:hover {
  border-color: var(--sem-pink);
  box-shadow: 0 0 18px var(--sem-pink-glow);
  transform: translateY(-1px);
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.copilot-subhint {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.02em;
  margin-top: -4px;
  margin-bottom: 6px;
}

/* Copilot orb pulse */
.copilot-orb {
  animation: orbPulse 2.6s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { box-shadow: 0 0 18px var(--sem-pink-glow), inset 0 0 16px var(--sem-blue-glow); transform: scale(1); }
  50%      { box-shadow: 0 0 32px var(--sem-pink-glow), inset 0 0 26px var(--sem-blue-glow); transform: scale(1.04); }
}

/* ===== Lineage demo state — preview before any question ===== */
.lineage-demo {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  overflow-y: auto;
}
.lineage-demo-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.lineage-demo-hint svg { flex-shrink: 0; margin-top: 2px; color: var(--sem-amber); }

.lineage-demo-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  background: color-mix(in oklab, var(--sem-amber) 6%, transparent);
  border: 1px solid color-mix(in oklab, var(--sem-amber) 22%, var(--border-soft));
  border-radius: 10px;
}
.lineage-demo-stat { display: flex; flex-direction: column; gap: 2px; }
.lineage-demo-stat-val {
  font: 600 18px/1 var(--font-serif, 'Instrument Serif'), Georgia, serif;
  color: var(--sem-amber);
  font-feature-settings: "tnum";
}
.lineage-demo-stat-label {
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}

.lineage-demo-card {
  border: 1px dashed color-mix(in oklab, var(--sem-amber) 35%, var(--border-soft));
  border-radius: 10px;
  padding: 12px 14px;
  background: color-mix(in oklab, var(--bg-1) 50%, transparent);
}
.lineage-demo-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.lineage-demo-breadcrumb .crumb-cite {
  color: var(--sem-amber);
  font-weight: 700;
  font-size: 11px;
}
.lineage-demo-breadcrumb .crumb-sep { color: var(--text-mute); opacity: 0.5; }
.lineage-demo-breadcrumb .crumb-doc { color: var(--sem-blue); }
.lineage-demo-excerpt {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  font-style: italic;
  padding-left: 10px;
  border-left: 2px solid var(--sem-amber);
}

/* ===== Knowledge Risk pane ===== */
.pane-risk .pane-head h2 { color: var(--text); }
.risk-meta {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--sem-pink);
  font-weight: 700;
  background: color-mix(in oklab, var(--sem-pink) 12%, transparent);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--sem-pink) 30%, transparent);
}
.risk-body {
  flex: 1;
  padding: 14px 22px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  overflow-y: auto;
}
.risk-card {
  background: color-mix(in oklab, var(--bg-1) 60%, transparent);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--risk-tone, var(--sem-blue));
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 200ms ease;
  animation: fadeUp 0.6s var(--ease) backwards;
}
.risk-card:nth-child(1) { animation-delay: 0.5s; }
.risk-card:nth-child(2) { animation-delay: 0.6s; }
.risk-card:nth-child(3) { animation-delay: 0.7s; }
.risk-card:nth-child(4) { animation-delay: 0.8s; }
.risk-card[data-tone="high"]   { --risk-tone: var(--sem-pink); }
.risk-card[data-tone="medium"] { --risk-tone: var(--sem-amber); }
.risk-card[data-tone="low"]    { --risk-tone: var(--sem-green); }
.risk-card:hover {
  background: color-mix(in oklab, var(--bg-1) 80%, transparent);
  box-shadow: 0 0 18px color-mix(in oklab, var(--risk-tone) 25%, transparent);
}
.risk-card-value {
  font: 600 26px/1 var(--font-serif, 'Instrument Serif'), Georgia, serif;
  color: var(--risk-tone);
  font-feature-settings: "tnum";
}
.risk-card-label {
  font-size: 11.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}
.risk-card-sub {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Mobile collapse — fall back to single column with risk last */
@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, minmax(380px, auto));
  }
  .pane-galaxy   { grid-column: 1; grid-row: 1; }
  .pane-copilot  { grid-column: 1; grid-row: 2; }
  .pane-lineage  { grid-column: 1; grid-row: 3; }
  .pane-risk     { grid-column: 1; grid-row: 4; }
  .pane-insights { grid-column: 1; grid-row: 5; }
}

/* ===== Phase 4 — compact copilot empty state to fit shorter pane ===== */
.copilot-empty {
  margin: auto;
  padding: 12px 14px;
  max-width: 360px;
  width: 100%;
}
/* Drop the big orb in the empty state — graph is the visual anchor. Keep
   the pulsing dot as a subtle aliveness signal next to the hint text. */
.copilot-empty .copilot-orb {
  width: 22px;
  height: 22px;
  display: inline-block;
  margin: 0 8px -3px 0;
  vertical-align: middle;
}
.copilot-empty .copilot-orb::after { inset: 6px; }
.copilot-empty .copilot-hint {
  font-size: 14px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.copilot-empty .copilot-subhint {
  margin-bottom: 8px;
  font-size: 10.5px;
}
.copilot-empty .suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 0;
}
.copilot-empty .suggestions .chip {
  font-size: 11px;
  padding: 7px 10px;
  text-align: left;
  line-height: 1.3;
}

/* ===========================================================================
   PHASE 5 — Narrative scroll layout
   ===========================================================================
   The previous version was a single-viewport command center. The new design
   tells a story: hero → answer → explainability → health → insights. Each
   section gets full breathing room. Old grid rules don't apply when `body`
   carries the .narrative class — we override them here.
   =========================================================================== */

/* ===== Reset: kill the old single-screen layout when narrative is active ===== */
body.narrative {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
}
body.narrative .grid,
body.narrative .cmd-bar,
body.narrative .pane,
body.narrative .pane-galaxy,
body.narrative .pane-copilot,
body.narrative .pane-lineage,
body.narrative .pane-insights,
body.narrative .pane-risk { display: none !important; }

/* Compatibility shim — keep DOM-required nodes invisible but reachable by JS */
.legacy-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

/* ===== Story sections ===== */
.story-section {
  position: relative;
  width: 100%;
  padding: clamp(60px, 8vh, 100px) clamp(24px, 5vw, 80px);
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 4vh, 56px);
  border-top: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  z-index: 1;
}
.story-section:nth-child(even) {
  background: color-mix(in oklab, var(--bg) 96%, var(--qz-blue) 4%);
}

.story-head {
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.story-eyebrow {
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sem-pink, var(--qz-pink));
}
.story-title {
  font: 400 clamp(28px, 4vw, 48px)/1.1 'Instrument Serif', Georgia, serif;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
.story-title em {
  font-style: italic;
  background: linear-gradient(120deg, var(--sem-pink, var(--qz-pink)), var(--sem-blue, var(--qz-blue)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.story-sub {
  font-size: clamp(14px, 1.3vw, 16.5px);
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 720px;
  margin: 0;
}
.cite-inline-demo {
  color: var(--sem-amber, #F5A623);
  font-weight: 600;
  background: color-mix(in oklab, var(--sem-amber, #F5A623) 14%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ============================================================
   SECTION 1 — HERO
   ============================================================ */
.hero-section {
  height: 100vh;
  min-height: 720px;
  padding: 0;
  border-top: none;
  position: relative;
  overflow: hidden;
  background: transparent;
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 75% 60%, color-mix(in oklab, var(--qz-pink) 12%, transparent), transparent 55%),
    radial-gradient(ellipse at 25% 70%, color-mix(in oklab, var(--qz-blue) 14%, transparent), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.hero-galaxy {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.hero-overlay {
  position: absolute;
  top: 50%;
  left: clamp(24px, 5vw, 80px);
  transform: translateY(-50%);
  width: min(560px, 50vw);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadeUp 1s var(--ease) 0.2s backwards;
}
.hero-eyebrow {
  font: 600 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sem-pink, var(--qz-pink));
}
.hero-title {
  font: 400 clamp(40px, 5.5vw, 72px)/1.0 'Instrument Serif', Georgia, serif;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0;
}
.hero-title em {
  font-style: italic;
  background: linear-gradient(120deg, var(--sem-pink, var(--qz-pink)) 10%, var(--sem-blue, var(--qz-blue)) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
  padding-right: 0.08em;       /* prevent italic-ascender clipping */
}
.hero-sub {
  font-size: clamp(14px, 1.2vw, 16px);
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 520px;
  margin: 0;
}

/* Big hero composer */
.hero-composer {
  display: flex;
  gap: 10px;
  background: color-mix(in oklab, var(--bg-1) 88%, transparent);
  border: 1px solid color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 35%, var(--border));
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.35), 0 0 0 1px color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 12%, transparent);
  transition: box-shadow 240ms ease, border-color 240ms ease;
}
.hero-composer:focus-within {
  border-color: var(--sem-pink, var(--qz-pink));
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), 0 0 28px color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 35%, transparent);
}
.hero-composer input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text);
  font: 500 16px/1 'Inter', sans-serif;
  padding: 12px 14px;
  outline: none;
}
.hero-composer input::placeholder { color: var(--text-mute); }
.hero-composer button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--sem-pink, var(--qz-pink)), var(--sem-blue, var(--qz-blue)));
  color: white;
  border: 0;
  font: 600 14px/1 'Inter', sans-serif;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 200ms ease;
}
.hero-composer button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 50%, transparent);
}
.hero-composer button:active { transform: translateY(0); }
.hero-composer button:disabled { opacity: 0.5; cursor: wait; }

.hero-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.hero-suggestions .chip {
  background: color-mix(in oklab, var(--bg-1) 78%, transparent);
  border: 1px solid color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 25%, var(--border));
  color: var(--text);
  font: 500 12.5px/1 'Inter', sans-serif;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 160ms ease;
  animation: fadeUp 0.5s var(--ease) backwards;
}
.hero-suggestions .chip:nth-child(1) { animation-delay: 0.35s; }
.hero-suggestions .chip:nth-child(2) { animation-delay: 0.45s; }
.hero-suggestions .chip:nth-child(3) { animation-delay: 0.55s; }
.hero-suggestions .chip:nth-child(4) { animation-delay: 0.65s; }
.hero-suggestions .chip:hover {
  border-color: var(--sem-pink, var(--qz-pink));
  background: color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 12%, var(--bg-1));
  box-shadow: 0 0 18px color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 30%, transparent);
}

.hero-scroll-cue {
  position: absolute;
  bottom: 32px;
  right: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  animation: scrollCue 2.4s ease-in-out infinite;
  z-index: 3;
}
@keyframes scrollCue {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(4px); opacity: 1; }
}

.hero-status {
  position: absolute;
  top: 30px;
  right: 32px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: color-mix(in oklab, var(--bg-1) 80%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 500 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.hero-status::before {
  content: '';
  width: 7px; height: 7px;
  background: var(--sem-green, #16C784);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--sem-green, #16C784);
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

/* ============================================================
   SECTION 2 — LIVE ANSWER
   ============================================================ */
.answer-stage {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.answer-stage-empty {
  text-align: center;
  padding: 60px 32px;
  border: 1px dashed color-mix(in oklab, var(--border) 80%, transparent);
  border-radius: 18px;
  background: color-mix(in oklab, var(--bg-1) 35%, transparent);
}
.answer-empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.answer-empty-icon .copilot-orb {
  width: 64px;
  height: 64px;
}
.answer-empty-icon .copilot-orb::after { inset: 18px; }
.answer-empty-hint {
  font: 400 18px/1.3 'Instrument Serif', Georgia, serif;
  color: var(--text-dim);
  margin: 0 0 24px;
}
.answer-empty-preview {
  margin: 0 auto;
  max-width: 580px;
  text-align: left;
  background: color-mix(in oklab, var(--bg-1) 70%, transparent);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 18px 20px;
}
.answer-preview-q {
  font: 600 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sem-pink, var(--qz-pink));
  margin-bottom: 8px;
}
.answer-preview-a {
  font-size: 13.5px;
  color: var(--text-mute);
  font-style: italic;
  line-height: 1.55;
}

.answer-stage-live {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeUp 0.7s var(--ease);
}
.answer-q-card,
.answer-a-card {
  border-radius: 18px;
  padding: 26px 32px;
  position: relative;
}
.answer-q-card {
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--sem-blue, var(--qz-blue)) 20%, transparent),
    color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 8%, transparent));
  border: 1px solid color-mix(in oklab, var(--sem-blue, var(--qz-blue)) 35%, var(--border));
}
.answer-q-eyebrow,
.answer-a-eyebrow {
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sem-blue, var(--qz-blue));
  display: block;
  margin-bottom: 10px;
}
.answer-a-eyebrow { color: var(--sem-pink, var(--qz-pink)); }
.answer-q-text {
  font: 400 22px/1.35 'Instrument Serif', Georgia, serif;
  color: var(--text);
}
.answer-a-card {
  background: color-mix(in oklab, var(--bg-1) 72%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.answer-a-text {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}
.answer-a-text sup.cite-ref {
  color: var(--sem-amber, #F5A623);
  font-weight: 600;
  background: color-mix(in oklab, var(--sem-amber, #F5A623) 16%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  margin: 0 2px;
  cursor: pointer;
  font-size: 0.7em;
  transition: all 120ms ease;
}
.answer-a-text sup.cite-ref:hover {
  background: color-mix(in oklab, var(--sem-amber, #F5A623) 30%, transparent);
  box-shadow: 0 0 14px color-mix(in oklab, var(--sem-amber, #F5A623) 50%, transparent);
}
.answer-a-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: center;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}
.answer-meta-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.meta-k {
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.meta-v {
  font: 600 18px/1 'Instrument Serif', Georgia, serif;
  color: var(--text);
}
.meta-v-amber { color: var(--sem-amber, #F5A623); }
.meta-v-blue { color: var(--sem-blue, var(--qz-blue)); }
.meta-bar {
  width: 120px;
  height: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
.meta-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sem-green, #16C784), var(--sem-blue, var(--qz-blue)));
  box-shadow: 0 0 10px color-mix(in oklab, var(--sem-green, #16C784) 50%, transparent);
  transition: width 1s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.answer-meta-conf .meta-v { color: var(--sem-green, #16C784); }

/* ============================================================
   SECTION 3 — EXPLAINABILITY
   ============================================================ */
.explain-stage {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.explain-panel {
  background: color-mix(in oklab, var(--bg-1) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 420px;
}
.explain-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.explain-panel-eyebrow {
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sem-amber, #F5A623);
}
.pillars-panel .explain-panel-eyebrow { color: var(--sem-blue, var(--qz-blue)); }

.lineage-panel .lineage-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.pillars-list {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.pillar {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 14px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--bg-1) 50%, transparent);
  border: 1px solid var(--border-soft);
  transition: all 180ms ease;
}
.pillar:hover {
  border-color: color-mix(in oklab, var(--sem-blue, var(--qz-blue)) 50%, var(--border));
  background: color-mix(in oklab, var(--bg-1) 80%, transparent);
}
.pillar-num {
  font: 400 26px/1 'Instrument Serif', Georgia, serif;
  color: var(--sem-blue, var(--qz-blue));
  align-self: center;
  text-align: center;
}
.pillar-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}
.pillar-sub {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

/* ============================================================
   SECTION 4 — KNOWLEDGE HEALTH
   ============================================================ */
.health-stage {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) 2fr;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.health-score-card {
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 14%, transparent),
    color-mix(in oklab, var(--sem-blue, var(--qz-blue)) 8%, transparent));
  border: 1px solid color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 30%, var(--border));
  border-radius: 18px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.health-score-eyebrow {
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--sem-pink, var(--qz-pink));
}
.health-score-display {
  position: relative;
  width: 200px;
  height: 200px;
}
.health-ring {
  width: 100%;
  height: 100%;
}
.ring-track-big {
  fill: none;
  stroke: color-mix(in oklab, var(--border-soft) 90%, transparent);
  stroke-width: 8;
}
.ring-fill-big {
  fill: none;
  stroke: var(--sem-green, #16C784);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 1.8s cubic-bezier(0.2,0.9,0.3,1.1), stroke 400ms ease;
}
.health-score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
}
.health-score-num {
  font: 400 64px/1 'Instrument Serif', Georgia, serif;
  color: var(--text);
  font-feature-settings: "tnum";
  display: inline-block;
  vertical-align: baseline;
}
.health-score-suffix {
  font-size: 15px;
  color: var(--text-mute);
  align-self: flex-end;
  padding-bottom: 12px;
}

.health-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.health-row {
  display: grid;
  grid-template-columns: 120px 1fr 36px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.health-row-label { color: var(--text-dim); font-weight: 500; }
.health-row-bar {
  height: 6px;
  background: color-mix(in oklab, var(--border-soft) 70%, transparent);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.health-row-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--w, 0%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sem-blue, var(--qz-blue)), var(--sem-green, #16C784));
  transition: width 1.4s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.health-row-bar[data-tone="warn"]::after { background: linear-gradient(90deg, var(--sem-amber, #F5A623), var(--sem-pink, var(--qz-pink))); }
.health-row-bar[data-tone="risk"]::after { background: var(--sem-pink, var(--qz-pink)); }
.health-row-val {
  font: 600 13px/1 'JetBrains Mono', monospace;
  color: var(--text);
  text-align: right;
  font-feature-settings: "tnum";
}

.health-risk-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-content: start;
}
.risk-card {
  background: color-mix(in oklab, var(--bg-1) 65%, transparent);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--risk-tone, var(--sem-blue, var(--qz-blue)));
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 200ms ease;
}
.risk-card[data-tone="high"]   { --risk-tone: var(--sem-pink, var(--qz-pink)); }
.risk-card[data-tone="medium"] { --risk-tone: var(--sem-amber, #F5A623); }
.risk-card[data-tone="low"]    { --risk-tone: var(--sem-green, #16C784); }
.risk-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px color-mix(in oklab, var(--risk-tone) 30%, transparent);
}
.risk-card-value {
  font: 400 38px/1 'Instrument Serif', Georgia, serif;
  color: var(--risk-tone);
  font-feature-settings: "tnum";
}
.risk-card-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}
.risk-card-sub {
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: 0.02em;
  margin-top: 4px;
  line-height: 1.5;
}

/* ============================================================
   SECTION 5 — INSIGHTS
   ============================================================ */
.insights-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.insights-stats .tile {
  background: color-mix(in oklab, var(--bg-1) 60%, transparent);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.insights-stats .tile-label {
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.insights-stats .tile-value {
  font: 400 32px/1 'Instrument Serif', Georgia, serif;
  color: var(--text);
  font-feature-settings: "tnum";
}
.insights-stats .tile-delta {
  font-size: 11px;
  color: var(--text-dim);
}

.insights-stage {
  background: color-mix(in oklab, var(--bg-1) 50%, transparent);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}
.insights-stage-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.insights-stage-head .tabs {
  display: flex;
  gap: 4px;
}
.insights-stage-head .tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  padding: 8px 16px;
  border-radius: 999px;
  font: 500 12.5px/1 'Inter', sans-serif;
  cursor: pointer;
  transition: all 160ms ease;
}
.insights-stage-head .tab:hover { color: var(--text); }
.insights-stage-head .tab.is-active {
  background: color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 15%, var(--bg-1));
  color: var(--text);
  border-color: color-mix(in oklab, var(--sem-pink, var(--qz-pink)) 40%, transparent);
}

.insights-body {
  min-height: 380px;
  padding: 24px 28px;
}
.insight-panel { display: none; }
.insight-panel.is-active { display: block; }

/* ============================================================
   Footer
   ============================================================ */
.story-footer {
  padding: 36px clamp(24px, 5vw, 80px);
  border-top: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--bg) 96%, var(--qz-blue) 4%);
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-brand,
.footer-meta {
  font: 500 11.5px/1.5 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  color: var(--text-mute);
}

/* ============================================================
   Navbar tweak for narrative — make Talk-to-Experts the CTA stand-out
   ============================================================ */
body.narrative .qz-nav { gap: 18px; }
body.narrative .qz-nav a.nav-scroll {
  color: var(--nav-text);
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   Mobile responsive
   ============================================================ */
@media (max-width: 980px) {
  .hero-overlay {
    width: calc(100% - 32px);
    left: 16px;
    right: 16px;
  }
  .hero-title { font-size: clamp(34px, 8vw, 52px); }
  .explain-stage,
  .health-stage {
    grid-template-columns: 1fr;
  }
  .health-risk-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .insights-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .answer-q-text { font-size: 18px; }
  .answer-a-text { font-size: 15px; }
}
@media (max-width: 640px) {
  .health-risk-grid,
  .insights-stats {
    grid-template-columns: 1fr;
  }
  .hero-section { min-height: 100vh; }
}

/* Disable old maturity-card / cmd-bar styles when narrative is active */
body.narrative .maturity-card,
body.narrative .cmd-status-wrap,
body.narrative .theme-toggle { display: none !important; }

/* ============================================================================
   Sticky ask bar (visible after user scrolls past the hero)
   ============================================================================ */
.sticky-ask {
  position: fixed;
  top: 60px; /* sits just under the qz-navbar */
  left: 0;
  right: 0;
  z-index: 40;
  padding: 10px 28px;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--bg) 92%, transparent),
    color-mix(in oklab, var(--bg) 78%, transparent));
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid color-mix(in oklab, var(--sem-pink) 22%, var(--border-soft));
  transform: translateY(-110%);
  opacity: 0;
  transition: transform 280ms cubic-bezier(0.2, 0.9, 0.3, 1.05), opacity 240ms ease;
  pointer-events: none;
}
.sticky-ask.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.sticky-ask-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}
.sticky-ask-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sem-pink);
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}
.sticky-ask-form {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.sticky-ask-form input {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  background: color-mix(in oklab, var(--bg-1) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font: 13px/1 var(--font-sans, 'Inter'), sans-serif;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.sticky-ask-form input::placeholder { color: var(--text-mute); }
.sticky-ask-form input:focus {
  outline: none;
  border-color: var(--sem-pink);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--sem-pink) 18%, transparent);
}
.sticky-ask-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  height: 38px;
  background: linear-gradient(135deg, var(--sem-pink), var(--sem-blue));
  border: none;
  border-radius: 999px;
  color: white;
  font: 600 12.5px/1 'Inter', sans-serif;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 180ms ease;
}
.sticky-ask-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px color-mix(in oklab, var(--sem-pink) 35%, transparent);
}

/* When sticky ask is visible, push sections down a touch so headings don't
   end up directly under the bar after smooth scroll */
.story-section {
  scroll-margin-top: 110px;
}

/* ============================================================================
   Dramatic graph activation — when an answer comes back, unrelated nodes fade
   hard, activated nodes pulse pink. This is the "BOOM" moment.
   ============================================================================ */
.galaxy-canvas.graph-activated {
  position: relative;
}
.galaxy-canvas.graph-activated::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at center,
    color-mix(in oklab, var(--sem-pink) 8%, transparent) 0%,
    transparent 50%);
  animation: graphBoom 1.6s cubic-bezier(0.2, 0.9, 0.4, 1.05);
  opacity: 0;
}
@keyframes graphBoom {
  0%   { opacity: 0; transform: scale(0.4); }
  30%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* ============================================================================
   Phase 5 — control fixes: visible "refreshing" feedback + scroll progress
   ============================================================================ */

/* Brief glow flash on the live answer card when a new question is answered.
   Tells the user "yes, your ask landed, here's the new answer" — without it,
   answer→answer transitions can look indistinguishable. */
.answer-stage-live.is-refreshing .answer-q-card,
.answer-stage-live.is-refreshing .answer-a-card {
  animation: answerRefresh 0.6s ease-out;
}
@keyframes answerRefresh {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--sem-pink) 35%, transparent); transform: translateY(2px); opacity: 0.7; }
  40%  { box-shadow: 0 0 0 8px color-mix(in oklab, var(--sem-pink) 20%, transparent); transform: translateY(0); opacity: 1; }
  100% { box-shadow: 0 0 0 0 transparent; transform: translateY(0); opacity: 1; }
}

/* Sticky submit "working" spinner — replaces the arrow with a small spinner */
.sticky-ask-submit.is-working {
  pointer-events: none;
  opacity: 0.85;
}
.sticky-ask-submit.is-working svg {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Scroll progress bar across the very top — gives a sense of place in the
   long narrative scroll. Sits above everything else, doesn't intercept clicks. */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 60;
  pointer-events: none;
}
.scroll-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sem-pink), var(--sem-amber), var(--sem-blue));
  box-shadow: 0 0 8px color-mix(in oklab, var(--sem-pink) 50%, transparent);
  transition: width 80ms linear;
}

/* Section-jump pill nav — fixed right side, shows current section, lets user
   jump directly. Compact, doesn't dominate. */
.section-nav {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}
.section-nav-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--text-mute) 50%, transparent);
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: all 180ms ease;
}
.section-nav-dot::after {
  content: attr(data-label);
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  font: 600 10px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: color-mix(in oklab, var(--bg-1) 95%, transparent);
  border: 1px solid var(--border-soft);
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 180ms ease;
}
.section-nav-dot:hover {
  background: var(--sem-pink);
  transform: scale(1.4);
}
.section-nav-dot:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.section-nav-dot.is-current {
  background: var(--sem-pink);
  box-shadow: 0 0 12px color-mix(in oklab, var(--sem-pink) 60%, transparent);
  transform: scale(1.25);
}

/* Hide section nav on narrow screens — it's a desktop convenience */
@media (max-width: 760px) {
  .section-nav { display: none; }
}

/* CRITICAL: sections need scroll-margin-top so anchor scrolls don't end up
   underneath the sticky navbar + sticky-ask bar (combined ~120px). */
.story-section { scroll-margin-top: 130px; }

/* ==========================================================================
   Retrieval mode badge — Phase 2
   Tells the truth about which retrieval path served the answer. Lexical and
   hybrid are visually distinct so a viewer can see the semantic layer come
   online mid-session rather than taking it on faith.
   ========================================================================== */
.retrieval-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-left: 0.85rem;
  padding: 0.22em 0.7em;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-transform: lowercase;
  white-space: nowrap;
  border: 1px solid currentColor;
  opacity: 0.78;
  transition: opacity 220ms ease, background-color 220ms ease, color 220ms ease;
  cursor: help;
}
.retrieval-badge::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: currentColor;
}
.retrieval-badge[data-mode="lexical"] { color: #8b9bb4; }
.retrieval-badge[data-mode="hybrid"] {
  color: #5eead4;
  background: rgba(94, 234, 212, 0.09);
  opacity: 1;
}
.retrieval-badge[data-mode="hybrid"]::before {
  animation: retrieval-pulse 2.4s ease-in-out infinite;
}
@keyframes retrieval-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.8); }
}
@media (prefers-reduced-motion: reduce) {
  .retrieval-badge[data-mode="hybrid"]::before { animation: none; }
}

/* ==========================================================================
   Derivation panels — Phase 2.1
   Confidence and Knowledge Health both show their working. A number a viewer
   cannot interrogate is a number they will not trust.
   ========================================================================== */
.why-btn {
  background: rgba(120, 140, 220, 0.12);
  border: 1px solid rgba(140, 160, 240, 0.28);
  color: #9db0e0; font: inherit; font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.03em; padding: 0.32em 0.85em; border-radius: 999px;
  cursor: pointer; transition: background 180ms ease, color 180ms ease;
}
.why-btn:hover { background: rgba(120, 140, 220, 0.24); color: #cfd9f5; }
.why-btn-wide { display: block; margin: 1.6rem auto 0; }

.derivation-panel {
  max-width: 1100px; margin: 1rem auto 0; padding: 1.5rem 1.75rem;
  background: rgba(18, 16, 44, 0.72);
  border: 1px solid rgba(140, 160, 240, 0.20);
  border-radius: 14px; color: #c3cbe6; font-size: 0.83rem; line-height: 1.6;
}
.derivation-panel h4 {
  margin: 1.4rem 0 0.6rem; font-size: 0.74rem; letter-spacing: 0.11em;
  text-transform: uppercase; color: #EE1C5C;
}
.derivation-panel code {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.76rem;
  color: #7fe3c8; background: rgba(0, 0, 0, 0.30);
  padding: 0.12em 0.45em; border-radius: 4px;
}

/* --- confidence rows --- */
.conf-headline { display: flex; align-items: baseline; gap: 0.8rem; margin-bottom: 0.4rem; }
.conf-headline-num { font-size: 2.1rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.conf-headline-band { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.conf-band-high { color: #4ade80; } .conf-band-moderate { color: #fbbf24; }
.conf-band-low { color: #fb923c; }  .conf-band-very-low { color: #f87171; }
.conf-method { color: #8e99bb; font-size: 0.78rem; margin: 0 0 1.1rem; }
.conf-row { padding: 0.7rem 0; border-top: 1px solid rgba(140, 160, 240, 0.13); }
.conf-row-head { display: flex; align-items: baseline; gap: 0.6rem; }
.conf-row-label { font-weight: 600; color: #e3e9fb; flex: 1; }
.conf-row-val { font-variant-numeric: tabular-nums; color: #fff; font-weight: 600; }
.conf-row-weight { font-size: 0.72rem; color: #7c86a8; }
.conf-row-bar { height: 3px; background: rgba(255,255,255,0.07); border-radius: 2px; margin: 0.4rem 0 0.45rem; }
.conf-row-bar span { display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #4D7CFF, #7fe3c8); }
.conf-row-how { margin-bottom: 0.25rem; }
.conf-row-why { color: #97a1c0; font-size: 0.79rem; }
.conf-caveats { margin-top: 1.1rem; padding: 0.85rem 1rem;
  background: rgba(248, 113, 113, 0.09); border-left: 2px solid #f87171; border-radius: 6px; }
.conf-caveats-clean { background: rgba(74, 222, 128, 0.08); border-left-color: #4ade80; }
.conf-caveats ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* --- health rows --- */
.health-derive-intro { color: #a8b2d0; margin: 0 0 0.5rem; }
.health-derive-row { padding: 0.8rem 0; border-top: 1px solid rgba(140, 160, 240, 0.13); }
.health-derive-head { display: flex; align-items: baseline; gap: 0.6rem; }
.health-derive-label { font-weight: 600; color: #e3e9fb; flex: 1; text-transform: capitalize; }
.health-derive-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; color: #fff; }
.health-band-strong { color: #4ade80; }   .health-band-adequate { color: #7fe3c8; }
.health-band-weak { color: #fbbf24; }     .health-band-critical { color: #f87171; }
.health-derive-formula { margin: 0.35rem 0; }
.health-derive-inputs { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; margin: 0.35rem 0; }
.hd-kv { font-size: 0.75rem; color: #9aa4c4; }
.hd-kv b { color: #c8d2ee; font-weight: 600; }
.health-derive-meaning { color: #b3bcd8; }
.health-derive-low { color: #8e99bb; font-size: 0.79rem; margin-top: 0.25rem; }
.health-derive-risk .health-derive-value { color: #fbbf24; font-size: 0.95rem; }
.health-derive-wrap { max-width: 1100px; margin: 0 auto; }

/* --- answer body --- */
.answer-lead { font-size: 0.78rem; color: #8e99bb; margin: 0 0 0.7rem; letter-spacing: 0.01em; }
.answer-lead strong { color: #b9c4e6; font-weight: 600; }
.answer-sent { display: inline; }
.answer-none { color: #e3e9fb; font-weight: 600; margin: 0 0 0.4rem; }
.answer-none-detail { color: #97a1c0; font-size: 0.85rem; margin: 0; }

/* ==========================================================================
   Phase 2.2 — premium surface, business-first disclosure
   Visual weight follows business meaning: the answer and the verdict lead,
   the derivation sits underneath, and the technical working is one click away.
   ========================================================================== */

/* ---- brand lockup: product first, authorship underneath ---------------- */
.qz-context { display: flex; flex-direction: column; gap: 0.1rem; line-height: 1.15; }
.qz-context-title {
  font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; color: #fff;
}
.qz-context-eyebrow {
  font-size: 0.62rem; letter-spacing: 0.11em; text-transform: uppercase;
  color: #8e99bb; font-weight: 600;
}

/* ---- hero ------------------------------------------------------------- */
.hero-eyebrow {
  display: inline-block; margin-bottom: 1rem; padding: 0.3em 0.95em;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.13em;
  text-transform: uppercase; color: #cbd5f5;
  background: linear-gradient(120deg, rgba(77,124,255,0.20), rgba(238,28,92,0.16));
  border: 1px solid rgba(150,170,255,0.30); border-radius: 999px;
  backdrop-filter: blur(8px);
}

/* ---- answer: reads as a reply ----------------------------------------- */
.answer-opener {
  font-size: 0.95rem; font-weight: 600; color: #cfd9f7;
  margin: 0 0 0.85rem; line-height: 1.5; letter-spacing: -0.005em;
}
.answer-body { line-height: 1.85; }
.answer-marker {
  color: #8fa3d4; font-style: italic; font-weight: 500;
}
.answer-closing {
  margin: 1.1rem 0 0; padding: 0.7rem 0.95rem;
  font-size: 0.82rem; color: #a8b2d0; line-height: 1.55;
  background: rgba(140, 160, 240, 0.07);
  border-left: 2px solid rgba(150, 170, 255, 0.45);
  border-radius: 0 6px 6px 0;
}

/* ---- progressive disclosure ------------------------------------------- */
.tech-detail { margin-top: 0.55rem; }
.tech-detail > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 0.35em;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: #7d88ab; padding: 0.15em 0; transition: color 160ms ease;
}
.tech-detail > summary::-webkit-details-marker { display: none; }
.tech-detail > summary::before {
  content: "+"; display: inline-block; width: 1em; text-align: center;
  font-size: 0.85rem; font-weight: 400; transition: transform 200ms ease;
}
.tech-detail[open] > summary::before { content: "−"; }
.tech-detail > summary:hover { color: #b9c4e6; }
.tech-detail-body {
  margin-top: 0.5rem; padding: 0.7rem 0.9rem;
  background: rgba(0, 0, 0, 0.22); border-radius: 8px;
  border-left: 2px solid rgba(127, 227, 200, 0.35);
}
.conf-row-tech { margin: 0.4rem 0 0; font-size: 0.76rem; color: #8e99bb; line-height: 1.55; }

/* ---- confidence: verdict first ---------------------------------------- */
.conf-verdict {
  font-size: 0.92rem; color: #dbe3f8; line-height: 1.55; margin: 0.2rem 0 0.6rem;
  font-weight: 500;
}
.conf-method { color: #7d88ab; font-size: 0.76rem; margin: 0 0 1.1rem; }
.conf-row-label { font-size: 0.88rem; }
.conf-row-why { color: #9aa4c4; font-size: 0.8rem; line-height: 1.5; }

/* ---- health verdict --------------------------------------------------- */
.health-verdict {
  max-width: 760px; margin: 1.4rem auto 0; padding: 1rem 1.3rem;
  background: linear-gradient(135deg, rgba(77,124,255,0.10), rgba(238,28,92,0.07));
  border: 1px solid rgba(150,170,255,0.22); border-radius: 12px;
}
.health-verdict-line {
  margin: 0 0 0.35rem; font-size: 1.02rem; font-weight: 600; color: #eef2ff;
  letter-spacing: -0.01em;
}
.health-verdict-detail { margin: 0; font-size: 0.85rem; color: #a8b2d0; line-height: 1.55; }
.health-verdict:empty { display: none; }

.health-derive-label { font-size: 0.95rem; letter-spacing: -0.005em; }
.health-derive-meaning { color: #c3cbe6; font-size: 0.86rem; }
.health-derive-low { color: #97a1c0; }
.health-derive-intro { font-size: 0.9rem; line-height: 1.65; }
.health-derive-intro strong { color: #fff; }

/* ---- premium touches: depth without motion cost ----------------------- */
.derivation-panel {
  box-shadow: 0 20px 60px -30px rgba(0, 0, 0, 0.9),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.why-btn {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.why-btn:focus-visible,
.tech-detail > summary:focus-visible {
  outline: 2px solid rgba(127, 227, 200, 0.65); outline-offset: 2px; border-radius: 4px;
}
.cite-ref { cursor: help; }

@media (prefers-reduced-motion: reduce) {
  .tech-detail > summary::before { transition: none; }
}

@media (max-width: 720px) {
  .derivation-panel { padding: 1.1rem 1rem; }
  .health-verdict { margin-left: 1rem; margin-right: 1rem; }
  .answer-opener { font-size: 0.9rem; }
}

/* ==========================================================================
   PHASE 2.3 — DESIGN SYSTEM PASS
   ==========================================================================
   Written in four layers, in dependency order:
     1. tokens      fluid type/space scale, refreshed palette
     2. lockup      brand hierarchy — client first, product second
     3. components  answer, graph story, heatmap, buttons
     4. adaptive    360px phone through 2560px display
   ========================================================================== */

/* ---------- 1. TOKENS ---------------------------------------------------- */
:root {
  /* Fluid type: one scale that interpolates between a 360px phone and a 1600px
     display, so nothing needs a font-size breakpoint. clamp() bounds it at both
     ends — text stays legible on a phone and stops growing absurdly on a TV. */
  --fs-micro:  clamp(0.62rem, 0.58rem + 0.18vw, 0.72rem);
  --fs-small:  clamp(0.76rem, 0.72rem + 0.20vw, 0.86rem);
  --fs-body:   clamp(0.90rem, 0.86rem + 0.24vw, 1.02rem);
  --fs-lead:   clamp(1.02rem, 0.95rem + 0.40vw, 1.20rem);
  --fs-h3:     clamp(1.20rem, 1.05rem + 0.72vw, 1.65rem);
  --fs-h2:     clamp(1.65rem, 1.30rem + 1.70vw, 2.90rem);
  --fs-hero:   clamp(2.30rem, 1.50rem + 4.20vw, 5.20rem);

  /* Spacing on a 4px grid, fluid at the larger end */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;   --sp-6: 2rem;     --sp-7: 3rem;
  --sp-8: clamp(3rem, 2rem + 4vw, 5rem);
  --sp-9: clamp(4rem, 2.5rem + 7vw, 8rem);

  /* Reading measure — prose past ~72ch loses the reader's line-return */
  --measure: 68ch;
  --measure-tight: 54ch;

  /* Palette refresh: same brand hues, slightly deeper and less saturated in the
     mid-tones so white text sits at a higher contrast ratio and the accents
     read as accents rather than competing with the content. */
  --surface-0: #0B1338;
  --surface-1: #111C4A;
  --surface-2: #17245C;
  --surface-raised: rgba(255, 255, 255, 0.035);
  --surface-sunken: rgba(0, 0, 0, 0.22);
  --hairline: rgba(150, 170, 255, 0.16);
  --hairline-strong: rgba(150, 170, 255, 0.30);

  --ink-1: #F2F5FD;   /* headings */
  --ink-2: #D3DAF0;   /* body */
  --ink-3: #A2AECD;   /* secondary */
  --ink-4: #7B87A8;   /* meta */

  --accent: #5B86FF;
  --accent-soft: rgba(91, 134, 255, 0.14);
  --signal: #FF2E6B;
  --positive: #47D6A6;
  --caution: #F6B44C;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 140ms;
  --dur: 240ms;
  --dur-slow: 420ms;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
}

/* ---------- 2. BRAND LOCKUP ---------------------------------------------
   Hierarchy: client (largest) > product > demonstrator (smallest).
   Nothing here is keyed to the client's NAME — only to its slot — so a longer or
   shorter client name inherits identical treatment. Verified by a test that fails
   if any client name appears anywhere in this stylesheet. */
.qz-navbar { gap: var(--sp-4); }

.qz-brand { text-decoration: none; flex-shrink: 0; }
.qz-client {
  display: block;
  font-size: clamp(1.05rem, 0.95rem + 0.55vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.022em;
  line-height: 1.05;
  color: var(--nav-text, #1A1F36);
  white-space: nowrap;
  transition: opacity var(--dur) var(--ease-soft);
}
.qz-brand:hover .qz-client { opacity: 0.72; }

.qz-divider {
  width: 1px; align-self: stretch; margin: 0.55rem 0;
  background: linear-gradient(180deg, transparent, var(--nav-border, #E5E8EE), transparent);
  flex-shrink: 0;
}

.qz-context { display: flex; flex-direction: column; gap: 0.08rem; min-width: 0; }
.qz-product {
  font-size: clamp(0.78rem, 0.72rem + 0.24vw, 0.95rem);
  font-weight: 700; letter-spacing: -0.008em; line-height: 1.15;
  color: var(--nav-text, #1A1F36);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qz-demoby { display: flex; flex-direction: column; line-height: 1.25; }
.qz-demoby > span {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.055em;
  text-transform: uppercase; color: var(--nav-text-dim, #5C6788);
  white-space: nowrap;
}
.qz-demoby > small {
  font-size: 0.56rem; font-weight: 600; letter-spacing: 0.10em;
  text-transform: uppercase; color: var(--nav-text-dim, #5C6788);
  opacity: 0.62; white-space: nowrap;
}

/* ---------- 3. COMPONENTS ------------------------------------------------ */

/* Assurance line — a checkable claim, placed with the evidence it describes */
.answer-assurance {
  margin: var(--sp-4) 0 0;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--hairline);
  font-size: var(--fs-small);
  color: var(--ink-4);
  line-height: 1.55;
  max-width: var(--measure);
}
.answer-assurance::before {
  content: "";
  display: inline-block; width: 0.62em; height: 0.62em; margin-right: 0.5em;
  border-radius: 50%; background: var(--positive);
  box-shadow: 0 0 0 3px rgba(71, 214, 166, 0.16);
  vertical-align: middle;
}

/* Answer readability: a measure, generous leading, clear sentence rhythm */
.answer-a-text { max-width: var(--measure); }
.answer-body { font-size: var(--fs-body); line-height: 1.85; color: var(--ink-2); }
.answer-opener { font-size: var(--fs-lead); max-width: var(--measure); }
.answer-sent + .answer-sent { margin-left: 0.15em; }

/* Graph purpose — the standing "what am I looking at" panel */
.graph-purpose {
  max-width: 640px; margin-top: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  background: linear-gradient(135deg, rgba(91,134,255,0.10), rgba(255,46,107,0.06));
  border: 1px solid var(--hairline); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  backdrop-filter: blur(10px);
  animation: gp-in var(--dur-slow) var(--ease-out) both;
}
@keyframes gp-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.gp-headline {
  margin: 0 0 var(--sp-2); font-size: var(--fs-body); font-weight: 650;
  color: var(--ink-1); line-height: 1.4; letter-spacing: -0.01em;
}
.gp-body { margin: 0; font-size: var(--fs-small); color: var(--ink-3); line-height: 1.6; }
.gp-stats { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin-top: var(--sp-3); }
.gp-stat { font-size: var(--fs-micro); color: var(--ink-4); letter-spacing: 0.02em; }
.gp-stat b {
  display: block; font-size: var(--fs-h3); font-weight: 700;
  color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums;
}

/* Graph contribution — the per-answer story */
.graph-value-wrap { max-width: 1100px; margin: var(--sp-5) auto 0; padding: 0 var(--sp-4); }
.graph-value {
  padding: var(--sp-5) var(--sp-6);
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px -40px rgba(0,0,0,0.95);
  animation: gp-in var(--dur-slow) var(--ease-out) both;
}
.gv-eyebrow {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--signal);
}
.gv-lead {
  margin: var(--sp-3) 0 0; font-size: var(--fs-body); line-height: 1.7;
  color: var(--ink-2); max-width: var(--measure);
}
.gv-lead strong { color: var(--ink-1); font-weight: 650; }
.gv-lead em { color: var(--accent); font-style: normal; font-weight: 600; }
.gv-cross {
  margin: var(--sp-3) 0 0; font-size: var(--fs-small); color: var(--ink-3);
  line-height: 1.6; max-width: var(--measure);
}
.gv-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.gv-chip {
  display: inline-flex; flex-direction: column; gap: 0.1rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface-sunken); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease-soft), transform var(--dur) var(--ease-out);
}
.gv-chip:hover { border-color: var(--hairline-strong); transform: translateY(-1px); }
.gv-chip-kind {
  font-size: 0.58rem; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 600;
}
.gv-chip-name { font-size: var(--fs-small); font-weight: 650; color: var(--ink-1); }
.gv-chip-reach { font-size: 0.6rem; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.gv-metric {
  margin: var(--sp-4) 0 0; padding: var(--sp-3) var(--sp-4);
  background: rgba(71, 214, 166, 0.08);
  border-left: 2px solid var(--positive);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--fs-small); color: var(--ink-2); line-height: 1.55;
}
.gv-metric strong { color: var(--positive); font-size: var(--fs-lead); font-weight: 700; }
.gv-tech { margin: 0.4rem 0 0; font-size: var(--fs-small); color: var(--ink-4); line-height: 1.6; }

/* Heatmap: collapsed by default */
.hm-toggle {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  width: 100%; margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4);
  background: var(--surface-sunken); border: 1px dashed var(--hairline);
  border-radius: var(--radius-sm); color: var(--ink-3);
  font: inherit; cursor: pointer;
  transition: background var(--dur) var(--ease-soft), border-color var(--dur) var(--ease-soft),
              color var(--dur) var(--ease-soft);
}
.hm-toggle:hover {
  background: var(--accent-soft); border-color: var(--hairline-strong); color: var(--ink-1);
}
.hm-toggle-label { font-size: var(--fs-small); font-weight: 650; letter-spacing: 0.01em; }
.hm-toggle-sub { font-size: var(--fs-micro); color: var(--ink-4); }
.hm-row-extra { animation: hm-in var(--dur) var(--ease-out) both; }
@keyframes hm-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Buttons: a consistent press model everywhere */
.why-btn, .hm-toggle, .qz-cta, .chip, .tab {
  will-change: transform;
}
.why-btn:active, .hm-toggle:active, .chip:active { transform: translateY(1px) scale(0.995); }
.qz-cta {
  position: relative; overflow: hidden;
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-soft);
}
.qz-cta::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.28), transparent 70%);
  transform: translateX(-110%);
  transition: transform var(--dur-slow) var(--ease-soft);
}
.qz-cta:hover { transform: translateY(-1px); box-shadow: 0 10px 26px -12px rgba(255,46,107,0.75); }
.qz-cta:hover::after { transform: translateX(110%); }

/* Focus visibility — one ring, everywhere, meets WCAG 2.4.7 */
a:focus-visible, button:focus-visible, input:focus-visible,
summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--positive); outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- 4. ADAPTIVE -------------------------------------------------- */

/* Phones — the navbar is the tightest constraint: three brand tiers plus nav
   cannot coexist, so the demonstrator credit drops to one line and the section
   nav collapses. Client name never shrinks below legibility. */
@media (max-width: 640px) {
  .qz-navbar { flex-wrap: wrap; padding: 0.6rem 0.9rem; gap: 0.55rem; }
  .qz-divider { display: none; }
  .qz-context { flex-basis: 100%; order: 3; flex-direction: row; align-items: baseline; gap: 0.5rem; }
  .qz-demoby > small { display: none; }
  .qz-nav { order: 2; margin-left: auto; }
  .qz-nav .nav-scroll { display: none; }

  .graph-purpose { max-width: none; margin-inline: 0; border-radius: var(--radius); }
  .gp-stats { gap: var(--sp-4); }
  .graph-value { padding: var(--sp-4); }
  .gv-chips { gap: 0.35rem; }
  .gv-chip { flex: 1 1 auto; min-width: 0; }
  .answer-assurance { font-size: var(--fs-micro); }
  .hm-label { max-width: 42vw; }
}

/* Small tablets */
@media (min-width: 641px) and (max-width: 900px) {
  .qz-nav .nav-scroll { display: none; }
  .graph-purpose { max-width: 560px; }
}

/* Large desktop — widen the shell but hold the reading measure, so lines never
   stretch past the point where the eye loses its return. */
@media (min-width: 1600px) {
  .graph-value-wrap, .derivation-panel, .health-derive-wrap { max-width: 1280px; }
  .graph-purpose { max-width: 720px; }
}

/* TV / very large displays — viewed from distance, so scale up the whole shell
   rather than only the type. */
@media (min-width: 2200px) {
  :root { --fs-body: 1.15rem; --fs-small: 0.95rem; --fs-micro: 0.8rem; --measure: 74ch; }
  .graph-value-wrap, .derivation-panel { max-width: 1560px; }
  .qz-navbar { padding-inline: 4vw; }
}

/* Short landscape (laptop in a meeting room, phone rotated) — reclaim
   vertical space rather than forcing a scroll to reach the ask box. */
@media (max-height: 620px) and (orientation: landscape) {
  .graph-purpose { display: none; }
  .hero-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* Print / PDF export — reviewers do circulate these */
@media print {
  .qz-navbar, .qz-nav, .section-nav, .sticky-ask, .hm-toggle { display: none !important; }
  .derivation-panel, .graph-value { break-inside: avoid; border-color: #999; }
  .tech-detail[open] .tech-detail-body { display: block; }
  body { background: #fff; color: #111; }
}

@media (prefers-reduced-motion: reduce) {
  .graph-purpose, .graph-value, .hm-row-extra { animation: none; }
  .qz-cta::after { display: none; }
  .why-btn:active, .hm-toggle:active, .chip:active { transform: none; }
}

@media (prefers-contrast: more) {
  :root { --ink-3: #C4CDE6; --ink-4: #A6B0CC; --hairline: rgba(170,190,255,0.34); }
}

/* ==========================================================================
   PHASE 2.4 — status chip states + answer subgraph
   ========================================================================== */

/* ---- Status chip: one element, two states ------------------------------
   At rest it states what the graph IS; during an answer, what it DID. Same
   position and styling, so the reader watches one thing change rather than
   scanning for a second panel. */
.hero-status {
  display: inline-flex; align-items: center; flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  transition: border-color var(--dur) var(--ease-soft), background var(--dur) var(--ease-soft);
}
.hero-status-text {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.85rem;
}
.gs-tag {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.2em 0.6em; border-radius: 999px;
  color: var(--ink-3, #A2AECD);
  background: rgba(150, 170, 255, 0.12);
  border: 1px solid rgba(150, 170, 255, 0.22);
  white-space: nowrap;
}
.gs-tag-live {
  color: #FF6E9C;
  background: rgba(255, 46, 107, 0.14);
  border-color: rgba(255, 46, 107, 0.40);
}
.gs-pair {
  font-size: var(--fs-micro, 0.68rem); color: var(--ink-3, #A2AECD);
  letter-spacing: 0.01em; white-space: nowrap;
}
.gs-pair b {
  color: var(--ink-1, #F2F5FD); font-weight: 700; font-variant-numeric: tabular-nums;
  margin-right: 0.28em;
}
.hero-status[data-state="live"] { border-color: rgba(255, 46, 107, 0.32); }
.hero-status[data-state="live"] .gs-pair b { color: #FF6E9C; }

/* ---- Answer card: explanation left, subgraph right --------------------- */
.graph-value-split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-6, 2rem); }
.gv-main { min-width: 0; }
.gv-viz {
  align-self: start;
  padding: var(--sp-3, 0.75rem);
  background: var(--surface-sunken, rgba(0,0,0,0.22));
  border: 1px solid var(--hairline, rgba(150,170,255,0.16));
  border-radius: var(--radius, 14px);
}

/* ---- Mini subgraph ----------------------------------------------------- */
.mini-graph { margin: 0; }
.mini-graph svg { width: 100%; height: auto; display: block; overflow: visible; }

.mg-edge {
  stroke: rgba(150, 170, 255, 0.42); stroke-width: 1.2;
  animation: mg-draw var(--dur-slow, 420ms) var(--ease-out, ease-out) both;
}
@keyframes mg-draw { from { opacity: 0; } to { opacity: 1; } }

.mg-node-hub { fill: #FF2E6B; }
.mg-node-hub-halo { fill: rgba(255, 46, 107, 0.18); animation: mg-pulse 3s ease-in-out infinite; }
@keyframes mg-pulse { 0%, 100% { r: 19; opacity: 0.6; } 50% { r: 23; opacity: 0.25; } }

.mg-node-doc { fill: #5B86FF; }
.mg-node-reg { fill: #47D6A6; }
.mg-doc { animation: mg-pop var(--dur, 240ms) var(--ease-out, ease-out) both; }
@keyframes mg-pop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }

.mg-label {
  fill: var(--ink-3, #A2AECD); font-size: 8.5px; font-weight: 500;
  font-family: inherit; letter-spacing: 0.01em;
}
.mg-hub-label {
  fill: var(--ink-1, #F2F5FD); font-size: 10.5px; font-weight: 700;
  font-family: inherit; letter-spacing: -0.005em;
}
.mg-doc:hover .mg-label { fill: var(--ink-1, #F2F5FD); }
.mg-doc circle { transition: r var(--dur, 240ms) var(--ease-out, ease-out); cursor: help; }
.mg-doc:hover circle { r: 9; }

.mg-caption {
  display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem;
  margin-top: var(--sp-2, 0.5rem); padding-top: var(--sp-2, 0.5rem);
  border-top: 1px solid var(--hairline, rgba(150,170,255,0.16));
}
.mg-key {
  display: inline-flex; align-items: center; gap: 0.3em;
  font-size: 0.6rem; color: var(--ink-4, #7B87A8); letter-spacing: 0.02em;
}
.mg-swatch { width: 0.55em; height: 0.55em; border-radius: 50%; display: inline-block; }
.mg-swatch-hub { background: #FF2E6B; }
.mg-swatch-doc { background: #5B86FF; }
.mg-swatch-reg { background: #47D6A6; }

/* ---- Adaptive ---------------------------------------------------------- */
@media (max-width: 1000px) {
  .graph-value-split { grid-template-columns: 1fr; }
  .gv-viz { max-width: 340px; margin-inline: auto; width: 100%; }
}
@media (max-width: 640px) {
  .hero-status { gap: 0.4rem 0.6rem; }
  .gs-pair { font-size: 0.62rem; }
  /* Three stat pairs will not fit a phone alongside the retrieval badge, and
     the third is the least load-bearing of them. */
  .hero-status[data-state="live"] .gs-pair:nth-of-type(3) { display: none; }
}
@media (min-width: 1600px) {
  .graph-value-split { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-edge, .mg-doc { animation: none; }
  .mg-node-hub-halo { animation: none; }
}

/* ==========================================================================
   PHASE 2.5 — the graph on small screens, and the health rings
   ========================================================================== */

/* ---- MOBILE HERO: the graph gets its own stage --------------------------
   On desktop the hero is text over a full-bleed graph, which works because
   there is room either side. On a phone the overlay went full-width and sat
   directly on top, leaving the graph as faint wallpaper behind body copy —
   unreadable, and it happens to be the single most persuasive thing on the
   page. So on small screens we stop overlaying and start stacking: the copy
   takes the top, the graph gets a framed stage of its own beneath it.

   This matters more than it looks. Reviewers open the link on a phone during a
   Teams call; whatever the phone shows IS the demo. */
@media (max-width: 900px) {
  .hero {
    display: flex !important;
    flex-direction: column;
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 1.25rem;
  }

  /* Copy first, in normal flow — no longer absolutely positioned over the map */
  .hero-overlay {
    position: static !important;
    transform: none !important;
    width: auto !important;
    left: auto !important;
    right: auto !important;
    order: 1;
    padding: 1.5rem 1rem 1rem;
    gap: 1rem;
  }

  /* The map becomes a deliberate, framed exhibit */
  .hero-galaxy {
    position: relative !important;
    inset: auto !important;
    order: 2;
    height: clamp(300px, 46vh, 440px);
    margin: 0 0.75rem;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(150, 170, 255, 0.24);
    background:
      radial-gradient(ellipse at 50% 40%, rgba(91,134,255,0.16), transparent 65%),
      rgba(8, 14, 44, 0.55);
    box-shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.9),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
  .hero-galaxy::after {
    content: "Pinch to zoom · tap a node";
    position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
    font-size: 0.6rem; letter-spacing: 0.09em; text-transform: uppercase;
    color: rgba(210, 220, 250, 0.5);
    background: rgba(8, 14, 44, 0.72);
    padding: 0.25em 0.7em; border-radius: 999px;
    pointer-events: none; z-index: 4;
    backdrop-filter: blur(6px);
  }
  .hero-galaxy .vis-network { touch-action: pan-x pan-y pinch-zoom; }

  /* Suppress the desktop wash that dimmed the canvas behind the overlay */
  .hero-veil, .hero-scrim { opacity: 0.25 !important; }

  .hero-status {
    order: 3;
    position: static !important;
    margin: 0.85rem 0.75rem 0;
    align-self: stretch;
  }
}

@media (max-width: 560px) {
  .hero-galaxy { height: clamp(260px, 40vh, 340px); margin-inline: 0.6rem; }
  .hero-title  { font-size: clamp(30px, 9vw, 44px) !important; }
}

/* Tall tablets get more of it — there is room, and it is the showpiece */
@media (min-width: 561px) and (max-width: 900px) and (min-height: 800px) {
  .hero-galaxy { height: 50vh; }
}

/* ---- MATURITY RINGS ---------------------------------------------------- */
.health-rings-host { width: 100%; }
.maturity-rings {
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
}
.mr-chart { position: relative; width: 100%; max-width: 280px; }
.mr-chart svg { width: 100%; height: auto; display: block; overflow: visible; }

.mr-track { fill: none; stroke: rgba(150, 170, 255, 0.10); stroke-linecap: round; }

.mr-arc {
  fill: none; stroke-linecap: round;
  stroke-dashoffset: var(--mr-len);          /* start empty */
  transition: stroke-dashoffset 1.15s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--mr-delay, 0ms);
  filter: drop-shadow(0 0 5px rgba(120, 150, 255, 0.28));
}
.is-drawn .mr-arc { stroke-dashoffset: var(--mr-off); }

.mr-cap {
  opacity: 0; transform-box: fill-box; transform-origin: center;
  transition: opacity 420ms ease var(--mr-delay, 0ms);
}
.is-drawn .mr-cap { opacity: 1; }

.mr-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; gap: 0.05rem;
}
.mr-score {
  font-size: clamp(2.4rem, 1.6rem + 3.2vw, 3.4rem);
  font-weight: 300; line-height: 1; color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.mr-suffix { font-size: 0.72rem; color: var(--ink-4, #7B87A8); letter-spacing: 0.06em; }
.mr-band {
  margin-top: 0.35rem; font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0.22em 0.7em; border-radius: 999px;
}
.mr-band-strong   { color: #47D6A6; background: rgba(71, 214, 166, 0.14); }
.mr-band-adequate { color: #7FD8FF; background: rgba(127, 216, 255, 0.14); }
.mr-band-weak     { color: #F6B44C; background: rgba(246, 180, 76, 0.14); }
.mr-band-critical { color: #FF6E9C; background: rgba(255, 110, 156, 0.16); }

.mr-legend { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 300px; }
.mr-legend-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.34rem 0; border-bottom: 1px solid rgba(150, 170, 255, 0.10);
  opacity: 0; transform: translateX(-6px);
  transition: opacity 380ms ease var(--mr-delay, 0ms),
              transform 380ms cubic-bezier(0.22, 1, 0.36, 1) var(--mr-delay, 0ms);
}
.is-drawn .mr-legend-item { opacity: 1; transform: none; }
.mr-legend-item:last-child { border-bottom: none; }
.mr-swatch { width: 0.6rem; height: 0.6rem; border-radius: 3px; flex-shrink: 0; }
.mr-legend-label {
  flex: 1; font-size: var(--fs-small, 0.82rem); color: var(--ink-2, #D3DAF0);
}
.mr-legend-val {
  font-size: var(--fs-small, 0.82rem); font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 900px) {
  .maturity-rings { gap: 1.4rem; }
  .mr-chart { max-width: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .mr-arc, .mr-cap, .mr-legend-item { transition: none; }
  .mr-arc { stroke-dashoffset: var(--mr-off); }
  .mr-cap, .mr-legend-item { opacity: 1; transform: none; }
}

/* ==========================================================================
   PHASE 2.6 — Typeahead
   The first control a reviewer touches, so it has to feel like every other
   search box they have used: instant, keyboard-driven, obvious.
   ========================================================================== */
.ta-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  z-index: 60;
  margin: 0; padding: 0.35rem;
  list-style: none;
  background: rgba(13, 20, 52, 0.97);
  border: 1px solid rgba(150, 170, 255, 0.28);
  border-radius: 14px;
  box-shadow: 0 28px 70px -24px rgba(0, 0, 0, 0.92),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
  max-height: min(52vh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: ta-in 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes ta-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.ta-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.62rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-2, #D3DAF0);
  font-size: 0.86rem;
  line-height: 1.4;
  transition: background 120ms ease, color 120ms ease;
}
.ta-item:hover,
.ta-item.is-active {
  background: rgba(91, 134, 255, 0.16);
  color: #fff;
}
.ta-item.is-active { box-shadow: inset 2px 0 0 var(--signal, #FF2E6B); }

/* A question mark, drawn in CSS — one less asset to load */
.ta-icon {
  flex-shrink: 0;
  width: 1.15rem; height: 1.15rem;
  border-radius: 50%;
  background: rgba(150, 170, 255, 0.14);
  position: relative;
}
.ta-icon::after {
  content: "?";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 0.66rem; font-weight: 700;
  color: rgba(190, 205, 255, 0.85);
}
.ta-item.is-active .ta-icon { background: rgba(255, 46, 107, 0.24); }
.ta-item.is-active .ta-icon::after { color: #fff; }

.ta-text { flex: 1; min-width: 0; }
.ta-text mark {
  background: transparent;
  color: var(--positive, #47D6A6);
  font-weight: 650;
}
.ta-item.is-active .ta-text mark { color: #7FFFD4; }

.ta-tier {
  flex-shrink: 0;
  font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-4, #7B87A8);
  border: 1px solid rgba(150, 170, 255, 0.22);
  border-radius: 999px;
  padding: 0.15em 0.5em;
}

.ta-foot {
  padding: 0.5rem 0.7rem 0.3rem;
  margin-top: 0.2rem;
  border-top: 1px solid rgba(150, 170, 255, 0.14);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  color: var(--ink-4, #7B87A8);
  text-align: center;
  pointer-events: none;
}

/* Brief flash when a sample chip fills the box, so the eye follows the value
   from the chip to the input rather than wondering where it went. */
.is-autofilled {
  animation: ta-fill 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes ta-fill {
  0%   { box-shadow: 0 0 0 0 rgba(71, 214, 166, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(71, 214, 166, 0); }
}

/* The sticky bar sits at the bottom of the viewport, so its list opens upward. */
.sticky-ask .ta-list {
  top: auto;
  bottom: calc(100% + 8px);
  animation-name: ta-in-up;
}
@keyframes ta-in-up {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
  /* Larger tap targets, and a shorter list so the on-screen keyboard does not
     bury the suggestions it is meant to be filtering. */
  .ta-item { padding: 0.8rem 0.7rem; font-size: 0.9rem; }
  .ta-list { max-height: 42vh; border-radius: 12px; }
  .ta-tier { display: none; }
  .ta-foot { font-size: 0.58rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ta-list { animation: none; }
  .is-autofilled { animation: none; }
}
