/* ================================================================
   INTELLIGENTSIA — INFLUENCE CHAIN DASHBOARD
   styles.css
================================================================ */

/* ── 1. DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* Color primitives */
  --clr-indigo-100: #e0e7ff;
  --clr-indigo-400: #818cf8;
  --clr-indigo-500: #6366f1;
  --clr-indigo-600: #4f46e5;
  --clr-violet-400: #a78bfa;
  --clr-violet-500: #8b5cf6;
  --clr-purple-500: #a855f7;
  --clr-sky-400:    #38bdf8;
  --clr-sky-500:    #0ea5e9;
  --clr-emerald-400:#34d399;
  --clr-emerald-500:#10b981;
  --clr-amber-400:  #fbbf24;
  --clr-amber-500:  #f59e0b;
  --clr-pink-400:   #f472b6;
  --clr-pink-500:   #ec4899;
  --clr-red-500:    #ef4444;
  --clr-slate-50:   #f8fafc;
  --clr-slate-100:  #f1f5f9;
  --clr-slate-200:  #e2e8f0;
  --clr-slate-300:  #cbd5e1;
  --clr-slate-400:  #94a3b8;
  --clr-slate-500:  #64748b;
  --clr-slate-600:  #475569;
  --clr-slate-700:  #334155;
  --clr-slate-800:  #1e293b;
  --clr-slate-900:  #0f172a;

  /* Semantic tokens — LIGHT mode */
  --bg-app:          var(--clr-slate-50);
  --bg-card:         #ffffff;
  --bg-card-hover:   #fafbff;
  --bg-panel:        #ffffff;
  --bg-sidebar:      var(--clr-slate-100);
  --bg-modal:        #ffffff;
  --bg-tag:          var(--clr-indigo-100);
  --bg-overlay:      rgba(15,23,42,0.45);
  --text-primary:    var(--clr-slate-900);
  --text-secondary:  var(--clr-slate-500);
  --text-muted:      var(--clr-slate-400);
  --text-on-accent:  #ffffff;
  --text-tag:        var(--clr-indigo-600);
  --border:          var(--clr-slate-200);
  --border-strong:   var(--clr-slate-300);
  --shadow-card:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-card-hover: 0 8px 24px rgba(99,102,241,.12), 0 2px 8px rgba(0,0,0,.08);
  --shadow-panel:    -4px 0 32px rgba(0,0,0,.1);
  --shadow-modal:    0 20px 60px rgba(0,0,0,.18);
  --accent:          var(--clr-indigo-500);
  --accent-hover:    var(--clr-indigo-600);

  /* Spacing */
  --sp-1:  0.25rem;   /* 4px  */
  --sp-2:  0.5rem;    /* 8px  */
  --sp-3:  0.75rem;   /* 12px */
  --sp-4:  1rem;      /* 16px */
  --sp-5:  1.25rem;   /* 20px */
  --sp-6:  1.5rem;    /* 24px */
  --sp-8:  2rem;      /* 32px */
  --sp-10: 2.5rem;    /* 40px */
  --sp-12: 3rem;      /* 48px */

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Motion */
  --dur-fast:   120ms;
  --dur-base:   220ms;
  --dur-slow:   380ms;
  --dur-xslow:  600ms;
  --ease-out:   cubic-bezier(0.16, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --topbar-h:    56px;
  --timeline-h:  58px;
  --sidebar-w:   256px;
  --panel-w:     480px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;
}

/* Dark mode token overrides */
[data-theme="dark"] {
  --bg-app:         var(--clr-slate-900);
  --bg-card:        var(--clr-slate-800);
  --bg-card-hover:  #243249;
  --bg-panel:       var(--clr-slate-800);
  --bg-sidebar:     #0c1526;
  --bg-modal:       var(--clr-slate-800);
  --bg-tag:         rgba(99,102,241,.18);
  --bg-overlay:     rgba(0,0,0,.6);
  --text-primary:   var(--clr-slate-50);
  --text-secondary: var(--clr-slate-400);
  --text-muted:     var(--clr-slate-500);
  --text-tag:       var(--clr-indigo-400);
  --border:         var(--clr-slate-700);
  --border-strong:  var(--clr-slate-600);
  --shadow-card:    0 1px 3px rgba(0,0,0,.3);
  --shadow-card-hover: 0 8px 24px rgba(99,102,241,.2);
  --shadow-panel:   -4px 0 32px rgba(0,0,0,.4);
  --shadow-modal:   0 20px 60px rgba(0,0,0,.5);
}

/* ── 2. RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background var(--dur-base), color var(--dur-base);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
dialog { border: none; padding: 0; border-radius: var(--radius-lg); background: var(--bg-modal); color: var(--text-primary); }
dialog::backdrop { background: var(--bg-overlay); }

/* ── 3. BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm); font-weight: var(--fw-medium);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent; color: var(--text-primary);
  transition: all var(--dur-fast);
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--icon {
  padding: var(--sp-2); width: 36px; height: 36px;
  justify-content: center; border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.btn--icon:hover { background: var(--border); color: var(--text-primary); }
.btn--outline {
  border-color: var(--border-strong); color: var(--text-secondary);
}
.btn--outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn--outline:disabled { opacity: .4; cursor: not-allowed; }
.btn--ghost { color: var(--text-secondary); }
.btn--ghost:hover { background: var(--border); color: var(--text-primary); }
.btn--sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-xs); }
.btn--primary {
  background: var(--accent); color: white; border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ── 4. TOP NAVIGATION ────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 400;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.topbar__left { display: flex; align-items: center; gap: var(--sp-4); }
.topbar__right { display: flex; align-items: center; gap: var(--sp-2); }
.topbar__logo {
  font-size: var(--text-lg); font-weight: var(--fw-bold);
  letter-spacing: -0.02em; color: var(--text-primary);
  background: linear-gradient(135deg, var(--clr-indigo-500), var(--clr-violet-500));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar__link {
  font-size: var(--text-sm); color: var(--text-secondary);
  transition: color var(--dur-fast);
}
.topbar__link:hover { color: var(--accent); text-decoration: none; }
.sidebar-toggle { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ── 5. APP SHELL ─────────────────────────────────────────────── */
#appShell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h) - var(--timeline-h));
  transition: grid-template-columns var(--dur-slow) var(--ease-out);
}
#appShell.panel-active #cardGrid { padding-right: calc(var(--panel-w) + var(--sp-6)); }

/* ── 6. FILTER SIDEBAR ────────────────────────────────────────── */
#filterPanel {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h) - var(--timeline-h));
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  transition: transform var(--dur-slow) var(--ease-out), width var(--dur-slow) var(--ease-out);
}
.filter-panel-inner { padding: var(--sp-6) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-5); }
.filter-panel-header { display: flex; align-items: center; justify-content: space-between; }
.filter-panel-title { font-size: var(--text-sm); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
#sidebarClose { display: none; }
.filter-section { display: flex; flex-direction: column; gap: var(--sp-2); }
.filter-heading {
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted);
}
.filter-checkboxes { display: flex; flex-direction: column; gap: var(--sp-2); }
.filter-checkbox-label {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--text-sm); color: var(--text-secondary);
  cursor: pointer; transition: color var(--dur-fast);
}
.filter-checkbox-label:hover { color: var(--text-primary); }
.filter-checkbox-label input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.filter-select {
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: var(--text-sm); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: var(--sp-8);
}
.filter-select:focus { outline: 2px solid var(--accent); }
.filter-count { display: flex; align-items: center; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 22px; padding: 0 var(--sp-2);
  background: var(--accent); color: white;
  font-size: var(--text-xs); font-weight: var(--fw-bold);
  border-radius: var(--radius-full);
  transition: background var(--dur-fast);
}
.count-label { font-size: var(--text-xs); color: var(--text-muted); }

/* ── 7. CARD GRID ─────────────────────────────────────────────── */
#cardGrid { padding: var(--sp-8) var(--sp-6); overflow-y: auto; transition: padding-right var(--dur-slow) var(--ease-out); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-5);
}
.no-results {
  grid-column: 1/-1; text-align: center; padding: var(--sp-12) 0;
  color: var(--text-muted); font-size: var(--text-base);
}

/* Thinker Card */
.thinker-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  cursor: pointer;
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base),
              border-color var(--dur-base),
              opacity var(--dur-base);
  box-shadow: var(--shadow-card);
  overflow: visible;
}
.thinker-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--clr-indigo-400);
}
.thinker-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thinker-card.card--dimmed { opacity: 0.35; pointer-events: none; }
.thinker-card.card--active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Card avatar + identity */
.card-avatar-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border);
  background: var(--bg-sidebar); flex-shrink: 0;
  transition: border-color var(--dur-fast);
  font-size: var(--text-xl); display: flex; align-items: center; justify-content: center;
  color: var(--text-on-accent); font-weight: var(--fw-bold);
}
.card-avatar-img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); flex-shrink: 0; }
.thinker-card:hover .card-avatar-img,
.thinker-card:hover .card-avatar { border-color: var(--accent); }
.card-identity { flex: 1; min-width: 0; }
.card-name { font-size: var(--text-base); font-weight: var(--fw-semibold); color: var(--text-primary); line-height: 1.25; }
.card-affiliation { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-one-liner { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.4; margin-bottom: var(--sp-3); }

/* Field tags */
.card-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.tag {
  display: inline-block; padding: 2px var(--sp-2);
  background: var(--bg-tag); color: var(--text-tag);
  font-size: 11px; font-weight: var(--fw-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.tag--field { }
.tag--window { background: rgba(16,185,129,.12); color: var(--clr-emerald-500); }

/* Chain strength bar */
.card-strength { display: flex; align-items: center; gap: var(--sp-2); }
.strength-bar-bg { flex: 1; height: 4px; background: var(--border); border-radius: var(--radius-full); overflow: hidden; }
.strength-bar-fill { height: 100%; background: linear-gradient(90deg, var(--clr-indigo-500), var(--clr-violet-500)); border-radius: var(--radius-full); transition: width .6s var(--ease-out); }
.strength-label { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }

/* Mini chain preview (hover) */
.card-mini-chain {
  position: absolute; bottom: calc(100% + var(--sp-2)); left: 50%;
  transform: translateX(-50%) scaleY(0); transform-origin: bottom center;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base);
  opacity: 0;
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4);
  pointer-events: none; z-index: 100;
  box-shadow: var(--shadow-modal); min-width: 260px; max-width: 320px;
  white-space: nowrap;
}
.thinker-card:hover .card-mini-chain { transform: translateX(-50%) scaleY(1); opacity: 1; }
.mini-chain-title { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: var(--sp-2); }
.mini-chain-steps { display: flex; align-items: center; gap: var(--sp-1); }
.mini-step { font-size: 11px; color: var(--text-secondary); max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.mini-arrow { color: var(--clr-indigo-400); font-size: var(--text-xs); flex-shrink: 0; }

/* ── 8. DEEP DIVE PANEL ───────────────────────────────────────── */
#deepDivePanel {
  position: fixed; top: var(--topbar-h); right: 0;
  width: var(--panel-w);
  height: calc(100vh - var(--topbar-h) - var(--timeline-h));
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  z-index: 300;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  overflow: hidden;
}
#deepDivePanel.panel--open { transform: translateX(0); }
.panel-header {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title-bar { flex: 1; min-width: 0; }
.panel-thinker-name { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-thinker-affil { font-size: var(--text-xs); color: var(--text-muted); }
#panelContent { flex: 1; overflow-y: auto; padding: var(--sp-6) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-8); }

/* Panel dimension sections */
.dimension { }
.dimension-label {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.dimension-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  background: var(--accent); color: white; font-size: 10px;
  font-weight: var(--fw-bold); border-radius: var(--radius-full);
}
.dimension-divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* Dim 1: Identity */
.identity-hero { display: flex; align-items: flex-start; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.identity-photo-wrap { position: relative; cursor: pointer; }
.identity-photo {
  width: 72px; height: 72px; border-radius: var(--radius-md);
  object-fit: cover; border: 2px solid var(--border);
  background: var(--bg-sidebar);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-2xl); font-weight: var(--fw-bold); color: var(--text-on-accent);
  flex-shrink: 0; transition: border-color var(--dur-fast);
}
.identity-photo-wrap:hover .identity-photo,
.identity-photo-wrap:hover .identity-photo-img { border-color: var(--accent); }
.identity-photo-hint { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 3px; }
.identity-photo-img { width: 72px; height: 72px; border-radius: var(--radius-md); object-fit: cover; border: 2px solid var(--border); }
.identity-info { flex: 1; }
.identity-name { font-size: var(--text-xl); font-weight: var(--fw-bold); line-height: 1.2; }
.identity-affil { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 3px; }
.identity-oneliner { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--sp-2); line-height: 1.5; font-style: italic; }
.identity-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-3); }

/* Dim 2: Core Output */
.output-toggle-row { display: flex; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.toggle-btn {
  padding: 4px var(--sp-3); font-size: var(--text-xs); font-weight: var(--fw-medium);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: all var(--dur-fast);
}
.toggle-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.output-summary { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.65; margin-bottom: var(--sp-4); }
.output-paper-link {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-sidebar); border-radius: var(--radius-md);
  border: 1px solid var(--border); margin-bottom: var(--sp-4);
  text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast);
}
.output-paper-link:hover { border-color: var(--accent); text-decoration: none; }
.paper-icon { color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.paper-title { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-primary); }
.paper-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.pull-quote {
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--accent);
  background: var(--bg-sidebar);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: var(--sp-3);
}
.pull-quote p { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.6; font-style: italic; }
.pull-quote cite { font-size: var(--text-xs); color: var(--text-muted); font-style: normal; display: block; margin-top: var(--sp-1); }

/* Dim 3: Chain Visual */
.chain-visual-wrap {
  overflow-x: auto; padding: var(--sp-2) 0;
  margin: 0 calc(-1 * var(--sp-1));
}
.chain-svg { display: block; }

/* Dim 4: Evidence Trail */
.evidence-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.evidence-item {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4); transition: border-color var(--dur-fast);
}
.evidence-item:hover { border-color: var(--border-strong); }
.evidence-item-header { display: flex; align-items: flex-start; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.evidence-type-badge {
  display: inline-block; padding: 2px var(--sp-2);
  border-radius: var(--radius-full); font-size: 10px; font-weight: var(--fw-semibold);
  text-transform: uppercase; flex-shrink: 0; margin-top: 1px;
}
.evidence-type-badge.testimony { background: rgba(239,68,68,.1); color: var(--clr-red-500); }
.evidence-type-badge.award { background: rgba(245,158,11,.12); color: var(--clr-amber-500); }
.evidence-type-badge.working-paper { background: rgba(99,102,241,.12); color: var(--clr-indigo-500); }
.evidence-type-badge.report { background: rgba(16,185,129,.1); color: var(--clr-emerald-500); }
.evidence-type-badge.public-appearance { background: rgba(139,92,246,.1); color: var(--clr-violet-500); }
.evidence-title { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-primary); line-height: 1.35; flex: 1; }
.evidence-date { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); }
.evidence-summary { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.5; margin-top: 2px; }
.evidence-raw {
  display: none; margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  background: var(--bg-sidebar); border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-family: var(--font-mono);
  color: var(--text-secondary); line-height: 1.5;
  border-left: 2px solid var(--accent);
}
.evidence-raw.visible { display: block; }
.evidence-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }

/* Dim 5: Scorecard */
.scorecard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.scorecard-metric {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--bg-sidebar); border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast);
}
.scorecard-metric:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.scorecard-metric.metric--active { border-color: var(--accent); background: rgba(99,102,241,.06); }
.metric-value { font-size: var(--text-2xl); font-weight: var(--fw-bold); color: var(--text-primary); line-height: 1; }
.metric-unit { font-size: var(--text-xs); color: var(--text-muted); }
.metric-label { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.35; }
.metric-sparkline { height: 28px; width: 100%; }

/* Dim 6: Network Graph */
.network-container {
  background: var(--bg-sidebar); border-radius: var(--radius-md);
  border: 1px solid var(--border); overflow: hidden;
  position: relative;
}
.network-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: var(--sp-2);
}
.network-toolbar-title { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.network-toggle-row { display: flex; gap: var(--sp-2); align-items: center; }
.network-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: var(--sp-1); font-size: 11px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.network-svg { display: block; cursor: grab; }
.network-svg:active { cursor: grabbing; }
.sankey-container { padding: var(--sp-4); }

/* Dim 7: Synthesis */
.synthesis-body { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.7; margin-bottom: var(--sp-4); }
.synthesis-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.synthesis-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--sp-3); }

/* ── 9. CHAIN VISUAL (SVG animations) ─────────────────────────── */
@keyframes chainPulse {
  0%   { stroke-dashoffset: 60; opacity: 0.35; }
  50%  { opacity: 1; }
  100% { stroke-dashoffset: 0;  opacity: 0.35; }
}
.chain-arrow-path {
  stroke-dasharray: 8 4;
  stroke-dashoffset: 60;
  animation: chainPulse 2s ease-in-out infinite;
}
.chain-arrow-path:hover { opacity: 1 !important; animation-play-state: paused; }
.chain-step-box {
  transition: filter var(--dur-fast);
  cursor: pointer;
}
.chain-step-box:hover { filter: brightness(1.06); }
.chain-step-box.step--dimmed { opacity: 0.28; }

/* ── 10. TIMELINE BAR ─────────────────────────────────────────── */
#timelineBar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: var(--timeline-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: var(--bg-panel); border-top: 1px solid var(--border);
}
.timeline-edge-label { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); flex-shrink: 0; }
.timeline-track { flex: 1; position: relative; display: flex; flex-direction: column; gap: var(--sp-1); }
#timelineSlider {
  width: 100%; accent-color: var(--accent); cursor: pointer;
  height: 4px; -webkit-appearance: none; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent) var(--slider-pct, 100%), var(--border) var(--slider-pct, 100%));
}
#timelineSlider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--accent); border-radius: 50%; border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: pointer; }
#timelineSlider::-moz-range-thumb { width: 16px; height: 16px; background: var(--accent); border-radius: 50%; border: 2px solid white; cursor: pointer; }
.timeline-markers { display: flex; justify-content: space-between; padding: 0 2px; }
.timeline-marker { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
.timeline-year-badge {
  padding: 3px var(--sp-2); background: var(--accent); color: white;
  font-size: var(--text-xs); font-family: var(--font-mono); font-weight: var(--fw-bold);
  border-radius: var(--radius-sm); flex-shrink: 0;
  min-width: 40px; text-align: center;
}

/* ── 11. OVERLAY ──────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 250;
  background: var(--bg-overlay);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-slow);
}
.overlay.overlay--visible { opacity: 1; pointer-events: all; }

/* ── 12. MODALS ───────────────────────────────────────────────── */
dialog { max-width: 680px; width: 90vw; max-height: 82vh; overflow: hidden; display: flex; flex-direction: column; }
dialog[open] { display: flex; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: var(--text-lg); font-weight: var(--fw-semibold); }
.modal-body { overflow-y: auto; padding: var(--sp-6); flex: 1; }

/* Bio Timeline */
.bio-timeline { display: flex; flex-direction: column; gap: 0; }
.bio-entry { display: flex; gap: var(--sp-4); padding-bottom: var(--sp-5); position: relative; }
.bio-entry:not(:last-child)::after {
  content: ''; position: absolute; left: 35px; top: 28px; bottom: 0;
  width: 2px; background: var(--border);
}
.bio-year-dot { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); flex-shrink: 0; }
.bio-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-modal); box-shadow: 0 0 0 2px var(--accent); flex-shrink: 0; margin-top: 5px; }
.bio-year { font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); min-width: 34px; text-align: right; }
.bio-event { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.5; padding-top: 2px; }
.bio-event strong { color: var(--text-primary); }

/* Evidence modal */
.evidence-modal-body .excerpt-box {
  background: var(--bg-sidebar); border-left: 3px solid var(--accent);
  padding: var(--sp-4); border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-sm); line-height: 1.7; color: var(--text-secondary);
  margin-bottom: var(--sp-4); font-style: italic;
}
.evidence-modal-body .excerpt-source { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--sp-2); font-style: normal; }
.evidence-modal-body .view-pdf-btn { display: inline-flex; align-items: center; gap: var(--sp-2); }

/* Compare modal */
.compare-modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.compare-col h3 { font-size: var(--text-sm); font-weight: var(--fw-semibold); margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
.compare-chain-step { font-size: var(--text-xs); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); margin-bottom: var(--sp-2); border: 1px solid var(--border); }
.compare-arrow { text-align: center; color: var(--text-muted); font-size: var(--text-xs); margin: var(--sp-1) 0; }

/* ── 13. MINI PAGE OVERLAY (D3 node) ──────────────────────────── */
.mini-page {
  position: fixed; z-index: 350;
  bottom: calc(var(--timeline-h) + var(--sp-4)); right: calc(var(--panel-w) + var(--sp-4));
  max-width: 280px;
}
.mini-page__inner {
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-modal);
  padding: var(--sp-4); position: relative;
}
.mini-page__inner h4 { font-size: var(--text-sm); font-weight: var(--fw-semibold); margin-bottom: var(--sp-2); }
.mini-page__inner p { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.5; }
#miniPageClose { position: absolute; top: var(--sp-2); right: var(--sp-2); }

/* ── 14. RESPONSIVE / MOBILE ─────────────────────────────────── */
@media (max-width: 900px) {
  :root { --panel-w: 100vw; }
  #deepDivePanel { width: 100vw; }
  #appShell.panel-active #cardGrid { padding-right: var(--sp-6); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #appShell { grid-template-columns: 1fr; }
  .sidebar-toggle { display: inline-flex !important; }
  .topbar__link { display: none; }
  #filterPanel {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 500;
    width: 280px; transform: translateX(-100%);
    border-right: 1px solid var(--border);
  }
  #filterPanel.sidebar--open { transform: translateX(0); }
  #sidebarClose { display: inline-flex; }
  #cardGrid { padding: var(--sp-4); }
  .scorecard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .compare-modal-body { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  #topbar { padding: 0 var(--sp-4); }
  .topbar__logo { font-size: var(--text-base); }
}

/* ── 15. SCROLLBAR STYLING ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── 16. UTILITY ──────────────────────────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.gap-2 { gap: var(--sp-2); }
