/* ═══════════════════════════════════════════════════════════
   Brain Viewer — Linear Dark Design System v2
   Design tokens from linear-dark-design.md
   3-column flex layout: sidebar(260px) | content(flex:1) | graphPanel(35%)
   ═══════════════════════════════════════════════════════════ */

/* ── §TOKENS — Design Tokens ──────────────────────────────── */
:root {
  /* Canvas — near-pure black with faint blue tint */
  --canvas:           #010102;
  /* Surface ladder — 4-step lift hierarchy */
  --surface-1:        #0f1011;
  --surface-2:        #141516;
  --surface-3:        #18191a;
  --surface-4:        #191a1b;
  /* Hairline borders — opaque 1px */
  --hairline:         #23252a;
  --hairline-strong:  #34343a;
  --hairline-tertiary: #3e3e44;
  /* Text — light gray on deep dark */
  --ink:              #f7f8f8;
  --ink-muted:        #d0d6e0;
  --ink-subtle:       #8a8f98;
  --ink-tertiary:     #62666d;
  /* Accent — Linear lavender-blue */
  --accent:           #5E6AD2;
  --accent-hover:     #828fff;
  --accent-focus:     #5e69d1;
  --accent-dim:       rgba(94,106,210,0.18);
  --accent-glow:      rgba(94,106,210,0.25);
  /* Graph node colors */
  --concept:          #6B7FE8;
  --concept-glow:     rgba(107,127,232,0.3);
  --source:           #4A4A5A;
  --source-hover:     #6A6A7A;
  /* Semantic */
  --success:          #27a644;
  /* Border radius — Linear's tight scale */
  --radius-xs:        4px;
  --radius-sm:        6px;
  --radius-md:        8px;
  --radius-lg:        12px;
  --radius-xl:        16px;
  --radius-full:      9999px;
  /* Spacing — 4px base */
  --space-xxs:        4px;
  --space-xs:         8px;
  --space-sm:         12px;
  --space-md:         16px;
  --space-lg:         24px;
  --space-xl:         32px;
  --space-xxl:        48px;
  /* Legacy aliases */
  --bg:               var(--canvas);
  --bg-base:          var(--surface-1);
  --bg-elevated:      var(--surface-2);
  --bg-surface:        var(--surface-3);
  --bg-glass:          rgba(255,255,255,0.04);
  --bg-glass-hover:    rgba(255,255,255,0.07);
  --border:            var(--hairline);
  --border-subtle:     rgba(255,255,255,0.05);
  --border-focus:      rgba(94,106,210,0.6);
  --text-1:            var(--ink);
  --text-2:            var(--ink-muted);
  --text-3:            var(--ink-subtle);
  --shadow-sm:         0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:         0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:         0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow:       0 0 20px var(--accent-glow);
}

/* Layout tokens — separate block for clarity */
:root {
  --sidebar-w:        260px;
  --graph-w:          35%;
  --toolbar-h:        52px;
}

/* Easing & Transitions */
:root {
  --ease:             cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast:   0.12s var(--ease);
  --transition-med:   0.22s var(--ease);
  --transition-slow:  0.35s var(--ease);
}

/* Typography */
:root {
  --font-display: 'Geist', -apple-system, 'SF Pro Display', system-ui, sans-serif;
  --font-text:    'Geist', -apple-system, 'SF Pro Text', system-ui, sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}


/* ── §RESET — Global Reset & Base ───────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  overflow: hidden;
  height: 100vh;
}

::selection {
  background: var(--accent-dim);
  color: var(--text-1);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

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


/* ── §LAYOUT — App Shell & 3-Column Flex ─────────────────── */
/* 3-column flex layout: sidebar(260px) | content(flex:1) | graphPanel(35%) */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#main {
  display: flex;
  flex-direction: row;
  height: calc(100vh - var(--toolbar-h));
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* ── §LAYOUT — App Shell & 3-Column Flex ─────────────────── */
/*
  #main flex children order:
    1. #fullGraphWrap  — full graph (graph-active state)
    2. #contentArea    — sidebar + content wrapper (split state)
    3. #graphPanel     — mini graph panel (split state)

  State classes on #main:
    .graph-active → full graph visible, content+graphPanel hidden
    .split        → sidebar+content visible + mini-graph panel visible
*/

/* Content area — wraps sidebar + content, shown in split mode */
#contentArea {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-width: 0;
  overflow: hidden;
}
#contentArea.hidden {
  display: none;
}

/* Sidebar — INSIDE #contentArea, LEFT */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  min-width: 0;
  height: 100%;
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: flex var(--transition-slow);
}
.sidebar.closed {
  flex: 0 0 0px;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}

/* Content — INSIDE #contentArea, CENTER */
.content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
}

/* Graph Panel — RIGHT (last flex child in #main) */
.graph-panel {
  flex: 0 0 var(--graph-w);
  min-width: 0;
  height: 100%;
  background: var(--surface-1);
  border-left: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    flex var(--transition-slow),
    opacity var(--transition-med);
}
.graph-panel.closed {
  flex: 0 0 0%;
  opacity: 0;
  overflow: hidden;
}
.graph-panel.open {
  flex: 0 0 var(--graph-w);
  opacity: 1;
}

/* Full graph — fills #main in graph-active mode */
.graph-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ── App State: graph-active (no article open) ─────────── */
/* Full graph fills #main; contentArea + graphPanel hidden */
.main.graph-active #fullGraphWrap {
  display: flex;
}
.main.graph-active #contentArea {
  display: none;
}
.main.graph-active .graph-panel {
  flex: 0 0 0%;
  opacity: 0;
}

/* ── App State: split (article open) ────────────────────── */
/* contentArea (sidebar+content) on left, mini-graph panel on right */
.main.split #fullGraphWrap {
  display: none;
}
.main.split #contentArea {
  display: flex;
}
.main.split .graph-panel {
  flex: 0 0 var(--graph-w);
  opacity: 1;
}


/* ── §TOOLBAR — Top Bar ─────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: var(--toolbar-h);
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
  flex-shrink: 0;
  z-index: 30;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Breadcrumb */
.breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  color: var(--text-2);
  padding-left: 4px;
}
.breadcrumb-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
  transition: color var(--transition-fast);
}
.breadcrumb-item a {
  color: var(--text-3);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb-item.current { color: var(--text-1); font-weight: 500; }
.breadcrumb-sep { color: var(--text-3); margin: 0 1px; opacity: 0.5; }

/* Icon buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 17px;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}
.icon-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-1);
}
.icon-btn:active { transform: scale(0.93); }
.icon-btn i { line-height: 1; pointer-events: none; }

/* Tooltip */
.icon-btn[title]::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--bg-elevated);
  color: var(--text-1);
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 100;
  font-family: inherit;
}
.icon-btn[title]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Focus ring */
button:focus-visible,
.icon-btn:focus-visible,
.nav-child:focus-visible,
.nav-folder-header:focus-visible,
.filter-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

/* Separator */
.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 2px;
  flex-shrink: 0;
}


/* ── §SIDEBAR — Navigation Sidebar ──────────────────────── */
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Sidebar header */
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(94,106,210,0.25);
  flex-shrink: 0;
}
.sidebar-brand i { font-size: 14px; color: var(--accent); }
.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
}
.sidebar-subtitle {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 1px;
}

/* Search */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg);
}
.search-icon { color: var(--text-3); font-size: 14px; flex-shrink: 0; }
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  min-width: 0;
}
.search-input::placeholder { color: var(--ink-tertiary); }
.search-kbd {
  font-size: 10px;
  color: var(--ink-tertiary);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-family: inherit;
}

/* Nav tree */
.nav-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-folder { margin-bottom: 2px; }
.nav-folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-radius: var(--radius-sm);
  margin: 0 6px;
}
.nav-folder-header:hover {
  background: var(--bg-glass-hover);
  color: var(--text-1);
}
.nav-chevron {
  font-size: 13px;
  color: var(--text-3);
  transition: transform var(--transition-med);
  flex-shrink: 0;
}
.nav-chevron.open { transform: rotate(90deg); }
.nav-folder-icon { font-size: 13px; flex-shrink: 0; }
.nav-folder-icon.ai   { color: #7C8EFA; }
.nav-folder-icon.src  { color: #F59E0B; }
.nav-folder-icon.cat  { color: #34D399; }
.nav-folder-label { flex: 1; letter-spacing: 0.02em; }
.nav-folder-count {
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-glass);
  border-radius: 10px;
  padding: 0 6px;
  min-width: 20px;
  text-align: center;
  font-weight: 500;
}

.nav-children { padding: 2px 0 4px 32px; }

.nav-child {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
  overflow: hidden;
  margin: 0 6px;
}
.nav-child:hover {
  background: var(--bg-glass-hover);
  color: var(--text-1);
}
.nav-child.active {
  background: var(--accent-dim);
  color: var(--accent-hover);
  font-weight: 500;
  position: relative;
}
.nav-child.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-child-icon { font-size: 13px; flex-shrink: 0; color: var(--text-3); }
.nav-child-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar footer */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
  background: var(--surface-1);
}
.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-footer-btn:hover { background: var(--bg-glass); color: var(--text-2); }
.sidebar-footer-btn i { font-size: 13px; }

/* Mobile sidebar close */
.sidebar-mobile-close { display: none; }
@media (max-width: 768px) {
  .sidebar-mobile-close { display: inline-flex; }
}


/* ── §CONTENT — Article / Content Area ─────────────────── */
.reading-progress {
  position: sticky;
  top: 0;
  height: 2px;
  background: rgba(255,255,255,0.04);
  z-index: 10;
  flex-shrink: 0;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* Article layout */
.article-layout {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.article-layout::-webkit-scrollbar { width: 4px; }
.article-layout::-webkit-scrollbar-track { background: transparent; }
.article-layout::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* Article shell */
.article {
  padding: 40px 48px 80px;
  max-width: 756px;
  margin: 0 auto;
  animation: articleReveal 400ms var(--ease) both;
}

@keyframes articleReveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Article header */
.article-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.article-header::before {
  content: '';
  position: absolute;
  inset: -40px -48px;
  background: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(94,106,210,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.article-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  background: var(--accent-dim);
  border: 1px solid rgba(94,106,210,0.25);
  border-radius: 100px;
  font-family: var(--font-text);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.article-type-badge:hover {
  background: rgba(94,106,210,0.24);
  border-color: rgba(94,106,210,0.4);
}
.article-type-badge i { font-size: 12px; }

.article-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-1);
  margin: 0 0 16px;
  text-wrap: balance;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.article-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
}
.article-meta-item i { color: var(--accent); font-size: 12px; }

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.article-tag {
  padding: 3px 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-3);
  cursor: default;
  transition: all var(--transition-fast);
}
.article-tag:hover {
  background: var(--accent-dim);
  border-color: rgba(94,106,210,0.3);
  color: var(--accent-hover);
}

/* Article empty state */
.article-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 60vh;
  text-align: center;
  padding: 40px;
  gap: 16px;
  animation: fadeIn 500ms ease both;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.article-empty-icon {
  font-size: 56px;
  color: var(--text-3);
  opacity: 0.3;
  margin-bottom: 8px;
}
.article-empty h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-2);
  margin: 0;
}
.article-empty p {
  font-size: 14px;
  color: var(--text-3);
  max-width: 280px;
  line-height: 1.6;
  margin: 0;
}

/* Markdown body */
.md {
  color: var(--text-1);
  line-height: 1.75;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  color: var(--text-1);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 1.8em 0 0.6em;
}
.md h1 {
  font-size: 1.6em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border-subtle);
  margin-top: 0;
}
.md h2 {
  font-size: 1.25em;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  margin-left: -14px;
}
.md h3 { font-size: 1.05em; color: var(--text-2); }
.md h4 { font-size: 0.95em; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.md p { margin: 0 0 1.2em; }
.md p:last-child { margin-bottom: 0; }
.md a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast);
}
.md a:hover { border-color: var(--accent); }
.md blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.75em 1.25em;
  background: var(--accent-dim);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-2);
  font-style: italic;
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
}
.md pre {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 1.25em 1.5em;
  overflow-x: auto;
  margin: 1.5em 0;
  position: relative;
}
.md pre::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(94,106,210,0.3), transparent);
}
.md pre code { background: transparent; border: none; padding: 0; font-size: 0.88em; }
.md ul, .md ol { padding-left: 1.5em; margin: 0 0 1.2em; }
.md li { margin: 0.35em 0; }
.md li::marker { color: var(--text-3); }
.md img { display: block; max-width: 100%; border-radius: var(--radius-lg); margin: 1.5em 0; border: 1px solid var(--border); }
.md table { border-collapse: collapse; width: 100%; margin: 1.5em 0; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.md th, .md td { border: none; border-bottom: 1px solid var(--border-subtle); padding: 8px 14px; text-align: left; font-size: 0.9em; }
.md th { background: var(--bg-elevated); font-weight: 600; color: var(--text-1); }
.md tr:last-child td { border-bottom: none; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }

/* Wiki links */
.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  margin: 0 -1px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent-hover);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.93em;
  border-bottom: none;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}
.wiki-link:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}
.wiki-source {
  background: var(--bg-glass);
  color: var(--text-2);
  border: 1px dashed var(--border);
}
.wiki-source:hover { background: var(--bg-glass-hover); color: var(--text-1); }
.wiki-missing { background: transparent; color: var(--text-3); border-bottom: 1px dashed var(--text-3); font-style: italic; }

/* Transcript block */
.transcript-block {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin: 1.5em 0;
}
.transcript-block .timestamp {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-right: 8px;
  opacity: 0.7;
}
.transcript-block .segment { margin-bottom: 8px; line-height: 1.6; }


/* ── §MINI-GRAPH — Mini Graph Panel ─────────────────────── */
.mini-graph-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.mini-graph-section {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.mini-graph-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}
.mini-graph-header i { font-size: 12px; color: var(--text-3); }
.mini-graph-body {
  flex: 0 0 180px;
  height: 180px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  flex-shrink: 0;
}
.mini-graph-body svg {
  display: block;
  width: 100%;
  height: 100%;
}
.mini-graph-legend {
  display: flex;
  gap: 12px;
  padding: 6px 14px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* TOC */
.toc-section {
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  max-height: 40%;
  overflow-y: auto;
}
.toc-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: rgba(9,9,12,0.95);
  backdrop-filter: blur(8px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.toc-header i { font-size: 12px; color: var(--text-3); }
.toc-nav { padding: 4px 0; }
.toc-item {
  display: block;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
  cursor: pointer;
  line-height: 1.4;
}
.toc-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-1);
}
.toc-item[data-level="3"] {
  padding-left: 28px;
  font-size: 11px;
  color: var(--text-3);
}

/* Legend */
.legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.concept { background: var(--concept); box-shadow: 0 0 4px var(--concept-glow); }
.dot.source  { background: var(--source); }

/* Graph panel header */
.graph-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.graph-head i { font-size: 13px; color: var(--ink-subtle); }
.graph-head span { flex: 1; }

/* Graph controls */
.graph-controls {
  display: flex;
  gap: 3px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.graph-controls .icon-btn {
  width: 28px;
  height: 28px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}
.graph-controls .icon-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Filter chips */
.graph-filters {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.filter-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  font-size: 10px;
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hover);
}
.filter-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Graph close buttons */
.close-graph-btn { display: inline-flex; }
.graph-mobile-close { display: none; }
@media (max-width: 768px) {
  .close-graph-btn { display: none; }
  .graph-mobile-close { display: inline-flex; }
}


/* ── §FULL-GRAPH — Knowledge Graph Canvas ────────────────── */
.full-graph-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Ambient background pattern */
.full-graph-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(94,106,210,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 70% 60%, rgba(107,127,232,0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.full-graph-svg {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* Graph node glow effect */
.node circle {
  transition:
    r 0.2s var(--ease-spring),
    filter 0.2s var(--ease);
}
.node:hover circle {
  filter: drop-shadow(0 0 6px var(--concept-glow));
}
.node.source-node:hover circle {
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.1));
}

/* Graph zoom hint */
.graph-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-3);
  background: rgba(9,9,12,0.7);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  opacity: 0.7;
}

.graph-legend {
  display: flex;
  gap: 12px;
  padding: 6px 14px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: rgba(9,9,12,0.5);
}


/* ── §UTILITIES — Utilities & Helpers ───────────────────── */
.text-1 { color: var(--text-1); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-accent { color: var(--accent); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}


/* ── §ANIMATIONS — Keyframes & Motion ───────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%       { box-shadow: 0 0 12px 4px var(--accent-glow); }
}

.animate-in { animation: fadeIn 0.3s var(--ease) both; }

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* ── §MOBILE — Responsive Breakpoint ───────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 85vw;
    --graph-w: 100%;
  }

  /* Sidebar: slides in as left drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 110;
    transform: translateX(-100%);
    flex: 0 0 auto !important;
    transition: transform var(--transition-slow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.closed { transform: translateX(-100%); flex: 0 0 auto !important; }

  /* Graph panel: slides up as bottom sheet */
  .graph-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 80vh;
    z-index: 110;
    transform: translateY(100%);
    flex: 0 0 auto !important;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--hairline);
  }
  .graph-panel.open {
    transform: translateY(0);
    opacity: 1 !important;
  }
  .graph-panel.closed {
    transform: translateY(100%);
    flex: 0 0 auto !important;
    opacity: 0;
  }

  /* Mini graph body: explicit height on mobile */
  .mini-graph-body {
    flex: 0 0 200px;
    height: 200px;
    overflow: hidden;
  }
  .mini-graph-body svg {
    display: block;
    width: 100%;
    height: 200px;
  }

  /* Main: column on mobile */
  .main { flex-direction: column; }
  .main.split { flex-direction: column; }
  .main.split .content { flex: 1; max-width: 100%; }

  /* Article: proper mobile padding */
  .article { padding: 24px 16px 100px; }
  .article-title { font-size: 1.4rem; }

  /* Toolbar: full width */
  .toolbar { padding: 0 10px; }
  .breadcrumb { font-size: 12px; }
  .toolbar-right { gap: 2px; }

  /* Sidebar backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 105;
    backdrop-filter: blur(4px);
  }
  .sidebar.open ~ .sidebar-backdrop { display: block; }

  /* TOC: mobile adjustments */
  .toc-section { max-height: 35%; }
}
