/* ============================================
   CHRONICLE — Research Spike Report
   Design System & Styles
   ============================================ */

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- Design Tokens --- */
:root {
  /* Backgrounds */
  --bg-primary: #0a0a0c;
  --bg-secondary: #111114;
  --bg-tertiary: #1a1a1f;
  --bg-elevated: #222228;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  /* Text */
  --text-primary: #e8e8ed;
  --text-secondary: #a0a0ab;
  --text-muted: #6b6b76;
  --text-inverse: #0a0a0c;

  /* Accent */
  --accent: #5b8def;
  --accent-hover: #7ba4ff;
  --accent-muted: rgba(91, 141, 239, 0.15);
  --accent-border: rgba(91, 141, 239, 0.3);

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --border-active: rgba(91, 141, 239, 0.5);

  /* Source Tier Colors */
  --tier-1: #4ade80;
  --tier-1-bg: rgba(74, 222, 128, 0.1);
  --tier-2: #60a5fa;
  --tier-2-bg: rgba(96, 165, 250, 0.1);
  --tier-3: #fbbf24;
  --tier-3-bg: rgba(251, 191, 36, 0.1);
  --tier-4: #a78bfa;
  --tier-4-bg: rgba(167, 139, 250, 0.1);

  /* Semantic */
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(91, 141, 239, 0.15);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-serif: 'Georgia', 'Newsreader', serif;

  --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;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 1.75;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-mono: 0.02em;

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

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 260px;
  --content-max-width: 820px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Light Mode --- */
[data-theme="light"] {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f4f5;
  --bg-elevated: #ffffff;
  --bg-overlay: rgba(255, 255, 255, 0.8);

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --text-inverse: #fafafa;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-muted: rgba(37, 99, 235, 0.08);
  --accent-border: rgba(37, 99, 235, 0.2);

  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --border-active: rgba(37, 99, 235, 0.5);

  --tier-1: #16a34a;
  --tier-1-bg: rgba(22, 163, 74, 0.08);
  --tier-2: #2563eb;
  --tier-2-bg: rgba(37, 99, 235, 0.08);
  --tier-3: #d97706;
  --tier-3-bg: rgba(217, 119, 6, 0.08);
  --tier-4: #7c3aed;
  --tier-4-bg: rgba(124, 58, 237, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.08);
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  background: var(--bg-primary);
  overflow-x: hidden;
}

::selection {
  background: var(--accent-muted);
  color: var(--text-primary);
}

/* --- Sidebar Navigation --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-base);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  margin-bottom: var(--space-2);
}

.sidebar-logo {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

.sidebar-version {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-6);
}

.nav-section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.nav-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-item.active .nav-item-icon {
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-secondary);
  transition: all var(--transition-base);
  width: 100%;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-spring);
}

.theme-toggle:hover .theme-toggle-icon {
  transform: rotate(15deg);
}

/* --- Mobile Nav Toggle --- */
.nav-toggle {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 90;
}

.nav-overlay.active {
  display: block;
}

/* --- Main Content --- */
.main-content {
  margin-left: 0;
  padding: var(--space-8) var(--space-8);
  max-width: calc(var(--content-max-width) + var(--space-8) * 2);
}

/* --- Section --- */
.section {
  margin-bottom: var(--space-24);
  scroll-margin-top: var(--space-8);
}

.section-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-3);
}

/* --- Typography --- */
h1 {
  font-family: var(--font-sans);
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

h2 {
  font-family: var(--font-sans);
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

h3 {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

h4 {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: var(--font-medium);
  line-height: var(--leading-snug);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

h5 {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: var(--leading-normal);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-2);
}

p {
  margin-bottom: var(--space-4);
  line-height: var(--leading-relaxed);
}

.lead {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--text-primary);
  margin-bottom: var(--space-6);
}

strong {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

/* --- Lists --- */
ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-relaxed);
}

li::marker {
  color: var(--text-muted);
}

/* --- Code --- */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  overflow-x: auto;
  margin-bottom: var(--space-6);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead {
  background: var(--bg-tertiary);
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  border-bottom: 1px solid var(--border);
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

/* --- Cards --- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* --- Event Cards --- */
.event-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.event-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.event-card-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-mono);
  margin-bottom: var(--space-2);
}

.event-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-2);
}

.event-card-location {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.event-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.event-card-source-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Tier indicators */
.tier-indicators {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.tier-dot--1 { background: var(--tier-1); }
.tier-dot--2 { background: var(--tier-2); }
.tier-dot--3 { background: var(--tier-3); }
.tier-dot--4 { background: var(--tier-4); }

/* --- Source Cards --- */
.source-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color var(--transition-fast);
}

.source-card:hover {
  border-color: var(--border-hover);
}

.source-card[data-tier="1"] { border-left: 3px solid var(--tier-1); }
.source-card[data-tier="2"] { border-left: 3px solid var(--tier-2); }
.source-card[data-tier="3"] { border-left: 3px solid var(--tier-3); }
.source-card[data-tier="4"] { border-left: 3px solid var(--tier-4); }

.source-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.source-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.tier-badge {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  white-space: nowrap;
}

.tier-badge--1 { color: var(--tier-1); background: var(--tier-1-bg); }
.tier-badge--2 { color: var(--tier-2); background: var(--tier-2-bg); }
.tier-badge--3 { color: var(--tier-3); background: var(--tier-3-bg); }
.tier-badge--4 { color: var(--tier-4); background: var(--tier-4-bg); }

.source-excerpt {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  font-style: italic;
}

.source-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}

.verification-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.verification-badge--verified { color: var(--success); background: rgba(74, 222, 128, 0.1); }
.verification-badge--disputed { color: var(--warning); background: rgba(251, 191, 36, 0.1); }
.verification-badge--unverified { color: var(--text-muted); background: var(--bg-tertiary); }

/* --- Timeline --- */
.timeline {
  position: relative;
  padding: var(--space-8) 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-node {
  position: relative;
  padding-left: 52px;
  margin-bottom: var(--space-8);
  animation: cardEntrance var(--transition-slow) ease both;
}

.timeline-node:nth-child(1) { animation-delay: 0ms; }
.timeline-node:nth-child(2) { animation-delay: 50ms; }
.timeline-node:nth-child(3) { animation-delay: 100ms; }
.timeline-node:nth-child(4) { animation-delay: 150ms; }
.timeline-node:nth-child(5) { animation-delay: 200ms; }
.timeline-node:nth-child(6) { animation-delay: 250ms; }
.timeline-node:nth-child(7) { animation-delay: 300ms; }
.timeline-node:nth-child(8) { animation-delay: 350ms; }
.timeline-node:nth-child(9) { animation-delay: 400ms; }
.timeline-node:nth-child(10) { animation-delay: 450ms; }

.timeline-marker {
  position: absolute;
  left: 15px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 2px solid var(--bg-primary);
  z-index: 2;
  transition: all var(--transition-base);
}

.timeline-node:hover .timeline-marker {
  width: 16px;
  height: 16px;
  left: 13px;
  top: 4px;
  box-shadow: var(--shadow-glow);
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: var(--tracking-mono);
  margin-bottom: var(--space-2);
}

.timeline-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-base);
}

.timeline-node:hover .timeline-content {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.timeline-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.timeline-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}

.timeline-tags {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* --- Narrative Comparison --- */
.narrative-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.narrative-panel {
  padding: var(--space-5);
  background: var(--bg-secondary);
}

.narrative-panel:first-child {
  border-right: 1px solid var(--border);
}

.narrative-panel-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.narrative-panel--official .narrative-panel-label { color: var(--tier-1); }
.narrative-panel--oral .narrative-panel-label { color: var(--tier-4); }

.narrative-text {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.discrepancy {
  background: rgba(251, 191, 36, 0.08);
  border-left: 2px solid var(--warning);
  padding: var(--space-2) var(--space-3);
  margin: var(--space-3) 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.discrepancy-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--warning);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

/* --- Collapsible Sections --- */
.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.collapsible-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: none;
  width: 100%;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  text-align: left;
  transition: background var(--transition-fast);
}

.collapsible-trigger:hover {
  background: var(--bg-tertiary);
}

.collapsible-icon {
  font-size: var(--text-sm);
  color: var(--text-muted);
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

.collapsible.open .collapsible-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.collapsible.open .collapsible-content {
  max-height: 5000px;
}

.collapsible-body {
  padding: var(--space-5);
  border-top: 1px solid var(--border);
}

/* --- Tabs --- */
.tabs {
  margin-bottom: var(--space-6);
}

.tab-list {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}

.tab-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: cardEntrance var(--transition-slow) ease both;
}

/* --- Bar Charts --- */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bar-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s ease;
}

.bar-fill--tier-1 { background: var(--tier-1); }
.bar-fill--tier-2 { background: var(--tier-2); }
.bar-fill--tier-3 { background: var(--tier-3); }
.bar-fill--tier-4 { background: var(--tier-4); }
.bar-fill--accent { background: var(--accent); }

.bar-value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  width: 48px;
  flex-shrink: 0;
}

/* --- Hero --- */
.hero {
  padding: var(--space-16) 0 var(--space-12);
}

.hero h1 {
  font-size: var(--text-5xl);
  margin-bottom: var(--space-6);
}

.hero-subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  margin-bottom: var(--space-4);
}

.hero-meta {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* --- Callout --- */
.callout {
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}

.callout-title {
  font-weight: var(--font-semibold);
  color: var(--accent);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.callout p {
  margin-bottom: 0;
  font-size: var(--text-sm);
}

/* --- Pipeline Diagram --- */
.pipeline-diagram {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}

.pipeline-stages {
  display: flex;
  gap: var(--space-4);
  align-items: stretch;
  min-width: 600px;
}

.pipeline-stage {
  flex: 1;
  text-align: center;
  padding: var(--space-4);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  position: relative;
}

.pipeline-stage-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.pipeline-stage-name {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.pipeline-stage-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.pipeline-arrow {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: var(--text-lg);
  flex-shrink: 0;
}

/* --- Blockquote / Oral History --- */
.oral-history {
  border: 1px dashed var(--tier-4);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  background: var(--tier-4-bg);
  position: relative;
}

.oral-history::before {
  content: '\201C';
  font-size: 3rem;
  color: var(--tier-4);
  opacity: 0.3;
  position: absolute;
  top: var(--space-2);
  left: var(--space-4);
  font-family: var(--font-serif);
  line-height: 1;
}

.oral-history-text {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  padding-left: var(--space-6);
}

.oral-history-attribution {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-left: var(--space-6);
}

/* --- Confidence Badge --- */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: var(--font-semibold);
}

.confidence-badge--confirmed { color: var(--success); background: rgba(74, 222, 128, 0.1); }
.confidence-badge--probable { color: var(--info); background: rgba(96, 165, 250, 0.1); }
.confidence-badge--reported { color: var(--warning); background: rgba(251, 191, 36, 0.1); }
.confidence-badge--contested { color: var(--error); background: rgba(248, 113, 113, 0.1); }

/* --- Stats Row --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- Animations --- */
@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* --- Parallel Timeline --- */
.parallel-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.parallel-timeline-column {
  background: var(--bg-primary);
  min-width: 0;
}

.parallel-timeline-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.parallel-timeline-header[data-tier="1-2"] { color: var(--tier-1); }
.parallel-timeline-header[data-tier="wire"] { color: var(--tier-2); }
.parallel-timeline-header[data-tier="3-4"] { color: var(--tier-4); }

.parallel-timeline-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Coverage gap indicator */
.coverage-gap {
  padding: var(--space-4);
  background: var(--bg-tertiary);
  border: 1px dashed var(--warning);
  border-radius: var(--radius-md);
  text-align: center;
}

.coverage-gap-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.coverage-gap-detail {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* --- Branching Timeline --- */
.branch-timeline {
  position: relative;
  padding: var(--space-8) 0;
}

.branch-node {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: var(--space-6);
}

.branch-fork {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.branch-fork-marker {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 3px solid var(--bg-primary);
  box-shadow: var(--shadow-glow);
  z-index: 2;
}

.branch-fork-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  max-width: 200px;
}

.branch-lines {
  display: flex;
  gap: var(--space-8);
  margin-top: var(--space-4);
  position: relative;
}

.branch-line {
  flex: 1;
  min-width: 200px;
  position: relative;
  padding-left: var(--space-6);
}

.branch-line::before {
  content: '';
  position: absolute;
  left: var(--space-3);
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.branch-line-header {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-4);
  padding-left: var(--space-4);
}

.branch-event {
  position: relative;
  margin-bottom: var(--space-4);
  padding-left: var(--space-4);
}

.branch-event::before {
  content: '';
  position: absolute;
  left: calc(var(--space-3) - 4px - var(--space-6));
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  border: 2px solid var(--bg-primary);
}

/* --- Density Chart --- */
.density-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.density-bar {
  flex: 1;
  min-width: 4px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.density-bar:hover {
  background: var(--accent);
  opacity: 0.8;
}

.density-bar.in-view {
  background: var(--accent);
}

.density-bar::after {
  content: attr(data-count);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-fast);
  padding-bottom: var(--space-1);
}

.density-bar:hover::after {
  opacity: 1;
}

.density-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 var(--space-4);
}

/* --- Mobile Bottom Nav --- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: var(--space-2) var(--space-4);
  padding-bottom: env(safe-area-inset-bottom, var(--space-2));
  z-index: 100;
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.bottom-nav-btn:hover,
.bottom-nav-btn.active {
  color: var(--accent);
}

.bottom-nav-icon {
  width: 20px;
  height: 20px;
}

/* Timeline scrubber */
.timeline-scrubber {
  width: 100%;
  padding: var(--space-2) 0;
}

.scrubber-track {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  position: relative;
}

.scrubber-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 2px solid var(--bg-primary);
  cursor: grab;
}

.scrubber-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-2);
}

.bottom-nav--timeline {
  flex-direction: column;
  gap: var(--space-2);
}

.bottom-nav--timeline .timeline-scrubber {
  width: 100%;
  order: -1;
}

.bottom-nav--timeline .bottom-nav-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* --- Responsive: Tablet (768-1023px) collapsed icon-only sidebar --- */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar {
    width: var(--sidebar-collapsed-width, 56px);
    padding: var(--space-2);
    overflow: hidden;
  }
  .sidebar .nav-section-label,
  .sidebar .sidebar-logo-text,
  .sidebar .nav-item-label,
  .sidebar .sidebar-version,
  .sidebar .theme-toggle-label {
    display: none;
  }
  .sidebar .nav-item {
    justify-content: center;
    padding: var(--space-2);
  }
  .sidebar .nav-item .nav-item-icon {
    width: 20px;
    height: 20px;
  }
  /* Expand on hover for discoverability */
  .sidebar:hover {
    width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
    z-index: 150;
  }
  .sidebar:hover .nav-section-label,
  .sidebar:hover .sidebar-logo-text,
  .sidebar:hover .nav-item-label,
  .sidebar:hover .sidebar-version,
  .sidebar:hover .theme-toggle-label {
    display: inline;
  }
  .sidebar:hover .nav-item {
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
  }
  .main-content {
    margin-left: var(--sidebar-collapsed-width, 56px);
    padding: var(--space-8) var(--space-6);
  }
}

/* --- Responsive: Mobile (< 768px) --- */
@media (max-width: 767px) {
  :root {
    --text-5xl: 2.25rem;
    --text-4xl: 1.875rem;
    --text-3xl: 1.5rem;
  }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .nav-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-16) var(--space-4) var(--space-8);
    padding-bottom: 80px;
  }

  .bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .narrative-comparison {
    grid-template-columns: 1fr;
  }

  .narrative-panel:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .pipeline-stages {
    flex-direction: column;
    min-width: unset;
  }

  .pipeline-arrow {
    justify-content: center;
    transform: rotate(90deg);
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero {
    padding: var(--space-8) 0 var(--space-8);
  }

  .tab-list {
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .parallel-timeline {
    grid-template-columns: 1fr;
  }

  .branch-lines {
    flex-direction: column;
    gap: var(--space-6);
  }

  .branch-line {
    min-width: 0;
  }
}

/* --- Responsive: Desktop (1024px+) --- */
@media (min-width: 1024px) {
  .main-content {
    margin-left: var(--sidebar-width);
  }
}

/* --- Print --- */
@media print {
  .sidebar, .nav-toggle, .theme-toggle, .nav-overlay, .bottom-nav {
    display: none !important;
  }
  .main-content {
    margin-left: 0;
    padding: 0;
    max-width: 100%;
  }
  body {
    color: #000;
    background: #fff;
  }
  .collapsible-content {
    max-height: none !important;
  }
  .event-card, .source-card, .card, .timeline-content {
    break-inside: avoid;
  }
}
