/* ═══════════════════════════════════════════════════════════════════════
   NeuronVault — Design System
   Inspired by: Linear (ultra-minimal, precise) + VoltAgent (void-black, emerald)
   DESIGN.md principles: Dark-first, agent-native, terminal aesthetic
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts ─────────────────────────────────────────────────────── */
/* ── CSS Custom Properties (Theme Definitions) ────────────────────────── */

/* Light Theme (Default, Clean Paper/Notion Aesthetic) */
:root {
  --bg-void: #f7f7f5;
  --bg-base: #ffffff;
  --bg-elevated: #ffffff;
  --bg-overlay: rgba(255, 255, 255, 0.8);
  --bg-card: #ffffff;
  --bg-muted: #f3f4f6;
  --bg-hover: #f3f4f6;

  /* Muted Accents */
  --accent-emerald: #10b981;
  --accent-emerald-dim: #059669;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;

  --color-positive: #10b981;
  --color-negative: #ef4444;
  --color-moderator: #f59e0b;
  --color-neutral: #6b7280;
  --color-info: #3b82f6;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-code: #8b5cf6;

  /* Clean subtle borders and shadows */
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-default: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.2);
  
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-elevated: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Typography Scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radii (Clean, minimal) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* PARA category colors */
  --para-projects: #3b82f6;
  --para-areas: #10b981;
  --para-resources: #8b5cf6;
  --para-archives: #6b7280;
  --para-sources: #f59e0b;

  /* Graph Semantic Nodes/Edges (High Contrast Light Mode) */
  --graph-project: #1d4ed8;
  --graph-area: #047857;
  --graph-resource: #6d28d9;
  --graph-archive: #374151;
  --graph-source: #b45309;
  --graph-entity: #be185d;
  
  --graph-core: #047857;
  --graph-fail: #b91c1c;
  --graph-mech: #b45309;
  --graph-ind: #0e7490;
  --graph-out: #475569;
  
  --graph-pos: #047857;
  --graph-neg: #b91c1c;
  --graph-mod: #d97706;
  --graph-def: #6d28d9;
  --graph-rel: #475569;
  
  --sidebar-width: 240px;
  --sidebar-collapsed: 60px;
}

/* Soft Dark Theme (Cognitive Minimalism) */
[data-theme="dark"] {
  --bg-void: #121214;
  --bg-base: #18181b;
  --bg-elevated: #27272a;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --bg-card: #1c1c1f;
  --bg-muted: #27272a;
  --bg-hover: #27272a;

  --text-primary: #ededed;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-code: #a78bfa;

  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 4px 6px rgba(0, 0, 0, 0.4);

  /* Graph Semantic Nodes/Edges (Vibrant Dark Mode) */
  --graph-project: #3b82f6;
  --graph-area: #10b981;
  --graph-resource: #8b5cf6;
  --graph-archive: #9ca3af;
  --graph-source: #f59e0b;
  --graph-entity: #ec4899;
  
  --graph-core: #10b981;
  --graph-fail: #ef4444;
  --graph-mech: #f59e0b;
  --graph-ind: #06b6d4;
  --graph-out: #94a3b8;
  
  --graph-pos: #10b981;
  --graph-neg: #ef4444;
  --graph-mod: #f59e0b;
  --graph-def: #8b5cf6;
  --graph-rel: #555577;
}


/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }


html { font-size: 16px; -webkit-font-smoothing: antialiased; height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-emerald); }

/* ── Top Bar ──────────────────────────────────────────────────────────────── */
#top-bar {
  height: 48px;
  background: var(--bg-void);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-4);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.top-bar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  min-width: var(--sidebar-width);
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-purple-mid) 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: var(--glow-emerald);
}

.logo-text {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-text span { color: var(--accent-emerald); }

.top-bar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px var(--sp-3);
  width: 100%;
  max-width: 480px;
  cursor: text;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#search-bar:hover { border-color: var(--border-default); }
#search-bar:focus-within {
  border-color: var(--accent-emerald-border);
  box-shadow: var(--glow-emerald);
}

#search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

#search-bar input::placeholder { color: var(--text-muted); }

.search-icon { color: var(--text-muted); font-size: 14px; }

.search-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.lang-toggle {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: var(--text-xs);
}

.lang-btn {
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  transition: all var(--transition-fast);
}

.lang-btn.active {
  background: var(--accent-emerald);
  color: var(--bg-void);
  font-weight: 600;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 15px;
}

.icon-btn:hover { border-color: var(--border-default); color: var(--text-primary); }

/* ── App Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width var(--transition-slow);
}

.sidebar-section {
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 var(--sp-2) var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 7px var(--sp-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-emerald);
  border-radius: 0 3px 3px 0;
}

.nav-icon { width: 16px; text-align: center; font-size: 14px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  font-size: var(--text-xs);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.nav-item.active .nav-badge {
  background: var(--accent-emerald-glow);
  color: var(--accent-emerald);
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-2) var(--sp-3);
}

/* PARA Color dots */
.para-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.para-dot.projects { background: var(--para-projects); }
.para-dot.areas { background: var(--para-areas); }
.para-dot.resources { background: var(--para-resources); }
.para-dot.archives { background: var(--para-archives); }

/* ── Main Content Area ─────────────────────────────────────────────────────── */
#main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel {
  display: none;
  height: 100%;
  overflow: hidden;
  flex-direction: column;
}

.panel.active {
  display: flex;
}

/* ── Panel Header ────────────────────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-void);
  flex-shrink: 0;
  gap: var(--sp-4);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.panel-title h2 {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.panel-title .panel-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-default);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px); /* Simple press effect */
}

.btn-primary {
  background: var(--accent-emerald);
  color: var(--bg-void);
  border-color: var(--accent-emerald);
}

.btn-primary:hover {
  background: var(--accent-emerald-dim);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-card);
}

.card:hover {
  border-color: var(--border-default);
}

.card-accent-emerald { border-left: 3px solid var(--accent-emerald); }
.card-accent-purple { border-left: 3px solid var(--accent-purple-mid); }
.card-accent-amber { border-left: 3px solid var(--accent-amber); }
.card-accent-red { border-left: 3px solid var(--color-negative); }
.card-accent-blue { border-left: 3px solid var(--color-info); }

/* ── Stat Cards ─────────────────────────────────────────────────────────────── */
.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-primary);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--sp-2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-change.positive { color: var(--color-positive); background: rgba(16,185,129,0.1); }
.stat-change.negative { color: var(--color-negative); background: rgba(239,68,68,0.1); }

/* ── Tags / Badges ──────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-weight: 500;
}

.tag-default { background: var(--bg-muted); color: var(--text-secondary); }
.tag-emerald { background: var(--accent-emerald-glow); color: var(--accent-emerald); border: 1px solid var(--accent-emerald-border); }
.tag-purple { background: var(--accent-purple-glow); color: var(--accent-purple-light); }
.tag-amber { background: var(--accent-amber-glow); color: var(--accent-amber); }

/* ── ═══════════════════════════════════════════════════════════════════
   GRAPH VIEW PANEL
   ═══════════════════════════════════════════════════════════════════ */
#panel-graph {
  position: relative;
}

#graph-canvas {
  flex: 1;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

#graph-controls {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 10;
}

.graph-control-group {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  backdrop-filter: blur(12px);
  min-width: 180px;
}

.control-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  user-select: none;
}

.filter-chip.active { border-color: currentColor; color: var(--accent-emerald); background: var(--accent-emerald-glow); }
.filter-chip:hover { border-color: var(--border-strong); color: var(--text-primary); }

.filter-chip[data-type="project"].active { color: var(--para-projects); background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.4); }
.filter-chip[data-type="area"].active { color: var(--para-areas); background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.4); }
.filter-chip[data-type="concept"].active { color: var(--para-resources); background: rgba(139,92,246,0.13); border-color: rgba(139,92,246,0.4); }
.filter-chip[data-type="source"].active { color: var(--accent-amber); background: var(--accent-amber-glow); border-color: rgba(245,158,11,0.4); }
.filter-chip[data-type="entity"].active { color: #ec4899; background: rgba(236,72,153,0.1); border-color: rgba(236,72,153,0.4); }

.time-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 3px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-emerald);
  cursor: pointer;
  box-shadow: var(--glow-emerald);
  transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Graph tooltip */
#graph-tooltip {
  position: fixed;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  pointer-events: none;
  z-index: 1000;
  max-width: 260px;
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-elevated);
}

#graph-tooltip.visible { opacity: 1; }

.tooltip-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: 4px; }
.tooltip-meta { font-size: var(--text-xs); color: var(--text-muted); }
.tooltip-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tooltip-connections { font-size: var(--text-xs); color: var(--accent-emerald); margin-top: 4px; font-family: var(--font-mono); }

/* ── ═══════════════════════════════════════════════════════════════════
   REASONING KNOWLEDGE GRAPH PANEL
   ═══════════════════════════════════════════════════════════════════ */
#reasoning-canvas {
  flex: 1;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

.reasoning-legend {
  position: absolute;
  bottom: var(--sp-4);
  left: var(--sp-4);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  min-width: 220px;
  backdrop-filter: blur(12px);
  z-index: 10;
}

.legend-section { margin-bottom: var(--sp-3); }
.legend-title { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; margin-bottom: var(--sp-2); }

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: 3px 0;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.legend-item:hover { color: var(--text-primary); }

.legend-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; flex-shrink: 0; }
.legend-dot.filled { background: currentColor; }
.legend-line { width: 20px; height: 2px; flex-shrink: 0; }
.legend-line.dashed { border-top: 2px dashed currentColor; background: none; }
.legend-line.dotted { border-top: 2px dotted currentColor; background: none; }

/* Node categories */
.node-core { color: #10b981; }
.node-failure { color: #ef4444; }
.node-mechanism { color: #f59e0b; }
.node-individual { color: #06b6d4; }
.node-outcome { color: #e2e8f0; }

/* ── ═══════════════════════════════════════════════════════════════════
   ANALYTICS DASHBOARD PANEL
   ═══════════════════════════════════════════════════════════════════ */
#panel-analytics .panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-content: start;
}

.analytics-grid {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}

@media (max-width: 1100px) { .metrics-row { grid-template-columns: repeat(2, 1fr); } }

.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-4);
}

.chart-container {
  position: relative;
  height: 180px;
}

/* Chart y-axis labels */
.chart-label {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  fill: var(--text-muted);
}

.chart-line { fill: none; stroke-width: 2; }
.chart-area { opacity: 0.15; }
.chart-dot { transition: r 0.15s ease; }
.chart-dot:hover { r: 5; }

/* Keyword table */
.kw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.kw-table th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}

.kw-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.kw-table td:first-child { color: var(--text-primary); font-weight: 500; }

.kw-table tr:hover td { background: var(--bg-overlay); color: var(--text-primary); }

.pos-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.pos-up { color: var(--color-positive); background: rgba(16,185,129,0.1); }
.pos-down { color: var(--color-negative); background: rgba(239,68,68,0.1); }
.pos-neutral { color: var(--text-muted); background: var(--bg-muted); }

/* Ads table */
.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.section-title .section-icon { color: var(--accent-emerald); }

/* ── ═══════════════════════════════════════════════════════════════════
   SELF-OPTIMIZATION PANEL
   ═══════════════════════════════════════════════════════════════════ */
.optimizer-grid {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--sp-5);
  align-content: start;
}

/* Growth Loop SVG animation */
#growth-loop-svg {
  width: 100%;
  height: 280px;
}

.loop-node circle {
  transition: all 0.3s ease;
  cursor: pointer;
}

.loop-node:hover circle { filter: brightness(1.2); }

.loop-label { font-family: var(--font-sans); font-size: 11px; fill: var(--text-primary); font-weight: 600; }
.loop-sublabel { font-family: var(--font-sans); font-size: 9px; fill: var(--text-muted); }

.opt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  gap: var(--sp-3);
}

.opt-card:hover {
  border-color: var(--border-default);
  background: var(--bg-hover);
  transform: translateX(2px);
}

.opt-priority {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.opt-priority.urgent { background: rgba(239,68,68,0.15); color: var(--color-negative); }
.opt-priority.high { background: rgba(245,158,11,0.15); color: var(--accent-amber); }
.opt-priority.medium { background: rgba(59,130,246,0.15); color: var(--color-info); }

.opt-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.opt-desc { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.6; }
.opt-meta { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ── ═══════════════════════════════════════════════════════════════════
   KNOWLEDGE BASE PANEL
   ═══════════════════════════════════════════════════════════════════ */
#panel-kb {
  flex-direction: row !important;
}

#kb-sidebar {
  width: 220px;
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: var(--sp-3);
  flex-shrink: 0;
  background: var(--bg-void);
}

#kb-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-10);
  max-width: 760px;
  margin: 0 auto;
}

#kb-backlinks {
  width: 220px;
  border-left: 1px solid var(--border-subtle);
  padding: var(--sp-4);
  overflow-y: auto;
  flex-shrink: 0;
}

.kb-nav-section { margin-bottom: var(--sp-4); }

.kb-nav-heading {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  padding: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
}

.kb-nav-item {
  display: block;
  padding: 5px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.kb-nav-item.active { color: var(--accent-emerald); background: var(--accent-emerald-glow); }

/* Markdown Rendering */
.md-content h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.04em; margin-bottom: var(--sp-4); line-height: 1.2; }
.md-content h2 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.03em; margin: var(--sp-8) 0 var(--sp-4); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border-subtle); }
.md-content h3 { font-size: var(--text-lg); font-weight: 600; margin: var(--sp-6) 0 var(--sp-3); }
.md-content p { color: var(--text-secondary); line-height: 1.75; margin-bottom: var(--sp-4); font-size: var(--text-base); }
.md-content ul, .md-content ol { color: var(--text-secondary); line-height: 1.75; margin-bottom: var(--sp-4); padding-left: var(--sp-5); }
.md-content li { margin-bottom: var(--sp-1); }
.md-content blockquote { border-left: 3px solid var(--accent-emerald); padding: var(--sp-3) var(--sp-4); background: var(--accent-emerald-glow); border-radius: 0 var(--radius-md) var(--radius-md) 0; margin: var(--sp-4) 0; color: var(--text-secondary); }
.md-content code { font-family: var(--font-mono); font-size: 0.85em; background: var(--bg-muted); padding: 2px 6px; border-radius: 4px; color: var(--text-code); }
.md-content pre { background: var(--bg-void); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--sp-4); overflow-x: auto; margin: var(--sp-4) 0; }
.md-content pre code { background: none; padding: 0; }
.md-content table { width: 100%; border-collapse: collapse; margin: var(--sp-4) 0; font-size: var(--text-sm); }
.md-content th { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 2px solid var(--border-default); font-weight: 600; color: var(--text-primary); }
.md-content td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.md-content tr:hover td { background: var(--bg-overlay); }

.wiki-link {
  color: var(--accent-emerald);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-emerald-border);
  transition: all var(--transition-fast);
}

.wiki-link:hover { border-bottom-color: var(--accent-emerald); }

.frontmatter {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
}

.fm-item {
  display: flex;
  gap: var(--sp-2);
  font-size: var(--text-xs);
}

.fm-key { color: var(--text-muted); }
.fm-val { color: var(--text-secondary); font-family: var(--font-mono); }

.backlinks-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

.backlink-item {
  padding: 6px var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--accent-emerald);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}

.backlink-item:hover { background: var(--accent-emerald-glow); }

/* ── ═══════════════════════════════════════════════════════════════════
   PATTERN MATCHER PANEL
   ═══════════════════════════════════════════════════════════════════ */
.pattern-grid {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  align-content: start;
}

.pattern-search {
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-void);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.pattern-input-wrap {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.pattern-input-wrap:focus-within {
  border-color: var(--accent-purple-mid);
  box-shadow: var(--glow-purple);
}

.pattern-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
}

.pattern-input::placeholder { color: var(--text-muted); }

.flow-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  transition: all var(--transition-base);
}

.flow-card:hover {
  border-color: var(--accent-purple-mid);
  box-shadow: var(--glow-purple);
  transform: translateY(-1px);
}

.flow-success { width: 8px; height: 8px; border-radius: 50%; background: var(--color-positive); }

.flow-title {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.flow-result {
  font-size: var(--text-xs);
  color: var(--accent-emerald);
  font-family: var(--font-mono);
  background: var(--accent-emerald-glow);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  margin: var(--sp-3) 0;
  border: 1px solid var(--accent-emerald-border);
}

.flow-steps {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--sp-3);
}

.flow-step {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-mono);
}

/* ── ═══════════════════════════════════════════════════════════════════
   SEARCH OVERLAY
   ═══════════════════════════════════════════════════════════════════ */
#search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

#search-overlay.open { display: flex; }

#command-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 1001;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

#command-overlay.open { display: flex; }

.search-modal {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-elevated), var(--glow-purple);
  overflow: hidden;
}

.search-modal-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}

.search-modal-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.search-modal-input::placeholder { color: var(--text-muted); }

.command-modal-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.command-modal-input::placeholder { color: var(--text-muted); }

.command-item.active {
  background: var(--bg-hover);
  border-color: var(--accent-emerald);
}

.command-item.command-disabled {
  opacity: 0.6;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--sp-2);
}

.search-result {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-result:hover { background: var(--bg-hover); }

.result-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; margin-top: 2px; }

.result-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.result-snippet {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-path {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.search-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--sp-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.shortcut { font-family: var(--font-mono); }

/* ── Empty States ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--sp-4);
  color: var(--text-muted);
  text-align: center;
  padding: var(--sp-10);
}

.empty-icon { font-size: 40px; opacity: 0.4; }
.empty-title { font-size: var(--text-md); font-weight: 600; color: var(--text-secondary); }
.empty-desc { font-size: var(--text-sm); line-height: 1.6; max-width: 320px; }

/* ── Pulse animation for data sync ─────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pulse { animation: pulse 2s ease-in-out infinite; }

/* ── Animate in ──────────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

/* Apply staggered animations */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 180ms; }

/* ── Scrollable containers ─────────────────────────────────────────────────── */
.scrollable { overflow-y: auto; flex: 1; }

/* ── Status indicator ─────────────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.live { background: var(--color-positive); box-shadow: 0 0 6px var(--color-positive); }
.status-dot.pending { background: var(--accent-amber); }
.status-dot.inactive { background: var(--text-muted); }

/* ── Section panels inside analytics ─────────────────────────────────────── */
.analytics-section-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  padding: 5px var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  border: none;
  background: none;
  font-family: var(--font-sans);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.tab-btn:hover:not(.active) { color: var(--text-secondary); }

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.toast {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow-elevated);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  animation: fadeInUp 0.3s ease forwards;
  backdrop-filter: blur(12px);
  min-width: 280px;
}

.toast.success { border-left: 3px solid var(--color-positive); }
.toast.info { border-left: 3px solid var(--color-info); }

/* ── Loading state ────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Hover glow border for important cards ──────────────────────────────── */
.glow-card:hover {
  box-shadow: var(--glow-emerald), var(--shadow-card);
  border-color: var(--accent-emerald-border);
}

/* ── Settings Overlay ─────────────────────────────────────────────────────── */
#settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}

#settings-overlay.active {
  display: flex;
}

.settings-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent-emerald) !important;
  box-shadow: 0 0 0 1px var(--accent-emerald);
}
