﻿:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #24292f;
  --muted: #6e7781;
  --accent: #1f6feb;
  --accent-soft: #e7f0fd;
  --sidebar-w: 340px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

.app {
  display: flex;
  min-height: 100vh;
}


/* ---------- 顶部导航栏 ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 84px;
  z-index: 100;
  background: linear-gradient(135deg, #3b82f6 0%, #7fb3f5 60%, #a8c9f7 100%);
  box-shadow: 0 2px 10px rgba(59, 130, 246, .18);
}

.topbar-inner {
  height: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar .brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: .5px;
  line-height: 1.3;
}

.topbar .brand .sub {
  margin-top: 2px;
  font-size: 13px;
  color: rgba(255, 255, 255, .85);
}

.top-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 20px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.top-search-btn:hover {
  background: rgba(255,255,255,.32);
  border-color: rgba(255,255,255,.85);
}

.mag-icon {
  position: relative;
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.mag-icon::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -3px;
  width: 6px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.mag-icon.big {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.mag-icon.big::after {
  right: -7px;
  bottom: -3px;
  width: 8px;
  height: 2px;
}

.app { padding-top: 84px; }

.sidebar {
  height: calc(100vh - 84px);
  top: 84px;
}


/* ---------- 搜索弹窗 ---------- */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 13vh 20px 20px;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
}

.search-modal[hidden] { display: none; }

.search-modal-box {
  width: 640px;
  max-width: 92vw;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
  overflow: hidden;
  animation: search-pop .18s ease;
}

@keyframes search-pop {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.search-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid #e8eaed;
  color: #5f6368;
}

.search-modal-head .mag-icon { color: #80868b; }

.search-modal-head input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 16px;
  color: #202124;
  background: transparent;
}

.search-modal-head input::placeholder { color: #9aa0a6; }

.search-close-btn {
  padding: 6px 15px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #5f6368;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.search-close-btn:hover { background: #f1f3f4; color: #202124; }

.search-modal .search-result {
  position: static;
  display: block;
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-height: calc(70vh - 58px);
}
/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: #f4f8fe;
  border-right: 1px solid #dbe7f7;
  overflow: hidden;
}





.search-wrap {
  position: relative;
  margin: 10px 12px;
}

.search-wrap input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fafbfc;
}

.search-wrap input:focus {
  border-color: var(--accent);
  background: #fff;
}

.search-result {
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 50;
  max-height: 380px;
  overflow: auto;
}

.search-result.open { display: block; }

.hit {
  display: block;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f1f3;
  text-decoration: none;
  color: var(--text);
}

.hit:last-child { border-bottom: none; }
.hit:hover { background: var(--accent-soft); }

.hit-title { display: block; font-size: 13px; font-weight: 600; }
.hit-snip { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.hit-snip mark { background: #fff3a3; color: inherit; border-radius: 2px; padding: 0 1px; }

.tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree .part {
  margin-top: 14px;
}

.part-label {
  display: block;
  padding: 10px 16px 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px calc(18px + var(--d, 0) * 18px);
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  border-left: 3px solid transparent;
  line-height: 1.55;
}

.toc-link:hover { background: #e9f1fc; }
.toc-link.active {
  background: linear-gradient(90deg, var(--accent-soft), rgba(231,240,253,.35));
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(31,111,235,.14);
}

.toc-link .toc-title { word-break: break-all; }
li.branch > .toc-link .toc-title { font-weight: 600; }

/* ---------- 主内容区 ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 40px 80px;
  max-width: 920px;
  margin: 0 auto;
}

.article-title {
  font-size: 26px;
  margin: 10px 0 6px;
  line-height: 1.3;
}

.article-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 22px;
}

.article-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 34px;
  line-height: 1.8;
  overflow-wrap: break-word;
}

.article-body h1 { font-size: 22px; margin: 24px 0 12px; }
.article-body h2 { font-size: 19px; margin: 26px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 16.5px; margin: 22px 0 10px; }
.article-body h4 { font-size: 15px; margin: 18px 0 8px; }
.article-body h5 { font-size: 14px; margin: 16px 0 6px; }

.article-body p { margin: 10px 0; }
.article-body strong { font-weight: 700; }
.article-body a { color: var(--accent); text-decoration: none; }
.article-body a:hover { text-decoration: underline; }

.article-body ul, .article-body ol {
  padding-left: 26px;
  margin: 10px 0;
}

.article-body li { margin: 4px 0; }

.article-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  display: block;
  overflow-x: auto;
  font-size: 13.5px;
}

.article-body th, .article-body td {
  border: 1px solid #d7dbe0;
  padding: 7px 11px;
  text-align: left;
}

.article-body th { background: #f2f4f7; font-weight: 600; }

.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.article-body .img-wrap { text-align: center; }

.article-body code {
  background: #f0f1f3;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 13px;
  font-family: Consolas, "Courier New", monospace;
}

.code-block {
  background: #0d1117;
  color: #e6edf3;
  border-radius: 8px;
  padding: 14px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

.code-block code { background: transparent; padding: 0; color: inherit; }

blockquote {
  border-left: 4px solid #d0d7de;
  margin: 12px 0;
  padding: 4px 16px;
  color: var(--muted);
  background: #fafbfc;
  border-radius: 0 6px 6px 0;
}

blockquote p { margin: 6px 0; }

/* ---------- 提示块 ---------- */
.callout {
  border-radius: 8px;
  padding: 12px 16px;
  margin: 14px 0;
  border: 1px solid transparent;
}

.callout p { margin: 6px 0; }

.callout-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.callout-success { background: #ebf9f0; border-color: #b7e4c7; }
.callout-success .callout-title { color: #1a7f37; }
.callout-info, .callout-note, .callout-tip { background: #e7f0fd; border-color: #b6d4f8; }
.callout-info .callout-title, .callout-note .callout-title, .callout-tip .callout-title { color: var(--accent); }
.callout-warning { background: #fff8e6; border-color: #f2d98d; }
.callout-warning .callout-title { color: #9a6700; }
.callout-error, .callout-danger { background: #fff0f0; border-color: #f3b8b8; }
.callout-error .callout-title, .callout-danger .callout-title { color: #d1242f; }

hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- 首页 ---------- */
.home-hero {
  background: linear-gradient(135deg, #1f6feb, #4d94f5);
  color: #fff;
  border-radius: 12px;
  padding: 40px 34px;
  margin-bottom: 18px;
}

.home-hero h1 { margin: 0 0 8px; font-size: 26px; }
.home-hero p { margin: 0 0 12px; font-size: 15px; opacity: .92; }
.home-stats { display: inline-block; background: rgba(255,255,255,.16); border-radius: 20px; padding: 5px 14px; font-size: 13px; }

.home-hint {
  background: var(--panel);
  border: 1px dashed #c8cdd3;
  border-radius: 10px;
  padding: 22px 30px;
  color: var(--muted);
}

.err { color: #d1242f; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9ced4; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 移动端自适应 ---------- */
.menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 8px;
  background: rgba(255,255,255,.18);
  cursor: pointer;
}
.menu-btn span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: #fff;
}

.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity .22s ease;
}
.sidebar-mask.show { opacity: 1; }

@media (max-width: 860px) {
  .topbar { height: 60px; }
  .app { padding-top: 60px; }
  .topbar-inner { padding: 0 12px; gap: 10px; }
  .topbar .brand h1 { font-size: 16px; }
  .topbar .brand .sub { font-size: 11px; }
  .menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    width: min(84vw, 340px);
    min-width: 0;
    height: auto;
    z-index: 200;
    transform: translateX(-105%);
    transition: transform .24s ease;
    border-radius: 0 12px 12px 0;
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  body.drawer-open .sidebar-mask { display: block; }
  .sidebar-mask { display: none; }
  .sidebar-mask.show { display: block; }

  .main { padding: 14px 12px 56px; }
  .article-title { font-size: 21px; }
  .article-body { padding: 16px 14px; border-radius: 8px; }
  .article-body h1 { font-size: 19px; }
  .article-body h2 { font-size: 17px; }
  .article-body h3 { font-size: 15.5px; }
  .article-body table { font-size: 12.5px; }
  .article-body th, .article-body td { padding: 6px 8px; }

  .home-hero { padding: 26px 18px; }
  .home-hero h1 { font-size: 22px; }
  .home-hint { padding: 16px 14px; }

  .search-modal { padding: 9vh 0 0; align-items: flex-start; }
  .search-modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 91vh;
    border-radius: 0;
  }

  .prev-next { flex-direction: column; gap: 8px; }
  .pn-link { padding: 10px 14px; }
}

@media (max-width: 480px) {
  .main { padding: 12px 8px 48px; }
  .article-body { padding: 14px 11px; }
  .toc-link { font-size: 14px; padding: 9px 12px 9px calc(16px + var(--d, 0) * 16px); }
  .top-search-btn { padding: 7px 12px; font-size: 13px; }
  .top-search-btn .btn-text { display: none; }
}

/* ---------- 目录折叠 ---------- */
li.branch { position: relative; }
li.branch > .toggle {
  position: absolute;
  left: 2px;
  top: 7px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  z-index: 1;
}
li.branch > .toggle:hover { background: #dfeaf8; color: var(--text); }
li.branch > .toggle svg { transition: transform .18s ease; }
li.branch > .toggle[aria-expanded="false"] svg { transform: rotate(0deg); }
li.branch.open > .toggle svg { transform: rotate(90deg); }
li.branch > ul.kids { overflow: hidden; transition: max-height .2s ease; }
li.branch:not(.open) > ul.kids { display: none; }
li.branch > .toc-link { padding-left: calc(32px + var(--d, 0) * 18px); }

/* ---------- 上一章 / 下一章 ---------- */
.prev-next {
  display: flex;
  gap: 12px;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.pn-link {
  flex: 1;
  min-width: 0;
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pn-link:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(31,111,235,.12); }
.pn-link.pn-next { text-align: right; }
.pn-link.pn-disabled { visibility: hidden; }
.pn-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pn-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pn-link:hover .pn-title { color: var(--accent); }


