:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --bg-elev: #ffffff;
  --fg: #1f2328;
  --fg-muted: #57606a;
  --border: #d8dee5;
  --accent: #0e7490;
  --accent-2: #0f766e;
  --accent-rgb: 14, 116, 148;
  --accent-soft: #e3f4f8;
  --accent-fg: #ffffff;
  --mark-bg: #fff3bf;
  --mark-border: #f4c430;
  --broken: #cf222e;
  --shadow: 0 1px 3px rgba(27, 31, 36, 0.1), 0 8px 24px rgba(27, 31, 36, 0.1);
  --shadow-sm: 0 1px 2px rgba(27, 31, 36, 0.08);
  --inbound: #1a7f37;
  --outbound: #7c5cbf;
  --center: #0e7490;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 170ms cubic-bezier(0.4, 0, 0.2, 1);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-elev: #1a212b;
  --fg: #e6edf3;
  --fg-muted: #93a1af;
  --border: #2d3540;
  --accent: #22d3ee;
  --accent-2: #2dd4bf;
  --accent-rgb: 34, 211, 238;
  --accent-soft: #113640;
  --accent-fg: #05262c;
  --mark-bg: #4a3a00;
  --mark-border: #9e7b00;
  --broken: #ff7b72;
  --shadow: 0 1px 3px rgba(1, 4, 9, 0.5), 0 8px 24px rgba(1, 4, 9, 0.6);
  --shadow-sm: 0 1px 2px rgba(1, 4, 9, 0.4);
  --inbound: #3fb950;
  --outbound: #b391f5;
  --center: #22d3ee;
}

* { box-sizing: border-box; }

/* ---------- Scrollbars ---------- */
/* Modern Firefox + Chrome 121+ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
/* WebKit (Chrome / Edge / Safari / embedded WebViews) */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
::-webkit-scrollbar-corner { background: var(--scroll-track); }

:root {
  --scroll-track: #f1f1f1;
  --scroll-thumb: #c1c8d0;
  --scroll-thumb-hover: #9aa3ae;
}
html[data-theme="dark"] {
  --scroll-track: #161b22;
  --scroll-thumb: #3d444d;
  --scroll-thumb-hover: #57606a;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(var(--accent-rgb), 0.08), 0 4px 10px -6px rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.site-title { font-weight: 650; white-space: nowrap; letter-spacing: -0.01em; }
.breadcrumb { display: flex; gap: 4px; flex-wrap: wrap; color: var(--fg-muted); font-size: 13px; overflow: hidden; }
.breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--fg); font-weight: 600; }

.comment-count {
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.comment-count.has { color: var(--accent); border-color: var(--accent); }
a.comment-count { text-decoration: none; cursor: pointer; }
a.comment-count:hover { border-color: var(--accent); color: var(--accent); }

.search-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.search-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}
.search-pill-icon { font-size: 12px; opacity: 0.85; }
.search-pill kbd { margin-left: 1px; }

.btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { font-size: 12px; padding: 4px 8px; }
.btn.ghost { background: transparent; }
.icon-btn {
  font: inherit;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-elev); border-color: var(--border); color: var(--accent); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--nav-w, 260px) 5px minmax(0, 1fr) 320px;
  height: calc(100vh - 48px);
  overflow: hidden;
}
.pane { overflow: auto; height: 100%; }
.pane-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  padding: 10px 12px 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
}
.nav-pane { background: var(--bg-alt); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.nav-pane.collapsed { display: none; }
body.nav-collapsed .layout { grid-template-columns: 0 0 minmax(0, 1fr) 320px; }
/* Review dashboard: no TOC/graph pane */
body.review-page .layout { grid-template-columns: var(--nav-w, 260px) 5px minmax(0, 1fr) 0; }
body.review-page.nav-collapsed .layout { grid-template-columns: 0 0 minmax(0, 1fr) 0; }
body.review-page .right-pane { display: none; }
.right-pane { border-left: 1px solid var(--border); background: var(--bg-alt); }
.content-pane { background: var(--bg); position: relative; }

.resizer { cursor: col-resize; background: transparent; transition: background var(--transition); }
.resizer:hover { background: var(--accent); }

/* ---------- Nav filter box ---------- */
.nav-filter-box {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 6px; background: var(--bg-alt);
}
.nav-filter-box input {
  flex: 1; font: inherit; font-size: 12.5px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-elev); color: var(--fg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.nav-filter-box input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
.nav-filter-count { font-size: 11px; color: var(--fg-muted); white-space: nowrap; }

/* ---------- Recently viewed ---------- */
.nav-recent { padding: 0 10px; }
.nav-recent:empty { display: none; }
.nav-recent .recent-heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted); padding: 6px 2px 4px;
}
.nav-recent .recent-item {
  display: block; padding: 4px 8px; border-radius: var(--radius);
  color: var(--fg-muted); text-decoration: none; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}
.nav-recent .recent-item:hover { background: var(--bg-elev); color: var(--accent); }
.nav-recent .recent-list { padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---------- Nav tree ---------- */
.nav-tree { padding: 4px 6px 40px; font-size: 13px; flex: 1; }
.nav-tree ul { list-style: none; margin: 0; padding-left: 13px; position: relative; }
.nav-tree > ul { padding-left: 4px; }
/* indent guides */
.nav-tree ul::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px;
  background: var(--border);
}
.nav-tree > ul::before { display: none; }
.nav-dir > .nav-dir-label {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; padding: 4px 6px; border-radius: var(--radius);
  color: var(--fg); font-weight: 600;
  transition: background var(--transition);
}
.nav-dir > .nav-dir-label:hover { background: var(--bg-elev); }
.nav-dir-label .twisty { width: 12px; display: inline-block; transition: transform var(--transition); color: var(--fg-muted); }
.nav-dir.collapsed > ul { display: none; }
.nav-dir.collapsed > .nav-dir-label .twisty { transform: rotate(-90deg); }
.nav-dir-label .dir-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-file a {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 18px; border-radius: var(--radius);
  color: var(--fg); text-decoration: none; white-space: nowrap;
  overflow: hidden;
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.nav-file a .file-label { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.nav-file a:hover { background: var(--bg-elev); }
.nav-file.active a {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  border-left-color: var(--accent);
}
.nav-badge {
  flex-shrink: 0; font-size: 10px; line-height: 1; font-weight: 600;
  color: var(--accent-fg); background: var(--accent-2);
  border-radius: 999px; padding: 2px 5px; min-width: 15px; text-align: center;
}
.nav-dot {
  flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-2); display: inline-block;
}
.nav-hidden { display: none !important; }
.nav-filter-match-count { color: var(--accent); }

/* ---------- Review dashboard nav entry ---------- */
.nav-review-link {
  display: flex; align-items: center; gap: 6px; margin: 0 10px 8px;
  padding: 6px 10px; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
}
.nav-review-link:hover { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12); }
/* app.js sets [hidden] via JS (static builds hide this link entirely), but
   author `display` declarations otherwise beat the UA [hidden] default. */
.nav-review-link[hidden] { display: none; }

/* ---------- Content ---------- */
/* Prose stays at a readable measure (--measure) while wide elements
   (tables, code, mermaid) may break out toward the pane edge. */
.markdown-body {
  --measure: 660px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr);
  padding: 30px 36px 100px;
}
.markdown-body > * { grid-column: 2; min-width: 0; }
.markdown-body > table,
.markdown-body > pre,
.markdown-body > p:has(> img:only-child) {
  grid-column: 1 / -1;
  justify-self: center;
  width: fit-content;
  /* panel is at least prose-width (left edge aligns when narrow),
     and stretches symmetrically into both gutters when wider */
  min-width: min(var(--measure), 100%);
  max-width: 100%;
}
.markdown-body > p:has(> img:only-child) { text-align: center; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  /* grid items don't margin-collapse; 0.7em top + 1em prev bottom ≈ old 1.7em */
  line-height: 1.28; margin-top: 0.7em; margin-bottom: 0.55em; font-weight: 650;
  scroll-margin-top: 16px;
}
.markdown-body h1 {
  font-size: 1.9em; letter-spacing: -0.015em; padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border); margin-top: 0;
}
.markdown-body h2 { font-size: 1.45em; letter-spacing: -0.01em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1.05em; color: var(--fg-muted); }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote { margin: 0 0 1em; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body code {
  font-family: var(--mono); font-size: 85%;
  background: var(--bg-alt); padding: 0.2em 0.4em; border-radius: 6px;
}
.markdown-body pre {
  position: relative;
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 16px 16px 14px; border-radius: var(--radius-lg); overflow: auto; margin-top: 0; margin-bottom: 1.1em;
}
.markdown-body pre code { background: transparent; padding: 0; font-size: 90%; }
.markdown-body pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 0; right: 0;
  font: 500 10.5px var(--sans); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted); background: var(--bg-elev); border: 1px solid var(--border);
  border-top: none; border-right: none; border-radius: 0 var(--radius-lg) 0 8px;
  padding: 3px 9px;
}
.markdown-body table { border-collapse: collapse; display: block; overflow: auto; margin-top: 0; margin-bottom: 1.1em; border-radius: 8px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 7px 12px; }
.markdown-body th { background: var(--bg-alt); text-align: left; }
.markdown-body tbody tr:nth-child(2n) td { background: var(--bg-alt); }
.markdown-body tbody tr:hover td { background: var(--accent-soft); }
.markdown-body blockquote {
  padding: 0.15em 1.1em; color: var(--fg-muted);
  border-left: 3px solid var(--accent-2); background: var(--bg-alt);
  border-radius: 0 8px 8px 0;
}
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.markdown-body .contains-task-list { list-style: none; padding-left: 0; }
.markdown-body .task-list-item { list-style: none; }
.markdown-body .task-list-item input { margin-right: 6px; }

/* heading anchor links */
.markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
  position: relative;
}
.heading-anchor {
  position: absolute; left: -1.15em; top: 0.08em;
  opacity: 0; text-decoration: none; color: var(--fg-muted); font-weight: 400;
  font-size: 0.82em; transition: opacity var(--transition), color var(--transition);
  padding: 2px 4px;
}
.markdown-body h2:hover .heading-anchor,
.markdown-body h3:hover .heading-anchor,
.markdown-body h4:hover .heading-anchor,
.markdown-body h5:hover .heading-anchor,
.markdown-body h6:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }

/* doc metadata strip */
.doc-meta-strip {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  color: var(--fg-muted); font-size: 12.5px; margin: -0.4em 0 1.6em;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.doc-meta-strip .dot { opacity: 0.5; }
.doc-meta-strip code { font-size: 90%; }

/* prev / next pager */
.doc-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin: 2.4em 0 1em; padding-top: 1.4em; border-top: 1px solid var(--border);
}
.doc-pager a {
  display: block; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-decoration: none; color: var(--fg);
  background: var(--bg-elev); transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.doc-pager a:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.doc-pager .pager-dir { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin-bottom: 4px; }
.doc-pager .pager-label { font-weight: 600; }
.doc-pager .pager-next { text-align: right; }
.doc-pager .pager-spacer { grid-column: span 1; }

/* frontmatter card */
.fm-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-alt); margin-bottom: 20px; font-size: 13px;
}
.fm-card summary { cursor: pointer; padding: 8px 12px; color: var(--fg-muted); font-weight: 600; }
.fm-card table { margin: 0; width: 100%; display: table; }
.fm-card td { border: none; border-top: 1px solid var(--border); padding: 4px 12px; }
.fm-card td.k { color: var(--fg-muted); width: 180px; font-family: var(--mono); font-size: 12px; }

/* links */
.broken-link { color: var(--broken) !important; text-decoration: line-through !important; cursor: help; }
.external-link::after { content: " ↗"; font-size: 0.8em; opacity: 0.6; }

/* ---------- Marks / comments ---------- */
mark.review-mark {
  background: var(--mark-bg);
  border-bottom: 2px solid var(--mark-border);
  border-radius: 2px;
  padding: 0 1px;
  cursor: pointer;
  position: relative;
}
mark.review-mark:hover { filter: brightness(0.96); }
@keyframes mark-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
  25% { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.35); }
}
mark.review-mark:target { animation: mark-flash 1.4s ease-out 2; }
.review-pin {
  display: inline-block; font-size: 10px; vertical-align: super;
  color: var(--accent); margin-left: 1px; user-select: none;
}
.comment-expander {
  margin: 8px 0 14px; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-alt); font-size: 13px;
  box-shadow: inset 3px 0 0 var(--accent-2);
}
.comment-item { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.comment-item + .comment-item { border-top: 1px dashed var(--border); }
.comment-meta { color: var(--fg-muted); font-size: 12px; }
.comment-body { flex: 1; }
.comment-delete {
  border: none; background: transparent; color: var(--fg-muted);
  cursor: pointer; font-size: 13px; padding: 0 4px;
}
.comment-delete:hover { color: var(--broken); }

/* selection popover + compose */
.selection-popover, .compose-box {
  position: absolute; z-index: 80; box-shadow: var(--shadow);
}
.selection-popover { }
.compose-box {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; width: 320px;
}
.compose-box textarea {
  width: 100%; resize: vertical; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px;
  background: var(--bg); color: var(--fg);
}
.compose-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.compose-error { color: var(--broken); font-size: 12px; margin-right: auto; }

/* ---------- Right pane graph + toc ---------- */
.pane-section { border-bottom: 1px solid var(--border); }
.mini-graph { height: 240px; margin: 0 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.toc { padding: 4px 8px 40px; font-size: 13px; }
.toc a {
  display: block; padding: 3px 8px; color: var(--fg-muted);
  text-decoration: none; border-left: 2px solid transparent; line-height: 1.4;
}
.toc a:hover { color: var(--accent); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc a[data-level="3"] { padding-left: 20px; }
.toc a[data-level="4"] { padding-left: 32px; }
.toc a[data-level="5"], .toc a[data-level="6"] { padding-left: 44px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 200; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-body {
  position: absolute; inset: 4% 4%; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column;
  box-shadow: var(--shadow); overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.full-graph { flex: 1; }

/* ---------- Global knowledge graph modal (premium size + polish) ---------- */
@keyframes graph-modal-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
#graph-modal .modal-backdrop { backdrop-filter: blur(3px); }
.graph-modal-body {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 90vw; height: 85vh; max-width: none;
  animation: graph-modal-pop 160ms cubic-bezier(0.4, 0, 0.2, 1);
}
.graph-root { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.graph-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-alt);
}
.graph-filter {
  font: inherit; font-size: 12.5px; padding: 6px 10px; min-width: 160px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-elev); color: var(--fg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.graph-filter:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
.graph-zoom-btn { width: 28px; height: 28px; font-size: 15px; }
.graph-orphan-toggle {
  display: flex; align-items: center; gap: 5px; font-size: 12.5px;
  color: var(--fg-muted); cursor: pointer; user-select: none; white-space: nowrap;
}
.graph-orphan-toggle input { cursor: pointer; }
.graph-stat { margin-left: auto; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.graph-legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.graph-legend-item {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  color: var(--fg-muted); cursor: pointer; padding: 2px 6px; border-radius: 999px;
  transition: background var(--transition), opacity var(--transition);
}
.graph-legend-item:hover { background: var(--bg-alt); }
.graph-legend-item.dimmed { opacity: 0.4; text-decoration: line-through; }
.graph-legend-swatch {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.graph-canvas { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.graph-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 7px 10px; font-size: 12px; max-width: 240px;
}
.graph-tooltip-title { font-weight: 650; color: var(--fg); margin-bottom: 2px; }
.graph-tooltip-path { color: var(--fg-muted); font-family: var(--mono); font-size: 10.5px; word-break: break-all; margin-bottom: 3px; }
.graph-tooltip-stats { color: var(--accent); font-size: 11px; }
@media (max-width: 700px) {
  .graph-modal-body { width: 98vw; height: 90vh; }
  .graph-stat { margin-left: 0; width: 100%; }
}

/* reload toast (deprecated single toast, kept for compatibility) */
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; z-index: 300; opacity: 0.92;
}

/* toast stack (copy link, etc.) */
.toast-container {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none;
}
.toast-item {
  background: var(--fg); color: var(--bg); padding: 7px 14px; border-radius: 999px;
  font-size: 12.5px; box-shadow: var(--shadow); opacity: 0;
  transform: translateY(6px); transition: opacity 160ms ease, transform 160ms ease;
}
.toast-item.show { opacity: 0.95; transform: translateY(0); }

/* ---------- Reading progress bar ---------- */
.reading-progress {
  position: sticky; top: 0; left: 0; right: 0; height: 3px; z-index: 40;
  background: transparent;
}
.reading-progress-bar {
  height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: transform 80ms linear;
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: sticky; bottom: 20px; float: right; margin-right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--fg);
  box-shadow: var(--shadow-sm); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition), border-color var(--transition), color var(--transition);
  pointer-events: none;
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Keyboard shortcuts help modal ---------- */
.help-modal-body { max-width: 420px; max-height: 60vh; inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.help-list { padding: 10px 16px 18px; overflow: auto; }
.help-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.help-row span { color: var(--fg-muted); }
.help-row.muted { opacity: 0.6; }
kbd {
  font-family: var(--mono); font-size: 11.5px; background: var(--bg-alt);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  padding: 2px 6px; color: var(--fg);
}

/* ---------- Search command palette ---------- */
@keyframes search-pop {
  from { opacity: 0; transform: translateX(-50%) scale(0.97) translateY(-6px); }
  to { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}
.search-modal .modal-backdrop { backdrop-filter: blur(2px); }
.search-modal-body {
  inset: auto; left: 50%; top: 12%; transform: translateX(-50%);
  width: 92vw; max-width: 640px; max-height: 60vh;
  display: flex; flex-direction: column;
  animation: search-pop 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-icon { font-size: 15px; opacity: 0.6; }
#search-input {
  flex: 1; font: inherit; font-size: 15px; border: none; outline: none;
  background: transparent; color: var(--fg);
}
#search-input::placeholder { color: var(--fg-muted); }
.search-esc { opacity: 0.6; flex-shrink: 0; }
.search-results { overflow-y: auto; padding: 6px; }
.search-result-item {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px 10px; border-radius: var(--radius); cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.search-result-item.active, .search-result-item:hover {
  background: var(--accent-soft); border-left-color: var(--accent);
}
.search-result-title-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.search-result-title {
  font-weight: 600; font-size: 13.5px; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result-path {
  font-size: 11px; color: var(--fg-muted); flex-shrink: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.search-result-snippet {
  font-size: 12.5px; color: var(--fg-muted); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-heading-marker { color: var(--accent); font-weight: 600; }
.search-hl {
  background: rgba(var(--accent-rgb), 0.22); color: var(--accent);
  border-radius: 3px; padding: 0 1px; font-weight: 600;
}
.search-recent-heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted); padding: 8px 10px 4px;
}
.search-empty { padding: 28px 14px; text-align: center; color: var(--fg-muted); font-size: 13px; }
@media (max-width: 700px) {
  .search-modal-body { width: 96vw; top: 6%; max-height: 80vh; }
}

/* Right panel toggle: hidden on desktop, shown in overlay mode */
#right-toggle { display: none; }

/* ── Tablet & mobile: overlay drawer mode (≤ 1100 px) ─────────────────────── */
@media (max-width: 1100px) {
  /* Content-only grid — override desktop and nav-collapsed states */
  .layout,
  body.nav-collapsed .layout {
    grid-template-columns: 0 0 minmax(0, 1fr) 0;
  }
  .resizer { display: none; }
  /* nav-pane/right-pane become position:fixed overlays and no longer
     participate in the grid, so content-pane must be pinned to the
     surviving 1fr track explicitly — otherwise it auto-places into the
     empty first (0px) track and the entire page collapses to 0 width. */
  .content-pane { grid-column: 3; }

  /* Left nav: slide-in overlay from the left, collapsed by default */
  .nav-pane,
  .nav-pane.collapsed {
    position: fixed;
    left: 0;
    top: 48px;
    bottom: 0;
    width: min(280px, 85vw);
    z-index: 110;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.18);
    display: block;
    overflow: auto;
  }
  .nav-pane.overlay-open {
    transform: translateX(0);
  }

  /* Right pane: slide-in overlay from the right, open by default */
  .right-pane {
    position: fixed;
    right: 0;
    top: 48px;
    bottom: 0;
    width: min(300px, 85vw);
    z-index: 110;
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.18);
    display: block;
    overflow: auto;
  }
  .right-pane.overlay-open {
    transform: translateX(0);
  }

  /* Backdrop — shown behind whichever overlay is open */
  .overlay-backdrop {
    display: none;
    position: fixed;
    inset: 48px 0 0 0;
    z-index: 109;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
  }
  .overlay-backdrop.visible {
    display: block;
  }

  /* Reveal the right-panel toggle button */
  #right-toggle {
    display: inline-block;
  }
}

/* ---------- Review dashboard page ---------- */
.markdown-body.review-page { max-width: 900px; }
.review-header {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 10px 20px; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.review-header h1 { margin: 0; border: none; padding: 0; }
.review-stats { display: flex; gap: 18px; font-size: 13px; color: var(--fg-muted); }
.review-stats strong { color: var(--accent); font-size: 15px; }
.review-doc-group {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-elev); margin-bottom: 14px; overflow: hidden;
}
.review-doc-summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 12px 16px; list-style: none; user-select: none;
}
.review-doc-summary::-webkit-details-marker { display: none; }
.review-doc-summary::before {
  content: "\25b8"; display: inline-block; color: var(--fg-muted); font-size: 11px;
  transition: transform var(--transition);
}
.review-doc-group[open] > .review-doc-summary::before { transform: rotate(90deg); }
.review-doc-title { font-weight: 650; }
.review-doc-path {
  font-size: 11.5px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; min-width: 0;
}
.review-doc-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--accent-fg);
  background: var(--accent-2); border-radius: 999px; padding: 2px 9px;
}
.review-doc-comments { padding: 4px 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.review-comment-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-alt);
  padding: 10px 12px; font-size: 13px;
}
.review-comment-excerpt {
  margin: 0 0 8px; padding: 6px 10px; background: var(--mark-bg);
  border-radius: 6px; font-style: italic; color: var(--fg); font-size: 12.5px;
}
.review-comment-text { margin-bottom: 8px; line-height: 1.5; }
.review-comment-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--fg-muted);
}
.review-comment-link { margin-left: auto; color: var(--accent); text-decoration: none; font-weight: 600; }
.review-comment-link:hover { text-decoration: underline; }
.review-empty {
  text-align: center; padding: 60px 20px; color: var(--fg-muted);
}
.review-empty-icon { font-size: 40px; margin-bottom: 10px; }
.review-empty p { margin: 4px 0; }
.review-empty-hint { font-size: 13px; }

/* ---------- Branding (topbar logo / favicon slot) ---------- */
.site-logo-slot { display: flex; align-items: center; }
.site-logo-slot:empty { display: none; }
.site-logo { height: 22px; width: auto; max-width: 140px; object-fit: contain; margin-right: 2px; }

/* ---------- Release notes nav entry ---------- */
.nav-releases-link {
  display: flex; align-items: center; gap: 6px; margin: 0 10px 10px;
  padding: 6px 10px; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600; color: var(--accent-2);
  background: var(--accent-soft); text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
}
.nav-releases-link:hover { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12); }
/* Same [hidden]-vs-author-display specificity issue as .nav-review-link. */
.nav-releases-link[hidden] { display: none; }

/* ---------- Release notes page (Option C categorized changelog) ---------- */
/* Uses the same nav / content / right-rail grid as doc pages (see .layout
   above) — the "Versions" nav is relocated into #right-pane by
   public/releases.js so it renders as a proper right rail instead of a
   floating panel over the content. */
.releases-empty { text-align: center; padding: 60px 20px; color: var(--fg-muted); }
.releases-empty h1 { color: var(--fg); }

.markdown-body.releases-page { display: block; max-width: 900px; margin: 0 auto; }

.releases-version-nav ul { list-style: none; margin: 0; padding: 0 8px 10px; }

/* Subtle "vX.Y" group divider between minor-version runs. */
.releases-version-divider {
  padding: 12px 8px 3px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted);
  opacity: 0.7;
}
.releases-version-divider:first-child { padding-top: 4px; }

/* Each row: tag + compact status dot + relative date on one line, per-
   category count chips on a second line — a dense-but-scannable changelog
   heat summary, not just a bare tag list. */
.releases-version-link {
  display: flex; flex-direction: column; gap: 3px;
  padding: 6px 8px; margin: 1px 0; border-radius: var(--radius);
  text-decoration: none; color: var(--fg-muted);
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.releases-version-link:hover { background: var(--bg-alt); color: var(--fg); }
.releases-version-item.active .releases-version-link {
  background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent);
}
.releases-version-item.active .rv-tag { font-weight: 700; }
.releases-version-item.is-prerelease .releases-version-link { opacity: 0.65; }
.releases-version-item[hidden] { display: none; }

.rv-row-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rv-tag {
  font-size: 12.5px; font-weight: 600; color: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rv-date {
  margin-left: auto; flex-shrink: 0; font-size: 10.5px; color: var(--fg-muted);
}

/* Compact status marker replacing the larger .pill treatment used in the
   main release header — a plain dot conveys latest/pre-release without
   competing visually with the tag text. */
.rv-status-dot {
  flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.rv-status-dot.rv-status-latest { background: var(--accent-2); }
.rv-status-dot.rv-status-rc { background: transparent; border: 1.5px solid var(--fg-muted); }
.rv-status-dot.rv-status-none { background: transparent; }

.rv-counts { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 12px; }
.rv-count {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700; line-height: 1;
}
.rv-count-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.rv-count-feat { color: var(--accent); }
.rv-count-feat .rv-count-dot { background: var(--accent); }
.rv-count-fix { color: var(--inbound); }
.rv-count-fix .rv-count-dot { background: var(--inbound); }
.rv-count-breaking { color: var(--broken); }
.rv-count-breaking .rv-count-dot { background: var(--broken); }

.releases-page-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.releases-page-header h1 { margin: 0; border: none; padding: 0; }
.releases-page-links { display: flex; gap: 8px; }
.releases-rss-btn, .releases-json-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--fg-muted);
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; background: var(--bg-elev);
  transition: color var(--transition), border-color var(--transition);
}
.releases-rss-btn:hover, .releases-json-btn:hover { color: var(--accent); border-color: var(--accent); }

.releases-controls {
  position: sticky; top: 0; z-index: 3;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 0 14px; margin-bottom: 18px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.releases-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--fg-muted); cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover { color: var(--fg); border-color: var(--accent); }
.chip.active {
  color: var(--accent-fg); background: var(--accent); border-color: var(--accent);
}
.chip-breaking-count {
  color: var(--broken); background: color-mix(in srgb, var(--broken) 12%, transparent);
  border-color: var(--broken); text-decoration: none; cursor: pointer;
}
.releases-search-box { flex: 1; min-width: 160px; max-width: 260px; }
.releases-search-box input {
  width: 100%; font: inherit; font-size: 12.5px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-elev); color: var(--fg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.releases-search-box input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
.releases-hide-rc {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--fg-muted); cursor: pointer; user-select: none;
}

.release-section {
  padding: 22px 0 30px; border-bottom: 1px solid var(--border);
}
.release-section:last-child { border-bottom: none; }
.release-section[hidden] { display: none; }
.release-header {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 8px 16px; position: sticky; top: 60px; z-index: 2;
  background: var(--bg); padding: 6px 0;
}
.release-header-title {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0; border: none; padding: 0; font-size: 20px;
}
.release-anchor-link {
  color: var(--fg-muted); text-decoration: none; font-size: 15px; opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}
.release-header-title:hover .release-anchor-link { opacity: 1; }
.release-anchor-link:hover { color: var(--accent); }
.release-version { font-weight: 700; }
.release-name { font-weight: 500; color: var(--fg-muted); font-size: 15px; }
.release-new-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-2); margin-left: 2px;
}
.release-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 12px; color: var(--fg-muted);
}
.release-meta a { color: var(--fg-muted); text-decoration: none; font-weight: 600; }
.release-meta a:hover { color: var(--accent); text-decoration: underline; }
.release-deployed { font-style: italic; }

.pill {
  display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; border-radius: 999px; padding: 2px 8px;
}
.pill-latest { background: var(--accent-2); color: var(--accent-fg); }
.pill-prerelease { background: var(--bg-alt); color: var(--fg-muted); border: 1px solid var(--border); }

.release-intro { margin: 10px 0 14px; color: var(--fg); }
.release-upgrade-callout {
  display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 16px;
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
  background: color-mix(in srgb, var(--broken) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--broken) 35%, transparent);
}
.release-upgrade-callout a { color: var(--broken); font-weight: 600; }
.release-upgrade-icon { font-size: 16px; }

.release-tier { margin-bottom: 10px; }
.release-tier[hidden] { display: none; }
.release-item-list { list-style: none; margin: 0; padding: 0; }
.release-item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
}
.release-item:last-child { border-bottom: none; }
.release-item[hidden] { display: none; }
/* All four categories (feat/fix/breaking/other) share one font-size so the
   whole row — including the badge — reads at identical typographic weight;
   only text color signals the lower-priority fix/other tier. */
.release-item-list-compact > .release-item { color: var(--fg-muted); }
.release-item-text { flex: 1; min-width: 200px; }
.release-item-text code { font-size: 0.92em; }

.badge {
  flex-shrink: 0; display: inline-flex; align-items: center; font-size: 10.5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  border-radius: 999px; padding: 2px 8px; line-height: 1.5;
  /* Normalize bold-text anti-aliasing/hinting at this small size so
     feat/breaking badges don't render visibly heavier than fix/other. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
.badge-feat { background: var(--accent-soft); color: var(--accent); }
.badge-fix { background: color-mix(in srgb, var(--inbound) 15%, transparent); color: var(--inbound); }
.badge-breaking { background: color-mix(in srgb, var(--broken) 15%, transparent); color: var(--broken); }
.badge-other { background: var(--bg-alt); color: var(--fg-muted); border: 1px solid var(--border); }

.release-author-chip {
  display: inline-flex; align-items: center; gap: 4px; color: var(--fg-muted);
  text-decoration: none; font-size: 11.5px;
}
.release-author-chip:hover { color: var(--accent); }
.release-author-chip img { border-radius: 50%; display: block; }
.release-pr-link { color: var(--fg-muted); text-decoration: none; font-size: 11.5px; font-weight: 600; }
.release-pr-link:hover { color: var(--accent); text-decoration: underline; }
.release-empty-note { color: var(--fg-muted); font-style: italic; }

@media (max-width: 900px) {
  /* Versions nav now lives inside #right-pane, which the existing
     ≤1100px overlay-drawer rules already handle generically — no
     releases-specific grid overrides needed here anymore. */
  .release-header { position: static; }
}
