/* ============================================================
   嵌入式技术栈知识库 — Obsidian 风格主题
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #1b1b1f;
  --bg-soft: #202025;
  --panel: #151518;
  --panel-2: #1e1e23;
  --text: #d7d7dd;
  --text-dim: #9c9ca7;
  --text-faint: #6d6d78;
  --border: #2b2b33;
  --border-soft: #24242b;
  --accent: #a882ff;
  --accent-strong: #bda1ff;
  --accent-soft: rgba(168, 130, 255, 0.14);
  --hover: rgba(255, 255, 255, 0.055);
  --active: rgba(168, 130, 255, 0.16);
  --code-bg: #26262c;
  --pre-bg: #121215;
  --hl-key: #bb9af7;
  --hl-str: #9ece6a;
  --hl-num: #ff9e64;
  --hl-fn: #7aa2f7;
  --hl-type: #2ac3de;
  --hl-meta: #e0af68;
  --hl-com: #636b8a;
  --table-head: rgba(255, 255, 255, 0.04);
  --table-stripe: rgba(255, 255, 255, 0.018);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --sidebar-w: 286px;
  --context-w: 300px;
  --topbar-h: 52px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f6f6f9;
  --panel: #f3f3f7;
  --panel-2: #ececf2;
  --text: #2d2d35;
  --text-dim: #5e5e6b;
  --text-faint: #8d8d99;
  --border: #e3e3eb;
  --border-soft: #ededf3;
  --accent: #7b5cf0;
  --accent-strong: #6847e8;
  --accent-soft: rgba(123, 92, 240, 0.1);
  --hover: rgba(20, 20, 40, 0.045);
  --active: rgba(123, 92, 240, 0.12);
  --code-bg: #f1f1f6;
  --pre-bg: #f7f7fb;
  --hl-key: #a626a4;
  --hl-str: #50a14f;
  --hl-num: #986801;
  --hl-fn: #4078f2;
  --hl-type: #0184bc;
  --hl-meta: #c18401;
  --hl-com: #a0a1a7;
  --table-head: rgba(20, 20, 40, 0.035);
  --table-stripe: rgba(20, 20, 40, 0.015);
  --shadow: 0 24px 60px rgba(30, 30, 60, 0.18);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-y: scroll;
}

body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------ scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; border: 2px solid transparent; }

/* ------------------------------------------------ layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--context-w);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  z-index: 40;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 10px;
}

.vault {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border-radius: 8px;
  padding: 4px 6px;
}
.vault:hover { background: var(--hover); }

.vault-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #6d4dd6);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(168, 130, 255, 0.28);
}

.vault-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.vault-text strong { font-size: 14px; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vault-text small { color: var(--text-faint); font-size: 11px; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 12px 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text); }
.search-trigger span { flex: 1; }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--panel-2);
  white-space: nowrap;
}

.quick-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 6px;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13.5px;
}
.quick-link svg { opacity: 0.75; flex: none; }
.quick-link:hover { background: var(--hover); color: var(--text); }
.quick-link.active { background: var(--active); color: var(--text); }
.quick-link.active svg { opacity: 1; color: var(--accent); }

.explorer {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 18px;
  overscroll-behavior: contain;
}

.explorer-group { margin-bottom: 2px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-align: left;
}
.group-head:hover { background: var(--hover); color: var(--text); }

.group-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03);
}
.group-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-count {
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  background: var(--panel-2);
  border-radius: 20px;
  padding: 0 6px;
  line-height: 1.6;
}
.chev { color: var(--text-faint); transition: transform 0.16s ease; flex: none; }
.explorer-group.collapsed .chev { transform: rotate(-90deg); }
.explorer-group.collapsed .note-list { display: none; }

.note-list { list-style: none; margin: 1px 0 6px; padding: 0 0 0 6px; }

.file-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 10px;
  margin: 1px 0;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.45;
  border-left: 1px solid var(--border-soft);
  margin-left: 3px;
}
.file-link .ico { color: var(--text-faint); font-size: 11px; flex: none; width: 10px; text-align: center; }
.file-link .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-link:hover { background: var(--hover); color: var(--text); }
.file-link.active {
  background: var(--active);
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 500;
}
.file-link.active .ico { color: var(--accent); }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.02em;
  flex: none;
}
.dot-sep { opacity: 0.5; }

.install-btn {
  margin: 0 14px 12px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  flex: none;
}
.install-btn:hover { border-color: var(--accent); color: var(--text); }

.scrim { display: none; }

/* ------------------------------------------------ main / topbar */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
}

.crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
  overflow: hidden;
  white-space: nowrap;
}
.crumbs a { color: var(--text-dim); border-radius: 4px; padding: 1px 3px; }
.crumbs a:hover { color: var(--text); background: var(--hover); }
.crumbs .sep { opacity: 0.5; }
.crumbs .current { color: var(--text); overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; gap: 4px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 15px;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.view {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 40px 110px;
}

.view.graph-view {
  max-width: none;
  padding: 0;
  height: calc(100vh - var(--topbar-h));
}

.view.view-home {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  height: calc(100vh - var(--topbar-h));
}

.hero-home {
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  margin: 0;
}

/* immersive routes: hide both rails (desktop only; mobile keeps the drawer) */
html[data-route="home"] .app,
html[data-route="graph"] .app { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 901px) {
  html[data-route="home"] .sidebar,
  html[data-route="home"] .context,
  html[data-route="graph"] .sidebar,
  html[data-route="graph"] .context { display: none; }
  html[data-route="home"] #menu-btn { display: none; }
}
html[data-route="home"] .topbar {
  background: transparent;
  border-bottom-color: transparent;
}

/* the immersive views own the remaining height; never let the page scroll */
html[data-route="home"] .main,
html[data-route="graph"] .main { height: 100vh; min-height: 0; overflow: hidden; }
html[data-route="home"] .view.view-home,
html[data-route="graph"] .view.graph-view {
  flex: 1 1 0;
  min-height: 0;
  height: auto;
}

.hero-home .branch-strip {
  position: absolute;
  left: 50%;
  bottom: 30px;
  z-index: 2;
  transform: translateX(-50%);
  width: min(980px, calc(100% - 48px));
  justify-content: center;
  margin: 0;
}

@media (min-width: 1100px) {
  .view.view-home .hero h1 { font-size: clamp(52px, 6.4vw, 92px); }
  .view.view-home .hero-inner { max-width: 900px; }
}

.hero-home.is-leaving .hero-inner,
.hero-home.is-leaving .branch-strip {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.hero-home .hero-inner,
.hero-home .branch-strip {
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.view.graph-view .graph-toolbar,
.view.graph-view .graph-legend,
.view.graph-view .graph-hintbar {
  animation: graphUiIn 0.5s ease both;
  animation-delay: 0.18s;
}
@keyframes graphUiIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------ note */
.note { max-width: 780px; margin: 0 auto; }

.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 2px 9px;
  line-height: 1.6;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.accent { color: var(--accent-strong); background: var(--accent-soft); border-color: transparent; }
.badge a { color: inherit; }

.note-title {
  font-size: clamp(28px, 3.4vw, 38px);
  line-height: 1.25;
  letter-spacing: -0.015em;
  font-weight: 700;
  margin: 0 0 10px;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  color: var(--text-faint);
  font-size: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 26px;
}
.note-meta .meta-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.meta-tag { color: var(--text-dim); background: var(--hover); border-radius: 5px; padding: 1px 6px; font-size: 11.5px; }
.meta-tag:hover { color: var(--accent-strong); }

.confidence {
  display: flex;
  gap: 8px;
  border: 1px solid var(--border);
  border-left: 3px solid #d19a66;
  background: rgba(209, 154, 102, 0.07);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 22px;
  line-height: 1.55;
}
.confidence b { color: #d19a66; font-weight: 600; letter-spacing: 0.04em; }

/* ------------------------------------------------ markdown content */
.note-content { font-size: 16px; line-height: 1.78; }

.note-content > *:first-child { margin-top: 0; }

.note-content h1,
.note-content h2,
.note-content h3,
.note-content h4 {
  line-height: 1.35;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--topbar-h) + 18px);
}

.note-content h1 { font-size: 1.85em; margin: 1.4em 0 0.6em; }
.note-content h2 {
  font-size: 1.42em;
  margin: 2em 0 0.7em;
  padding-bottom: 0.28em;
  border-bottom: 1px solid var(--border-soft);
}
.note-content h3 { font-size: 1.16em; margin: 1.7em 0 0.5em; color: var(--text); }
.note-content h4 { font-size: 1.02em; margin: 1.4em 0 0.4em; color: var(--text-dim); }

.note-content p { margin: 0.85em 0; }
.note-content strong { font-weight: 650; }
.note-content ul, .note-content ol { margin: 0.8em 0; padding-left: 1.5em; }
.note-content li { margin: 0.32em 0; }
.note-content li > ul, .note-content li > ol { margin: 0.25em 0; }
.note-content li::marker { color: var(--text-faint); }

.note-content hr { border: 0; border-top: 1px solid var(--border-soft); margin: 2.4em 0; }

.note-content blockquote {
  margin: 1.2em 0;
  padding: 0.7em 1.1em;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 0.97em;
}
.note-content blockquote p { margin: 0.35em 0; }

.note-content a { color: var(--accent-strong); text-decoration: none; border-bottom: 1px solid transparent; }
.note-content a:hover { border-bottom-color: var(--accent); }

.wikilink { border-bottom: 1px dotted var(--accent) !important; }
.wikilink.missing { color: var(--text-faint); border-bottom: 1px dashed var(--text-faint) !important; cursor: help; }

.note-content code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 0.12em 0.38em;
  white-space: break-spaces;
}

.note-content pre {
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  margin: 1.2em 0;
}
.note-content pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }

/* syntax highlighting (highlight.js tokens) */
.note-content pre code.hljs { display: block; color: var(--text); }
.hljs-comment, .hljs-quote { color: var(--hl-com); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in, .hljs-doctag { color: var(--hl-key); }
.hljs-string, .hljs-attr, .hljs-regexp, .hljs-template-tag, .hljs-template-variable { color: var(--hl-str); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--hl-num); }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--hl-fn); }
.hljs-type, .hljs-title.class_, .hljs-class .hljs-title, .hljs-selector-class, .hljs-selector-id { color: var(--hl-type); }
.hljs-meta, .hljs-preprocessor, .hljs-meta .hljs-keyword { color: var(--hl-meta); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

.note-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: 14.2px;
  line-height: 1.6;
  display: table;
}
.note-content thead th {
  background: var(--table-head);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.note-content th, .note-content td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  vertical-align: top;
}
.note-content tbody tr:nth-child(even) { background: var(--table-stripe); }
.note-content tbody tr:hover { background: var(--hover); }

.note-content .math-block {
  margin: 1.3em 0;
  padding: 4px 2px;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}
.math-tex:not(.katex-rendered) {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--text-faint);
  word-break: break-all;
}
.note-content .katex { font-size: 1.04em; }
.note-content .katex-display { margin: 0.6em 0; }
.math-fallback { color: #e06c75; }

.note-content img { max-width: 100%; border-radius: 8px; }

/* table of contents (in content, not used) */

/* ------------------------------------------------ pager */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 54px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  min-width: 0;
}
.pager a:hover { border-color: var(--accent); background: var(--accent-soft); }
.pager .dir { font-size: 11px; color: var(--text-faint); letter-spacing: 0.05em; }
.pager .name { font-size: 13.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager .next { grid-column: 2; text-align: right; align-items: flex-end; }
.pager-empty { visibility: hidden; }

/* ------------------------------------------------ context panel */
.context {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px 18px 40px;
  border-left: 1px solid var(--border-soft);
  background: var(--bg-soft);
  font-size: 12.5px;
}

.ctx-block { margin-bottom: 26px; }
.ctx-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 9px;
}
.ctx-head .pill {
  font-size: 10px;
  font-family: var(--mono);
  background: var(--panel-2);
  border-radius: 20px;
  padding: 0 6px;
  color: var(--text-dim);
  line-height: 1.7;
}

.toc { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-soft); }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 3px 10px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--text-dim);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc a:hover { color: var(--text); background: var(--hover); }
.toc a.active { color: var(--accent-strong); border-left-color: var(--accent); background: var(--accent-soft); }
.toc li.lvl-3 a { padding-left: 22px; font-size: 12px; }
.toc-empty { color: var(--text-faint); font-size: 12px; }

.backlinks { display: flex; flex-direction: column; gap: 7px; }
.backlink {
  display: block;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  line-height: 1.5;
}
.backlink:hover { border-color: var(--accent); }
.backlink-title { display: block; color: var(--text); font-size: 12.5px; font-weight: 550; margin-bottom: 2px; }
.backlink-ctx {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 11.5px;
}
.ctx-empty { color: var(--text-faint); font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

.branch-legend { display: flex; flex-direction: column; gap: 2px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--text-dim);
}
.legend-item:hover { background: var(--hover); color: var(--text); }
.legend-item .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.legend-item .n { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }

/* ------------------------------------------------ home */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 16px;
  background:
    radial-gradient(760px 340px at 84% -12%, rgba(168, 130, 255, 0.2), transparent 62%),
    radial-gradient(560px 300px at -6% 112%, rgba(97, 175, 239, 0.12), transparent 60%),
    var(--panel-2);
}
.hero-home {
  min-height: 0;
  display: grid;
  place-items: center;
}
.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  padding: 64px 28px;
  text-align: center;
}
.hero-kicker {
  font-size: 10.5px;
  letter-spacing: 0.34em;
  color: var(--accent-strong);
  font-family: var(--mono);
  margin-bottom: 20px;
  opacity: 0.85;
}
.hero h1 {
  font-size: clamp(38px, 6vw, 66px);
  margin: 0;
  letter-spacing: -0.035em;
  line-height: 1.04;
  font-weight: 650;
}
.hero-line {
  margin: 18px 0 32px;
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.1em;
  font-family: var(--mono);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 550; }
.btn.primary:hover { background: var(--accent-strong); color: #fff; }
.btn.ghost { background: transparent; backdrop-filter: blur(6px); }
.btn.small { padding: 5px 10px; font-size: 12px; }

.branch-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 34px;
}
.branch-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  transition: border-color 0.15s, color 0.15s;
}
.branch-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; }
.branch-pill .bp-n { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
.branch-pill:hover { border-color: var(--c); color: var(--text); }
.branch-pill:hover .bp-n { color: var(--text-dim); }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 14px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

/* ------------------------------------------------ search modal */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 18px 18px;
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(6px);
}
.search-modal[hidden] { display: none; }

.search-box {
  width: min(660px, 100%);
  max-height: 68vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.16s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}
.search-input-row input {
  flex: 1;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.search-input-row input::placeholder { color: var(--text-faint); }

.search-results { overflow-y: auto; padding: 6px; }
.search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
}
.search-result .sr-top { display: flex; align-items: center; gap: 8px; }
.search-result .sr-title { font-size: 13.5px; font-weight: 550; color: var(--text); }
.search-result .sr-branch { font-size: 10.5px; color: var(--text-faint); margin-left: auto; display: flex; align-items: center; gap: 5px; }
.search-result .sr-dot { width: 6px; height: 6px; border-radius: 50%; }
.search-result .sr-snippet { font-size: 12px; color: var(--text-dim); line-height: 1.5; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-result .sr-snippet mark, .sr-title mark { background: rgba(168, 130, 255, 0.28); color: var(--accent-strong); border-radius: 3px; padding: 0 1px; }
.search-result.active { background: var(--active); }

.search-empty { padding: 26px 14px; text-align: center; color: var(--text-faint); font-size: 13px; }

.search-hint {
  display: flex;
  gap: 18px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 11px;
}
.search-hint span { display: flex; align-items: center; gap: 4px; }

/* ------------------------------------------------ graph */
.graph-view { position: relative; }
.view.graph-view,
.graph-stage,
.graph-stage * { touch-action: none; }
.graph-legend { touch-action: none; }
.graph-stage {
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(760px 340px at 84% -12%, rgba(168, 130, 255, 0.2), transparent 62%),
    radial-gradient(560px 300px at -6% 112%, rgba(97, 175, 239, 0.12), transparent 60%),
    var(--panel-2);
}
#graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#graph-canvas.dragging { cursor: grabbing; }
#graph-canvas.hovering { cursor: pointer; }

.graph-toolbar {
  position: absolute;
  top: 16px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  background: color-mix(in srgb, var(--panel-2) 86%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 12.5px;
}
.graph-title { font-weight: 600; letter-spacing: 0.01em; }
.graph-sub { color: var(--text-faint); font-size: 11.5px; font-family: var(--mono); }

.graph-legend {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  background: color-mix(in srgb, var(--panel-2) 86%, transparent);
  backdrop-filter: blur(10px);
  font-size: 11.5px;
  max-height: 54%;
  overflow-y: auto;
}
.graph-legend .lg-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.graph-legend .lg-toggle:hover { background: var(--hover); color: var(--text); }
.graph-legend .lg-toggle::after { content: '▾'; font-size: 9px; opacity: 0.55; }
.graph-legend.collapsed { padding: 3px; }
.graph-legend.collapsed .lg-toggle::after { content: '▸'; }
.graph-legend.collapsed .lg-body { display: none; }
.graph-legend .lg-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 3px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
}
.legend-row:hover { background: var(--hover); color: var(--text); }
.legend-row.dim { opacity: 0.35; }
.legend-row.active { background: var(--hover); color: var(--text); }
.legend-row .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.graph-hintbar {
  position: absolute;
  right: 20px;
  bottom: 20px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  background: color-mix(in srgb, var(--panel-2) 86%, transparent);
  backdrop-filter: blur(10px);
  color: var(--text-faint);
  font-size: 11px;
}

.graph-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  max-width: 240px;
  transform: translate(12px, 12px);
}
.graph-tip .tt { font-weight: 600; color: var(--text); }
.graph-tip .tb { color: var(--text-faint); font-size: 11px; margin-top: 2px; }

/* ------------------------------------------------ misc */
.note-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 13.5px;
  padding: 30px 0;
}
.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.notfound { max-width: 560px; margin: 12vh auto; text-align: center; color: var(--text-dim); }
.notfound h1 { color: var(--text); font-size: 24px; }
.only-mobile { display: none !important; }

/* first-paint skeleton (replaced as soon as scripts run) */
.booting {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 13px;
  padding: 22px 14px;
}
.view > .booting { padding: 16vh 0 0; justify-content: center; }
.sk-lines { padding: 6px 14px; }
.sk-line {
  height: 9px;
  margin: 10px 0;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--panel-2), var(--border), var(--panel-2));
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.sk-line.w1 { width: 62%; }
.sk-line.w2 { width: 78%; }
.sk-line.w3 { width: 48%; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -80% 0; } }

@media (max-width: 1320px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .context { display: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(84vw, 320px);
    transform: translateX(-103%);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
    z-index: 60;
  }
  .sidebar.open { transform: none; }
  .scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
  }
  .scrim.show { display: block; }
  .only-mobile { display: inline-flex !important; }
  .view { padding: 24px 18px 88px; }
  .view.graph-view { height: calc(100vh - var(--topbar-h)); padding: 0; }
  .hero { padding: 26px 22px 22px; }
  .note-content { font-size: 15.5px; }
  .note-content table { font-size: 13px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; text-align: left; align-items: flex-start; }
  .graph-legend { max-height: 48%; }
  .graph-hintbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------ git history */
.history-page { max-width: 1180px; margin: 0 auto; }
.history-head { padding: 6px 2px 18px; }
.history-head h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.history-sub { margin: 7px 0 0; color: var(--text-faint); font-size: 12.5px; }
.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}
.history-graph {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--bg-soft);
  overflow: hidden;
}
.hg-row {
  display: flex;
  width: 100%;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.hg-row:last-child { border-bottom: 0; }
.hg-row:hover { background: rgba(168, 130, 255, 0.06); }
.hg-row.active { background: rgba(168, 130, 255, 0.1); }
.hg-lane { flex: none; display: flex; align-items: center; padding-left: 8px; }
.hg-svg { display: block; }
.hg-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 10px 14px 10px 6px;
}
.hg-subject {
  font-size: 13.5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hg-row.active .hg-subject { color: var(--accent-strong, #c9b2ff); }
.hg-meta { display: flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: 11.5px; }
.hg-meta code, .hd-meta code, .ci-meta code {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
}
.history-detail {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--bg-soft);
}
.hd-head { font-size: 15px; font-weight: 620; line-height: 1.45; }
.hd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 7px; color: var(--text-faint); font-size: 11.5px; }
.hd-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 18px 0 9px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hd-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.hd-files li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hd-file {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hd-file:hover { color: var(--accent, #a882ff); }
.st-badge {
  flex: none;
  min-width: 34px;
  text-align: center;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.6;
}
.st-badge.add { color: #8fd18a; background: rgba(143, 209, 138, 0.13); }
.st-badge.mod { color: #e2c07a; background: rgba(226, 192, 122, 0.13); }
.st-badge.del { color: #e2838c; background: rgba(226, 131, 140, 0.13); }
.st-badge.ren { color: #7fb6ef; background: rgba(127, 182, 239, 0.13); }
.hd-others { display: flex; flex-wrap: wrap; gap: 6px; }
.hd-other {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-faint);
  font-size: 11px;
}
.hist-empty { padding: 18px 4px; color: var(--text-faint); font-size: 12.5px; }

/* note page commit list */
.commit-list { display: flex; flex-direction: column; gap: 2px; }
.commit-item {
  display: flex;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}
.commit-item:hover { background: rgba(168, 130, 255, 0.07); }
.ci-dot { flex: none; width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--accent, #a882ff); }
.ci-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ci-subject {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ci-meta { color: var(--text-faint); font-size: 10.5px; }

@media (max-width: 860px) {
  .history-layout { grid-template-columns: minmax(0, 1fr); }
  .history-detail { position: static; max-height: none; }
  .history-head h1 { font-size: 21px; }
  .hg-subject { font-size: 12.5px; }
}

.note-history-inline {
  display: none;
  margin: 30px 0 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.note-history-inline summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
@media (max-width: 1319px) {
  .note-history-inline { display: block; }
}
