:root {
  --bg: #0d0f0e;
  --bg2: #121512;
  --bg3: #171a16;
  --surface: #1c201b;
  --surface2: #222622;
  --border: #2a2e29;
  --border2: #333733;
  --text: #d4d8d3;
  --text2: #8a9088;
  --text3: #5a5f58;
  --accent: #6bde8c;
  --accent2: #4ab86a;
  --accent-dim: rgba(107,222,140,0.12);
  --accent-dim2: rgba(107,222,140,0.06);
  --yellow: #e8d06b;
  --blue: #6baade;
  --pink: #de6b8a;
  --orange: #de956b;
  --sidebar-w: 280px;
  --header-h: 52px;
}

body.light-mode {
  --bg: #fdfdfc;
  --bg2: #f5f5f3;
  --bg3: #efefec;
  --surface: #ffffff;
  --surface2: #f0f0ed;
  --border: #e0e0db;
  --border2: #d4d4cd;
  --text: #1a1c1a;
  --text2: #4a4d4a;
  --text3: #7a7d7a;
  --accent: #2d8a4e;
  --accent2: #1e6334;
  --accent-dim: rgba(45,138,78,0.1);
  --accent-dim2: rgba(45,138,78,0.05);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── HEADER ── */
#header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  z-index: 100;
}
#header .logo {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
  white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
#header .logo-icon {
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #000; font-weight: 700;
}
.version-badge {
  font-size: 9px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-weight: 400;
}
@media (max-width: 700px) { .version-badge { display: none; } }
#search-wrap {
  flex: 1; max-width: 400px; position: relative;
}
#search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px 7px 34px;
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
#search::placeholder { color: var(--text3); }
#search:focus { border-color: var(--border2); }
#search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }

.header-pills {
  display: flex; gap: 6px; margin-left: auto;
}
.pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── LAYOUT ── */
#layout {
  display: flex;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.sidebar-section {
  border-bottom: 1px solid var(--border);
}
.sidebar-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  position: sticky; top: 0;
  background: var(--bg2);
  z-index: 1;
}
.sidebar-section-header:hover { background: var(--surface); }
.sidebar-section-header .phase-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.phase-0 .phase-tag { background: rgba(139,92,246,0.2); color: #a78bfa; }
.phase-1 .phase-tag { background: rgba(107,222,140,0.15); color: var(--accent); }
.phase-2 .phase-tag { background: rgba(107,170,222,0.15); color: var(--blue); }
.phase-3 .phase-tag { background: rgba(232,208,107,0.15); color: var(--yellow); }
.phase-4 .phase-tag { background: rgba(222,107,138,0.15); color: var(--pink); }
.phase-5 .phase-tag { background: rgba(107,213,222,0.15); color: #22d3ee; }
.phase-cap .phase-tag { background: rgba(222,149,107,0.15); color: var(--orange); }
.phase-dt .phase-tag { background: rgba(240,171,252,0.15); color: #f0abfc; }

.sidebar-section-header .section-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-section-header .chevron {
  color: var(--text3);
  font-size: 10px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.sidebar-section.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-module-group,
.sidebar-section.collapsed .sidebar-file { display: none; }
.sidebar-section.collapsed .quick-link-item { display: none; }

/* Quick Links */
.quick-link-item { cursor: pointer; }
.quick-link-item:hover .file-name { color: var(--accent); }

.sidebar-module-group { }
.sidebar-module-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  padding: 8px 14px 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-file {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 24px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s;
  user-select: none;
  position: relative;
}
.sidebar-file:hover { background: var(--surface); }
.sidebar-file.active {
  background: var(--accent-dim);
}
.sidebar-file.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}
.sidebar-file .file-icon {
  font-size: 11px;
  flex-shrink: 0;
  color: var(--text3);
}
.sidebar-file.moc-file .file-icon { color: var(--accent2); }
.sidebar-file .file-name {
  font-size: 12px;
  color: var(--text2);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.sidebar-file.active .file-name { color: var(--accent); }

/* drag states */
.sidebar-file.drag-over {
  background: var(--accent-dim2);
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}
.sidebar-file[draggable="true"] { cursor: grab; }
.sidebar-file[draggable="true"]:active { cursor: grabbing; }
.drag-ghost {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--accent);
  pointer-events: none;
  z-index: 9999;
  opacity: 0.9;
  font-family: 'IBM Plex Mono', monospace;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* drop zone when dragging over section header */
.sidebar-section-header.drop-target {
  background: var(--accent-dim2);
  outline: 1px dashed var(--accent);
}

/* ── MAIN ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* TABS */
#tabs-bar {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  min-height: 38px;
  flex-shrink: 0;
}
#tabs-bar::-webkit-scrollbar { display: none; }

.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px;
  height: 38px;
  white-space: nowrap;
  cursor: pointer;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  transition: background 0.1s;
  user-select: none;
}
.tab:hover { background: var(--surface); }
.tab.active {
  background: var(--bg3);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
}
.tab .tab-name {
  font-size: 12px;
  color: var(--text2);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab.active .tab-name { color: var(--text); }
.tab .tab-close {
  font-size: 14px;
  color: var(--text3);
  line-height: 1;
  border-radius: 3px;
  padding: 1px 3px;
  transition: all 0.1s;
}
.tab .tab-close:hover { background: var(--surface2); color: var(--text); }

/* WELCOME SCREEN */
#welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px;
  text-align: center;
}
.welcome-logo {
  width: 64px; height: 64px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.welcome-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.welcome-sub {
  font-size: 13px;
  color: var(--text2);
  max-width: 400px;
  line-height: 1.7;
}
.welcome-stats {
  display: flex; gap: 24px;
  margin-top: 8px;
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
}
.stat-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
}
.stat-label {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.welcome-hint {
  font-size: 12px;
  color: var(--text3);
  font-family: 'IBM Plex Mono', monospace;
}

/* CONTENT AREA */
#content-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#content-pane {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}
#content-pane::-webkit-scrollbar { width: 6px; }
#content-pane::-webkit-scrollbar-track { background: transparent; }
#content-pane::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* NOTE HEADER */
#note-header {
  padding: 28px 40px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.note-phase-breadcrumb {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.note-phase-breadcrumb span { color: var(--text2); }
.note-title-h1 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 12px;
}
.note-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.meta-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text3);
}
.meta-tag.status-mature { border-color: rgba(107,222,140,0.3); color: var(--accent2); background: var(--accent-dim2); }
.meta-tag.status-draft { border-color: rgba(232,208,107,0.3); color: var(--yellow); }
.meta-tag.meta-date { border-color: var(--border); color: var(--text3); font-variant-numeric: tabular-nums; }

/* MARKDOWN CONTENT */
#note-body {
  padding: 28px 40px 60px;
  max-width: 800px;
}
#note-body h1 { display: none; }
#note-body h2 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 32px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
#note-body h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 8px;
}
#note-body h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin: 16px 0 6px;
}
#note-body p {
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.75;
  font-size: 13.5px;
}
#note-body ul, #note-body ol {
  margin: 8px 0 12px 20px;
  color: var(--text);
}
#note-body li {
  margin-bottom: 4px;
  line-height: 1.7;
  font-size: 13.5px;
}
#note-body li p { margin-bottom: 4px; }
#note-body strong { color: var(--text); font-weight: 600; }
#note-body em { color: var(--text2); font-style: italic; }
#note-body code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent);
}
#note-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 12px 0 16px;
}
#note-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}
#note-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 13px;
}
#note-body th {
  background: var(--surface);
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#note-body td {
  padding: 9px 14px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
  line-height: 1.6;
}
#note-body tr:nth-child(even) td { background: var(--surface); }
#note-body blockquote {
  border-left: 2px solid var(--accent);
  margin: 12px 0;
  padding: 8px 16px;
  background: var(--accent-dim2);
  border-radius: 0 6px 6px 0;
}
#note-body blockquote p { color: var(--text2); font-size: 13px; margin: 0; }
#note-body a { color: var(--blue); text-decoration: none; }
#note-body a:hover { text-decoration: underline; }
#note-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* SEARCH RESULTS */
#search-results {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
#search-results::-webkit-scrollbar { width: 6px; }
#search-results::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
.search-header {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 16px;
}
.search-result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.search-result-item:hover {
  border-color: var(--border2);
  background: var(--surface2);
}
.search-result-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 13px;
}
.search-result-path {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 6px;
}
.search-result-snippet {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}
.search-result-snippet mark {
  background: rgba(107,222,140,0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

/* DRAG DROP OVERLAY */
.drop-indicator {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 50;
  border-radius: 1px;
  box-shadow: 0 0 6px var(--accent);
}

/* RESIZE HANDLE */
#resize-handle {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.2s;
}
#resize-handle:hover { background: var(--accent); }

/* EMPTY STATE */
.empty-state {
  padding: 60px 40px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* KEYBOARD SHORTCUT BADGE */
.kbd {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text3);
}

/* scrollbar for main */
#content-pane { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

/* TOOLTIP */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  pointer-events: none;
  z-index: 200;
}

/* animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.animate-in { animation: fadeIn 0.2s ease forwards; }

/* UI ENHANCEMENTS */
.copy-code-btn {
  position: absolute; top: 8px; right: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; padding: 2px 8px;
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text3); border-radius: 4px;
  cursor: pointer; opacity: 0; transition: all 0.2s;
  z-index: 10;
}
pre:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--bg3); }

.toc-item {
  font-size: 12px; color: var(--text2);
  padding: 4px 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all 0.15s;
  border-radius: 4px;
}
.toc-item:hover { color: var(--accent); padding-left: 4px; background: var(--accent-dim2); }
.toc-h2 { font-weight: 500; margin-top: 4px; }
.toc-h3 { padding-left: 12px; font-size: 11px; color: var(--text3); }

/* graph view */
#graph-svg { background: var(--bg); }
#graph-svg .node { cursor: pointer; }
#graph-svg .node circle { stroke-width: 1.5px; transition: r 0.15s; }
#graph-svg .node text { font-family: 'IBM Plex Mono', monospace; font-size: 9px; fill: var(--text2); pointer-events: none; }
#graph-svg .link { stroke: var(--border2); stroke-opacity: 0.3; }
#graph-svg .link.highlighted { stroke: var(--accent); stroke-opacity: 0.8; stroke-width: 1.5px; }
#graph-svg .node.dimmed circle { opacity: 0.15; }
#graph-svg .node.dimmed text { opacity: 0.1; }
#graph-svg .link.dimmed { stroke-opacity: 0.05; }
#graph-svg .node.search-match circle { stroke-width: 3px; stroke-opacity: 1; filter: drop-shadow(0 0 4px currentColor); }
#graph-svg .node.search-match text { fill: var(--text) !important; font-size: 11px !important; }
.graph-legend-item { display: flex; align-items: center; gap: 4px; font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text3); cursor: default; }
.graph-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.graph-ctrl-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; padding: 4px 10px;
  border-radius: 4px; border: 1px solid var(--border);
  background: rgba(13,15,14,0.9); color: var(--text3);
  cursor: pointer; transition: all 0.15s;
}
.graph-ctrl-btn:hover { border-color: var(--accent); color: var(--accent); }
.graph-ctrl-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
#canvas-tooltip {
  position: fixed; z-index: 500; pointer-events: none;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 8px 12px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--text2); box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  white-space: nowrap; line-height: 1.6;
}
#canvas-hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 10; pointer-events: none;
  background: var(--bg2); border: 1px solid var(--yellow);
  border-radius: 20px; padding: 6px 16px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--yellow); white-space: nowrap;
}
#canvas-sim-stats, #canvas-sim-stats-b {
  position: absolute; top: 10px; left: 10px; z-index: 10; pointer-events: none;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 8px 12px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--text3); line-height: 1.8;
}
/* Canvas split-view splitter */
#canvas-splitter {
  width: 6px; cursor: col-resize;
  background: var(--border);
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative; z-index: 5;
}
#canvas-splitter:hover, #canvas-splitter.dragging {
  background: var(--accent);
}
#canvas-splitter::after {
  content: ''; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 32px;
  border-radius: 1px;
  background: var(--text3); opacity: 0.5;
}
/* Comparison trade-off table */
#canvas-comparison-table {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 12px 20px; max-height: 180px; overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
}
#canvas-comparison-table table {
  width: 100%; border-collapse: collapse;
}
#canvas-comparison-table th {
  text-align: left; padding: 6px 12px;
  font-size: 10px; text-transform: uppercase;
  color: var(--text3); border-bottom: 1px solid var(--border);
  letter-spacing: 0.04em;
}
#canvas-comparison-table td {
  padding: 6px 12px; color: var(--text2);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
#canvas-comparison-table tr td:first-child {
  color: var(--text3); font-size: 10px; text-transform: uppercase;
}
#canvas-comparison-table .metric-better {
  color: var(--accent); font-weight: 600;
}
#canvas-comparison-table .metric-worse {
  color: var(--pink);
}
#graph-minimap svg { width: 100%; height: 100%; }
#graph-minimap .minimap-viewport {
  fill: rgba(107,222,140,0.08);
  stroke: var(--accent);
  stroke-width: 1.5;
  rx: 2;
}

/* export button */
.pill-export { border-color: var(--accent-dim); color: var(--accent2); }
.pill-export:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.pill-export.exporting { pointer-events: none; opacity: 0.6; }

/* study button */
.pill-study { border-color: rgba(232,208,107,0.25); color: var(--yellow); }
.pill-study:hover { background: rgba(232,208,107,0.1); border-color: var(--yellow); }

/* study screen */
#study-container {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  overflow-y: auto;
}
#study-header {
  display: flex; align-items: center; gap: 12px;
}
#study-progress-bar {
  flex: 1; height: 4px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}
#study-progress-fill {
  height: 100%; width: 0%;
  background: var(--yellow);
  border-radius: 2px;
  transition: width 0.3s ease;
}
#study-progress-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--text3);
  white-space: nowrap;
}
#study-note-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#study-prompt {
  font-size: 16px; line-height: 1.7;
  color: var(--text);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
#study-answer {
  font-size: 13.5px; line-height: 1.75;
  color: var(--text2);
  padding: 20px 24px;
  background: var(--accent-dim2);
  border: 1px solid rgba(107,222,140,0.15);
  border-radius: 10px;
  border-left: 3px solid var(--accent2);
}
#study-answer h2 { display: none; }
#study-answer h3 { font-size: 13px; font-weight: 600; color: var(--text); margin: 12px 0 6px; }
#study-answer p { margin-bottom: 8px; }
#study-answer ul, #study-answer ol { margin: 4px 0 8px 18px; }
#study-answer li { margin-bottom: 3px; font-size: 13px; }
#study-answer code { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--accent); }
#study-actions {
  display: flex; gap: 10px; align-items: center;
}
.study-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; padding: 8px 18px;
  border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.study-btn-primary {
  background: var(--accent-dim); border-color: var(--accent);
  color: var(--accent);
}
.study-btn-primary:hover { background: rgba(107,222,140,0.2); }
.study-btn-secondary {
  background: transparent; color: var(--text2);
}
.study-btn-secondary:hover { background: var(--surface); color: var(--text); }
#study-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: auto; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.study-filter-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.study-phase-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; padding: 3px 8px;
  border-radius: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--text3);
  cursor: pointer; transition: all 0.15s;
}
.study-phase-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.study-phase-btn:hover { border-color: var(--text2); color: var(--text2); }
.study-complete {
  text-align: center; padding: 60px 20px;
}
.study-complete-icon { font-size: 48px; margin-bottom: 16px; }
.study-complete-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px; font-weight: 600; color: var(--accent);
  margin-bottom: 8px;
}
.study-complete-sub { font-size: 13px; color: var(--text2); }

/* mermaid diagrams */
.mermaid-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 16px;
  margin: 16px 0;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  cursor: zoom-in;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.mermaid-wrapper:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.mermaid-wrapper svg { max-width: 100%; height: auto; }

/* copy SVG button on hover */
.mermaid-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 2;
}
.mermaid-wrapper:hover .mermaid-copy-btn { opacity: 1; }
.mermaid-copy-btn:hover { background: var(--surface2); color: var(--accent); border-color: var(--accent); }
.mermaid-copy-btn.copied { color: var(--accent); }

/* overflow fade indicator */
.mermaid-wrapper.has-overflow::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--surface));
  border-radius: 0 8px 8px 0;
  pointer-events: none;
}

/* lazy loading placeholder */
.mermaid-placeholder {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 40px 16px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  min-height: 120px;
}

/* modal toolbar */
#mermaid-modal-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
}
.mm-tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: 'IBM Plex Mono', monospace;
}
.mm-tool-btn:hover { background: var(--surface); border-color: var(--border); color: var(--accent); }
.mm-tool-btn:active { transform: scale(0.92); }
.mm-zoom-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text2);
  min-width: 38px;
  text-align: center;
}
.mm-tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* modal SVG container for zoom/pan */
#mermaid-modal-svg {
  transform-origin: center center;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mermaid-modal-svg svg {
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  transition: none;
}
#mermaid-modal-close:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
}
#mermaid-modal-close:active {
  transform: scale(0.95);
}

/* diagram error UX */
.mermaid-error {
  border: 1px solid var(--pink);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}
.mermaid-error-hint {
  font-size: 13px;
  color: var(--pink);
  margin-bottom: 8px;
}
.mermaid-error-toggle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
}
.mermaid-error-toggle:hover { color: var(--text2); }
.mermaid-error-raw {
  display: none;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text3);
  white-space: pre-wrap;
  font-family: 'IBM Plex Mono', monospace;
}
.mermaid-error-link {
  display: inline-block;
  margin-top: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}
.mermaid-error-link:hover { text-decoration: underline; }

/* study keyboard hints */
.study-keyboard-hints {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  text-align: center;
  margin-top: 12px;
  letter-spacing: 0.02em;
}
.study-keyboard-hints kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  font-size: 10px;
}

/* mobile hamburger */
#mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
#mobile-toggle:hover { background: var(--surface); color: var(--text); }
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}

/* responsive */
@media (max-width: 900px) {
  #header { gap: 8px; padding: 0 12px; }
  #search-wrap { max-width: 200px; }
  .logo-text { display: none; }
}

@media (max-width: 768px) {
  #mobile-toggle { display: block; }
  #sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 280px !important;
    min-width: 280px !important;
  }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar.mobile-open ~ #sidebar-overlay { display: block !important; }
  #resize-handle { display: none; }
  #note-body, #note-header { padding-left: 16px; padding-right: 16px; }
  #note-body { max-width: 100%; }
  .note-title-h1 { font-size: 18px; }

  .header-pills {
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: -4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    justify-content: flex-start;
  }
  .header-pills::-webkit-scrollbar { display: none; }

  .pill {
    padding: 3px 8px;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .tab .tab-name { max-width: 100px; }
  #search { font-size: 14px; }
  .welcome-stats { flex-wrap: wrap; gap: 12px; }
  .stat-box { padding: 12px 18px; }

  /* mobile diagram improvements */
  .mermaid-wrapper { min-height: 120px; padding: 16px 12px; }
  .mermaid-wrapper::before {
    content: 'Tap to expand';
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    color: var(--text3);
    opacity: 0.7;
    pointer-events: none;
  }
  .mermaid-copy-btn { display: none; }
  #mermaid-modal-toolbar { top: 8px; left: 8px; padding: 2px 4px; }
  .mm-tool-btn { width: 36px; height: 36px; }

  /* Hide note TOC on mobile */
  #note-toc { display: none !important; }

  /* ── CANVAS MOBILE LAYOUT ── */
  #canvas-screen { flex-direction: column !important; }
  #canvas-palette {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    max-height: 56px;
    flex-direction: row !important;
    overflow: hidden;
  }
  #canvas-palette > div:first-child { display: none; }
  #palette-list {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 6px 8px !important;
    gap: 6px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #palette-list::-webkit-scrollbar { display: none; }
  #palette-list .palette-item {
    flex-shrink: 0 !important;
    padding: 6px 10px !important;
    margin-bottom: 0 !important;
    font-size: 11px !important;
    white-space: nowrap;
  }
  #canvas-props {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 40vh;
    border-left: none !important;
    border-top: 1px solid var(--border);
    z-index: 60;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
  }
  #canvas-toolbar {
    flex-wrap: wrap !important;
    padding: 8px !important;
    gap: 6px !important;
  }
  #canvas-toolbar .graph-ctrl-btn {
    padding: 4px 8px !important;
    font-size: 10px !important;
  }
  #canvas-scale-control {
    margin-left: 0 !important;
    width: 100%;
    justify-content: center;
  }
}

/* ── SIDEBAR FILTER ── */
#sidebar-filter-wrap {
  position: relative;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
}
#sidebar-filter {
  flex: 1;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text);
  outline: none;
  width: 100%;
}
#sidebar-filter:focus { border-color: var(--accent); }
#sidebar-filter::placeholder { color: var(--text3); }
.sidebar-filter-clear {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.sidebar-filter-clear:hover { color: var(--text); }
.sidebar-filter-empty {
  padding: 20px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  text-align: center;
}

/* ── PHASE PROGRESS BADGE ── */
.phase-progress {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--accent2);
  background: var(--accent-dim2);
  border: 1px solid rgba(107,222,140,0.2);
  border-radius: 10px;
  padding: 1px 6px;
  flex-shrink: 0;
  margin-right: 4px;
}

/* ── STARRED SIDEBAR SECTION ── */
.sidebar-section.starred .starred-tag {
  background: rgba(232,208,107,0.2);
  color: var(--yellow);
}

/* ── COMPLETED NOTES ── */
.sidebar-file.completed .file-name {
  color: var(--text3);
}
.sidebar-file.completed .file-icon {
  color: var(--accent2);
}
.file-done-dot {
  font-size: 10px;
  color: var(--accent2);
  flex-shrink: 0;
}
.file-bookmark-dot {
  font-size: 10px;
  color: var(--yellow);
  flex-shrink: 0;
}

/* ── NOTE META ACTION BUTTONS ── */
.meta-action-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}
.meta-action-btn:hover { border-color: var(--border2); color: var(--text2); }
.btn-bookmark.active { color: var(--yellow); border-color: rgba(232,208,107,0.4); background: rgba(232,208,107,0.08); }
.btn-complete.active { color: var(--accent2); border-color: rgba(107,222,140,0.4); background: var(--accent-dim2); }
.btn-study-toggle.active { color: var(--blue); border-color: rgba(107,170,222,0.4); background: rgba(107,170,222,0.08); }

/* ── STUDY MODE REVEAL ── */
.study-revealable {
  position: relative;
}
.study-revealable:not(.revealed) > *:not(.study-blur-overlay) {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
}
.study-revealable.revealed > * { filter: none; user-select: auto; pointer-events: auto; }
.study-blur-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  background: rgba(13,15,14,0.15);
  border-radius: 8px;
}
.light-mode .study-blur-overlay { background: rgba(253,253,252,0.15); }
.study-reveal-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: var(--bg2);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
  z-index: 6;
}
.study-reveal-btn:hover { background: var(--accent-dim); }

/* ── READING TIME TAG ── */
.meta-tag.meta-readtime {
  border-color: rgba(107,170,222,0.3);
  color: var(--blue);
}

/* ── COMPLETED STAT BOX ── */
.stat-box.stat-box-accent .stat-num { color: var(--accent); }
.stat-box.stat-box-accent .stat-label { color: var(--accent2); }

/* ── STUDY RATING BUTTONS ── */
.study-rating-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 4px;
}
.study-btn-again {
  border-color: rgba(222,107,138,0.5);
  color: var(--pink);
}
.study-btn-again:hover { background: rgba(222,107,138,0.1); }
.study-btn-hard {
  border-color: rgba(232,208,107,0.5);
  color: var(--yellow);
}
.study-btn-hard:hover { background: rgba(232,208,107,0.1); }
.study-btn-easy {
  border-color: rgba(107,222,140,0.5);
  color: var(--accent);
}
.study-btn-easy:hover { background: var(--accent-dim); }

/* ── STUDY DUE BADGE ── */
.study-due-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pink);
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  font-family: 'IBM Plex Mono', monospace;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1.4;
}

/* ── WELCOME FOOTER ── */
#welcome-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  text-align: center;
}
#welcome-footer a { color: var(--accent2); text-decoration: none; }
#welcome-footer a:hover { color: var(--accent); text-decoration: underline; }
#welcome-footer .footer-sep { margin: 0 6px; opacity: 0.4; }

/* ── ONBOARDING MODAL ── */
#onboarding-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}
#onboarding-modal {
  max-width: 480px; width: 100%;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.onboarding-step-dots {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 24px;
}
.onboarding-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border2); transition: all 0.2s;
}
.onboarding-dot.active { background: var(--accent); transform: scale(1.3); }
.onboarding-title {
  font-size: 20px; color: var(--text); text-align: center;
  margin-bottom: 12px; line-height: 1.3;
}
.onboarding-body {
  font-size: 13px; color: var(--text2); line-height: 1.6;
  text-align: center; margin-bottom: 28px;
}
.onboarding-body kbd {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px;
}
.onboarding-actions {
  display: flex; gap: 12px; justify-content: center;
}
.onboarding-btn {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  padding: 10px 24px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); transition: all 0.15s;
}
.onboarding-btn-next {
  background: var(--accent); color: var(--bg); border-color: var(--accent);
  font-weight: 600;
}
.onboarding-btn-next:hover { opacity: 0.9; }
.onboarding-btn-back {
  background: none; color: var(--text3);
}
.onboarding-btn-back:hover { color: var(--text); border-color: var(--border2); }

/* ── ARIA FOCUS STYLES ── */
.sidebar-file:focus-visible,
.tab:focus-visible,
.pill:focus-visible,
.graph-ctrl-btn:focus-visible,
.meta-action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── PRINT-FRIENDLY ── */
@media print {
  #header, #sidebar, #sidebar-overlay, #resize-handle,
  #tabs-bar, #note-toc, #canvas-tooltip, #mermaid-modal,
  #onboarding-overlay, .meta-action-btn, .copy-code-btn,
  #welcome-footer, .study-blur-overlay { display: none !important; }

  body, .light-mode { background: #fff !important; color: #222 !important; }

  #layout { display: block !important; }
  #main { margin: 0 !important; padding: 0 !important; }
  #content-area { overflow: visible !important; }
  #note-screen { display: block !important; overflow: visible !important; }
  #content-pane { overflow: visible !important; }

  #note-header { margin-bottom: 16px; }
  .note-title-h1 { font-size: 22px; color: #000; }
  .note-phase-breadcrumb { color: #666; }
  #note-body { font-size: 12pt; line-height: 1.6; }
  #note-body h2 { page-break-after: avoid; }
  #note-body pre { page-break-inside: avoid; border: 1px solid #ddd; }
  #note-body table { page-break-inside: avoid; }
  #note-body a { color: #222; text-decoration: underline; }

  .study-revealable { filter: none !important; }
  .study-revealable > * { filter: none !important; pointer-events: auto !important; user-select: auto !important; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Narrative HUD */
#narrative-hud {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  background: rgba(18, 21, 18, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#narrative-hud.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-20px);
}
#hud-era {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
#hud-scale {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}
#hud-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* Chronicles Sidebar Tab */
.chronicle-item {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.chronicle-item:hover {
  border-color: var(--accent2);
  background: var(--accent-dim2);
}
.chronicle-item.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.chronicle-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}
.chronicle-desc {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}

/* Evolution Slider Enhancements */
#canvas-scale-control {
  transition: all 0.3s;
}
#canvas-scale-control:hover {
  border-color: var(--accent);
}
#canvas-scale-slider {
  accent-color: var(--accent);
}

#chronicles-slider-wrap {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  background: rgba(18, 21, 18, 0.9);
  padding: 12px 24px;
  border-radius: 40px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center; gap: 16px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#chronicles-slider-wrap.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}
#evolution-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
#slider-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  min-width: 80px;
  text-align: right;
}

/* Node Pulse Animation */
.node-pulse rect {
  animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
  0% { stroke-width: 2px; stroke: var(--border); }
  50% { stroke-width: 4px; stroke: var(--accent); }
  100% { stroke-width: 2px; stroke: var(--border); }
}

/* ── Interactive visualizations (js/viz.js) ─────────────────────────────── */
.viz-widget {
  margin: 20px 0;
  padding: 16px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-family: 'IBM Plex Mono', monospace;
}
.viz-fallback { color: var(--text); opacity: 0.6; font-size: 12px; }
.viz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.viz-badge {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); border: 1px solid var(--accent);
  border-radius: 4px; padding: 1px 6px; opacity: 0.9;
}
.viz-title { font-size: 14px; font-weight: 600; color: var(--text); }
.viz-sub { font-size: 12px; color: var(--text); opacity: 0.72; margin-bottom: 12px; line-height: 1.4; }
.viz-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.viz-btn {
  font-family: inherit; font-size: 12px; cursor: pointer;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 5px 11px;
  transition: background 0.15s, transform 0.05s;
}
.viz-btn:hover { background: var(--accent); color: var(--bg); }
.viz-btn:active { transform: translateY(1px); }
.viz-btn-danger { color: var(--pink); border-color: var(--pink); background: transparent; }
.viz-btn-danger:hover { background: var(--pink); color: var(--bg); }
.viz-btn-ghost { color: var(--text); border-color: var(--border); background: transparent; }
.viz-btn-ghost:hover { background: var(--border); color: var(--text); }
.viz-btn-toggle { color: var(--text); border-color: var(--border); background: transparent; }
.viz-btn-toggle.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.viz-select {
  font-family: inherit; font-size: 12px; padding: 5px 8px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.viz-slider-group { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 6px 0 4px; }
.viz-slider-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text); margin: 4px 0; }
.viz-slider-label { opacity: 0.8; min-width: 96px; }
.viz-slider { accent-color: var(--accent); cursor: pointer; }
.viz-slider-val { color: var(--accent); font-weight: 600; min-width: 30px; }
.viz-canvas-wrap {
  display: flex; justify-content: center; margin: 12px 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px;
}
.viz-svg { width: 100%; max-width: 340px; height: auto; }
.viz-canvas-wrap canvas { max-width: 100%; }
.viz-stat { font-size: 12px; color: var(--text); line-height: 1.55; margin-top: 8px; }
.viz-stat b { color: var(--accent); }
.viz-muted { opacity: 0.62; }
.viz-note {
  font-size: 11px; color: var(--text); opacity: 0.7; line-height: 1.5;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
}
.viz-result { font-size: 12px; color: var(--text); margin-top: 10px; min-height: 18px; line-height: 1.5; }
.viz-result code, .viz-stat code { background: var(--accent-dim); color: var(--accent); padding: 1px 5px; border-radius: 4px; }
.viz-yes { color: var(--accent); font-weight: 600; }
.viz-no { color: var(--pink); font-weight: 600; }
.viz-maybe { color: var(--yellow); font-weight: 600; }
.viz-input {
  font-family: inherit; font-size: 12px; padding: 5px 8px; width: 120px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
}
.viz-bits { display: flex; flex-wrap: wrap; gap: 3px; margin: 12px 0; justify-content: center; }
.viz-bit {
  width: 20px; height: 20px; border-radius: 3px;
  background: var(--bg); border: 1px solid var(--border);
  transition: background 0.2s, transform 0.1s;
}
.viz-bit.on { background: var(--accent); border-color: var(--accent); }
.viz-bit.hl { outline: 2px solid var(--yellow); outline-offset: 1px; transform: scale(1.12); }
.viz-log { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.viz-log-line { font-size: 11px; }
.viz-log-line.ok { color: var(--accent); }
.viz-log-line.bad { color: var(--pink); }
