/* 月裔萌芽 wiki —— 主题样式（零依赖，深/浅色双主题） */
:root {
  --bg: #0e1412;
  --bg-soft: #131b18;
  --panel: #16201c;
  --panel-2: #1b2622;
  --fg: #e9f1ec;
  --fg-soft: #c6d4cd;
  --dim: #8ea39a;
  --line: #23322c;
  --accent: #6fe3a4;
  --accent-soft: rgba(111, 227, 164, .14);
  --accent-2: #c3a6ff;
  --code-bg: #101a17;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --radius: 12px;
  --sidebar-w: 258px;
  --toc-w: 218px;
}
html[data-theme="light"] {
  --bg: #f7faf8;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f6f3;
  --fg: #17231e;
  --fg-soft: #34473f;
  --dim: #5d7268;
  --line: #dfe9e3;
  --accent: #12855a;
  --accent-soft: rgba(18, 133, 90, .1);
  --accent-2: #6d4fd0;
  --code-bg: #f0f5f2;
  --shadow: 0 6px 20px rgba(20, 40, 30, .1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.75 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.skip { position: absolute; left: -9999px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 18px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-mark { font-size: 19px; }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--fg-soft);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input, .searchpage input {
  width: 100%; padding: 9px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--fg); font-size: 14px; outline: none;
}
.search input:focus, .searchpage input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.results {
  position: absolute; top: 46px; left: 0; right: 0; max-height: 62vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.results a, .results-list a {
  display: block; padding: 10px 13px; border-bottom: 1px solid var(--line); color: var(--fg);
}
.results a:last-child { border-bottom: 0; }
.results a:hover, .results a.sel { background: var(--accent-soft); text-decoration: none; }
.r-page { font-size: 12px; color: var(--dim); margin-bottom: 2px; }
.r-head { font-weight: 600; font-size: 14px; }
.r-snip { font-size: 13px; color: var(--fg-soft); margin-top: 3px; word-break: break-word; }
.r-snip mark, .r-head mark { background: var(--accent-soft); color: var(--accent); padding: 0 2px; border-radius: 3px; }
.r-empty { padding: 14px; color: var(--dim); font-size: 14px; }

/* 布局 */
.layout {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 28px; max-width: 1400px; margin: 0 auto; padding: 0 18px;
}
.sidebar { position: sticky; top: 58px; height: calc(100vh - 58px); overflow: auto; padding: 18px 6px 60px 0; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 12px; letter-spacing: .08em; color: var(--dim); text-transform: uppercase;
  padding: 6px 10px; font-weight: 700;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block; padding: 6px 10px; border-radius: 8px; color: var(--fg-soft); font-size: 14px;
  border-left: 2px solid transparent;
}
.sidebar a:hover { background: var(--panel); color: var(--fg); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

main { min-width: 0; padding: 22px 0 80px; }
.crumb { font-size: 12.5px; color: var(--dim); margin-bottom: 6px; }
article { font-size: 15.5px; }
article h1 { font-size: 30px; line-height: 1.3; margin: 6px 0 18px; letter-spacing: .01em; }
article h2 {
  font-size: 21px; margin: 38px 0 12px; padding-top: 12px; border-top: 1px solid var(--line);
  scroll-margin-top: 72px;
}
article h2:first-of-type { border-top: 0; padding-top: 0; }
article h3 { font-size: 17px; margin: 26px 0 10px; color: var(--fg); scroll-margin-top: 72px; }
article h4 { font-size: 15.5px; margin: 20px 0 8px; color: var(--fg-soft); }
.anchor { opacity: 0; margin-left: 8px; font-weight: 400; font-size: .8em; }
h2:hover .anchor, h3:hover .anchor { opacity: .5; }
article p { margin: 12px 0; color: var(--fg-soft); }
article strong { color: var(--fg); }
article ul, article ol { padding-left: 22px; color: var(--fg-soft); }
article li { margin: 6px 0; }
article code {
  background: var(--code-bg); border: 1px solid var(--line); padding: 1px 5px;
  border-radius: 5px; font-size: .9em; font-family: ui-monospace, Consolas, monospace;
}
article pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; overflow: auto;
}
article pre code { border: 0; background: none; padding: 0; }
article blockquote {
  margin: 16px 0; padding: 10px 16px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--fg-soft);
}
article blockquote p { margin: 4px 0; }
article img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; margin: 16px 0; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
article table {
  width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14.5px;
  display: block; overflow-x: auto;
}
article th, article td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; vertical-align: top; }
article th { background: var(--panel-2); color: var(--fg); font-weight: 650; white-space: nowrap; }
article tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel) 55%, transparent); }
.arrow { text-align: center; color: var(--accent); font-size: 20px; line-height: 1; margin: 6px 0; }

/* 首页组件 */
.hero {
  background: linear-gradient(150deg, var(--accent-soft), transparent 70%), var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 26px 24px; margin: 8px 0 26px;
}
.hero-kicker { margin: 0; font-size: 12.5px; letter-spacing: .12em; color: var(--accent); text-transform: uppercase; }
.hero-title { margin: 8px 0 6px; font-size: 30px; }
.hero-sub { margin: 0; color: var(--dim); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0 8px; }
.card {
  display: flex; flex-direction: column; gap: 5px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--fg);
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card b { font-size: 15.5px; }
.card span { font-size: 13px; color: var(--dim); }
.hero-img { width: 100%; margin: 16px 0 0; border-radius: 10px; border: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.gallery img { margin: 0; height: 100%; object-fit: cover; }

/* 右侧目录 */
.toc { position: sticky; top: 58px; height: calc(100vh - 58px); overflow: auto; padding: 22px 0 60px; font-size: 13.5px; }
.toc-title { font-size: 12px; letter-spacing: .08em; color: var(--dim); text-transform: uppercase; font-weight: 700; margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 4px 0 4px 12px; color: var(--dim); border-left: 2px solid transparent; margin-left: -1px; }
.toc a:hover { color: var(--fg); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc .lv3 a { padding-left: 24px; font-size: 13px; }

/* 翻页与页脚 */
.pager { display: flex; gap: 12px; margin: 44px 0 0; flex-wrap: wrap; }
.pager a {
  flex: 1 1 200px; padding: 12px 15px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--fg); font-size: 14px;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 3px; }
.pager a.next { text-align: right; }
.foot { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; }

/* 搜索页 */
.searchpage { margin: 10px 0 20px; }
.searchpage .hint { color: var(--dim); font-size: 13px; margin: 8px 0 16px; }
.results-list a { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--panel); }
.results-list a:hover { border-color: var(--accent); }
.notfound { display: grid; place-items: center; height: 100vh; text-align: center; }

.only-mobile { display: none; }
@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-block; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 14px; }
  .sidebar {
    position: fixed; top: 58px; left: 0; width: 82%; max-width: 320px; z-index: 45;
    background: var(--bg-soft); border-right: 1px solid var(--line); padding: 16px 12px 60px;
    transform: translateX(-102%); transition: transform .22s ease;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .brand-text { display: none; }
  article h1 { font-size: 25px; }
  article h2 { font-size: 19px; }
}
@media print {
  .topbar, .sidebar, .toc, .pager, .foot { display: none; }
  .layout { display: block; }
  article h2 { break-inside: avoid; }
}
