/* ==========================================================================
   LLM Wiki — Catppuccin Mocha + glassmorphism
   ========================================================================== */

/* Catppuccin Mocha palette */
:root {
  --ctp-base:     #1e1e2e;
  --ctp-mantle:   #181825;
  --ctp-crust:    #11111b;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-surface2: #585b70;
  --ctp-overlay0: #6c7086;
  --ctp-overlay1: #7f849c;
  --ctp-overlay2: #9399b2;
  --ctp-text:     #cdd6f4;
  --ctp-subtext1: #bac2de;
  --ctp-subtext0: #a6adc8;
  --ctp-lavender: #b4befe;
  --ctp-blue:     #89b4fa;
  --ctp-sapphire: #74c7ec;
  --ctp-sky:      #89dceb;
  --ctp-teal:     #94e2d5;
  --ctp-green:    #a6e3a1;
  --ctp-yellow:   #f9e2af;
  --ctp-peach:    #fab387;
  --ctp-maroon:   #eba0ac;
  --ctp-red:      #f38ba8;
  --ctp-mauve:    #cba6f7;
  --ctp-pink:     #f5c2e7;
  --ctp-rosewater:#f5e0dc;

  /* semantic */
  --accent:         var(--ctp-lavender);
  --accent-strong:  var(--ctp-mauve);
  --bg:             var(--ctp-base);
  --bg-elevated:    var(--ctp-mantle);
  --bg-deep:        var(--ctp-crust);
  --fg:             var(--ctp-text);
  --fg-strong:      #ecedf5;
  --fg-muted:       var(--ctp-subtext0);
  --fg-soft:        var(--ctp-overlay1);
  --border-soft:    rgba(180, 190, 254, 0.08);
  --border-med:     rgba(180, 190, 254, 0.16);

  /* glass */
  --glass-bg:       rgba(24, 24, 37, 0.55);
  --glass-bg-strong:rgba(24, 24, 37, 0.72);
  --glass-border:   rgba(203, 166, 247, 0.14);
  --glass-shadow:   0 8px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  /* severity */
  --sev-info:    var(--ctp-sky);
  --sev-suggest: var(--ctp-mauve);
  --sev-warn:    var(--ctp-peach);
  --sev-error:   var(--ctp-red);

  /* graph groups */
  --grp-concepts:  var(--ctp-lavender);
  --grp-entities:  var(--ctp-peach);
  --grp-summaries: var(--ctp-teal);
  --grp-other:     var(--ctp-overlay1);

  /* dims */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --topbar-h:  56px;
  --sidebar-l: 280px;
  --sidebar-r: 320px;

  /* type scale */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: ui-serif, 'Iowan Old Style', 'Apple Garamond', serif;
}

/* reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100vh; }
body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  background: var(--bg-deep);
}

/* aurora background: radial gradients layered on a dark base */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 15% 0%, rgba(203, 166, 247, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 85% 10%, rgba(137, 180, 250, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 50% 100%, rgba(148, 226, 213, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, var(--ctp-mantle) 0%, var(--ctp-base) 40%, var(--ctp-mantle) 100%);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(rgba(203, 166, 247, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.1));
}

/* ==========================================================================
   Layout grid
   ========================================================================== */

body {
  display: grid;
  grid-template-columns: var(--sidebar-l) 1fr var(--sidebar-r);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "top top top"
    "left main right";
  gap: 14px;
  padding: 14px;
}

#topbar { grid-area: top; }
#sidebar-left { grid-area: left; }
main { grid-area: main; }
#sidebar-right { grid-area: right; }

/* ==========================================================================
   Glass primitive
   ========================================================================== */

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow);
}

/* ==========================================================================
   Top bar
   ========================================================================== */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 5;
}
.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}
.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-strong);
  white-space: nowrap;
}
.brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 12px var(--accent-strong);
  margin-right: 8px;
  vertical-align: middle;
}
#wiki-title {
  color: var(--fg-muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  border: 1px solid var(--border-med);
  background: rgba(49, 50, 68, 0.5);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 160ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.btn:hover {
  background: rgba(69, 71, 90, 0.7);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(203, 166, 247, 0.12);
}
.btn:active { transform: translateY(0); }
.btn.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn.btn-ghost:hover {
  background: rgba(49, 50, 68, 0.55);
  border-color: var(--border-med);
}
.btn.btn-cta {
  background: linear-gradient(135deg, var(--ctp-lavender), var(--ctp-mauve));
  color: var(--ctp-crust);
  border-color: transparent;
  font-weight: 600;
}
.btn.btn-cta:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 24px rgba(203, 166, 247, 0.3);
}
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 10px;
  font-size: 15px;
}

/* ==========================================================================
   Sidebars
   ========================================================================== */

#sidebar-left, #sidebar-right {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#sidebar-left header,
#sidebar-right header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#sidebar-left header h1 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
}
#sidebar-right header h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
}
#tree, #audit-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 14px 20px;
}

/* nav tree */
#tree ul {
  list-style: none;
  padding-left: 8px;
  margin: 0;
}
#tree > ul { padding-left: 0; }
#tree li {
  margin: 2px 0;
}
#tree .tree-dir {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-soft);
  padding: 10px 8px 4px;
  margin-top: 4px;
}
#tree a {
  display: block;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
  position: relative;
}
#tree a::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  transition: width 160ms ease;
}
#tree a:hover {
  background: rgba(49, 50, 68, 0.6);
  color: var(--fg-strong);
}
#tree a.active {
  background: rgba(203, 166, 247, 0.12);
  color: var(--accent);
  font-weight: 500;
}
#tree a.active::before { width: 3px; }

/* scrollbar */
#tree::-webkit-scrollbar, #audit-list::-webkit-scrollbar, main::-webkit-scrollbar {
  width: 10px;
}
#tree::-webkit-scrollbar-track, #audit-list::-webkit-scrollbar-track, main::-webkit-scrollbar-track {
  background: transparent;
}
#tree::-webkit-scrollbar-thumb, #audit-list::-webkit-scrollbar-thumb, main::-webkit-scrollbar-thumb {
  background: rgba(108, 112, 134, 0.3);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
#tree::-webkit-scrollbar-thumb:hover, #audit-list::-webkit-scrollbar-thumb:hover, main::-webkit-scrollbar-thumb:hover {
  background: rgba(108, 112, 134, 0.55);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ==========================================================================
   Main content area
   ========================================================================== */

main {
  overflow-y: auto;
  min-height: 0;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

article {
  max-width: 76ch;
  margin: 0 auto;
  padding: 48px 64px 120px;
  line-height: 1.72;
  font-size: 15.5px;
  color: var(--fg);
}

/* typography */
article h1, article h2, article h3, article h4 {
  color: var(--fg-strong);
  letter-spacing: -0.015em;
  font-weight: 700;
  line-height: 1.2;
}
article h1 {
  font-size: 2.1em;
  margin: 0 0 0.4em;
  background: linear-gradient(135deg, var(--ctp-lavender) 0%, var(--ctp-mauve) 60%, var(--ctp-pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.025em;
}
article h2 {
  font-size: 1.45em;
  margin: 2em 0 0.7em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-soft);
}
article h3 {
  font-size: 1.15em;
  margin: 1.6em 0 0.5em;
  color: var(--ctp-lavender);
}
article p, article li {
  margin: 0.7em 0;
  color: var(--ctp-subtext1);
}
article strong {
  color: var(--fg-strong);
  font-weight: 600;
}
article em { color: var(--ctp-rosewater); }

article a {
  color: var(--ctp-blue);
  text-decoration: none;
  border-bottom: 1px dashed rgba(137, 180, 250, 0.3);
  transition: color 140ms ease, border-color 140ms ease;
}
article a:hover {
  color: var(--ctp-sapphire);
  border-bottom-color: var(--ctp-sapphire);
}

/* wikilinks */
article .wikilink {
  color: var(--ctp-lavender);
  text-decoration: none;
  border-bottom: 1px dashed rgba(203, 166, 247, 0.35);
  padding: 0 2px;
  border-radius: 3px;
  transition: background 140ms ease, color 140ms ease;
}
article .wikilink:hover {
  color: var(--fg-strong);
  background: rgba(203, 166, 247, 0.12);
  border-bottom-color: var(--ctp-lavender);
}
article .wikilink-dead {
  color: var(--ctp-red);
  border-bottom-color: rgba(243, 139, 168, 0.35);
  border-bottom-style: dotted;
}

/* code */
article code {
  background: rgba(49, 50, 68, 0.6);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--ctp-peach);
  border: 1px solid var(--border-soft);
}
article pre {
  background: var(--ctp-crust);
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
article pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: var(--ctp-text);
  font-size: inherit;
}

/* blockquote */
article blockquote {
  margin: 1.2em 0;
  padding: 0.6em 1.2em;
  border-left: 3px solid var(--accent);
  background: rgba(203, 166, 247, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ctp-subtext1);
  font-style: italic;
}
article blockquote p { margin: 0.3em 0; color: inherit; }

/* tables */
article table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.2em 0;
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 14px;
}
article th, article td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
article th {
  background: rgba(49, 50, 68, 0.5);
  color: var(--fg-strong);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
article tr:last-child td { border-bottom: none; }
article tr:hover td { background: rgba(49, 50, 68, 0.3); }

/* mermaid + math */
article .mermaid-block {
  background: rgba(17, 17, 27, 0.5);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 24px;
  margin: 1.5em 0;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
article .mermaid-block svg { max-width: 100%; height: auto; }
article .mermaid-block pre {
  background: transparent;
  border: none;
  padding: 0;
}

article .katex, article .katex-display {
  color: var(--fg-strong);
}
article .katex-display {
  margin: 1.3em 0;
  padding: 14px 20px;
  background: rgba(17, 17, 27, 0.4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  overflow-y: hidden;
}

/* heading anchors — subtle */
article .header-anchor {
  color: var(--fg-soft);
  opacity: 0;
  text-decoration: none;
  margin-right: 8px;
  transition: opacity 140ms ease;
  border: none;
}
article h1:hover .header-anchor,
article h2:hover .header-anchor,
article h3:hover .header-anchor { opacity: 0.7; }

/* ==========================================================================
   Audit panel
   ========================================================================== */

.audit-item {
  background: rgba(49, 50, 68, 0.35);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 12.5px;
  position: relative;
  transition: all 160ms ease;
}
.audit-item:hover {
  background: rgba(49, 50, 68, 0.55);
  border-color: var(--border-med);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.audit-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--ctp-overlay0);
}
.audit-item.sev-info::before    { background: var(--sev-info);    box-shadow: 0 0 8px var(--sev-info); }
.audit-item.sev-suggest::before { background: var(--sev-suggest); box-shadow: 0 0 8px var(--sev-suggest); }
.audit-item.sev-warn::before    { background: var(--sev-warn);    box-shadow: 0 0 8px var(--sev-warn); }
.audit-item.sev-error::before   { background: var(--sev-error);   box-shadow: 0 0 8px var(--sev-error); }

.audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  margin-left: 8px;
}
.sev-pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(203, 166, 247, 0.1);
  color: var(--fg-strong);
  border: 1px solid var(--border-med);
}
.sev-pill.sev-info    { background: rgba(137, 220, 235, 0.15); color: var(--sev-info);    border-color: rgba(137, 220, 235, 0.3); }
.sev-pill.sev-suggest { background: rgba(203, 166, 247, 0.15); color: var(--sev-suggest); border-color: rgba(203, 166, 247, 0.3); }
.sev-pill.sev-warn    { background: rgba(250, 179, 135, 0.15); color: var(--sev-warn);    border-color: rgba(250, 179, 135, 0.3); }
.sev-pill.sev-error   { background: rgba(243, 139, 168, 0.15); color: var(--sev-error);   border-color: rgba(243, 139, 168, 0.3); }

.audit-item .author {
  font-weight: 600;
  color: var(--fg-strong);
  font-size: 12px;
}
.audit-item .audit-body {
  color: var(--ctp-subtext1);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  margin-left: 8px;
}
.audit-item .audit-meta {
  color: var(--fg-soft);
  font-size: 10px;
  margin-top: 6px;
  margin-left: 8px;
  font-family: var(--font-mono);
}
.audit-item .audit-actions {
  margin-top: 8px;
  margin-left: 8px;
  display: flex;
  gap: 6px;
}
.audit-item .audit-actions button {
  font: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-med);
  cursor: pointer;
  transition: all 140ms ease;
}
.audit-item .audit-actions button:hover {
  color: var(--ctp-green);
  border-color: var(--ctp-green);
  background: rgba(166, 227, 161, 0.08);
}

/* ==========================================================================
   Feedback popover + dialog
   ========================================================================== */

#feedback-popover {
  position: absolute;
  z-index: 100;
  pointer-events: auto;
  animation: popIn 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#feedback-popover .btn-cta {
  box-shadow: 0 8px 30px rgba(203, 166, 247, 0.35);
}

#feedback-dialog {
  border: none;
  padding: 0;
  max-width: 560px;
  width: 90vw;
  background: transparent;
  color: var(--fg);
  overflow: visible;
}
#feedback-dialog::backdrop {
  background: rgba(17, 17, 27, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
#feedback-dialog .dialog-inner {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
  padding: 28px 32px;
}
#feedback-dialog h3 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-strong);
  letter-spacing: -0.01em;
}

#feedback-dialog .field {
  margin-bottom: 18px;
}
#feedback-dialog .field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

#feedback-preview {
  margin: 0;
  background: rgba(17, 17, 27, 0.5);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 7em;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ctp-subtext1);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* severity chip selector */
#feedback-severity {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#feedback-severity label {
  cursor: pointer;
  position: relative;
}
#feedback-severity label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
#feedback-severity .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-med);
  background: rgba(49, 50, 68, 0.35);
  color: var(--fg-muted);
  transition: all 160ms ease;
  user-select: none;
}
#feedback-severity .chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 transparent;
  transition: box-shadow 160ms ease;
}
#feedback-severity label[data-sev="info"]    .chip { color: var(--sev-info); }
#feedback-severity label[data-sev="suggest"] .chip { color: var(--sev-suggest); }
#feedback-severity label[data-sev="warn"]    .chip { color: var(--sev-warn); }
#feedback-severity label[data-sev="error"]   .chip { color: var(--sev-error); }
#feedback-severity label:hover .chip {
  background: rgba(49, 50, 68, 0.6);
  border-color: currentColor;
}
#feedback-severity label input:checked + .chip {
  background: color-mix(in oklab, currentColor 15%, transparent);
  border-color: currentColor;
  color: var(--fg-strong);
}
#feedback-severity label input:checked + .chip::before {
  box-shadow: 0 0 10px currentColor, 0 0 18px currentColor;
}

#feedback-comment {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  font: inherit;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg);
  background: rgba(17, 17, 27, 0.5);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
#feedback-comment:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(203, 166, 247, 0.12);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ==========================================================================
   Graph overlay
   ========================================================================== */

#graph-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(203, 166, 247, 0.08) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 100%, rgba(148, 226, 213, 0.06) 0%, transparent 40%),
    rgba(11, 11, 20, 0.82);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  backdrop-filter: blur(32px) saturate(160%);
  display: flex;
  flex-direction: column;
  animation: fadeIn 300ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#graph-overlay .graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 4;
}
#graph-overlay .graph-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-strong);
  display: flex;
  align-items: center;
  gap: 10px;
}
#graph-overlay .graph-header h2::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ctp-mauve);
  box-shadow: 0 0 16px var(--ctp-mauve), 0 0 30px rgba(203, 166, 247, 0.4);
  animation: brandPulse 3s ease-in-out infinite;
}
@keyframes brandPulse {
  0%, 100% { box-shadow: 0 0 16px var(--ctp-mauve), 0 0 30px rgba(203, 166, 247, 0.4); }
  50%      { box-shadow: 0 0 24px var(--ctp-mauve), 0 0 50px rgba(203, 166, 247, 0.6); }
}
#graph-overlay .graph-controls {
  display: flex;
  gap: 8px;
}

#graph-svg-wrap {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
/* subtle inner vignette above the particles */
#graph-svg-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 3;
}

/* layered canvas + svg */
#graph-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
#graph-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: grab;
}
#graph-svg:active { cursor: grabbing; }

/* Links — curved paths */
#graph-svg .link {
  stroke: rgba(180, 190, 254, 0.18);
  stroke-width: 1.1;
  fill: none;
  transition: stroke 220ms ease, stroke-width 220ms ease, stroke-opacity 220ms ease;
}
#graph-svg .link.dim { stroke-opacity: 0.05; }
#graph-svg .link.highlight {
  stroke: var(--ctp-lavender);
  stroke-width: 2.2;
  stroke-opacity: 0.92;
  stroke-dasharray: 8 6;
  animation: dashflow 22s linear infinite;
  filter: drop-shadow(0 0 4px rgba(180, 190, 254, 0.55));
}
@keyframes dashflow {
  to { stroke-dashoffset: -1000; }
}

/* Node halo — blurred circle behind the node, colored by group */
#graph-svg .node-halo {
  opacity: 0.2;
  pointer-events: none;
}
#graph-svg .node.group-concepts  .node-halo { fill: var(--grp-concepts); }
#graph-svg .node.group-entities  .node-halo { fill: var(--grp-entities); }
#graph-svg .node.group-summaries .node-halo { fill: var(--grp-summaries); }
#graph-svg .node.group-other     .node-halo { fill: var(--grp-other); }

/* Node main circle */
#graph-svg .node .node-main {
  stroke: rgba(17, 17, 27, 0.9);
  stroke-width: 1.4;
  transition: stroke-width 220ms ease;
}
#graph-svg .node.group-concepts  .node-main { fill: var(--grp-concepts); }
#graph-svg .node.group-entities  .node-main { fill: var(--grp-entities); }
#graph-svg .node.group-summaries .node-main { fill: var(--grp-summaries); }
#graph-svg .node.group-other     .node-main { fill: var(--grp-other); }

/* Node group element (d3 sets transform) */
#graph-svg .node {
  cursor: pointer;
  transition: opacity 240ms ease;
}
#graph-svg .node.dim { opacity: 0.18; }
#graph-svg .node.highlight .node-main {
  stroke: var(--fg-strong);
  stroke-width: 2.6;
}
#graph-svg .node.highlight .node-halo { opacity: 0.75; }

/* Labels — appear on hover or when big */
#graph-svg .node text {
  fill: var(--fg);
  font: 500 11px var(--font-sans);
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
  text-shadow:
    0 1px 4px rgba(17, 17, 27, 0.95),
    0 0 10px rgba(17, 17, 27, 0.8);
}
#graph-svg .node.highlight text,
#graph-svg .node.big text { opacity: 1; }

/* Staggered entry animation — driven by inline animation-delay */
#graph-svg .node-inner {
  animation: nodeIn 720ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes nodeIn {
  from { opacity: 0; transform: scale(0.35); }
  to   { opacity: 1; transform: scale(1); }
}

.graph-legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  z-index: 4;
}
.graph-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.graph-legend .legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.graph-legend .legend-dot.concepts  { background: var(--grp-concepts); }
.graph-legend .legend-dot.entities  { background: var(--grp-entities); }
.graph-legend .legend-dot.summaries { background: var(--grp-summaries); }
.graph-legend .legend-dot.other     { background: var(--grp-other); }

.graph-hint {
  position: absolute;
  top: 20px;
  right: 32px;
  font-size: 11px;
  color: var(--fg-soft);
  font-family: var(--font-mono);
  z-index: 4;
}
.graph-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(49, 50, 68, 0.7);
  border: 1px solid var(--border-med);
  border-bottom-width: 2px;
  color: var(--fg);
  font-size: 10px;
  margin: 0 2px;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.muted { color: var(--fg-muted); }
.hidden { display: none !important; }
.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--fg-soft);
  font-size: 13px;
}
.loading::after {
  content: "•";
  animation: blink 1.4s infinite;
  color: var(--accent);
  margin-left: 4px;
}
@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* subtle content transition */
article { animation: fadeUp 240ms cubic-bezier(0.22, 0.61, 0.36, 1); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* responsive: collapse right sidebar on narrow */
@media (max-width: 1200px) {
  body {
    grid-template-columns: var(--sidebar-l) 1fr;
    grid-template-areas:
      "top top"
      "left main";
  }
  #sidebar-right { display: none; }
}
@media (max-width: 800px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "main";
  }
  #sidebar-left { display: none; }
  article { padding: 24px 20px 80px; }
}
