/* === 极简东方·读书馆 v2：自写完整主题，不依赖 docsify vue.css === */
:root {
  --bg: #faf6ef;
  --bg-alt: #f3eee5;
  --bg-elv: #ffffff;
  --text: #1c1917;
  --text-mute: #6b6660;
  --text-faint: #a8a29e;
  --border: #dcd5c8;
  --divider: #e8e2d5;
  --accent: #a72b2a;
  --accent-soft: #c63c3c;
  --shadow: rgba(28, 25, 23, 0.08);
  --shadow-lg: rgba(28, 25, 23, 0.14);
  --nav-blur: rgba(250, 246, 239, 0.85);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Menlo", "Consolas", monospace;
  --nav-h: 56px;
  --sidebar-w: 280px;
  --toc-w: 220px;
}
[data-theme="dark"] {
  --bg: #1c1814;
  --bg-alt: #26211c;
  --bg-elv: #2d2823;
  --text: #f0e8d8;
  --text-mute: #a8a094;
  --text-faint: #6b665d;
  --border: #3d3631;
  --divider: #332e29;
  --accent: #d97070;
  --accent-soft: #e88585;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-lg: rgba(0, 0, 0, 0.6);
  --nav-blur: rgba(28, 24, 20, 0.85);
}
[data-theme="dark"] strong, [data-theme="dark"] b { font-weight: 600; }

*, *::before, *::after { box-sizing: border-box; }
/* 注意：html/body 不能用 overflow-x: hidden，否则 sticky TOC 会失效（破坏 sticky 上下文）
   用 max-width: 100% 防止溢出；如有水平滚动条出现，需排查具体溢出元素
   scrollbar-gutter: stable 让 drawer 打开时（body overflow hidden）滚动条不消失，避免内容横向跳动 */
html { scroll-behavior: smooth; max-width: 100%; scrollbar-gutter: stable; }
/* body 滚动锁仅在窄屏 drawer 打开时启用；宽屏 body.close 是"折叠侧栏"，背景应可继续滚动 */
body {
  margin: 0;
  padding: var(--nav-h) 0 0;
  max-width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(circle at 18% 28%, rgba(167, 43, 42, 0.014) 0%, transparent 45%),
    radial-gradient(circle at 82% 68%, rgba(90, 124, 110, 0.016) 0%, transparent 50%);
  transition: background 0.5s ease, color 0.5s ease;
}

/* === 顶栏 (hardcoded header.topbar) === */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--nav-blur);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.8rem;
  z-index: 99;
  font-family: var(--sans);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
}
.brand-seal {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  width: 1.65rem;
  height: 1.65rem;
  line-height: 1.65rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: var(--serif);
  border-radius: 3px;
  box-shadow: 0 1px 3px var(--shadow);
  transform: rotate(-3deg);
  transition: transform 0.3s ease;
  vertical-align: -0.32rem;
}
.brand:hover .brand-seal { transform: rotate(6deg); }
.brand-text {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}
.nav-mid {
  display: flex;
  gap: 1.8rem;
  font-size: 0.92rem;
  color: var(--text-mute);
}
.nav-mid a {
  color: inherit;
  text-decoration: none;
  position: relative;
  padding: 0.25rem 0;
  transition: color 0.2s;
}
.nav-mid a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: all 0.3s ease;
}
.nav-mid a:hover { color: var(--accent); }
.nav-mid a:hover::after { left: 0; width: 100%; }
.nav-right { display: flex; gap: 0.4rem; align-items: center; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  transition: all 0.2s;
  padding: 0;
}
.icon-btn:hover {
  border-color: var(--border);
  color: var(--accent);
  background: var(--bg-alt);
}
.icon-btn svg { width: 18px; height: 18px; }

/* === Sidebar (docsify aside.sidebar) === */
aside.sidebar {
  position: fixed !important;
  top: var(--nav-h) !important;
  left: 0 !important;
  bottom: 0 !important;
  width: var(--sidebar-w) !important;
  max-width: var(--sidebar-w) !important;
  background: var(--bg);
  border-right: 1px solid var(--divider);
  padding: 1.8rem 1.2rem 4rem;
  font-family: var(--sans);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  transform: none !important;
  transition: transform 0.3s ease;
}
aside.sidebar::-webkit-scrollbar { width: 4px; }
aside.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

aside.sidebar h1.app-name {
  margin: 0 0 1.8rem;
  padding: 0;
  font-weight: normal;
}
aside.sidebar h1.app-name a.app-name-link {
  display: block;
  color: var(--text);
  text-decoration: none;
  border: none !important;
}
/* 站名：仅文字（朱砂印章已挪到顶栏品牌处独占，避免双印章视觉竞争） */
.site-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.site-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.18rem;
  letter-spacing: 0.05em;
  color: var(--text);
}
.site-subtitle {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.16em;
  text-transform: lowercase;
  margin-top: 0.2rem;
  white-space: nowrap;
}

/* 搜索框 */
.sidebar .search {
  margin: 0 0 1.4rem;
  padding: 0;
  border-bottom: none;
}
.sidebar .search input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text);
  transition: all 0.2s;
}
.sidebar .search input::placeholder { color: var(--text-faint); }
.sidebar .search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elv);
}
.sidebar .search .clear-button {
  color: var(--text-faint);
  transform: translateY(-50%);
}
.sidebar .search h2 {
  font-family: var(--serif);
  color: var(--text-mute);
  font-size: 0.85rem;
  margin: 1rem 0 0.4rem;
  font-weight: 500;
}
.sidebar .search .matching-post {
  border-bottom: 1px solid var(--divider);
  padding: 0.6rem 0;
}
.sidebar .search .matching-post a {
  color: var(--text);
  text-decoration: none;
}
.sidebar .search .matching-post .em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}
.sidebar .search p { color: var(--text-mute); font-size: 0.82rem; }

/* 侧栏目录 */
.sidebar-nav { padding: 0; line-height: 1.6; }
.sidebar-nav > ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-nav > ul > li {
  padding: 0;
  margin: 0 0 1.4rem;
}
.sidebar-nav > ul > li > p,
.sidebar-nav > ul > li > strong {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-mute);
  letter-spacing: 0.06em;
  margin: 0 0 0.5rem;
  padding-left: 0.1rem;
  border: none;
  display: block;
}
.sidebar-nav ul ul {
  list-style: none;
  padding: 0 0 0 1.1rem;
  margin: 0;
  border-left: 1px solid var(--divider);
}
.sidebar-nav ul ul li {
  margin: 0;
  padding: 0;
  position: relative;
}
.sidebar-nav a {
  display: block;
  padding: 0.32rem 0.5rem;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 3px;
  transition: all 0.18s;
  line-height: 1.5;
  border: none;
}
.sidebar-nav a:hover {
  color: var(--accent);
  background: var(--bg-alt);
  transform: translateX(2px);
}
.sidebar-nav li.active > a {
  color: var(--accent);
  font-weight: 500;
  background: var(--bg-alt);
}
.sidebar-nav li.active > a::before {
  content: "";
  position: absolute;
  left: -1.15rem;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
}
.app-sub-sidebar { padding: 0; }

/* === 加载状态 (docsify 接管前的占位 placeholder，避免裸 emoji 与品牌断裂) === */
#app.initial-load {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h));
}
.loading-mark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text-mute);
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.loading-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 3px;
  box-shadow: 0 2px 8px var(--shadow);
  transform: rotate(-3deg);
}
.loading-text {
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
}

/* === 回到顶部按钮 (滚到 600px+ 显出，右下；与 sidebar-toggle 左下对称) === */
.back-to-top {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--bg-elv);
  border: 1px solid var(--border);
  color: var(--text-mute);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 100;
  box-shadow: 0 2px 12px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, color 0.2s, background 0.2s, box-shadow 0.2s;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  color: var(--accent);
  background: var(--bg-alt);
  box-shadow: 0 4px 16px var(--shadow-lg);
  transform: translateY(-2px);
}
.back-to-top svg { width: 19px; height: 19px; }

/* docsify 自动注入的 sidebar-toggle 按钮的 click handler 走 isMobile (UA 判定)，
   桌面缩窄无响应，整体藏掉。下方用 [data-custom-toggle] 标记自家按钮替代它。 */
button.sidebar-toggle:not([data-custom-toggle]) { display: none !important; }

/* 浮动按钮：sidebar 左下（全屏宽常驻，宽屏点击折叠侧栏）、TOC 右上（仅窄屏显示，对齐原 TOC sticky 锚点） */
.sidebar-toggle,
.toc-toggle {
  position: fixed;
  width: 42px;
  height: 42px;
  background: var(--bg-elv);
  border: 1px solid var(--border);
  border-radius: 999px;
  z-index: 101;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: var(--text-mute);
  box-shadow: 0 2px 12px var(--shadow);
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.sidebar-toggle { display: flex; bottom: 1.2rem; left: 1.2rem; top: auto; right: auto; }
.toc-toggle { display: none; top: calc(var(--nav-h) + 1.2rem); right: 1.2rem; bottom: auto; left: auto; }
.sidebar-toggle:hover,
.toc-toggle:hover {
  color: var(--accent);
  background: var(--bg-alt);
  box-shadow: 0 4px 16px var(--shadow-lg);
  transform: translateY(-1px);
}
.sidebar-toggle svg,
.toc-toggle svg { width: 19px; height: 19px; }
/* drawer 打开时按钮反色给视觉反馈 */
body.close .sidebar-toggle,
body.toc-open .toc-toggle {
  color: var(--accent);
  border-color: var(--accent);
}

/* === 主内容区 === */
main {
  margin-left: var(--sidebar-w) !important;
  margin-right: 0 !important;
  padding: 0 !important;
  min-height: calc(100vh - var(--nav-h));
  background: var(--bg);
  position: relative;
  transition: margin-left 0.3s ease;
}
/* 宽屏点击 sidebar-toggle: body.close 表示用户折叠了侧栏，sidebar 滑出 + main 占满全宽。
   （窄屏的 body.close 语义在 max-width: 1180px 媒体查询里相反——drawer 唤起，CSS 各自处理） */
@media (min-width: 1181px) {
  body.close aside.sidebar { transform: translateX(-100%) !important; }
  body.close main { margin-left: 0 !important; }
}
/* 用 grid 让 article 和 TOC 并排，TOC 自然贴在正文右侧 */
section.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 0 2rem;
  padding: 3rem 3rem 2rem !important;
  position: relative;
  top: 0 !important;
  max-width: 1200px;
  margin: 0 auto !important;
}
/* 第 1 列固定视觉顺序：article → 翻页 → 评论 → 页脚
   footer 跟 article、waline 同列，共享同一条对齐中线（max-width: 820px + margin auto） */
section.content > article { grid-column: 1; order: 0; }
section.content > .docsify-pagination-container { grid-column: 1; order: 1; }
section.content > #waline { grid-column: 1; order: 2; }
section.content > .reading-footer { grid-column: 1; order: 3; }
/* docsify 默认在 body 直接渲染 button.sidebar-toggle + aside + main + nav 同级
   #app 加载完会被 docsify 接管，避免它残留占位 */
#app:empty { display: none; }
article.markdown-section {
  max-width: 820px;
  margin: 0 auto;
  padding: 0;
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.88;
  color: var(--text);
  display: flex;
  flex-direction: column;
}
/* docsify-count 插件注入的 #main 字数统计：移到 h1 下方，作为小字元数据 */
article.markdown-section h1 { order: 0; }
article.markdown-section #main {
  order: 1;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  margin: -1.2rem 0 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--divider);
  line-height: 1.5;
}
article.markdown-section #main div { display: inline; }
article.markdown-section #main span { color: var(--text-mute); }
article.markdown-section > *:not(h1):not(#main) { order: 2; }
/* h1 自己的 border-bottom 撤掉（让 #main 接管底分隔线） */
article.markdown-section h1 {
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: 0.6rem !important;
}

article.markdown-section p {
  font-family: var(--serif);
  margin: 0 0 1.5rem;
  color: var(--text);
}

/* h1 - 书名 */
article.markdown-section h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 0 0 1.8rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
}

/* h2 - 章节，古籍式装饰线 */
article.markdown-section h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.45rem;
  text-align: center;
  margin: 4rem auto 1.8rem;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.3rem;
  color: var(--text);
  line-height: 1.4;
}
article.markdown-section h2::before,
article.markdown-section h2::after {
  content: "";
  flex: 1;
  max-width: 90px;
  height: 1px;
  background: var(--accent);
  opacity: 0.45;
}

/* h3 - 朱砂竖条 */
article.markdown-section h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 2.4rem 0 1rem;
  padding-left: 0.85rem;
  position: relative;
  color: var(--text);
}
article.markdown-section h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42rem;
  width: 3px;
  height: 1rem;
  background: var(--accent);
  border-radius: 1px;
}

article.markdown-section h4,
article.markdown-section h5,
article.markdown-section h6 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--text);
  margin: 1.8rem 0 0.8rem;
}

/* 链接 */
article.markdown-section a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: all 0.2s;
}
article.markdown-section a:hover {
  color: var(--accent-soft);
  border-bottom-color: var(--accent);
}

/* 引言 */
article.markdown-section blockquote {
  margin: 2rem 0;
  padding: 1rem 0 1rem 1.6rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  border-radius: 0 6px 6px 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.8;
  position: relative;
}
article.markdown-section blockquote::before {
  content: "「";
  position: absolute;
  left: 0.45rem;
  top: -0.25rem;
  font-size: 1.9rem;
  color: var(--accent);
  opacity: 0.32;
  line-height: 1;
  font-family: var(--serif);
}
article.markdown-section blockquote p {
  color: var(--text);
  margin: 0;
}

/* docsify tip / warn */
article.markdown-section .tip,
article.markdown-section .warn {
  margin: 2rem 0;
  padding: 1.4rem 1.5rem;
  background: var(--bg-elv);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--accent);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.85;
  box-shadow: 0 1px 4px var(--shadow);
}

/* 列表 */
article.markdown-section ul,
article.markdown-section ol {
  margin: 1rem 0 1.5rem;
  padding-left: 1.4rem;
  line-height: 1.85;
}
article.markdown-section li {
  margin-bottom: 0.45rem;
  color: var(--text);
}
article.markdown-section li::marker { color: var(--accent); font-weight: 600; }

/* 代码 */
article.markdown-section code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-alt);
  color: var(--accent);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  margin: 0;
}
article.markdown-section pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}
article.markdown-section pre > code {
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.7;
}
article.markdown-section pre::after { background: transparent; content: none; }

article.markdown-section strong {
  color: var(--text);
  font-weight: 700;
}
[data-theme="dark"] article.markdown-section strong { font-weight: 600; }

article.markdown-section em {
  font-style: italic;
  color: var(--text);
}

article.markdown-section img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px var(--shadow);
  margin: 1.5rem 0;
}

article.markdown-section table {
  border-collapse: collapse;
  margin: 1.5rem 0;
  width: 100%;
  font-family: var(--sans);
  font-size: 0.95rem;
}
article.markdown-section th,
article.markdown-section td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.9rem;
  background: transparent;
  color: var(--text);
}
article.markdown-section th {
  background: var(--bg-alt);
  font-weight: 600;
}

article.markdown-section hr {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 2.5rem 0;
}

/* === 右侧 TOC ===
   策略：默认所有 TOC 隐藏，只有移到 section.content 直接子位置才显示
   这样在 plugin 移动前，TOC 不会闪现在 article 顶部或别的奇怪位置 */
nav.page_toc,
.page_toc,
nav[class*="page_toc"] {
  display: none !important;
}
section.content > nav.page_toc,
section.content > .page_toc,
section.content > nav[class*="page_toc"] {
  display: block !important;
  grid-column: 2 !important;
  grid-row: 1 / span 99 !important;
  position: sticky !important;
  top: calc(var(--nav-h) + 2rem) !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
  width: 100% !important;
  max-width: var(--toc-w) !important;
  align-self: start !important;
  max-height: calc(100vh - var(--nav-h) - 4rem) !important;
  overflow-y: auto !important;
  padding: 0 0 0 1rem !important;
  margin: 0 !important;
  border-left: 1px solid var(--divider);
  font-family: var(--sans);
  background: transparent !important;
  z-index: 5 !important;
  float: none !important;
}
nav.page_toc::before {
  content: "本 章";
  display: block;
  font-family: var(--serif);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--divider);
}
nav.page_toc::-webkit-scrollbar { width: 3px; }
nav.page_toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
nav.page_toc .nav,
nav.page_toc ul {
  background: transparent;
  list-style: none;
  padding: 0;
  margin: 0;
}
nav.page_toc li { margin: 0; padding: 0; }
nav.page_toc a,
nav.page_toc a:link,
nav.page_toc a:visited,
nav.page_toc a:hover,
nav.page_toc a:active,
nav.page_toc a:focus,
.page_toc a,
.page_toc a:link,
.page_toc a:visited,
[class*="page_toc"] a {
  display: block !important;
  padding: 0.3rem 0 0.3rem 0.7rem !important;
  border: none !important;
  border-left: 1px solid transparent !important;
  outline: none !important;
  font-size: 0.82rem !important;
  color: var(--text-mute) !important;
  text-decoration: none !important;
  transition: all 0.18s !important;
  line-height: 1.5 !important;
  font-family: var(--sans) !important;
  background: transparent !important;
}
nav.page_toc a:hover,
nav.page_toc .active > a,
.page_toc a:hover,
.page_toc .active > a {
  color: var(--accent) !important;
  border-left-color: var(--accent) !important;
  text-decoration: none !important;
}
nav.page_toc .active > a,
.page_toc .active > a { font-weight: 500 !important; }
/* （旧 article 内 TOC 隐藏的规则已上移到全局，这里删除避免重复） */

/* === 翻页 (docsify-pagination plugin) === */
.docsify-pagination-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: 4rem auto 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--divider);
  font-family: var(--sans);
  max-width: 820px;
  border-bottom: none;
}
.pagination-item {
  display: flex !important;
  flex-direction: column;
  padding: 1rem 1.2rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.25s;
}
.pagination-item:hover {
  border-color: var(--accent);
  background: var(--bg-elv);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-2px);
}
.pagination-item-label {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
  font-family: var(--sans);
}
.pagination-item-title {
  font-family: var(--serif);
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--text);
}
.pagination-item:hover .pagination-item-title { color: var(--accent); }
.pagination-item--next { text-align: right; align-items: flex-end; }

/* === Footer (hardcoded, section.content 第 1 列末尾，与 article 同条对齐线) === */
.reading-footer {
  font-family: var(--serif);
  color: var(--text-mute);
  text-align: center;
  font-style: italic;
  border-top: 1px solid var(--divider);
  padding: 2rem 1rem;
  margin: 2rem auto 0;        /* 顶部 2rem 与 Waline 拉开，左右 auto 居中于第 1 列 */
  max-width: 820px;           /* 与 article.markdown-section 的 max-width 一致 */
  width: 100%;
  font-size: 0.92rem;
  line-height: 1.9;
}
.reading-footer .footer-quote {
  display: block;
  font-family: var(--serif);
}
.reading-footer .footer-meta {
  display: block;
  margin-top: 0.6rem;
  font-style: normal;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}
.reading-footer a {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
.reading-footer a:hover {
  color: var(--accent-soft);
  border-bottom-color: var(--accent);
}
#sitetime {
  display: inline;
  font-style: normal;
  font-family: var(--sans);
  color: var(--text-faint);
}

/* === Waline 评论区 ===
   通过覆盖 --waline-* 变量，把 waline 配色绑到 reading 主题 token 上。
   注意：waline v3 的变量是 --waline-bg-color（带连字符），不是 --waline-bgcolor。
   dark mode 走 walineConfig.dark = 'html[data-theme="dark"]'，会自动切到下方 [data-theme="dark"] 分支。 */
#waline {
  font-family: var(--sans) !important;
  margin: 2rem 0 0 !important;
  max-width: none !important;
  width: 100% !important;
  padding: 0 !important;

  --waline-font-family: var(--sans);
  --waline-theme-color: var(--accent);
  --waline-active-color: var(--accent-soft);

  --waline-color: var(--text);
  --waline-bg-color: var(--bg);
  --waline-bg-color-light: var(--bg-alt);
  --waline-bg-color-hover: var(--bg-elv);
  --waline-border-color: var(--border);
  --waline-border: 1px solid var(--border);

  --waline-info-bg-color: var(--bg-alt);
  --waline-info-color: var(--text-mute);
  --waline-bq-color: var(--bg-alt);

  --waline-disable-bg-color: var(--bg-alt);
  --waline-disable-color: var(--text-faint);

  --waline-code-bg-color: var(--bg-alt);
  --waline-code-color: var(--text);

  /* primary 按钮文字色：waline 默认用 --waline-white = #fff，朱砂底配白字正好 */
}
[data-theme="dark"] #waline {
  /* dark 下默认硬编码的 #fff/#999/#666 会很扎眼，统一拉到主题灰阶 */
  --waline-white: var(--bg-elv);
  --waline-light-grey: var(--text-faint);
  --waline-dark-grey: var(--text-mute);
}

/* === 锚点 === */
.anchor span { color: var(--text); }
.anchor:hover span { color: var(--accent); }
.anchor:hover { text-decoration: none; }

/* === 滚动条 === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* === Page-load reveal 动画 === */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
article.markdown-section h1,
article.markdown-section > p:first-of-type,
article.markdown-section h2,
article.markdown-section h3 {
  animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}
article.markdown-section h1 { animation-delay: 0.05s; }
article.markdown-section > p:first-of-type { animation-delay: 0.15s; }

/* === 响应式 ===
   <=1180px: sidebar 收为左 drawer，TOC 收为右 drawer，浮动按钮唤起；
   共享背景遮罩（body.close 或 body.toc-open 任一开启都铺一层）。 */
@media (max-width: 1180px) {
  :root { --sidebar-w: 0px; }
  main { margin-left: 0 !important; }

  /* 窄屏 drawer 打开时锁定 body 滚动，避免背景跟着滑（drawer 自身 overflow-y: auto，不受影响）
     宽屏 body.close 是"折叠侧栏"语义，不应锁滚动，所以放在窄屏媒体查询里 */
  body.close,
  body.toc-open { overflow: hidden; }

  section.content {
    grid-template-columns: minmax(0, 1fr) !important;
    margin-right: 0;
  }

  /* 左 drawer: sidebar
     注意 1180+ 的 aside.sidebar 用了 transform: none !important，这里必须同样带 !important 才能覆盖 */
  aside.sidebar {
    width: 280px !important;
    max-width: 82vw !important;
    transform: translateX(-100%) !important;
    box-shadow: 4px 0 20px var(--shadow);
    transition: transform 0.3s ease !important;
  }
  body.close aside.sidebar { transform: translateX(0) !important; }

  /* 右 drawer: TOC（覆盖 1180+ 时的 sticky / grid 定位） */
  section.content > nav.page_toc,
  section.content > .page_toc,
  section.content > nav[class*="page_toc"] {
    position: fixed !important;
    top: var(--nav-h) !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: 280px !important;
    max-width: 82vw !important;
    height: calc(100vh - var(--nav-h)) !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 1.8rem 1.4rem !important;
    background: var(--bg) !important;
    border-left: 1px solid var(--divider) !important;
    box-shadow: -4px 0 20px var(--shadow);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 50 !important;
  }
  body.toc-open section.content > nav.page_toc,
  body.toc-open section.content > .page_toc,
  body.toc-open section.content > nav[class*="page_toc"] {
    transform: translateX(0);
  }

  /* 仅当当前页确实有 TOC 时显示触发按钮（README 等无目录页面不出现） */
  body:has(section.content > nav.page_toc) .toc-toggle,
  body:has(section.content > .page_toc) .toc-toggle {
    display: flex;
  }

  /* 共享遮罩：sidebar 或 TOC 任一打开时铺一层暗背景，点击关闭 */
  body.close::after,
  body.toc-open::after {
    content: "";
    position: fixed;
    inset: var(--nav-h) 0 0;
    background: rgba(0, 0, 0, 0.32);
    z-index: 9;
    animation: drawer-fade 0.25s ease;
  }
}
@keyframes drawer-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* nav-mid 中屏隐藏（5 个工具链接需要更宽空间） */
@media (max-width: 1024px) {
  .nav-mid { display: none; }
}

/* === 打印样式：去掉所有 chrome，只留正文，链接 URL 显式化 === */
@media print {
  .topbar,
  aside.sidebar,
  .sidebar-toggle,
  .toc-toggle,
  .back-to-top,
  #waline,
  .docsify-pagination-container,
  nav.page_toc,
  .page_toc,
  .reading-footer { display: none !important; }
  body { background: white; color: black; padding: 0; }
  main { margin: 0 !important; min-height: 0; display: block !important; }
  section.content {
    display: block !important;
    padding: 0 !important;
    max-width: none !important;
    margin: 0 !important;
  }
  article.markdown-section {
    max-width: none !important;
    color: black !important;
    font-size: 11pt;
    line-height: 1.6;
  }
  article.markdown-section h1,
  article.markdown-section h2,
  article.markdown-section h3,
  article.markdown-section h4 { color: black; page-break-after: avoid; }
  article.markdown-section pre,
  article.markdown-section blockquote,
  article.markdown-section table { page-break-inside: avoid; }
  a { color: black !important; text-decoration: underline; }
  /* 站外链接附带 URL；锚点和站内链接不显示，避免噪音 */
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #555; }
  a[href^="#"]::after,
  a[href^="/"]::after { content: ""; }
}

@media (max-width: 768px) {
  section.content { padding: 2rem 1.2rem 1rem !important; }
  .reading-footer { padding: 1.5rem 1rem; }
  article.markdown-section h1 { font-size: 2rem; }
  .topbar { padding: 0 1rem; }
}
