/* ============================================================
   中医知识站 · 样式表
   设计基调：宣纸米白 / 墨色文字 / 朱砂点缀
   浅色为默认，深色跟随系统并可手动切换
   ============================================================ */

:root {
  /* 浅色（宣纸） */
  --paper:        #f7f4ee;
  --paper-2:      #fffdf9;
  --surface:      #ffffff;
  --surface-2:    #f2ede3;
  --ink:          #23201c;
  --ink-2:        #4a443c;
  --ink-3:        #7d7568;
  --line:         #e2dbcd;
  --line-2:       #cfc5b2;
  --brand:        #8c6d46;
  --brand-ink:    #6d5436;
  --brand-soft:   #f0e7d8;
  --cinnabar:     #9a4b3f;
  --jade:         #4a7c6f;
  --violet:       #5c5a86;
  --mark-bg:      #f6e6bf;
  --mark-ink:     #6b4d12;
  --shadow-sm:    0 1px 2px rgba(60, 48, 30, .06), 0 1px 3px rgba(60, 48, 30, .04);
  --shadow-md:    0 4px 12px rgba(60, 48, 30, .08), 0 2px 4px rgba(60, 48, 30, .04);
  --shadow-lg:    0 12px 32px rgba(60, 48, 30, .12);
  --radius:       14px;
  --radius-sm:    9px;
  --header-h:     116px;
  --sidebar-w:    286px;
  --content-max:  860px;
  --fs-base:      16px;
  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --paper:        #14161a;
  --paper-2:      #191c21;
  --surface:      #1e2127;
  --surface-2:    #252932;
  --ink:          #e8e6e1;
  --ink-2:        #b9b5ad;
  --ink-3:        #8b8781;
  --line:         #2f343d;
  --line-2:       #3d434e;
  --brand:        #c9a878;
  --brand-ink:    #e0c69c;
  --brand-soft:   #2b2a25;
  --cinnabar:     #d08476;
  --jade:         #7fb5a4;
  --violet:       #a3a1cf;
  --mark-bg:      #4a3f22;
  --mark-ink:     #f0dcae;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md:    0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg:    0 14px 36px rgba(0, 0, 0, .45);
}

/* ---------------------------------------------------------- 基础 */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: var(--fs-base);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 14px);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* 宣纸纹理：极淡的网格，避免大面积纯色 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 12% 8%, rgba(140, 109, 70, .05), transparent 42%),
    radial-gradient(circle at 88% 4%, rgba(74, 124, 111, .045), transparent 40%);
}

img, svg { max-width: 100%; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

h1, h2, h3, h4, h5 { font-family: var(--serif); font-weight: 600; line-height: 1.35; margin: 0 0 .6em; letter-spacing: .01em; }
p { margin: 0 0 1em; }
a { color: var(--brand-ink); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { color: var(--cinnabar); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 300;
  transform: translateY(-160%);
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
  transition: transform .18s;
}
.skip-link:focus { transform: translateY(0); }

/* ---------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px clamp(12px, 3vw, 28px) 12px;
}

.topbar-in { display: flex; align-items: center; gap: 12px; }

.brand {
  display: flex; align-items: center; gap: 11px;
  text-decoration: none; color: var(--ink); margin-right: auto; min-width: 0;
}
.brand-seal {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--cinnabar), #7d3830);
  color: #fff; border-radius: 9px;
  font-family: var(--serif); font-size: 21px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-family: var(--serif); font-size: 17px; letter-spacing: .04em; }
.brand-text small { color: var(--ink-3); font-size: 11.5px; letter-spacing: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  flex: none; width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent; color: var(--ink-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .16s, color .16s, border-color .16s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.nav-toggle { display: none; }

.i-moon { display: none; }
html[data-theme="dark"] .i-sun { display: none; }
html[data-theme="dark"] .i-moon { display: block; }

.searchbar {
  position: relative; margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 12px; height: 44px;
  transition: border-color .16s, box-shadow .16s;
}
.searchbar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-ico { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.searchbar input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  color: var(--ink); font-size: 15px; font-family: inherit; height: 100%;
}
.searchbar input::placeholder { color: var(--ink-3); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.search-kbd {
  flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px;
}
.search-clear {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--surface-2); border: 0; border-radius: 50%; cursor: pointer; color: var(--ink-3);
}
/* hidden 属性的优先级低于上面的 display，需显式声明 */
.search-clear[hidden] { display: none; }
.search-clear svg { width: 13px; height: 13px; }

/* ---------------------------------------------------------- 布局 */

.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 40px);
  max-width: 1420px; margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(12px, 3vw, 28px) 60px;
  align-items: start;
}

.sidebar {
  position: sticky; top: calc(var(--header-h) + 16px);
  max-height: calc(100dvh - var(--header-h) - 32px);
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.main { min-width: 0; max-width: var(--content-max); outline: none; }

.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 16, 10, .45);
  backdrop-filter: blur(2px);
}

/* ---------------------------------------------------------- 导航树 */

.nav-loading, .nav-empty { color: var(--ink-3); font-size: 13.5px; padding: 8px 10px; }

.nav-group { margin-bottom: 20px; }
.nav-group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .16em;
  color: var(--ink-3); text-transform: uppercase;
  padding: 0 10px 8px; margin: 0;
}
.nav-group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.nav-dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }

.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none;
  font-size: 14px; line-height: 1.45;
  transition: background .14s, color .14s;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.is-active {
  background: var(--brand-soft); color: var(--brand-ink);
  font-weight: 600; box-shadow: inset 2px 0 0 var(--brand);
}
.nav-link .nav-meta { margin-left: auto; font-size: 11px; color: var(--ink-3); flex: none; }
.nav-link.is-active .nav-meta { color: var(--brand-ink); }

.sidebar-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.disclaimer-mini { font-size: 12px; color: var(--ink-3); line-height: 1.65; margin: 0; }
.disclaimer-mini strong { color: var(--cinnabar); }

/* ---------------------------------------------------------- 首页 */

.hero { margin-bottom: 34px; }
.hero-seal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.hero-tag {
  font-size: 11.5px; letter-spacing: .14em; color: var(--brand-ink);
  background: var(--brand-soft); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px;
}
.hero h1 {
  font-size: clamp(28px, 5.4vw, 42px); line-height: 1.24;
  letter-spacing: .02em; margin-bottom: 14px;
}
.hero h1 em {
  font-style: normal; color: var(--cinnabar);
}
.hero-lead {
  font-size: clamp(15px, 2.2vw, 16.5px); color: var(--ink-2);
  max-width: 60ch; margin-bottom: 22px;
}

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 32px;
}
.stat {
  background: var(--surface); padding: 15px 14px; text-align: center;
}
.stat-num {
  display: block; font-family: var(--serif);
  font-size: clamp(21px, 3.6vw, 27px); font-weight: 700;
  color: var(--brand-ink); line-height: 1.2;
}
.stat-num small { font-size: .52em; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.stat-label { font-size: 12px; color: var(--ink-3); letter-spacing: .06em; }

.section-head {
  display: flex; align-items: baseline; gap: 12px;
  margin: 34px 0 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 20px; margin: 0; }
.section-head .count { font-size: 12.5px; color: var(--ink-3); margin-left: auto; flex: none; }

.system-grid { display: grid; gap: 14px; }
.sys-card {
  position: relative; overflow: hidden;
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 18px 16px;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.sys-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--sys-accent, var(--brand));
}
.sys-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: var(--line-2); color: inherit;
}
.sys-top { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.sys-icon {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: 9px; font-family: var(--serif); font-size: 17px; font-weight: 700;
  background: color-mix(in srgb, var(--sys-accent, var(--brand)) 13%, transparent);
  color: var(--sys-accent, var(--brand));
  border: 1px solid color-mix(in srgb, var(--sys-accent, var(--brand)) 30%, transparent);
}
.sys-name { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.sys-en { font-size: 11px; color: var(--ink-3); letter-spacing: .07em; }
.sys-tagline {
  font-family: var(--serif); font-size: 13px; color: var(--sys-accent, var(--brand));
  letter-spacing: .04em; margin-bottom: 7px;
}
.sys-desc { font-size: 13.5px; color: var(--ink-2); line-height: 1.7; margin: 0 0 12px; }
.sys-docs { display: flex; flex-wrap: wrap; gap: 6px; }
.sys-chip {
  font-size: 11.5px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 9px; border-radius: 999px;
}

/* 文档卡片 */
.doc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); }
.doc-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px;
  text-decoration: none; color: inherit;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); color: inherit; }
.doc-card-top { display: flex; align-items: flex-start; gap: 9px; }
.doc-title { font-family: var(--serif); font-size: 15.5px; font-weight: 600; line-height: 1.4; flex: 1; }
.doc-card h3 { margin: 0; font-size: 15.5px; }
.doc-author { font-size: 11.5px; color: var(--brand-ink); letter-spacing: .02em; }
.doc-desc {
  font-size: 12.8px; color: var(--ink-2); line-height: 1.68; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.doc-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: auto; padding-top: 4px;
  font-size: 11px; color: var(--ink-3);
}
.doc-stat {
  background: var(--surface-2); border-radius: 5px; padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.doc-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.doc-tag {
  font-size: 10.5px; color: var(--brand-ink);
  background: var(--brand-soft); padding: 1px 7px; border-radius: 4px;
}

/* 速查表 */
.atlas-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.atlas-tab {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-size: 13.5px; font-family: inherit; transition: all .15s;
}
.atlas-tab:hover { border-color: var(--brand); color: var(--ink); }
.atlas-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.atlas-search {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 12px;
  font-size: 14px; font-family: inherit; color: var(--ink);
}
.atlas-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.atlas-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.atlas-chip {
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); padding: 5px 11px; border-radius: 999px;
  cursor: pointer; font-size: 13px; font-family: var(--serif);
  transition: all .14s;
}
.atlas-chip:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.atlas-chip .pg { font-family: var(--sans); font-size: 10.5px; color: var(--ink-3); margin-left: 4px; }
.atlas-more { color: var(--ink-3); font-size: 12.5px; padding: 8px 2px; }
.atlas-empty { color: var(--ink-3); font-size: 13.5px; padding: 20px 0; }

/* ---------------------------------------------------------- 文档阅读页 */

.doc-header { margin-bottom: 22px; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 12px; flex-wrap: wrap; }
.crumb a { color: var(--ink-3); text-decoration: none; }
.crumb a:hover { color: var(--brand-ink); text-decoration: underline; }
.crumb .sep { color: var(--line-2); }

.doc-header h1 { font-size: clamp(23px, 4.4vw, 31px); margin-bottom: 10px; }
.doc-byline {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-3); margin-bottom: 12px;
}
.doc-badge {
  background: var(--cinnabar); color: #fff;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.doc-summary {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); padding: 13px 15px;
  font-size: 14px; color: var(--ink-2); line-height: 1.75;
}
.doc-summary p:last-child { margin: 0; }

.doc-tools {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 16px 0 22px; padding: 11px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  font-size: 12.8px; font-family: inherit; transition: all .15s;
}
.tool-btn:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.tool-btn svg { width: 14px; height: 14px; }

.doc-toc {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; margin-bottom: 26px;
}
.doc-toc-title {
  font-size: 11.5px; letter-spacing: .16em; color: var(--ink-3);
  font-weight: 700; margin: 0 0 11px;
}
.toc-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 26px; }
.toc-list li { break-inside: avoid; margin-bottom: 3px; }
.toc-list a {
  display: block; padding: 4px 9px; border-radius: 6px;
  font-size: 13.2px; color: var(--ink-2); text-decoration: none;
  border-left: 2px solid transparent; transition: all .14s;
}
.toc-list a:hover { background: var(--surface-2); color: var(--brand-ink); }
.toc-list a.is-current { background: var(--brand-soft); color: var(--brand-ink); border-left-color: var(--brand); font-weight: 600; }
.toc-list .lv3 { padding-left: 20px; font-size: 12.6px; color: var(--ink-3); }

/* 正文排版 */
.prose { font-size: 16px; line-height: 1.85; }
.prose > section { scroll-margin-top: calc(var(--header-h) + 16px); }
.prose h3 {
  font-size: 19px; margin: 34px 0 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.prose h3:first-child { margin-top: 0; }
.prose h4 { font-size: 16.5px; margin: 24px 0 9px; color: var(--ink); }
.prose h5, .prose h6 { font-size: 15px; margin: 20px 0 8px; color: var(--ink-2); }

.prose h3.verse, .prose h4.verse {
  background: var(--brand-soft); border: 1px dashed var(--brand);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 16px; color: var(--brand-ink); text-align: center;
}

.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.prose li { margin-bottom: .45em; }
.prose li::marker { color: var(--brand); }

.prose strong { font-weight: 700; color: var(--ink); }

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }

.prose blockquote {
  margin: 0 0 1.1em; padding: 11px 15px;
  background: var(--surface-2); border-left: 3px solid var(--line-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-2); font-size: 14.5px;
}
.prose blockquote p:last-child { margin: 0; }

mark.tag {
  background: var(--mark-bg); color: var(--mark-ink);
  padding: 0 4px; border-radius: 3px; font-size: .92em; font-weight: 600;
}
.star { color: var(--cinnabar); }
.prose code {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 4px; font-size: .88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* 表格 */
.tw {
  margin: 0 0 1.3em; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
}
.tw.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.prose table {
  width: 100%; border-collapse: collapse;
  font-size: 14px; line-height: 1.7;
}
.prose table[style] { min-width: 560px; }
.prose thead th {
  background: var(--surface-2); color: var(--ink);
  font-family: var(--serif); font-weight: 600; font-size: 13.5px;
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.prose tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  color: var(--ink-2); vertical-align: top;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 42%, transparent); }
.prose tbody tr:hover { background: var(--brand-soft); }
.prose td strong { color: var(--brand-ink); }

/* 文档底部 */
.doc-footer-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line);
}
.df-link {
  display: flex; flex-direction: column; gap: 3px;
  padding: 13px 15px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
  text-decoration: none; color: inherit; transition: all .15s;
}
.df-link:hover { border-color: var(--brand); background: var(--brand-soft); color: inherit; }
.df-link.next { text-align: right; }
.df-label { font-size: 11px; color: var(--ink-3); letter-spacing: .1em; }
.df-title { font-family: var(--serif); font-size: 14.5px; color: var(--brand-ink); }

.doc-disclaimer {
  margin-top: 26px; padding: 14px 16px;
  background: color-mix(in srgb, var(--cinnabar) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--cinnabar) 28%, var(--line));
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--ink-2); line-height: 1.75;
}
.doc-disclaimer strong { color: var(--cinnabar); }

/* ---------------------------------------------------------- 搜索结果页 */

.search-hero { margin-bottom: 20px; }
.search-hero h1 { font-size: clamp(22px, 4vw, 28px); margin-bottom: 8px; }
.search-summary { color: var(--ink-3); font-size: 14px; margin: 0; }
.search-summary b { color: var(--brand-ink); }

.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; font-family: inherit; transition: all .14s;
}
.filter-chip:hover { border-color: var(--brand); color: var(--ink); }
.filter-chip.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.result {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; transition: all .15s;
}
.result:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.result-top {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px; font-size: 11.5px; color: var(--ink-3);
}
.result-doc { color: var(--brand-ink); font-weight: 600; }
.result-sec { color: var(--ink-3); }
.result-snippet {
  font-size: 14px; color: var(--ink-2); line-height: 1.75; margin: 0;
}
.result-snippet em {
  font-style: normal; background: var(--mark-bg); color: var(--mark-ink);
  padding: 0 2px; border-radius: 3px; font-weight: 600;
}
.result-type {
  font-size: 10.5px; padding: 1px 7px; border-radius: 4px;
  background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line);
}

/* 搜索下拉（输入框内） */
.suggest {
  position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 120;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: min(64dvh, 520px); overflow-y: auto;
  display: none;
}
.suggest.is-open { display: block; }
.suggest-head {
  padding: 8px 14px; font-size: 11px; letter-spacing: .12em;
  color: var(--ink-3); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface);
}
.suggest-item {
  display: block; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover, .suggest-item.is-cursor { background: var(--brand-soft); }
.suggest-item-top { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.suggest-item-title { font-size: 14px; color: var(--ink); font-weight: 600; }
.suggest-item-title em, .suggest-item-text em { font-style: normal; background: var(--mark-bg); color: var(--mark-ink); padding: 0 2px; border-radius: 3px; }
.suggest-item-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.suggest-foot {
  padding: 8px 14px; font-size: 11.5px; color: var(--ink-3);
  border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center;
}

/* 404 */
.notfound { text-align: center; padding: 60px 20px; }
.notfound h1 { font-size: 60px; color: var(--line-2); margin-bottom: 8px; }
.notfound p { color: var(--ink-3); margin-bottom: 20px; }

/* ---------------------------------------------------------- 页脚 / 提示 */

.site-foot {
  position: relative; z-index: 1;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 26px clamp(14px, 4vw, 32px) 34px;
  max-width: 1420px; margin: 0 auto;
}
.site-foot p { font-size: 12.5px; color: var(--ink-3); line-height: 1.8; max-width: 90ch; margin: 0 0 10px; }
.site-foot strong { color: var(--cinnabar); }
.site-foot .src { font-size: 11.5px; color: var(--ink-3); opacity: .85; padding-top: 10px; border-top: 1px dashed var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 200;
  transform: translate(-50%, 140%);
  background: var(--ink); color: var(--paper);
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); transition: transform .24s cubic-bezier(.2,.9,.3,1.2);
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.is-show { transform: translate(-50%, 0); }

/* 返回顶部 */
.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-2);
  color: var(--ink-2); cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.to-top.is-show { opacity: 1; pointer-events: auto; }
.to-top:hover { border-color: var(--brand); color: var(--brand-ink); }
.to-top svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------- 响应式 */

/* 中屏：收窄侧栏 */
@media (max-width: 1080px) {
  :root { --sidebar-w: 244px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toc-list { columns: 1; }
}

/* 平板与手机：侧栏转为抽屉 */
@media (max-width: 860px) {
  :root { --header-h: 108px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-bottom: 40px; }

  .nav-toggle { display: grid; }

  .sidebar {
    position: fixed; z-index: 95;
    top: 0; left: 0; bottom: 0;
    width: min(84vw, 320px);
    max-height: 100dvh;
    background: var(--paper-2);
    border-right: 1px solid var(--line);
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.3, .8, .3, 1);
    overscroll-behavior: contain;
  }
  .sidebar.is-open { transform: translateX(0); }

  .main { max-width: 100%; }
  .doc-footer-nav { grid-template-columns: 1fr; }
  .df-link.next { text-align: left; }
}

@media (max-width: 560px) {
  :root { --fs-base: 15.5px; }
  .brand-text small { display: none; }
  .searchbar { height: 42px; }
  .search-kbd { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 12px 8px; }
  .doc-grid { grid-template-columns: 1fr; }
  .prose { font-size: 15.5px; }
  .prose h3 { font-size: 17.5px; }
  .hero { margin-bottom: 26px; }
  .section-head { margin: 28px 0 13px; }
  .site-foot { padding-bottom: calc(34px + env(safe-area-inset-bottom)); }
}

/* 宽屏：限制超大字号下的行宽 */
@media (min-width: 1600px) {
  :root { --fs-base: 17px; }
  :root { --content-max: 940px; }
}

/* 打印 */
@media print {
  .topbar, .sidebar, .site-foot, .to-top, .doc-toc, .doc-tools, .toast, .suggest { display: none !important; }
  .layout { display: block; padding: 0; }
  .prose { font-size: 11.5pt; }
  .tw { break-inside: avoid; }
  body { background: #fff; }
}
