/* =========================================================
   烟雨黑帽 - custom theme (rebuilt for the web)
   ========================================================= */

:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef1f7;
  --text: #1c2333;
  --text-soft: #5a6478;
  --text-mute: #8b93a7;
  --border: #e2e6ef;
  --border-strong: #cfd6e4;
  --brand: #2f6bff;
  --brand-2: #7a5cff;
  --brand-soft: #e8efff;
  --accent: #12b981;
  --warn: #f0a020;
  --danger: #e5484d;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06);
  --shadow: 0 6px 24px rgba(17, 24, 39, .08);
  --shadow-lg: 0 24px 60px rgba(17, 24, 39, .14);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 300px;
  --topbar-h: 60px;
  --searchbar-h: 56px;
  --header-h: calc(var(--searchbar-h) + var(--topbar-h));
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 860px;
}

html[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elev: #121a2e;
  --bg-soft: #182238;
  --text: #e6ebf5;
  --text-soft: #a9b3c7;
  --text-mute: #7b869c;
  --border: #232e47;
  --border-strong: #33405e;
  --brand: #6f95ff;
  --brand-2: #a58bff;
  --brand-soft: #1a2542;
  --accent: #32d29a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 26px 64px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ---------------- inline ad banner (under breadcrumbs) ---------------- */
.ad-banner { display: block; margin: 16px 0 6px; border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); }
.ad-banner img { display: block; width: 100%; height: auto; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky;
  top: var(--searchbar-h);
  z-index: 60;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

/* ---------------- search bar (top row) ---------------- */
.searchbar {
  position: sticky;
  top: 0;
  z-index: 61;
  display: flex;
  align-items: center;
  height: var(--searchbar-h);
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 11px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: .18s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
#menuBtn { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 700;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 14px;
  letter-spacing: .5px;
  font-weight: 800;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; }
.brand-text i { font-style: normal; font-size: 11px; color: var(--text-mute); letter-spacing: .4px; }

.search { flex: 1; max-width: 460px; margin: 0 auto; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-soft) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.3-4.3'/></svg>") no-repeat 13px center;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: .18s;
}
.search input:focus { border-color: var(--brand); background-color: var(--bg-elev); box-shadow: 0 0 0 4px var(--brand-soft); }

/* ---------------- layout ---------------- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: var(--header-h);
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-soft);
}
.sidebar-head .count {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 20px;
  padding: 2px 9px;
}
.nav-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 20px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 18px; font-size: 12.5px; }
.sidebar-foot a { color: var(--text-mute); }

.home-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 2px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
}
.home-btn svg { flex: none; color: var(--brand); }
.home-btn:hover {
  text-decoration: none;
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

/* ---------------- nav tree ---------------- */
.nav-tree, .nav-children { list-style: none; margin: 0; padding: 0; }
.nav-children { padding-left: 12px; border-left: 1px dashed var(--border-strong); margin-left: 8px; }
.nav-item > a {
  display: block;
  padding: 7px 10px;
  margin: 1px 0;
  border-radius: 9px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.45;
  transition: .15s;
}
.nav-item.depth-0 > a { color: var(--text); font-weight: 650; font-size: 14.5px; }
.nav-item > a:hover { background: var(--bg-soft); color: var(--brand); text-decoration: none; }
.nav-item.active > a {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav-item.hidden { display: none; }

/* ---------------- content ---------------- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 32px clamp(18px, 5vw, 56px) 80px;
}
.article { max-width: var(--maxw); margin: 0 auto; }

.crumbs {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.crumbs li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.crumbs li + li::before {
  content: "/";
  color: var(--text-mute);
}
.crumbs a { color: var(--text-mute); }
.crumbs a:hover { color: var(--brand); }
.crumbs [aria-current="page"] { color: var(--text-soft); }

.article h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 6px 0 4px;
}
.cn-title {
  color: var(--text-soft);
  font-size: 15px;
  margin: 0 0 22px;
}

/* ---------------- toc box ---------------- */
.toc-box {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin: 0 0 26px;
  box-shadow: var(--shadow-sm);
}
.toc-box > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-soft);
  letter-spacing: .3px;
}
.toc-box .toc > ul, .toc-box ul { margin: 8px 0 0; padding-left: 18px; }
.toc-box ul { list-style: none; }
.toc-box li { margin: 3px 0; }
.toc-box a { color: var(--text-soft); font-size: 14px; }
.toc-box a:hover { color: var(--brand); }

/* ---------------- article body ---------------- */
.article-body { font-size: 16.5px; }
.article-body h2 {
  font-size: 25px;
  margin: 2.1em 0 .7em;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--border);
  letter-spacing: -.01em;
}
.article-body h3 { font-size: 20px; margin: 1.7em 0 .6em; }
.article-body h4 { font-size: 17px; margin: 1.4em 0 .5em; color: var(--text-soft); }
.article-body p { margin: .85em 0; }
.article-body ul, .article-body ol { padding-left: 1.5em; margin: .8em 0; }
.article-body li { margin: .3em 0; }
.article-body blockquote {
  margin: 1.1em 0;
  padding: 10px 18px;
  border-left: 4px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 10px 10px 0;
  color: var(--text-soft);
}
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.article-body img {
  display: block;
  margin: 1.2em auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.article-body a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.article-body code {
  font-family: var(--mono);
  font-size: .88em;
  padding: .16em .42em;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: #d6336c;
}
html[data-theme="dark"] .article-body code { color: #ff8fab; }

.article-body pre {
  position: relative;
  margin: 1.2em 0;
  padding: 16px 18px;
  background: #1f2430;
  color: #e6edf3;
  border-radius: var(--radius);
  overflow: auto;
  border: 1px solid #2c3444;
  box-shadow: var(--shadow-sm);
}
.article-body pre code {
  display: block;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-family: var(--sans);
  color: #cbd5e1;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: .15s;
}
.article-body pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.copy-btn.done { color: var(--accent); border-color: var(--accent); }

/* tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14.5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.article-body th, .article-body td { padding: 9px 13px; border: 1px solid var(--border); text-align: left; }
.article-body thead th { background: var(--bg-soft); font-weight: 700; }
.article-body tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }

/* ---------------- pager ---------------- */
.pager {
  max-width: var(--maxw);
  margin: 44px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.pg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: .18s;
}
.pg:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.pg span { font-size: 12px; color: var(--text-mute); }
.pg b { font-size: 15px; }
.pg.next { text-align: right; align-items: flex-end; }

/* ---------------- hero + chapters (home) ---------------- */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px 0 26px;
}
.hero h1 {
  font-size: clamp(30px, 5.4vw, 52px);
  line-height: 1.08;
  letter-spacing: -.03em;
  margin: 0 0 8px;
  background: linear-gradient(120deg, var(--brand), var(--brand-2) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-cn { font-size: 17px; color: var(--text-soft); margin: 0 0 14px; font-weight: 600; }
.hero-desc { font-size: 16px; color: var(--text-soft); max-width: 680px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero-meta span {
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}

.chapters { max-width: 1060px; margin: 20px auto 0; }
.chapters h2 { font-size: 22px; margin: 0 0 18px; }
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.chapter-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: .18s;
}
.chapter-card:hover {
  text-decoration: none;
  border-color: var(--brand);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.chapter-card b { font-size: 15.5px; line-height: 1.4; }
.chapter-card i { font-style: normal; font-size: 12.5px; color: var(--text-mute); }

.notice {
  max-width: 1060px;
  margin: 30px auto 0;
  padding: 16px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text-soft);
  font-size: 14px;
}
.notice p { margin: 0; }

/* ---------------- footer ---------------- */
.site-foot {
  max-width: var(--maxw);
  margin: 60px auto 0;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13.5px;
}
.site-foot p { margin: .3em 0; }
.site-foot .muted { color: var(--text-mute); font-size: 12.5px; }

/* ---------------- scrim / mobile ---------------- */
.scrim {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(8, 12, 24, .5);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.scrim.show { display: block; }

@media (max-width: 980px) {
  #menuBtn { display: inline-flex; }
  .search { max-width: none; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    z-index: 50;
    transform: translateX(-104%);
    transition: transform .26s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 24px 18px 64px; }
  .pager { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  :root { --searchbar-h: 0px; }
  .searchbar { display: none; }
  .brand-text i { display: none; }
  .article-body { font-size: 16px; }
}

.nav-item > .nav-label{display:block;padding:7px 10px;margin:1px 0;border-radius:9px;color:var(--text);font-weight:650;font-size:14.5px;line-height:1.45}
