/* ============================================================
   K2AI ATLAS — visual system
   Theme tokens live on <html data-theme="dark|light">.
   ============================================================ */

html[data-theme="dark"] {
  --bg-canvas: #1A1A1E;
  --bg-surface: #1F1F23;
  --bg-raised: #26262B;
  --bg-overlay: #2D2D33;
  --border: #3B3B41;
  --text-1: #F4F4F5;
  --text-2: #A1A1AA;
  --text-3: #6B6B74;
  --accent: #7C8CF8;
  --accent-soft: rgba(124, 140, 248, .14);
  --edge-default: #34343B;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --scrollbar: #3B3B41;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg-canvas: #F5F5F4;
  --bg-surface: #FFFFFF;
  --bg-raised: #FAFAF9;
  --bg-overlay: #FFFFFF;
  --border: #E0E0DD;
  --text-1: #1B1B1F;
  --text-2: #5C5C66;
  --text-3: #9A9AA2;
  --accent: #5B6CDB;
  --accent-soft: rgba(91, 108, 219, .12);
  --edge-default: #D6D6D2;
  --shadow: 0 8px 28px rgba(30, 30, 40, .14);
  --scrollbar: #D0D0CC;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* author display rules must never defeat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-canvas);
  color: var(--text-1);
  font-family: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI",
               -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* shared transitions — 120ms ease everywhere */
button, .chip, .legend-row, .search-result, .wikilink, .pill-btn, .icon-btn, .ctl-btn, .mode-btn {
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease,
              opacity 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

/* blur-glass chrome */
.glass {
  background: color-mix(in srgb, var(--bg-surface) 78%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
}

/* ============================================================
   TOP BAR
   ============================================================ */
#topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 0 16px;
  border-left: none; border-right: none; border-top: none;
  z-index: 60;
  flex: none;
}

.topbar-left { display: flex; align-items: center; min-width: 0; }
.topbar-center { display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; min-width: 0; }

.app-mark {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--text-3);
  text-decoration: none;
  white-space: nowrap;
}
.app-mark:hover { color: var(--text-2); text-decoration: none; }
.app-mark-glyph { flex: none; }

/* search */
.search-box {
  position: relative;
  width: 360px;
  display: flex; align-items: center;
}
.search-icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
#search-input {
  width: 100%; height: 32px;
  padding: 0 34px 0 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-1);
  font-size: 13px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search-input::placeholder { color: var(--text-3); }
.search-kbd {
  position: absolute; right: 9px;
  font-size: 10px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; background: var(--bg-surface);
  pointer-events: none;
}

.search-dropdown {
  position: absolute; top: 38px; left: 0; right: 0;
  max-height: 420px; overflow-y: auto;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
  padding: 4px;
}
.search-result {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.search-result:hover, .search-result.active { background: var(--accent-soft); }
.search-result .dot { width: 9px; height: 9px; border-radius: 50%; justify-self: center; }
.search-result-main { min-width: 0; }
.search-result-title { font-size: 13px; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-title mark { background: transparent; color: var(--accent); font-weight: 600; }
.search-result-crumb { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 14px; color: var(--text-3); font-size: 12.5px; text-align: center; }

.stats-chip {
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text-1); border-color: var(--text-3); }

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-2);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.pill-btn:hover { color: var(--text-1); border-color: var(--accent); background: var(--accent-soft); }
.dl-arrow { color: var(--accent); font-weight: 700; }

/* ============================================================
   WING CHIPS
   ============================================================ */
.wingbar {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  overflow-x: auto;
  flex: none;
  scrollbar-width: thin;
  z-index: 50;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.chip:hover { border-color: var(--text-3); color: var(--text-1); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-1);
}
.chip .chip-count { font-size: 10.5px; color: var(--text-3); }
.chip.active .chip-count { color: var(--accent); }
.chip.chip-reset { border-style: dashed; }

/* ============================================================
   STAGE / GRAPH
   ============================================================ */
#stage { position: relative; flex: 1; min-height: 0; }

#graph-stage { position: absolute; inset: 0; }
#graph-stage.hidden-stage { visibility: hidden; pointer-events: none; }

#sigma-container { position: absolute; inset: 0; background: var(--bg-canvas); }

#halo-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* subtle radial vignette over the canvas */
#vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at center,
              transparent 55%,
              color-mix(in srgb, var(--bg-canvas) 55%, transparent) 86%,
              color-mix(in srgb, black 22%, transparent) 100%);
}
html[data-theme="light"] #vignette {
  background: radial-gradient(ellipse at center,
              transparent 60%,
              color-mix(in srgb, var(--bg-canvas) 50%, transparent) 88%,
              rgba(60,60,70,.10) 100%);
}

/* ============================================================
   LEGEND (bottom-left)
   ============================================================ */
.legend {
  position: absolute;
  left: 16px; bottom: 16px;
  width: 218px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 10;
  font-size: 12px;
  user-select: none;
}

.legend-modes {
  display: flex; gap: 4px; align-items: center;
  margin-bottom: 8px;
}
.mode-btn {
  flex: 1;
  height: 24px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 11px; font-weight: 600;
  cursor: pointer;
}
.mode-btn:hover { color: var(--text-1); }
.mode-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-1);
}
.legend-help-btn {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
}
.legend-help-btn:hover { color: var(--text-1); border-color: var(--text-3); }

.legend-kinds { display: flex; flex-direction: column; gap: 1px; max-height: 232px; overflow-y: auto; }
.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
}
.legend-row:not(.static):hover { background: var(--accent-soft); color: var(--text-1); }
.legend-row.excluded { opacity: .38; }
.legend-row.excluded .dot { background: var(--text-3) !important; }
.legend-row .dot { width: 9px; height: 9px; border-radius: 50%; justify-self: center; flex: none; }
.legend-name { text-transform: capitalize; }
.legend-hint, .legend-count { font-size: 10.5px; color: var(--text-3); }

.legend-divider { height: 1px; background: var(--border); margin: 8px 2px; }

.legend-tiers .legend-row { cursor: default; }
.tier-gradient-bar {
  width: 12px; height: 5px; border-radius: 3px;
  justify-self: center;
  background: linear-gradient(90deg, #E74C3C, #F5D442, #9ACD32);
}

.legend-recent {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 6px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 12px;
}
.legend-recent:hover { color: var(--text-1); }
.legend-recent input { accent-color: var(--accent); margin: 0; }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); opacity: .65; }
  50% { box-shadow: 0 0 0 5px var(--accent-soft); opacity: 1; }
}

.legend-popover {
  position: absolute;
  left: 0; bottom: calc(100% + 8px);
  width: 252px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px;
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.5;
  z-index: 20;
}
.legend-popover h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.legend-popover p { margin: 0 0 8px; }
.legend-popover .key-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: baseline; }

/* ============================================================
   GRAPH CONTROLS (bottom-right)
   ============================================================ */
.graph-controls {
  position: absolute;
  right: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 4px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 10;
}
.ctl-btn {
  height: 28px; min-width: 28px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
}
.ctl-btn.wide { font-size: 11.5px; font-weight: 600; }
.ctl-btn:hover { background: var(--accent-soft); color: var(--text-1); }
.ctl-btn.running { color: var(--accent); border-color: var(--accent); }
.ctl-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

/* ============================================================
   NODE CARD (bottom-right float)
   ============================================================ */
.node-card {
  position: absolute;
  right: 16px; bottom: 64px;
  width: 320px;
  border-radius: 12px;
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow);
  padding: 13px 14px 12px;
  z-index: 11;
  animation: card-in 160ms ease;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.node-card-title {
  font-size: 15.5px; font-weight: 600;
  margin: 0 0 3px;
  color: var(--text-1);
  line-height: 1.3;
}
.node-card-crumb {
  font-size: 11px; color: var(--text-3);
  margin-bottom: 8px;
}
.node-card-crumb .crumb-sep { margin: 0 4px; opacity: .6; }
.node-card-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tier-badge {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 8px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .04em;
  color: #15151a;
  white-space: nowrap;
}
.node-card-counts { font-size: 11.5px; color: var(--text-2); }
.node-card-excerpt {
  font-size: 12px; color: var(--text-2);
  line-height: 1.5;
  margin: 0 0 10px;
  max-height: 72px; overflow: hidden;
}
.node-card-excerpt.loading { color: var(--text-3); font-style: italic; }
.node-card-actions { display: flex; gap: 8px; }
.node-card-actions button {
  flex: 1;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-1);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.node-card-actions button:hover { border-color: var(--accent); background: var(--accent-soft); }
.node-card-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.node-card-actions button.primary:hover { filter: brightness(1.08); }
.node-card-close {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: var(--text-3); font-size: 12px;
  cursor: pointer; border-radius: 6px;
}
.node-card-close:hover { color: var(--text-1); background: var(--accent-soft); }

/* ============================================================
   PAGE VIEW
   ============================================================ */
#page-stage {
  position: absolute; inset: 0;
  overflow-y: auto;
  background: var(--bg-canvas);
}
.page-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 32px 80px;
  display: grid;
  grid-template-columns: minmax(0, 860px) 320px;
  gap: 44px;
  justify-content: center;
}
@media (max-width: 1100px) {
  .page-shell { grid-template-columns: minmax(0, 860px); }
  .page-rail { display: none; }
}

.page-breadcrumb {
  font-size: 12px; color: var(--text-3);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.page-breadcrumb a { color: var(--text-3); }
.page-breadcrumb a:hover { color: var(--text-1); text-decoration: none; }
.page-breadcrumb .crumb-kind { font-weight: 600; }

.page-title {
  font-size: 30px; font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.2;
  color: var(--text-1);
}
.page-title-underline {
  width: 48px; height: 3px;
  border-radius: 2px;
  margin: 0 0 14px;
  background: var(--accent);
}

.page-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-2);
  margin-bottom: 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-meta .open-in-graph { font-weight: 600; }

/* article typography */
.page-article { min-width: 0; font-size: 14.5px; line-height: 1.66; color: var(--text-1); }
.page-article h2 { font-size: 21px; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.page-article h3 { font-size: 16.5px; margin: 26px 0 8px; }
.page-article h4 { font-size: 14px; margin: 20px 0 6px; color: var(--text-2); letter-spacing: .03em; text-transform: uppercase; font-size: 12px; }
.page-article p { margin: 0 0 12px; }
.page-article ul, .page-article ol { padding-left: 24px; margin: 0 0 12px; }
.page-article li { margin: 3px 0; }
.page-article blockquote {
  margin: 0 0 12px; padding: 8px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-2);
  background: var(--bg-surface);
  border-radius: 0 8px 8px 0;
}
.page-article code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12.5px;
  font-family: "Cascadia Code", "SF Mono", Consolas, monospace;
}
.page-article pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 14px;
}
.page-article pre code { background: transparent; border: none; padding: 0; }
.page-article hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }
.page-article img.md-image {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
  margin: 6px 0 14px;
}

/* tables */
.page-article table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 16px;
  font-size: 13.5px;
}
.page-article th, .page-article td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  text-align: left;
  vertical-align: top;
}
.page-article th {
  background: var(--bg-raised);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.page-article tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-surface) 55%, transparent); }

/* identity table card */
.identity-table {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  padding: 6px 14px;
  margin: 0 0 20px;
  box-shadow: var(--shadow);
}
.identity-table table { margin: 0; font-size: 13px; }
.identity-table th, .identity-table td { border: none; border-bottom: 1px solid var(--border); background: transparent !important; }
.identity-table tr:last-child td { border-bottom: none; }
.identity-table thead { display: none; }
.identity-table td:first-child {
  width: 35%;
  color: var(--text-2);
  font-weight: 600;
}

/* wikilinks */
.wikilink { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.wikilink:hover { border-bottom-color: var(--accent); text-decoration: none; }
.wikilink-ghost {
  color: var(--text-3);
  border-bottom: 1px dashed var(--text-3);
  cursor: help;
}
.wikilink-ghost:hover { color: var(--text-2); text-decoration: none; }

/* callouts */
.callout {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--bg-surface);
  margin: 0 0 14px;
  overflow: hidden;
}
.callout > summary {
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.callout > summary::-webkit-details-marker { display: none; }
.callout > summary::before { content: "▸"; font-size: 11px; transition: transform 120ms ease; color: var(--text-3); }
.callout[open] > summary::before { transform: rotate(90deg); }
.callout-body { padding: 2px 14px 10px; font-size: 13.5px; color: var(--text-2); }
.callout-body > :last-child { margin-bottom: 0; }

.callout-note, .callout-info  { border-left-color: #56B6F5; }
.callout-note > summary, .callout-info > summary { color: #56B6F5; }
.callout-tip, .callout-success { border-left-color: #2ECC71; }
.callout-tip > summary, .callout-success > summary { color: #2ECC71; }
.callout-warning, .callout-caution { border-left-color: #F5A742; }
.callout-warning > summary, .callout-caution > summary { color: #F5A742; }
.callout-danger, .callout-error, .callout-bug { border-left-color: #F56456; }
.callout-danger > summary, .callout-error > summary, .callout-bug > summary { color: #F56456; }
.callout-cite, .callout-quote { border-left-color: #B788F5; }
.callout-cite > summary, .callout-quote > summary { color: #B788F5; }
.callout-example, .callout-abstract { border-left-color: #3FC9B8; }
.callout-example > summary, .callout-abstract > summary { color: #3FC9B8; }
.callout-question, .callout-todo { border-left-color: #F5D442; }
.callout-question > summary, .callout-todo > summary { color: #F5D442; }

/* mermaid */
.mermaid-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 14px;
  overflow-x: auto;
  text-align: center;
}
.mermaid-block svg { max-width: 100%; }
.mermaid-error { color: #F56456; font-size: 12px; font-family: monospace; white-space: pre-wrap; }

/* tags */
.tag-chip {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px; font-weight: 600;
  margin: 0 5px 5px 0;
}

/* ============================================================
   PAGE RAIL
   ============================================================ */
.page-rail {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex; flex-direction: column; gap: 16px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-bottom: 20px;
}
.rail-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.rail-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.rail-card-head .rail-actions { display: flex; gap: 4px; }
.rail-card-head button, .rail-card-head a {
  font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  border-radius: 5px;
  padding: 2px 7px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  text-decoration: none;
}
.rail-card-head button:hover, .rail-card-head a:hover { color: var(--text-1); border-color: var(--text-3); }
.rail-card-head button.active { color: var(--accent); border-color: var(--accent); }

#local-graph-container { height: 230px; position: relative; background: var(--bg-canvas); }

.backlinks-list { padding: 6px; max-height: 300px; overflow-y: auto; }
.backlink-item {
  display: block;
  padding: 8px 9px;
  border-radius: 8px;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.backlink-item:hover { background: var(--accent-soft); text-decoration: none; }
.backlink-title { font-size: 13px; font-weight: 600; color: var(--text-1); display: flex; align-items: center; gap: 6px; }
.backlink-title .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.backlink-excerpt { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.rail-empty { padding: 14px; font-size: 12px; color: var(--text-3); text-align: center; }

.details-body { padding: 11px 13px; font-size: 12px; color: var(--text-2); }
.details-body .detail-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.details-body .detail-row .k { color: var(--text-3); }
.details-tags { margin-top: 8px; }

.toc-list { padding: 8px 6px; }
.toc-item {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 10px;
  border-left: 2px solid var(--border);
  text-decoration: none;
  line-height: 1.4;
}
.toc-item.toc-h3 { padding-left: 22px; }
.toc-item:hover { color: var(--text-1); text-decoration: none; }
.toc-item.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* page loading / error */
.page-loading, .page-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  padding: 100px 20px;
  color: var(--text-3);
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   OVERLAYS
   ============================================================ */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(10, 10, 14, .88);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  cursor: zoom-out;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; box-shadow: var(--shadow); }
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.4);
  color: #fff; font-size: 15px;
  cursor: pointer;
}

.hover-preview {
  position: fixed;
  width: 280px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 11px 13px;
  z-index: 150;
  pointer-events: none;
  animation: card-in 140ms ease;
}
.hover-preview-title { font-size: 13px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; display: flex; align-items: center; gap: 7px; }
.hover-preview-title .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hover-preview-body { font-size: 12px; color: var(--text-2); line-height: 1.5; max-height: 110px; overflow: hidden; }

.toast {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 9px 18px;
  font-size: 12.5px;
  color: var(--text-1);
  z-index: 300;
  animation: card-in 160ms ease;
}
