/* ============================================================
   RL-for-LLMs Wiki Reader — styles
   Editorial palette borrowed from the project dashboard.
   ============================================================ */

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

:root {
  --bg: #fafafa;
  --bg-soft: #f4f4f4;
  --bg-card: #ffffff;
  --bg-code: #f6f7f9;
  --border: #ddd;
  --border-soft: #eee;
  --ink: #1a1a1a;
  --ink-2: #2a2a2a;
  --ink-3: #444;
  --muted: #555;
  --muted-2: #777;
  --muted-3: #888;
  --muted-4: #999;
  --muted-5: #aaa;
  --accent: #0f3787;        /* deep editorial blue */
  --accent-deep: #0a275f;
  --accent-soft: #dde6f5;
  --accent-hover-row: #c8d6ee;
  --good: #1c7c3f;
  --warn: #9a6b00;
  --danger: #a12d2d;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.03);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", "Helvetica Neue", system-ui, sans-serif;
  --sidebar-w: 280px;
  --aside-w: 248px;
}

[data-theme="dark"] {
  --bg: #15171a;
  --bg-soft: #1b1e22;
  --bg-card: #1e2228;
  --bg-code: #14181d;
  --border: #2e343c;
  --border-soft: #262b31;
  --ink: #e9ecf0;
  --ink-2: #dfe3e8;
  --ink-3: #c4cad2;
  --muted: #aab2bd;
  --muted-2: #8b94a0;
  --muted-3: #79828e;
  --muted-4: #69707b;
  --muted-5: #585f69;
  --accent: #8fb2f0;
  --accent-deep: #b6cdf7;
  --accent-soft: #20304d;
  --accent-hover-row: #28395a;
  --good: #6fcf8f;
  --warn: #e0b15a;
  --danger: #e08585;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 2px 10px rgba(0,0,0,0.25);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; cursor: pointer; min-width: 0; }
.brand .logo {
  font-family: var(--mono); font-weight: 600; font-size: 16px;
  letter-spacing: 0.5px; color: var(--ink); white-space: nowrap;
}
.brand .logo .dot { color: var(--accent); }
.brand .tag {
  font-size: 11.5px; color: var(--muted-2); font-weight: 300;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.counts {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--muted-2); letter-spacing: 0.3px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.counts .n { color: var(--accent); font-weight: 600; }
.counts .sep { color: var(--muted-4); margin: 0 8px; }
.topbar .spacer { flex: 1 1 auto; }
.toolbar { display: flex; align-items: center; gap: 7px; }
.btn {
  font-family: var(--mono); font-size: 10.5px; font-weight: 400; letter-spacing: 0.4px;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg-card); color: var(--muted); cursor: pointer;
  transition: all .15s; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { border-color: var(--muted-3); color: var(--ink); }
.icon-btn { padding: 5px 8px; font-size: 13px; line-height: 1; }
/* internal nav (sources) — tinted to read as primary, not an external link */
.btn-sources { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; font-weight: 500; }
.btn-sources:hover { background: var(--accent-hover-row); color: var(--accent-deep); border-color: transparent; }
.btn-sources.active { background: var(--accent); color: #fff; }
[data-theme="dark"] .btn-sources.active { color: #0b1220; }

/* ── Mobile sidebar toggle ─────────────────────────────── */
.menu-toggle { display: none; }

/* ── Layout ────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 1180px) {
  .layout.has-aside {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--aside-w);
  }
}

/* ── Sidebar (navigation) ──────────────────────────────── */
.sidebar {
  position: sticky; top: 53px; align-self: start;
  height: calc(100vh - 53px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 16px 14px 40px;
  background: var(--bg);
}
/* sidebar section header — "Topics" (the first-class citizen) */
.side-head {
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-2); margin: 2px 2px 12px;
}

.search-wrap { position: relative; margin-bottom: 16px; }
.search {
  width: 100%; font-family: var(--sans); font-size: 13px;
  padding: 8px 44px 8px 28px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card); color: var(--ink);
}
.search:focus { outline: none; border-color: var(--accent); }
.search-wrap::before {
  content: "⌕"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted-3); font-size: 15px;
}
/* the one global-search affordance: click (or ⌘K) → command palette */
.search-k {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--muted-3);
  cursor: pointer; transition: all .12s;
}
.search-k:hover { border-color: var(--accent); color: var(--accent-deep); }

.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted-3);
  padding: 4px 8px; margin-bottom: 2px;
  display: flex; justify-content: space-between; align-items: center;
}
.nav-group-title .c { color: var(--muted-4); font-weight: 500; }
.nav-item {
  display: block; padding: 5px 9px; border-radius: 5px;
  font-size: 12.5px; color: var(--ink-3); cursor: pointer;
  line-height: 1.35; transition: background .12s, color .12s;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--bg-soft); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent-deep);
  border-left-color: var(--accent); font-weight: 500;
}
.nav-item .ni-sub {
  display: block; font-family: var(--mono); font-size: 9.5px;
  color: var(--muted-4); margin-top: 1px; letter-spacing: 0.2px;
}
.nav-empty { color: var(--muted-4); font-size: 11.5px; padding: 8px; font-style: italic; }
.mini-spin { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; margin-right: 4px;
  border: 1.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── Main content ──────────────────────────────────────── */
.main { min-width: 0; padding: 26px 38px 80px; }
@media (max-width: 760px) { .main { padding: 20px 18px 60px; } }

.crumbs {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted-3);
  letter-spacing: 0.3px; margin-bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.crumbs a { color: var(--muted-2); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--muted-5); }

/* doc header */
.doc-head { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.doc-kicker {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 8px;
}
.doc-title {
  font-family: var(--mono); font-weight: 600; font-size: 26px; line-height: 1.2;
  color: var(--ink); letter-spacing: -0.2px;
}
.doc-meta-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 12px; }
.doc-authors { font-size: 12.5px; color: var(--muted); }
.doc-sub { font-size: 12px; color: var(--muted-2); font-family: var(--mono); }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.4px;
  padding: 2.5px 8px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--muted); text-transform: uppercase;
  white-space: nowrap;
}
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-4); }
.badge.mat-comprehensive { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.badge.mat-comprehensive .b-dot { background: var(--good); }
.badge.mat-developing { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.badge.mat-developing .b-dot { background: var(--warn); }
.badge.mat-stub { color: var(--muted-2); }
.badge.mat-stub .b-dot { background: var(--muted-4); }
.badge.type { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }

/* ── Prose (rendered markdown) ─────────────────────────── */
.prose { font-size: 14.5px; line-height: 1.75; color: var(--ink-2); max-width: 860px; }
.prose > *:first-child { margin-top: 0; }
.prose h1 { display: none; } /* title handled by doc-head */
.prose h2 {
  font-family: var(--mono); font-size: 19px; font-weight: 600; color: var(--ink);
  margin: 34px 0 12px; padding-top: 6px; letter-spacing: -0.1px;
  scroll-margin-top: 70px;
}
.prose h3 {
  font-family: var(--mono); font-size: 15.5px; font-weight: 600; color: var(--ink-2);
  margin: 26px 0 10px; scroll-margin-top: 70px;
}
.prose h4 { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 20px 0 8px; scroll-margin-top: 70px; }
.prose h2 .anchor, .prose h3 .anchor, .prose h4 .anchor {
  opacity: 0; margin-left: 8px; font-size: 0.6em; vertical-align: middle;
  transition: opacity .12s; text-decoration: none; border-bottom: none; cursor: pointer;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 0.55; }
.prose .anchor:hover { opacity: 1 !important; }

/* page-level "copy link" button in the doc header */
.share-btn {
  margin-left: 12px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.4px;
  padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card);
  color: var(--muted-2); cursor: pointer; transition: all .12s; text-transform: none; vertical-align: middle;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent-deep); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--bg-card); font-family: var(--mono); font-size: 11.5px;
  padding: 8px 16px; border-radius: 6px; box-shadow: var(--shadow); z-index: 300;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
[data-theme="dark"] #toast { background: var(--accent); color: #0b1220; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* source hovercard */
#hovercard {
  position: fixed; z-index: 250; max-width: 340px; pointer-events: none;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18); padding: 10px 13px;
  opacity: 0; transition: opacity .12s; font-family: var(--sans);
}
#hovercard.show { opacity: 1; }
#hovercard .hc-title { font-size: 13px; font-weight: 500; color: var(--ink); line-height: 1.35; margin-bottom: 4px; }
#hovercard .hc-authors { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
#hovercard .hc-line { font-size: 11px; color: var(--muted-2); margin-top: 3px; }
#hovercard .hc-id { font-family: var(--mono); font-size: 9.5px; color: var(--muted-4); margin-top: 5px; letter-spacing: 0.2px; }
.prose p { margin: 12px 0; }
.prose ul, .prose ol { margin: 12px 0 12px 24px; }
.prose li { margin: 5px 0; }
.prose li::marker { color: var(--muted-3); }
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

.prose a { border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.prose a:hover { border-bottom-color: var(--accent); }

/* inline code & blocks */
.prose code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--bg-code); border: 1px solid var(--border-soft);
  padding: 1px 5px; border-radius: 4px; color: var(--ink);
}
.prose pre {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 16px 0;
  font-size: 12.8px; line-height: 1.55;
}
.prose pre code { background: none; border: none; padding: 0; font-size: inherit; color: var(--ink-2); }

/* blockquote */
.prose blockquote {
  margin: 16px 0; padding: 8px 16px; border-left: 3px solid var(--accent);
  background: var(--bg-soft); color: var(--muted); border-radius: 0 6px 6px 0;
}
.prose blockquote p { margin: 6px 0; }

/* tables */
.prose table {
  border-collapse: collapse; margin: 18px 0; font-size: 13px; width: 100%;
  display: block; overflow-x: auto; box-shadow: var(--shadow); border-radius: 8px;
}
.prose thead { background: var(--bg-soft); }
.prose th {
  text-align: left; font-family: var(--mono); font-weight: 600; font-size: 11px;
  letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted);
  padding: 9px 13px; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.prose td { padding: 8px 13px; border-bottom: 1px solid var(--border-soft); color: var(--ink-3); vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover { background: var(--bg-soft); }
.prose td code { white-space: nowrap; }

/* KaTeX */
.prose .katex { font-size: 1.04em; }
.prose .katex-display {
  margin: 18px 0; padding: 6px 4px; overflow-x: auto; overflow-y: hidden;
}
.prose .katex-display > .katex { white-space: nowrap; }
.katex-error { color: var(--danger) !important; font-family: var(--mono); font-size: 0.9em; }

/* ── Citation chips (the signature feature) ────────────── */
.cite {
  display: inline-block; font-family: var(--mono); font-size: 0.74em;
  font-weight: 500; letter-spacing: 0.2px; line-height: 1.3;
  padding: 0.5px 5px; margin: 0 1px; border-radius: 4px; vertical-align: 0.12em;
  background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid transparent; white-space: nowrap; cursor: pointer;
  transition: background .12s, border-color .12s; border-bottom: none;
}
.cite:hover { background: var(--accent-hover-row); color: var(--accent-deep); border-color: var(--accent); }
.cite.unresolved { background: var(--bg-soft); color: var(--muted-2); }
.cite.unresolved:hover { border-color: var(--muted-4); color: var(--ink-3); }
.cite .cite-mark { opacity: 0.65; margin-right: 2px; }

/* ── Right aside (metadata + TOC) ──────────────────────── */
.aside {
  position: sticky; top: 53px; align-self: start;
  height: calc(100vh - 53px); overflow-y: auto;
  padding: 26px 20px 60px 4px; display: none;
}
@media (min-width: 1180px) { .layout.has-aside .aside { display: block; } }

.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 15px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel-title {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.3px; color: var(--muted-3); margin-bottom: 10px;
}
.meta-row { display: flex; gap: 8px; font-size: 12px; margin: 6px 0; line-height: 1.5; }
.meta-row .k {
  flex: 0 0 78px; color: var(--muted-3); font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.3px; padding-top: 1px;
}
.meta-row .v { flex: 1; color: var(--ink-3); min-width: 0; word-break: break-word; }
.meta-row .v a { word-break: break-all; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; font-family: var(--mono); font-size: 10.5px;
  padding: 2px 7px; border-radius: 5px; background: var(--bg-soft);
  border: 1px solid var(--border-soft); color: var(--muted); cursor: pointer; transition: all .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }
.chip.ext::after { content: "↗"; margin-left: 4px; opacity: 0.5; font-size: 0.9em; }
.chip.res { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }

.toc { line-height: 1.4; }
.toc a {
  display: block; font-size: 12px; color: var(--muted-2); padding: 3px 0 3px 10px;
  border-left: 2px solid var(--border-soft); transition: all .12s;
}
.toc a:hover { color: var(--ink); border-left-color: var(--muted-3); }
.toc a.h3 { padding-left: 22px; font-size: 11.5px; }
.toc a.active { color: var(--accent-deep); border-left-color: var(--accent); font-weight: 500; }

.oq-list { list-style: none; margin: 0 !important; }
.oq-list li {
  font-size: 12px; color: var(--ink-3); padding: 8px 0; border-bottom: 1px solid var(--border-soft);
  line-height: 1.5;
}
.oq-list li:last-child { border-bottom: none; }
.oq-list li::before { content: "?"; color: var(--accent); font-family: var(--mono); font-weight: 600; margin-right: 7px; }

/* ── Home view ─────────────────────────────────────────── */
.home { padding: 40px 38px 80px; max-width: 780px; margin: 0 auto; }
@media (max-width: 760px) { .home { padding: 28px 18px 60px; } }

/* ── Hero + foreword (the "book intro") ────────────────── */
.hero { margin-bottom: 22px; }
.hero h1 {
  font-family: var(--mono); font-weight: 600; font-size: 38px; line-height: 1.1;
  letter-spacing: -0.5px; color: var(--ink); margin-bottom: 14px;
}
.hero h1 .dot { color: var(--accent); }
.hero-tag { font-size: 17px; line-height: 1.5; color: var(--muted); font-weight: 300; max-width: 640px; }

.foreword { margin: 26px 0 24px; }
.foreword p {
  font-size: 15.5px; line-height: 1.72; color: var(--ink-2); font-weight: 300;
  margin: 0 0 14px;
}
.foreword p:last-child { margin-bottom: 0; }
.foreword em { font-style: italic; color: var(--ink); }
.foreword strong { font-weight: 600; color: var(--ink); }
.foreword abbr, .prose abbr { text-decoration: none; border-bottom: 1px dotted var(--muted-4); cursor: help; font-weight: 500; color: var(--ink); }
/* acronym hovers inside article prose — subtle (there can be many); inherit color, faint underline */
.prose abbr.ac { font-weight: inherit; color: inherit; border-bottom: 1px dotted var(--muted-5); }
/* in-article §N section references */
.prose a.secref {
  color: var(--accent); border-bottom: 1px dotted color-mix(in srgb, var(--accent) 45%, transparent);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.prose a.secref:hover { border-bottom-style: solid; }

/* slim stats line — present but subordinate to the narrative */
.home-stats {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0;
  font-family: var(--mono); font-size: 12px; color: var(--muted-2);
  padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 8px; font-variant-numeric: tabular-nums;
}
.home-stats a, .home-stats span { color: var(--muted); text-decoration: none; }
.home-stats a:hover { color: var(--accent); }
.home-stats b { color: var(--accent); font-weight: 600; }
.home-stats .sep { color: var(--muted-4); margin: 0 12px; }

.section-head {
  font-family: var(--mono); font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--ink-3); margin: 34px 0 6px;
  display: flex; align-items: center; gap: 10px;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.section-lead { font-size: 13px; color: var(--muted-2); margin: 0 0 14px; line-height: 1.5; }

/* Start-here featured cards */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 15px 16px; cursor: pointer; transition: all .15s; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.feature-card .fc-cat { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); }
.feature-card .fc-title { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.feature-card .fc-scope { font-size: 12px; color: var(--muted-2); line-height: 1.45; }

.built-open {
  margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted-2); line-height: 1.6;
}
.built-open a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--border); }
.built-open a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.cat-block { margin-bottom: 22px; }
.cat-name {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted-2); margin-bottom: 8px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 15px 16px; cursor: pointer; transition: all .15s; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; min-height: 84px;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .c-title { font-family: var(--mono); font-size: 13.5px; font-weight: 500; color: var(--ink); line-height: 1.35; }
.card .c-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.card .c-id { font-family: var(--mono); font-size: 10px; color: var(--muted-4); letter-spacing: 0.2px; }

/* source rows on home */
.src-row {
  display: flex; align-items: baseline; gap: 12px; padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background .12s; border-radius: 6px;
}
.src-row:hover { background: var(--bg-soft); }
.src-row .sr-id { font-family: var(--mono); font-size: 11px; color: var(--accent); flex: 0 0 150px; }
.src-row .sr-title { font-size: 13.5px; color: var(--ink-2); flex: 1; min-width: 0; }
.src-row .sr-year { font-family: var(--mono); font-size: 11px; color: var(--muted-4); white-space: nowrap; }

/* ── Sources browser (#/sources, main area) ────────────── */
.src-browser { max-width: 920px; }
.src-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 6px; }
.src-search-wrap { position: relative; flex: 1 1 280px; }
.src-search-wrap::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-3); font-size: 15px; }
.src-search { width: 100%; font-family: var(--sans); font-size: 13.5px; padding: 9px 12px 9px 32px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-card); color: var(--ink); }
.src-search:focus { outline: none; border-color: var(--accent); }
.src-browser .sort-switch { margin: 0; flex: 0 0 auto; width: auto; }
.src-browser .ns-chips { margin: 0 0 10px; }
.src-browser .list-meta { padding: 2px 4px 8px; }

/* ── States ───────────────────────────────────────────── */
.loading, .error-box {
  padding: 40px; text-align: center; color: var(--muted-2); font-family: var(--mono); font-size: 13px;
}
.error-box { color: var(--danger); }
.spinner {
  width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skel { background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border-soft) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 5px; }
@keyframes sh { to { background-position: -200% 0; } }

/* footer */
.foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--muted-3); display: flex; gap: 16px; flex-wrap: wrap; }
.foot a { color: var(--muted-2); }

/* ── Responsive sidebar ────────────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 290px; z-index: 100;
    height: 100vh; transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--shadow); padding-top: 60px;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
  body.nav-open .nav-scrim { display: block; }
}
@media (min-width: 901px) { .nav-scrim { display: none !important; } }

/* ── command palette ───────────────────────────────────── */
.palette-foot kbd, .pal-esc {
  font-family: var(--mono); font-size: 10px; padding: 1.5px 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--muted-2); line-height: 1.4;
}

.palette-scrim {
  position: fixed; inset: 0; z-index: 200; background: rgba(15,18,22,0.42);
  backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
}
.palette-scrim[hidden] { display: none; }
.palette {
  width: 100%; max-width: 580px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,0.28); overflow: hidden;
  display: flex; flex-direction: column; max-height: 70vh;
}
.palette-search { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.pal-icon { color: var(--muted-3); font-size: 17px; }
.palette-input {
  flex: 1; border: none; background: none; outline: none; color: var(--ink);
  font-family: var(--sans); font-size: 15px; font-weight: 300;
}
.palette-results { overflow-y: auto; padding: 6px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer;
}
.pal-item.sel { background: var(--accent-soft); }
.pal-kind {
  flex: 0 0 auto; font-family: var(--mono); font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 2px 6px; border-radius: 4px; width: 50px; text-align: center;
}
.pal-kind.topic { background: var(--accent-soft); color: var(--accent-deep); }
.pal-kind.source { background: var(--bg-soft); color: var(--muted-2); border: 1px solid var(--border-soft); }
.pal-text { flex: 1; min-width: 0; }
.pal-label { font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-label b { color: var(--accent-deep); font-weight: 600; }
.pal-sub { font-family: var(--mono); font-size: 10px; color: var(--muted-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-empty { padding: 24px; text-align: center; color: var(--muted-3); font-size: 13px; }
.palette-foot {
  display: flex; gap: 14px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--border-soft);
  font-size: 10.5px; color: var(--muted-3); font-family: var(--mono); flex-wrap: wrap;
}
.pal-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; vertical-align: middle; margin: 0 2px 0 6px; }
.pal-dot.pal-t { background: var(--accent); }
.pal-dot.pal-s { background: var(--muted-4); }

/* ── Collapsible taxonomy tree (topics sidebar) ────────── */
.nav-cat { margin-bottom: 10px; }
.nav-cat-head {
  display: flex; align-items: baseline; gap: 7px; width: 100%; padding: 5px 6px; cursor: pointer;
  border-radius: 5px; background: none; border: none; text-align: left;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600; letter-spacing: 0;
  color: var(--ink); transition: background .12s;
}
.nav-cat-head:hover { background: var(--bg-soft); }
.nav-cat-head .caret { font-size: 9px; color: var(--muted-4); transition: transform .15s; width: 9px; align-self: center; }
.nav-cat-head.collapsed .caret { transform: rotate(-90deg); }
.nav-cat-head .cat-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-cat-head .cat-count {
  font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--muted-4); font-variant-numeric: tabular-nums;
}
.nav-cat-head .cat-count .w { color: var(--accent); font-weight: 600; }
/* items sit visually under their (bolder) heading */
.nav-cat-body { padding-left: 16px; margin-top: 1px; border-left: 1px solid var(--border-soft); margin-left: 9px; }
.nav-cat-body.collapsed { display: none; }
.nav-cat-body .nav-item { font-size: 12.5px; }

/* ── Namespace filter chips (sources sidebar) ──────────── */
.ns-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.ns-chip {
  font-family: var(--mono); font-size: 10px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--muted-2); cursor: pointer; transition: all .12s;
}
.ns-chip:hover { border-color: var(--muted-3); color: var(--ink); }
.ns-chip.active { background: var(--ink); color: var(--bg-card); border-color: var(--ink); }
[data-theme="dark"] .ns-chip.active { background: var(--accent); border-color: var(--accent); color: #0b1220; }
.ns-chip .c { opacity: 0.6; }
.list-meta {
  font-family: var(--mono); font-size: 10px; color: var(--muted-4); letter-spacing: 0.2px;
  padding: 8px 9px 4px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.list-meta .hint { color: var(--muted-5); }

/* ── Home: the map ─────────────────────────────────────── */
.map-cat { margin-bottom: 24px; }
.map-cat-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.map-cat-head h3 {
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -0.1px;
}
.map-cat-head .cnt {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted-3); font-variant-numeric: tabular-nums;
}
.map-cat-head .cnt .w { color: var(--accent); font-weight: 600; }
.map-cat-desc { font-size: 12.5px; color: var(--muted-2); margin-bottom: 10px; max-width: 760px; }
.map-nodes { display: flex; flex-wrap: wrap; gap: 7px; }
.map-node {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 7px;
  font-size: 12.5px; cursor: pointer; transition: all .13s; border: 1px solid var(--border); background: var(--bg-card);
}
.map-node.written { color: var(--ink-2); box-shadow: var(--shadow); }
.map-node.written:hover { border-color: var(--accent); color: var(--accent-deep); transform: translateY(-1px); }
.map-node.written .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); flex: 0 0 auto; }
.map-node.planned {
  color: var(--muted-4); border-style: dashed; background: none; cursor: default;
  font-family: var(--mono); font-size: 11px;
}
.map-node.planned .dot { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--muted-5); flex: 0 0 auto; }
.map-node.planned[title] { cursor: help; }

/* ── Sources sort switch ───────────────────────────────── */
.sort-switch { display: flex; gap: 0; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.sort-opt {
  flex: 1; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.3px; text-transform: uppercase;
  padding: 5px 4px; border: none; background: var(--bg-card); color: var(--muted-2); cursor: pointer;
  border-right: 1px solid var(--border); transition: all .12s;
}
.sort-opt:last-child { border-right: none; }
.sort-opt:hover { color: var(--ink); background: var(--bg-soft); }
.sort-opt.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

/* ── Cited-by panel (source page) ──────────────────────── */
.cite-loading { font-size: 11.5px; color: var(--muted-3); font-style: italic; padding: 2px 0; }
.citedby-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft); cursor: pointer;
}
.citedby-row:last-child { border-bottom: none; }
.citedby-row .cb-title { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; border-bottom: none; }
.citedby-row:hover .cb-title { color: var(--accent-deep); }
.citedby-row .cb-cat { font-family: var(--mono); font-size: 9px; color: var(--muted-4); text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
