:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #7c3aed;
  --accent-soft: #f3efff;
  --code-bg: #f4f4f5;
  --radius: 12px;
  --sidebar-w: 260px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d22;
    --bg-soft: #23262d;
    --text: #e6e6e6;
    --muted: #9aa0a6;
    --border: #33373f;
    --accent: #a78bfa;
    --accent-soft: #2a2440;
    --code-bg: #2b2e36;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 56px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; color: var(--text); cursor: pointer; }

/* 布局 */
.layout { display: flex; max-width: 1180px; margin: 0 auto; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  padding: 24px 16px; border-right: 1px solid var(--border);
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.side-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 14.5px; }
.sidebar nav a:hover { background: var(--bg-soft); text-decoration: none; }
.content { flex: 1; min-width: 0; padding: 32px 40px 80px; }
.note { max-width: 760px; }
.note-head h1 { font-size: 30px; margin: 0 0 8px; line-height: 1.3; }
.tags { margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12.5px; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }

/* 正文 */
h2 { font-size: 23px; margin: 34px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
h3 { font-size: 19px; margin: 26px 0 10px; }
h1 .header-anchor, h2 .header-anchor, h3 .header-anchor { color: var(--muted); opacity: 0; margin-right: 6px; font-weight: 400; }
h1:hover .header-anchor, h2:hover .header-anchor, h3:hover .header-anchor { opacity: .5; }
p { margin: 12px 0; }
ul, ol { padding-left: 1.5em; }
li { margin: 4px 0; }
li input[type="checkbox"] { margin-right: 6px; }
blockquote {
  margin: 16px 0; padding: 4px 16px; color: var(--muted);
  border-left: 3px solid var(--border);
}
hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
img.embed-img { max-width: 100%; border-radius: 8px; margin: 10px 0; }
mark { background: #fde68a; color: inherit; padding: 0 2px; border-radius: 3px; }

/* 代码 */
code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; font-size: .9em;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; }
pre { background: var(--code-bg); padding: 14px 16px; border-radius: var(--radius); overflow-x: auto; margin: 16px 0; }
pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.6; }

/* 表格 */
table { border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 14.5px; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
th { background: var(--bg-soft); }

/* 双链 */
.wikilink { background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; color: var(--accent); white-space: nowrap; }
.wikilink:hover { text-decoration: none; filter: brightness(0.95); }
.wikilink.missing { color: var(--muted); background: var(--bg-soft); border-bottom: 1px dashed var(--muted); }
.transclude {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 4px 18px 8px; margin: 16px 0; background: var(--bg-soft);
}
.transclude-head { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }

/* Callout */
.callout { margin: 16px 0; border-radius: var(--radius); padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.callout-title { font-weight: 700; margin-bottom: 4px; }
.callout-body > p:first-child { margin-top: 0; }
.callout-body > p:last-child { margin-bottom: 0; }
.callout-warning, .callout-caution, .callout-attention { border-color: #f59e0b; background: #fff7e6; }
.callout-danger, .callout-error, .callout-bug, .callout-failure { border-color: #ef4444; background: #fdeceb; }
.callout-tip, .callout-success, .callout-check, .callout-done { border-color: #10b981; background: #e9f9f2; }
.callout-info, .callout-note, .callout-abstract, .callout-summary { border-color: #3b82f6; background: #eaf2fe; }
.callout-example { border-color: #8b5cf6; background: #f3efff; }
.callout-quote { border-color: #9ca3af; background: var(--bg-soft); }
@media (prefers-color-scheme: dark) {
  .callout-warning, .callout-caution, .callout-attention { background: #3a2e12; }
  .callout-danger, .callout-error, .callout-bug, .callout-failure { background: #3c1f1f; }
  .callout-tip, .callout-success, .callout-check, .callout-done { background: #12302a; }
  .callout-info, .callout-note, .callout-abstract, .callout-summary { background: #17293f; }
}

.foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13.5px; }

/* 移动端 */
@media (max-width: 820px) {
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed; top: 56px; bottom: 0; left: 0; z-index: 15;
    background: var(--bg); transform: translateX(-100%); transition: transform .2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 8px 30px rgba(0,0,0,.2); }
  .content { padding: 22px 18px 60px; }
}
