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

:root {
  --bg: #161618;
  --bg-card: #1c1c1f;
  --bg-hover: #242428;
  --bg-surface: #1e1e21;
  --fg: #e0e0e0;
  --fg-muted: #777777;
  --fg-dim: #4a4a4e;
  --border: #2a2a2e;
  --accent: #d4d4d4;
  --accent-bright: #ffffff;
  --accent-dim: #444444;
  --high: #ffffff;
  --medium: #888888;
  --low: #444444;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 3px;
}

body {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ──────────────────────────── */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.hdr-left { display: flex; align-items: center; gap: 16px; }

.hdr-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hdr-title span { color: var(--accent-bright); }

.hdr-back {
  font-size: 10px;
  color: var(--fg-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: var(--radius);
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.15s;
}

.hdr-back:hover { border-color: var(--accent); color: var(--fg); }

.hdr-meta {
  font-size: 10px;
  color: var(--fg-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Stats Bar ───────────────────────── */
.stats-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.stat {
  flex: 1;
  padding: 16px 24px;
  border-right: 1px solid var(--border);
  text-align: center;
}

.stat:last-child { border-right: none; }

.stat-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-label {
  font-size: 9px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 6px;
}

/* ── Layout ──────────────────────────── */
.content {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 120px);
}

/* ── Sidebar ─────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 56px;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-heading {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--fg-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Source List ──────────────────────── */
.source-item {
  padding: 6px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-dim);
  flex-shrink: 0;
}

.source-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-type {
  font-size: 9px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Tag Cloud ───────────────────────── */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.tag:hover { border-color: var(--accent); color: var(--fg); }
.tag.active { background: var(--accent-dim); color: var(--accent-bright); border-color: var(--accent); }

.tag .tag-count {
  font-size: 8px;
  color: var(--fg-dim);
  margin-left: 3px;
}

/* ── Confidence Bar ──────────────────── */
.conf-bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
  gap: 2px;
}

.conf-bar .seg {
  height: 100%;
  border-radius: 1px;
}

.conf-bar .seg.high { background: var(--high); }
.conf-bar .seg.medium { background: var(--medium); }
.conf-bar .seg.low { background: var(--low); }

.conf-legend {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 9px;
  color: var(--fg-muted);
}

.conf-legend span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  margin-right: 4px;
  vertical-align: middle;
}

.conf-legend .ch::before { background: var(--high); }
.conf-legend .cm::before { background: var(--medium); }
.conf-legend .cl::before { background: var(--low); }

/* ── Main Panel ──────────────────────── */
.main {
  padding: 20px 24px;
  overflow-y: auto;
}

/* ── Tabs ────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--fg); }
.tab-btn.active { color: var(--accent-bright); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Themes Grid ─────────────────────── */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.theme-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 16px;
  transition: border-color 0.15s;
}

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

.theme-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.theme-desc {
  font-size: 11px;
  color: var(--fg-muted);
  margin-bottom: 10px;
  font-family: var(--sans);
  line-height: 1.5;
}

.theme-freq {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-bright);
  line-height: 1;
}

.theme-freq-label {
  font-size: 9px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Insight Cards ───────────────────── */
.insight-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 14px 16px;
  transition: border-color 0.15s;
  cursor: default;
}

.insight:hover { border-color: var(--accent-dim); }

.insight-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.insight-conf {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-top: 4px;
  flex-shrink: 0;
}

.insight-conf.high { background: var(--high); }
.insight-conf.medium { background: var(--medium); }
.insight-conf.low { background: var(--low); }

.insight-finding {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
  line-height: 1.5;
}

.insight-meta {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--fg-muted);
  margin-top: 6px;
  padding-left: 18px;
}

.insight-evidence {
  margin-top: 8px;
  padding-left: 18px;
}

.insight-evidence details {
  font-size: 10px;
  color: var(--fg-muted);
}

.insight-evidence summary {
  cursor: pointer;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-dim);
  padding: 2px 0;
}

.insight-evidence summary:hover { color: var(--fg-muted); }

.insight-evidence blockquote {
  border-left: 2px solid var(--border);
  padding: 4px 0 4px 12px;
  margin: 4px 0;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--fg-muted);
  line-height: 1.5;
}

.insight-tags {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding-left: 18px;
}

.insight-tag {
  font-size: 9px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--fg-dim);
  letter-spacing: 0.5px;
}

/* ── Persona Cards ───────────────────── */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.persona-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}

.persona-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.persona-name { font-size: 13px; font-weight: 700; }

.persona-role {
  font-size: 10px;
  color: var(--fg-muted);
  font-family: var(--sans);
}

.persona-body { padding: 14px 16px; }

.persona-section {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--fg-muted);
  margin-top: 10px;
  margin-bottom: 4px;
}

.persona-section:first-child { margin-top: 0; }

.persona-list {
  list-style: none;
  font-size: 11px;
  font-family: var(--sans);
  color: var(--fg);
  line-height: 1.8;
}

.persona-list li::before {
  content: '—';
  color: var(--fg-dim);
  margin-right: 6px;
}

/* ── Empty ───────────────────────────── */
.empty-note {
  text-align: center;
  padding: 40px;
  color: var(--fg-muted);
  font-size: 11px;
}

/* ── Scrollbar ───────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #222; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ── Responsive ──────────────────────── */
@media (max-width: 768px) {
  .content { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
  .stats-bar { flex-wrap: wrap; }
  .stat { min-width: 50%; }
}
