/* ============================================================
   专业个人文集站 — 静态样式
   风格参照 Chapbook guide:清爽文档式布局,左侧导航 + 正文
   ============================================================ */

:root {
  /* 亮色主题 */
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-sidebar: #fbfbfc;
  --bg-code: #f4f5f7;
  --bg-hover: #eef0f3;
  --bg-active: #e7eaf0;
  --bg-chip: #f3f4f7;
  --text: #1f2329;
  --text-soft: #4e5969;
  --text-mute: #86909c;
  --border: #e5e6eb;
  --border-strong: #d4d6dc;
  --accent: #2b5fd6;
  --accent-soft: #eaf0fd;
  --accent-text: #1d4abf;
  --quote-bar: #c9d4ef;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --radius: 8px;

  --sidebar-w: 300px;
  --content-max: 760px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC",
    "STSong", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code",
    Consolas, "Liberation Mono", Menlo, monospace;

  /* 纸张纹理(SVG fractalNoise,极淡) */
  --paper-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --ornament: "\2766";        /* ❦ 章节结束符 */
  --section-mark: "\204B";    /* ⁋ 分节符 */

  /* 分类配色 — 每个大目录一种色调,用于目录名/子目录名文字着色 */
  --cat-0: #2b5fd6;  /* 学术 - 蓝 */
  --cat-1: #b07a1a;  /* 杂文 - 金棕 */
  --cat-2: #8b4789;  /* 小说 - 紫 */
  --cat-3: #2d7a5f;  /* 散文 - 绿 */
  --cat-4: #c25450;  /* 互动小说 - 红 */
  --cat-5: #0d7a9e;  /* 诗歌 - 青 */
}

[data-theme="dark"] {
  --bg: #1a1b1e;
  --bg-soft: #202227;
  --bg-sidebar: #161719;
  --bg-code: #26282d;
  --bg-hover: #26282d;
  --bg-active: #2c2f36;
  --bg-chip: #222428;
  --text: #e4e6eb;
  --text-soft: #b6bac1;
  --text-mute: #7a7f87;
  --border: #2a2c30;
  --border-strong: #383b41;
  --accent: #6b95f0;
  --accent-soft: #1f2735;
  --accent-text: #8db4ff;
  --quote-bar: #3a4566;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.35);
  --cat-0: #7ba3f5;
  --cat-1: #d4a843;
  --cat-2: #c08bb8;
  --cat-3: #5dae8e;
  --cat-4: #e07872;
  --cat-5: #4ab0d4;
}

/* 按分类索引设置 --cat-color,供 nav-group / home-section / sub-section 等使用 */
[data-cat-idx="0"] { --cat-color: var(--cat-0); }
[data-cat-idx="1"] { --cat-color: var(--cat-1); }
[data-cat-idx="2"] { --cat-color: var(--cat-2); }
[data-cat-idx="3"] { --cat-color: var(--cat-3); }
[data-cat-idx="4"] { --cat-color: var(--cat-4); }
[data-cat-idx="5"] { --cat-color: var(--cat-5); }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  z-index: 1000;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background-color: var(--bg-sidebar);
  background-image: var(--paper-texture);
  background-repeat: repeat;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow: hidden;
}
.sidebar::before {
  /* 右侧装饰双线,书脊感 */
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(var(--accent), var(--quote-bar));
  opacity: .35;
  pointer-events: none;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-serif);
  flex: 0 0 auto;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-size: 16px; font-weight: 650; letter-spacing: .3px; }
.brand-sub { font-size: 12px; color: var(--text-mute); }

.sidebar-close {
  display: none;
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-mute);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.sidebar-close:hover { background: var(--bg-hover); color: var(--text); }

.search {
  padding: 6px 20px 10px;
  flex: 0 0 auto;
}
.search input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input::placeholder { color: var(--text-mute); }

/* 快捷入口区:首页 + 最近更新(位于搜索框上方) */
.nav-quick {
  flex: 0 0 auto;
  padding: 8px 12px 0;
}
.nav-quick .nav-item { padding: 8px 12px; font-size: 14px; }

.nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 12px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 2px solid var(--bg-sidebar);
}

.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 6px; }

/* 总分类链接(可点击进入分类总页) */
.nav-cat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--cat-color, var(--text));
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  border-left: 2px solid transparent;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-cat:hover {
  background: var(--bg-hover);
  border-left-color: var(--cat-color, var(--accent-soft));
  text-decoration: none;
}
.nav-cat.active {
  background: var(--bg-active);
  color: var(--cat-color, var(--accent-text));
  border-left-color: var(--cat-color, var(--accent));
}
.nav-cat-name { flex: 1 1 auto; }
.nav-cat-count,
.nav-sub-count {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* 子分类组:包裹子分类链接及其文章 */
.nav-subgroup {
  margin-left: 8px;
  border-left: 1px dashed var(--border);
  padding-left: 4px;
}

/* 子分类链接 */
.nav-sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--cat-color, var(--text-soft));
  opacity: .82;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-sub:hover {
  background: var(--bg-hover);
  opacity: 1;
  text-decoration: none;
}
.nav-sub.active {
  background: var(--bg-active);
  opacity: 1;
  color: var(--cat-color, var(--accent-text));
  border-left-color: var(--cat-color, var(--accent));
}
.nav-sub-name { flex: 1 1 auto; }

/* 文章链接(分类根或子分类下) */
.nav-item {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.4;
  cursor: pointer;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--bg-active);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-item-title { font-weight: 500; }
.nav-item.active .nav-item-title { font-weight: 600; }
.nav-item-date {
  font-size: 11px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  font-weight: 400;
}
.nav-item-sub { padding-left: 22px; }

.nav-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-mute);
  font-style: italic;
}

/* "最近更新"作为大目录之首,与其它大目录平行,但带钟形符号以示区别 */
.nav-cat-recent {
  position: relative;
  padding-left: 26px;
}
.nav-cat-recent::before {
  content: "\25F7";  /* 时钟符号 ◷ */
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--accent);
  opacity: .85;
}
.nav-cat-recent.active::before { color: var(--accent-text); }

.sidebar-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-soft);
  width: 34px; height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.theme-icon::before { content: "☀"; }
[data-theme="dark"] .theme-icon::before { content: "☾"; }

.repo-link {
  font-size: 13px;
  color: var(--text-mute);
}
.repo-link:hover { color: var(--accent); }

/* ---------- 主区 ---------- */
.main {
  margin-left: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;  /* 移动端动态视口高度,地址栏隐藏时自动延展 */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* 桌面端右侧主正文独立滚动,侧边栏不随之滚动 */
  overscroll-behavior: contain;
}
.main::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
.main::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
/* 桌面端:menuBtn 可折叠侧边栏 */
.sidebar.collapsed { display: none; }
.sidebar.collapsed ~ .main { margin-left: 0; }

.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.menu-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow);
}
.menu-btn:active { transform: scale(.96); }
.menu-btn-bars {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 16px;
}
.menu-btn-bars span {
  display: block;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s, background .15s;
}
.menu-btn:hover .menu-btn-bars span { background: var(--accent-text); }
.menu-btn-label { letter-spacing: .04em; }
/* 抽屉打开时,汉堡变叉号 */
.sidebar.open ~ .main .menu-btn-bars span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.sidebar.open ~ .main .menu-btn-bars span:nth-child(2) { opacity: 0; }
.sidebar.open ~ .main .menu-btn-bars span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
.topbar-crumbs {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.crumb-arrow {
  color: var(--cat-color, var(--text-mute));
  font-size: 14px;
  font-weight: 600;
  margin-right: 2px;
}
.crumb-pill {
  display: inline-block;
  font-size: 12.5px;
  color: var(--text-soft);
  text-decoration: none;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
a.crumb-pill:hover {
  color: var(--cat-color, var(--accent));
  border-color: var(--cat-color, var(--accent));
  background: var(--accent-soft);
  text-decoration: none;
}
.crumb-current {
  color: var(--text-mute);
  background: var(--bg-soft);
  cursor: default;
}

.content {
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 48px 32px 24px;
  flex: 1 1 auto;
}

.loading {
  color: var(--text-mute);
  font-style: italic;
  padding: 40px 0;
}

/* ---------- 文章头部 ---------- */
.article-head {
  position: relative;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.article-head::after {
  /* 底部装饰:细线 + 居中 ❦ 符号,书页感 */
  content: var(--ornament);
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--quote-bar);
  background: var(--bg);
  padding: 0 14px;
  line-height: 1;
}
.article-cat {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--cat-color, var(--accent-text));
  background: var(--accent-soft);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.article-title {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.3;
  font-weight: 650;
  margin: 0 0 10px;
  letter-spacing: .01em;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}
.article-meta span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- 正文排版 ---------- */
.prose {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
}
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }

/* 正文结束符:居中 ❦,标志一篇文章读尽,如实体书的章节末 */
.prose::after {
  content: var(--ornament);
  display: block;
  text-align: center;
  margin: 2.4em 0 0;
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--quote-bar);
  line-height: 1;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: .01em;
  scroll-margin-top: 20px;
}
.prose h1 { font-size: 1.4em; margin: 1.4em 0 .6em; }
.prose h2 {
  position: relative;
  font-size: 1.25em;
  margin: 1.6em 0 .6em;
  padding-bottom: .25em;
  padding-left: 1.4em;
  border-bottom: 1px solid var(--border);
}
.prose h2::before {
  /* 分节小记号 §,淡色,书页感 */
  content: "\00A7";
  position: absolute;
  left: 0;
  top: 0;
  font-size: .7em;
  color: var(--quote-bar);
  font-weight: 400;
}
.prose h3 { font-size: 1.12em; margin: 1.4em 0 .5em; }
.prose h4 { font-size: 1em; margin: 1.2em 0 .4em; }

.prose p { margin: 0 0 1.1em; }
.prose p + p { text-indent: 0; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--quote-bar);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.prose a:hover { text-decoration-color: var(--accent); }

.prose strong { font-weight: 650; color: var(--text); }
.prose em { font-style: italic; }

.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.6em; }
.prose li { margin: .25em 0; }
.prose li::marker { color: var(--text-mute); }

.prose blockquote {
  margin: 1.4em 0;
  padding: .4em 1.1em;
  border-left: 3px solid var(--quote-bar);
  background: var(--bg-soft);
  color: var(--text-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p { margin: .5em 0; }

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.2em 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--bg-code);
  padding: .15em .4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.prose pre {
  font-family: var(--font-mono);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 1.3em 0;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.4em auto;
  display: block;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 14.5px;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.prose th {
  background: var(--bg-soft);
  font-weight: 600;
}
.prose tr:nth-child(even) td { background: var(--bg-soft); }

.prose sup { font-size: .72em; vertical-align: super; line-height: 0; }

/* 导语 / 对话 — 主要用于 HTML 格式文章 */
.prose p.lead {
  font-size: 1.1em;
  color: var(--text-soft);
  line-height: 1.8;
  margin-bottom: 1.4em;
}
.prose p.dialog {
  margin: .5em 0;
  padding-left: 1.2em;
  position: relative;
  color: var(--text-soft);
}
.prose p.dialog::before {
  content: "";
  position: absolute;
  left: 0;
  top: .4em;
  bottom: .4em;
  width: 2px;
  background: var(--border-strong);
  border-radius: 1px;
}
.prose p.dialog cite {
  font-style: normal;
  font-weight: 600;
  color: var(--accent-text);
  margin-right: .6em;
}
.prose section { margin: 1.6em 0; }
.prose section > h2:first-child { margin-top: 0; }

/* ---------- Markdown/HTML 混排组件 ---------- */

/* 边注/提示框 */
.prose aside.note,
.prose aside.tip,
.prose aside.warn {
  margin: 1.4em 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-soft);
}
.prose aside.note p,
.prose aside.tip p,
.prose aside.warn p { margin: .4em 0; }
.prose aside.warn { border-left-color: #d68a3c; background: rgba(214, 138, 60, .08); }

/* 折叠组件 */
.prose details {
  margin: 1.4em 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.prose details[open] { background: var(--bg); }
.prose details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  outline: none;
  list-style-position: outside;
  padding: 2px 0;
  user-select: none;
}
.prose details summary:hover { color: var(--accent-text); }
.prose details > :not(summary) { margin-top: 12px; }

/* 图注块 */
.prose figure {
  margin: 1.6em 0;
  text-align: center;
}
.prose figure img { margin: 0 auto 8px; }
.prose figure figcaption,
.prose figure blockquote {
  font-size: 14px;
  color: var(--text-soft);
  font-style: italic;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
}
.prose figure figcaption { margin-top: 6px; }

/* 题记(epigraph)引文 */
.prose blockquote.epigraph {
  margin: 1.6em 0;
  padding: 8px 0 8px 24px;
  border-left: 3px solid var(--quote-bar);
  background: none;
  color: var(--text-soft);
  font-style: italic;
  font-size: 15px;
}

/* 对照列表 */
.prose dl.compare {
  margin: 1.4em 0;
  padding: 16px 20px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.prose dl.compare dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  margin-top: 10px;
  letter-spacing: .03em;
}
.prose dl.compare dt:first-child { margin-top: 0; }
.prose dl.compare dd {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--text);
}

/* 行内高亮 */
.prose mark {
  background: rgba(255, 213, 79, .35);
  color: inherit;
  padding: 1px 4px;
  border-radius: 3px;
}
[data-theme="dark"] .prose mark { background: rgba(255, 213, 79, .22); }

/* 脚注 */
.prose .fn-ref a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.prose .footnotes {
  margin-top: 2.6em;
  font-size: 14px;
  color: var(--text-soft);
}
.prose .footnotes hr { margin-bottom: 1em; }
.prose .footnotes ol { padding-left: 1.5em; }
.prose .footnotes li { margin: .4em 0; line-height: 1.6; }
.prose .footnotes li:target { background: var(--accent-soft); border-radius: 4px; }
.prose .fn-ref:target a,
.prose .footnotes .fn-back { text-decoration: none; }

/* 文章底部 */
.article-foot {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.article-foot a {
  font-size: 14px;
  color: var(--text-soft);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s, color .15s, border-color .15s;
}
.article-foot a:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-soft);
  text-decoration: none;
}

/* 文章首尾的返回导航:总页 / 大目录 / 分目录 */
.article-back {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 18px;
}
.article-back::before {
  content: "\2190";
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
}
/* 文章末尾的返回导航:与上方分隔,有更明显的视觉提示 */
.article-back + .article-back {
  margin-top: 36px;
  margin-bottom: 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.article-back .back-link {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-soft);
  background: var(--bg);
  transition: background .15s, color .15s, border-color .15s;
}
.article-back .back-link:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-soft);
  text-decoration: none;
}
@media (max-width: 600px) {
  .article-back { font-size: 12px; margin-bottom: 14px; }
  .article-back .back-link { padding: 3px 9px; }
}

/* ---------- 首页 ---------- */
.home-hero {
  text-align: left;
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.home-hero h1 {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 650;
  line-height: 1.25;
  margin: 0 0 14px;
  letter-spacing: .01em;
}
.home-hero p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-soft);
  max-width: 60ch;
  margin: 0;
}

.home-section { margin: 40px 0; }
.home-section-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--cat-color, var(--text));
}
.home-section-title a {
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}
.home-section-title a:hover { color: var(--accent); }
.home-section-title .count {
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 400;
}
.home-section-desc {
  margin: -8px 0 18px;
  font-size: 14px;
  color: var(--text-soft);
}

/* 子分类区块(首页/分类页内) */
.sub-section {
  margin: 20px 0;
  padding: 16px 18px;
  background: var(--bg-soft);
  background-image: var(--paper-texture);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sub-section-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--cat-color, var(--text));
}
.sub-section-title a {
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}
.sub-section-title a:hover { color: var(--accent); }
.sub-section-title .count {
  font-size: 11.5px;
  color: var(--text-mute);
  background: var(--bg-chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.sub-section-desc {
  margin: -6px 0 12px;
  font-size: 13px;
  color: var(--text-mute);
}
.sub-section-empty {
  font-size: 13px;
  color: var(--text-mute);
  font-style: italic;
  margin: 4px 0;
}
/* 子分类页 hero 中的父分类链接 */
.hero-parent {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 6px;
  letter-spacing: .04em;
}
.hero-parent a {
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-strong);
}
.hero-parent a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* hero 顶部返回导航:返回主页 / (子分类页)返回上级分类 */
.hero-back {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 10px;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.hero-back a {
  color: var(--text-soft);
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color .15s, color .15s, background .15s;
}
.hero-back a:hover {
  color: var(--cat-color, var(--accent));
  border-color: var(--cat-color, var(--accent));
  background: var(--accent-soft);
}
.hero-back .sep {
  color: var(--text-mute);
  opacity: .6;
}

.card-list { display: grid; gap: 6px; }

/* 单行紧凑列表 — 首页"最近更新"专用 */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.timeline-item {
  border-bottom: 1px solid var(--border);
}
.timeline-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 8px;
  color: var(--text);
  border-radius: var(--radius);
  transition: background .15s;
  text-decoration: none;
}
.timeline-row:hover {
  background: var(--bg-soft);
  text-decoration: none;
}
.timeline-date {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  min-width: 6em;
}
.timeline-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.timeline-title {
  font-weight: 600;
  color: var(--text);
}
.timeline-summary {
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.timeline-cat {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 窄屏:日期缩短,摘要换行 */
@media (max-width: 600px) {
  .timeline-row {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 11px 6px;
  }
  .timeline-date { min-width: 0; order: 2; font-size: 11.5px; }
  .timeline-main { order: 1; flex-direction: column; align-items: flex-start; gap: 2px; }
  .timeline-summary { white-space: normal; }
  .timeline-cat { order: 3; }
}
.card {
  display: block;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.card:hover {
  text-decoration: none;
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
/* 标题+描述同一行:标题略加粗,紧跟描述 */
.card-line {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}
.card-title {
  font-weight: 550;
  color: var(--text);
}
.card-dash {
  color: var(--text-mute);
  margin: 0 .15em;
}
.card-summary {
  color: var(--text-soft);
}
.card-date {
  font-size: 11px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  margin-left: 5px;
}
/* 标签另起一行,紧凑 */
.card-tags {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.4;
}
.card-tags .tag-sep { opacity: .5; margin: 0 .15em; }
.card-meta {
  font-size: 12.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

/* 互动小说卡片:封面感 + 开始按钮 */
.card-interactive {
  position: relative;
  padding-left: 56px;
  border-color: var(--border-strong);
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--bg) 60%);
}
.card-interactive::before {
  content: "\25B6";
  position: absolute;
  left: 20px;
  top: 18px;
  font-size: 16px;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-soft);
}
.card-interactive:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(43, 95, 214, .12);
}
.card-cta {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  letter-spacing: .02em;
}
.card-interactive:hover .card-cta { color: var(--accent); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-mute);
}
.empty-state h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--text);
  margin: 0 0 8px;
}

/* ---------- 页脚 ---------- */
.footer {
  padding: 24px 32px 40px;
  font-size: 13px;
  color: var(--text-mute);
  text-align: center;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}
.footer a { color: var(--text-mute); }
.footer a:hover { color: var(--accent); }

/* ---------- 互动小说全屏查看器 ---------- */
body.viewer-mode {
  overflow: hidden;
}
body.viewer-mode .sidebar,
body.viewer-mode .sidebar-backdrop,
body.viewer-mode .topbar,
body.viewer-mode .footer {
  display: none !important;
}
body.viewer-mode .main {
  margin-left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;  /* viewer 模式下,iframe 内部自己滚 */
}
body.viewer-mode .content {
  max-width: none;
  padding: 0;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.viewer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-sidebar);
  background-image: var(--paper-texture);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.viewer-back {
  color: var(--text-soft);
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.viewer-back:hover {
  color: var(--accent-text);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
  text-decoration: none;
}
.viewer-title {
  flex: 1 1 auto;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-open {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--text-mute);
  text-decoration: none;
  white-space: nowrap;
}
.viewer-open:hover { color: var(--accent); }
.viewer-frame {
  flex: 1 1 0;
  width: 100%;
  border: none;
  background: #000;
  min-height: 0;
}
@media (max-width: 600px) {
  .viewer-bar { padding: 8px 14px; gap: 10px; }
  .viewer-title { font-size: 14px; }
  .viewer-open { display: none; }
}

/* ---------- 移动端 ---------- */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, .45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 35;
  border: none;
  opacity: 0;
  transition: opacity .3s ease;
  cursor: pointer;
}
.sidebar-backdrop[hidden] { display: none; }
/* 遮罩透明度由侧边栏 open 状态驱动,实现淡入淡出 */
body:has(.sidebar.open) .sidebar-backdrop { opacity: 1; }

/* 抽屉打开时禁止背景滚动(现代浏览器 :has 支持) */
@media (max-width: 960px) {
  body:has(.sidebar.open) { overflow: hidden; }
}

/* ---------- 平板竖屏 ---------- */
@media (max-width: 960px) {
  .sidebar {
    width: min(86vw, 340px);
    transform: translateX(-100%);
    transition: transform .32s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow);
    will-change: transform;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  /* 移动端:侧边栏变抽屉,主区恢复整页滚动 */
  .main { margin-left: 0; height: auto; overflow-y: visible; }
  .topbar {
    display: flex;
    padding: 10px 16px;
  }
  .content {
    padding: 28px 22px 80px;  /* 底部留大,鼓励滚动以触发地址栏自动隐藏 */
    max-width: 680px;
  }
  .article-title { font-size: 24px; }
  .home-hero h1 { font-size: 26px; }
  .prose { font-size: 16.5px; line-height: 1.85; }
  .prose p { margin: 0 0 1.2em; }
  /* 触控友好:导航项点击区域加大 */
  .nav-item { padding: 11px 14px; }
  .nav-item-title { font-size: 15px; }
  .nav-group-title { padding: 10px 14px 8px; }
  .search { padding: 16px 16px 10px; }
  .search input { padding: 10px 14px; font-size: 14px; }
  .sidebar-head { padding: 18px 16px 14px; }
  .sidebar-foot { padding: 12px 16px; }
  .theme-toggle { width: 38px; height: 38px; }
}

/* ---------- 手机竖屏 ---------- */
@media (max-width: 600px) {
  .content { padding: 22px 18px 80px; }
  .article-head { margin-bottom: 28px; padding-bottom: 24px; }
  .article-head::after { font-size: 16px; }
  .article-title { font-size: 22px; line-height: 1.3; }
  .article-meta { gap: 10px; font-size: 13px; }
  .home-hero { margin-bottom: 32px; padding-bottom: 24px; }
  .home-hero h1 { font-size: 24px; }
  .home-hero p { font-size: 15px; }
  .home-section-title { font-size: 18px; }
  .card { padding: 6px 9px; }
  .card-line { font-size: 13.5px; }
  .card-list { gap: 5px; }
  .prose { font-size: 16.5px; line-height: 1.9; }
  .prose h2 { font-size: 1.2em; padding-left: 1.3em; }
  .prose h3 { font-size: 1.1em; }
  .prose blockquote { padding: .6em 1em; }
  .prose pre { padding: 14px; font-size: 12.5px; }
  .prose table { font-size: 13.5px; }
  .prose th, .prose td { padding: 7px 9px; }
  .article-foot { flex-direction: column; gap: 8px; }
  .article-foot a { text-align: center; }
  .footer { padding: 20px 18px 32px; font-size: 12.5px; }
}

/* ---------- 小屏手机 ---------- */
@media (max-width: 380px) {
  .content { padding: 18px 14px 80px; }
  .article-title { font-size: 20px; }
  .home-hero h1 { font-size: 22px; }
  .prose { font-size: 16px; }
  .prose h2 { font-size: 1.15em; }
}

@media print {
  .sidebar, .topbar, .footer, .article-foot { display: none; }
  .main { margin: 0; }
  .content { max-width: 100%; padding: 0; }
}

/* 焦点可见 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
