

:root {
  --bg: #f7f9fc;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --lock: #7c3aed;
  --lock-soft: rgba(124, 58, 237, 0.1);
  --code-bg: #f1f5f9;
  --shadow: 0 10px 28px -14px rgba(15, 23, 42, 0.12);
  --glow-a: rgba(37, 99, 235, 0.09);
  --glow-b: rgba(217, 119, 6, 0.07);
  --scene-hill-1: #94a3b8;
  --scene-hill-2: #cbd5e1;
  --scene-line: #64748b;
  --art-mist: #e2e8f0;
  --art-ink: #1e293b;
  --art-paper: #ffffff;
  --art-roof: #334155;
  --art-bamboo: #2f6f5e;
  --art-moon: #94a3b8;
  --art-lantern-glow: #f59e0b;
  --art-seal: #b91c1c;
  --art-seal-bg: rgba(185, 28, 28, 0.06);
  --hero-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 250, 252, 0.84) 62%, rgba(241, 245, 249, 0.88) 100%);
}
[data-theme="dark"] {
  --bg: #090d16;
  --surface: rgba(17, 24, 39, 0.84);
  --surface-solid: #111827;
  --text: #f8fafc;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --lock: #c084fc;
  --lock-soft: rgba(192, 132, 252, 0.15);
  --code-bg: rgba(15, 23, 42, 0.9);
  --shadow: 0 16px 38px -16px rgba(0, 0, 0, 0.6);
  --glow-a: rgba(59, 130, 246, 0.14);
  --glow-b: rgba(245, 158, 11, 0.1);
  --scene-hill-1: #334155;
  --scene-hill-2: #1e293b;
  --scene-line: #64748b;
  --art-mist: #1e293b;
  --art-ink: #cbd5e1;
  --art-paper: #131c2e;
  --art-roof: #334155;
  --art-bamboo: #5eead4;
  --art-moon: #fde68a;
  --art-lantern-glow: #fbbf24;
  --art-seal: #f87171;
  --art-seal-bg: rgba(248, 113, 113, 0.08);
  --hero-bg: linear-gradient(135deg, rgba(17, 24, 39, 0.88) 0%, rgba(15, 23, 42, 0.78) 62%, rgba(22, 31, 48, 0.84) 100%);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  position: relative;
  overflow-x: hidden;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: -2;
  background:
    radial-gradient(620px 340px at 14% -4%, var(--glow-a), transparent 70%),
    radial-gradient(540px 320px at 88% 8%, var(--glow-b), transparent 72%);
}
.bg-scene { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.bg-mountains { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 300px; opacity: 0.7; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--amber-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); flex-shrink: 0;
}
.brand-mark svg { width: 17px; height: 17px; display: block; }
.brand-mono { font-size: 0.96rem; letter-spacing: 0.02em; }
.brand-pill { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.68rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.lantern-halo { transform-origin: center; animation: lantern-breathe 5.6s ease-in-out infinite; }
@keyframes lantern-breathe { 0%,100% { opacity: 0.76; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lantern-halo { animation: none; } }
.nav-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 0.83rem; font-family: inherit; cursor: pointer;
  text-decoration: none;
}
.nav-btn:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-solid); text-decoration: none; }
.nav-btn-private { border-color: color-mix(in srgb, var(--lock) 32%, var(--border)); color: var(--lock); background: var(--lock-soft); }
.nav-btn-private:hover { border-color: var(--lock); color: var(--lock); }
.search-input {
  height: 34px; width: 210px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-solid);
  color: var(--text); font-size: 0.84rem; font-family: inherit; outline: none;
}
.search-input:focus { border-color: var(--accent); }
.prose h1 { font-size: 1.85rem; line-height: 1.28; margin: 0 0 16px; letter-spacing: -0.02em; }
.prose h2 { font-size: 1.32rem; margin: 32px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); scroll-margin-top: 78px; }
.prose h3 { font-size: 1.08rem; margin: 24px 0 8px; scroll-margin-top: 78px; }
.prose p { margin: 0 0 14px; color: var(--text-2); }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; color: var(--text-2); }
.prose li { margin-bottom: 6px; }
.prose blockquote {
  margin: 18px 0; padding: 12px 16px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0;
}
.prose blockquote p { margin: 0; color: var(--text); }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em; padding: 2px 6px; border-radius: 6px; background: var(--code-bg);
}
.prose pre {
  margin: 16px 0; padding: 14px 16px; border-radius: 12px;
  background: var(--code-bg); border: 1px solid var(--border); overflow-x: auto;
}
.prose pre code { padding: 0; background: transparent; font-size: 0.85rem; line-height: 1.6; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }
.table-wrap { overflow-x: auto; margin: 18px 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.prose th, .prose td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--code-bg); font-weight: 650; }
.footer { border-top: 1px solid var(--border); padding: 20px; font-size: 0.82rem; color: var(--muted); text-align: center; margin-top: auto; }
@media (max-width: 720px) {
  .search-input { width: 140px; }
  .hide-sm { display: none; }
}

.docs-shell {
  max-width: 1240px; width: 100%; margin: 0 auto; padding: 26px 20px 56px;
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 200px; gap: 28px; align-items: start;
}
.sidebar { position: sticky; top: 82px; max-height: calc(100vh - 104px); overflow-y: auto; padding-right: 8px; }
.sidebar-drawer > summary { display: none; list-style: none; cursor: pointer; }
.sidebar-drawer > summary::-webkit-details-marker { display: none; }
.sidebar-jump { display: none; }
.cat-block { margin-bottom: 18px; }
.cat-title { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px 10px; }
.side-link {
  display: block; padding: 7px 10px; border-radius: 9px; font-size: 0.88rem;
  color: var(--text-2); text-decoration: none; margin-bottom: 2px;
}
.side-link:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.side-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.doc-main {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 30px 34px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.study-hero {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(200px, 0.85fr);
  align-items: center; gap: 22px; padding: 22px 24px; margin-bottom: 24px;
  border-radius: 16px; background: var(--hero-bg); border: 1px solid var(--border);
}
.study-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; background: var(--surface-solid); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem; color: var(--muted); margin-bottom: 10px;
}
.study-hero h1 { margin: 0 0 8px; font-size: 1.7rem; }
.study-hero p { margin: 0; font-size: 0.92rem; color: var(--text-2); line-height: 1.72; }
.study-art { display: flex; justify-content: flex-end; }
.study-art svg { width: 100%; max-width: 240px; height: auto; display: block; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--border) 80%, transparent); }
.doc-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.8rem; color: var(--muted); margin-bottom: 20px; }
.tag { padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc { position: sticky; top: 82px; font-size: 0.82rem; border-left: 1px solid var(--border); padding-left: 14px; }
.toc-title { font-weight: 700; color: var(--muted); margin-bottom: 8px; font-size: 0.76rem; }
.toc a { display: block; color: var(--muted); padding: 4px 0; text-decoration: none; }
.toc a:hover { color: var(--accent); }
.toc a.lv-3 { padding-left: 12px; font-size: 0.79rem; }
.doc-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.doc-card {
  display: block; padding: 18px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface-solid); text-decoration: none; color: inherit;
}
.doc-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); transition: all 0.2s ease; }
.doc-card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--text); }
.doc-card p { margin: 0; font-size: 0.84rem; color: var(--muted); }
.search-results {
  position: fixed; top: 64px; right: 20px; width: min(420px, calc(100vw - 40px));
  max-height: 65vh; overflow-y: auto; z-index: 40;
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow); padding: 8px; display: none;
}
.search-results.is-open { display: block; }
.search-item { display: block; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; }
.search-item:hover { background: var(--accent-soft); text-decoration: none; }
.search-item strong { display: block; font-size: 0.9rem; color: var(--text); }
.search-item span { font-size: 0.78rem; color: var(--muted); }
@media (max-width: 1040px) {
  .docs-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 780px) {
  .docs-shell { grid-template-columns: 1fr; gap: 14px; padding-top: 14px; }
  .sidebar { position: static; max-height: none; padding: 0; border-bottom: none; }
  .sidebar-drawer {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 0; box-shadow: var(--shadow);
  }
  .sidebar-drawer > summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; font-size: 0.88rem; font-weight: 650; color: var(--text);
  }
  .sidebar-drawer > summary::after { content: '展开 ▾'; font-size: 0.78rem; color: var(--muted); font-weight: 500; }
  .sidebar-drawer[open] > summary { border-bottom: 1px solid var(--border); }
  .sidebar-drawer[open] > summary::after { content: '收起 ▴'; }
  .sidebar-body { padding: 12px 12px 6px; }
  .doc-main { padding: 22px 18px; }
  .study-hero { grid-template-columns: 1fr; padding: 18px; }
  .study-art { justify-content: center; }
  .doc-cards { grid-template-columns: 1fr; }
}
