/* ===== 学习平台 - Vercel 极简黑白设计系统 + Ant Design 组件规范 ===== */

:root {
  /* Vercel 主色调 - 近黑墨色 */
  --primary: #171717;
  --primary-pressed: #000000;
  --primary-pale: #f5f5f5;
  --primary-soft: #404040;

  /* 文字色 - Vercel 灰阶 */
  --ink: #171717;
  --ink-soft: #4d4d4d;
  --ink-light: #888888;
  --ink-muted: #a1a1a1;

  /* 背景色 - Vercel 四层表面 */
  --paper: #ffffff;
  --paper-warm: #fafafa;
  --paper-soft: #f5f5f5;
  --paper-deep: #ededed;

  /* 边框 - Vercel 发丝线 */
  --line: #ebebeb;
  --line-soft: #f5f5f5;
  --line-strong: #a1a1a1;

  /* 链接色 - Vercel 蓝 */
  --link: #0070f3;
  --link-deep: #0761d1;

  /* 语义色 */
  --error: #ee0000;
  --warning: #f5a623;
  --success: #0070f3;
  --violet: #7928ca;
  --cyan: #50e3c2;

  /* 兼容映射（旧变量名 → Vercel 新色） */
  --cinnabar: #171717;
  --cinnabar-soft: #000000;
  --cinnabar-pale: #f5f5f5;
  --gold: #ab570a;
  --jade: #0070f3;

  /* 阴影 - Vercel 堆叠式微影 */
  --shadow: 0px 1px 1px rgba(0,0,0,0.02), 0px 2px 2px rgba(0,0,0,0.04);
  --shadow-deep: 0px 4px 8px rgba(0,0,0,0.06), 0px 8px 16px rgba(0,0,0,0.08);
  --shadow-xl: 0px 12px 24px rgba(0,0,0,0.08), 0px 24px 48px rgba(0,0,0,0.12);

  /* 字体 - Geist 几何无衬线 */
  --serif: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Geist Mono", "JetBrains Mono", "Fira Code", "Source Code Pro", "Courier New", monospace;

  /* 圆角系统 - Vercel */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 100px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper-warm);
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 统一的交互基线：让文档、工具台和后台共享同一套反馈语言。 */
button, input, select, textarea { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.surface-muted {
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

a { color: var(--link); text-decoration: none; transition: color .15s; }
a:hover { color: var(--link-deep); }

::selection { background: var(--ink); color: var(--paper); }

/* ===== 顶部导航 - Vercel 64px 发丝边框 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand .seal {
  display: inline-block;
  width: 28px; height: 28px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  font-size: 14px;
  line-height: 28px;
  text-align: center;
  font-family: var(--sans);
  font-weight: 600;
}
.topbar nav { display: flex; gap: 8px; align-items: center; }
.topbar nav a {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all .15s;
}
.topbar nav a:hover { color: var(--ink); background: var(--paper-soft); }
.topbar nav a.active { color: var(--ink); }
.topbar nav a.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -22px;
  height: 2px;
  background: var(--ink);
}

/* ===== 目录首页 - Vercel 极简 hero ===== */
.hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 96px 32px 48px;
  text-align: center;
}
.hero .book-cover {
  display: inline-block;
  padding: 64px 80px;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  position: relative;
  margin-bottom: 48px;
  overflow: hidden;
}
.hero .book-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, rgba(0,112,243,0.15), transparent 50%),
              radial-gradient(ellipse at bottom right, rgba(121,40,202,0.15), transparent 50%);
  pointer-events: none;
}
.hero .book-cover .vol {
  font-family: var(--mono);
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  text-transform: uppercase;
  position: relative;
}
.hero .book-cover h1 {
  font-family: var(--sans);
  color: var(--paper);
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  position: relative;
}
.hero .book-cover .sub {
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  margin-top: 16px;
  font-weight: 400;
  position: relative;
}
.hero .meta {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.hero .meta .item {
  text-align: center;
}
.hero .meta .num {
  font-family: var(--sans);
  font-size: 36px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}
.hero .meta .label {
  font-size: 13px;
  color: var(--ink-light);
  margin-top: 8px;
  font-weight: 400;
}

.section-title {
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  margin: 48px 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.02em;
}
.section-title::before {
  content: '';
  width: 3px; height: 20px;
  background: var(--ink);
  border-radius: 2px;
}
.section-title .en {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-light);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chapter-grid {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 32px 80px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.chapter-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}
.chapter-card:hover {
  border-color: var(--ink);
  box-shadow: var(--shadow-deep);
}
.chapter-card .ch-no {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-light);
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.chapter-card .ch-title {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.chapter-card .ch-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-light);
  align-items: center;
}
.chapter-card .ch-meta .badge {
  background: var(--paper-soft);
  color: var(--ink-soft);
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 500;
  font-size: 12px;
}
.chapter-card.front { border-style: dashed; }
.chapter-card.front .ch-no { color: var(--link); }

/* 最近笔记 - Vercel 卡片风 */
.recent-notes {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 32px 80px;
}
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.recent-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  transition: border-color .2s;
}
.recent-item:hover { border-color: var(--ink); }
.recent-item .body { flex: 1; }
.recent-item .anchor {
  font-size: 12px;
  color: var(--ink-light);
  font-style: italic;
  margin-bottom: 4px;
}
.recent-item .content {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
}
.recent-item .from {
  font-size: 12px;
  color: var(--link);
  white-space: nowrap;
  font-weight: 500;
}

/* ===== 博客风格章节页 ===== */
.blog-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  grid-template-areas: "nav nav" "post toc";
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* 顶部导航条 */
.blog-nav-bar {
  grid-area: nav;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 32px;
}
.chapter-select {
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  max-width: 400px;
}
.chapter-select:hover { border-color: var(--cinnabar); }
.blog-nav-links { display: flex; gap: 20px; }
.nav-arrow {
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all .15s;
}
.nav-arrow:hover { background: var(--paper-warm); color: var(--cinnabar); }

/* 博客文章 */
.blog-post {
  grid-area: post;
  max-width: 860px;
  padding: 0 32px 0 0;
}
.post-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.post-meta {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-light);
  margin-bottom: 12px;
}
.post-meta .dot { margin: 0 8px; }
.post-title {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
  margin: 0 0 12px;
}
.post-info {
  font-size: 13px;
  color: var(--ink-light);
}
.post-content #content { max-width: none; }

/* 文章底部导航 */
.post-footer {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.post-nav-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: all .2s;
}
.post-nav-card:hover {
  border-color: var(--cinnabar);
  box-shadow: 0 4px 16px var(--shadow);
  transform: translateY(-2px);
}
.post-nav-card.next { text-align: right; }
.post-nav-card.disabled { opacity: 0.4; pointer-events: none; }
.post-nav-card .nav-label { font-size: 13px; color: var(--ink-light); }
.post-nav-card .nav-title { font-size: 16px; font-weight: 600; }

/* 右侧悬浮目录 */
.blog-toc {
  grid-area: toc;
  position: sticky;
  top: 70px;
  height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--line-soft);
}
.blog-toc .toc-label {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-light);
  letter-spacing: 2px;
  margin-bottom: 14px;
  text-transform: uppercase;
}

/* ===== 术语高亮 - Vercel 链接蓝 ===== */
.glossary-term {
  color: var(--link);
  border-bottom: 1px dashed var(--link);
  cursor: help;
  font-weight: 500;
  transition: all .15s;
}
.glossary-term:hover {
  background: rgba(0, 112, 243, 0.08);
  border-bottom-style: solid;
}
body.mode-night .glossary-term { color: #3291ff; border-bottom-color: #3291ff; }
body.mode-night .glossary-term:hover { background: rgba(50, 145, 255, 0.15); }

/* 术语提示框 */
.glossary-tooltip {
  position: absolute;
  display: none;
  max-width: 520px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(26,26,46,0.2);
  padding: 0;
  z-index: 9998;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.7;
  pointer-events: auto;
  max-width: 520px;
}
.glossary-tooltip.show { display: block; animation: ttFadeIn .15s ease; }
.glossary-tooltip.pinned { box-shadow: 0 16px 48px rgba(0,112,243,0.3); border-color: var(--link); }
@keyframes ttFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.glossary-tooltip .gt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px 12px 0 0;
  gap: 8px;
}
.glossary-tooltip .gt-term { font-size: 15px; font-weight: 700; }
.glossary-tooltip .gt-cat { font-size: 11px; opacity: 0.8; text-transform: uppercase; margin-left: auto; }
.glossary-tooltip .gt-close {
  background: none; border: none; color: #fff; font-size: 22px; cursor: pointer;
  line-height: 1; padding: 0 4px; opacity: 0.7; flex-shrink: 0;
}
.glossary-tooltip .gt-close:hover { opacity: 1; }
.glossary-tooltip .gt-body {
  padding: 14px 16px;
  color: var(--ink);
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  word-break: break-word;
}
.glossary-tooltip .gt-body::-webkit-scrollbar { width: 6px; }
.glossary-tooltip .gt-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
body.mode-night .glossary-tooltip { background: var(--paper-warm); }

/* ===== 旧布局保留兼容 ===== */
.read-layout {
  display: grid;
  grid-template-columns: 220px 1fr 200px;
  gap: 0;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 0;
}

/* 左侧章节目录 */
.side-toc {
  position: sticky;
  top: 70px;
  height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 0 12px 0 24px;
  border-right: 1px solid var(--line-soft);
}
.side-toc .toc-label {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-light);
  letter-spacing: 2px;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.side-toc .ch-link {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-soft);
  border-radius: 5px;
  margin-bottom: 2px;
  line-height: 1.5;
  transition: all .15s;
  border-left: 2px solid transparent;
}
.side-toc .ch-link:hover { background: var(--paper-warm); color: var(--cinnabar); }
.side-toc .ch-link.active {
  background: var(--cinnabar-pale);
  color: var(--cinnabar);
  font-weight: 600;
  border-left-color: var(--cinnabar);
}
.side-toc .ch-link.front { color: var(--jade); font-size: 12px; }

/* 中央阅读区 */
.reader {
  padding: 0 40px;
  max-width: none;
  min-width: 0;
}
.reader #content {
  max-width: 1000px;
}
.reader .ch-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ink);
  position: relative;
}
.reader .ch-header::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 60px; height: 2px;
  background: var(--cinnabar);
}
.reader .ch-header .ch-num {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--cinnabar);
  letter-spacing: 4px;
  margin-bottom: 8px;
}
.reader .ch-header h1 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 2px;
}
.reader .ch-header .ch-info {
  font-size: 13px;
  color: var(--ink-light);
  margin-top: 12px;
  display: flex;
  gap: 18px;
}

/* 段落 */
.para {
  position: relative;
  margin-bottom: 18px;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.9;
  text-align: justify;
}
.para.body { text-indent: 2em; }
.para.heading {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  margin-top: 36px;
  margin-bottom: 16px;
  text-indent: 0;
  scroll-margin-top: 90px;
}
.para.heading .lvl2 { font-size: 24px; display: block; }
.para.heading .lvl3 { font-size: 20px; display: block; }
.para.heading .lvl4 { font-size: 17px; color: var(--ink-soft); display: block; }
.para.heading .sec-no {
  color: var(--cinnabar);
  margin-right: 10px;
  font-family: var(--mono);
  font-size: 0.85em;
}
.para.code {
  font-family: var(--mono);
  font-size: 13.5px;
  background: var(--ink);
  color: #e8e0cc;
  padding: 16px 20px;
  border-radius: 6px;
  overflow-x: auto;
  text-indent: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  border-left: 3px solid var(--gold);
}
.para.image_ref {
  text-indent: 0;
  text-align: center;
  margin: 24px 0;
}
/* 连续图片无缝拼接 */
.para.image_ref + .para.image_ref {
  margin-top: 2px;
}
.para.image_ref img {
  max-width: 100%;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 6px 20px var(--shadow-deep);
  border: 1px solid var(--line);
  cursor: zoom-in;
  transition: transform .3s;
}
.para.image_ref img:hover { transform: scale(1.01); }
.para.image_ref .caption {
  font-size: 13px;
  color: var(--ink-light);
  margin-top: 10px;
  font-style: italic;
}

/* 段落笔记按钮 */
.para .add-note-btn {
  position: absolute;
  right: -36px;
  top: 2px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  color: var(--ink-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: all .2s;
}
.para:hover .add-note-btn { opacity: 1; }
.para .add-note-btn:hover {
  background: var(--cinnabar);
  color: #fff;
  border-color: var(--cinnabar);
  transform: scale(1.1);
}

/* 段落右上角笔记标记（有笔记的段落常驻显示） */
.para-mark {
  position: absolute;
  right: -14px;
  top: -10px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--cinnabar);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 5;
  animation: markPop .3s ease;
  font-family: var(--sans);
}
@keyframes markPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.para-mark::before {
  content: '✎ ';
  font-size: 11px;
}
.para-mark:hover {
  background: var(--cinnabar-soft);
  transform: scale(1.1);
}

/* 自定义右键菜单 */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 15, 15, 0.18);
  overflow: hidden;
  animation: ctxFade .12s ease;
}
@keyframes ctxFade {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.ctx-menu .ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s;
  font-family: var(--sans);
}
.ctx-menu .ctx-item:hover {
  background: var(--cinnabar-pale);
  color: var(--cinnabar);
}
.ctx-menu .ctx-item .ctx-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
}
.ctx-menu .ctx-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 0;
}

/* 批注高亮 */
.annotated {
  background: linear-gradient(transparent 60%, var(--cinnabar-pale) 60%);
  cursor: pointer;
  padding: 0 2px;
  border-radius: 2px;
  position: relative;
}
.annotated:hover { background: linear-gradient(transparent 60%, #f3cdc6 60%); }
.annotated .annot-mark {
  color: var(--cinnabar);
  font-weight: 700;
  font-size: 0.7em;
  vertical-align: super;
  margin-left: 2px;
}

/* 段落内嵌笔记卡片 */
.inline-note {
  background: var(--cinnabar-pale);
  border-left: 3px solid var(--cinnabar);
  border-radius: 0 8px 8px 0;
  margin: 10px 0;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  transition: all .25s;
}
.inline-note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.inline-note-header:hover { background: rgba(0, 0, 0, 0.06); }
.inline-note .note-tag {
  display: inline-block;
  font-size: 11px;
  background: var(--cinnabar);
  color: #fff;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  flex-shrink: 0;
}
.inline-note .note-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  flex: 1;
  word-break: break-word;
  line-height: 1.4;
}
.inline-note .note-title-placeholder {
  flex: 1;
  font-size: 13px;
  color: var(--ink-light);
  font-style: italic;
}
.inline-note .note-toggle {
  font-size: 10px;
  color: var(--ink-light);
  transition: transform .25s;
  flex-shrink: 0;
}
.inline-note.collapsed .note-toggle { transform: rotate(-90deg); }
.inline-note-body {
  padding: 0 16px 12px;
  max-height: 600px;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s ease, opacity .2s;
  opacity: 1;
}
.inline-note.collapsed .inline-note-body {
  max-height: 0;
  padding: 0 16px;
  opacity: 0;
}
.inline-note .note-anchor {
  font-size: 13px;
  color: var(--ink-light);
  font-style: italic;
  margin-bottom: 6px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.5);
  border-radius: 4px;
  line-height: 1.6;
}
.inline-note .note-content { color: var(--ink); line-height: 1.7; }
.inline-note .note-meta {
  font-size: 11px;
  color: var(--ink-light);
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.inline-note .note-meta .note-time,
.inline-note .note-meta .note-author-meta {
  font-size: 11px;
  color: var(--ink-light);
}
.inline-note .note-actions { display: flex; gap: 12px; align-items: center; }
.inline-note .note-actions button {
  background: none;
  border: none;
  color: var(--cinnabar);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.inline-note .note-actions button:hover { text-decoration: underline; }
.inline-note .note-actions button.del { color: #dc2626; }
.inline-note .note-readonly {
  font-size: 11px;
  color: var(--ink-light);
  opacity: 0.6;
}
.inline-note .note-tags { color: var(--gold); font-size: 11px; }
.inline-note .note-author {
  font-size: 11px;
  color: var(--ink-light);
  background: var(--paper-deep);
  padding: 1px 8px;
  border-radius: 8px;
  margin-right: 6px;
}
.inline-note .note-owner-badge {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--cinnabar);
  padding: 1px 8px;
  border-radius: 8px;
  margin-right: 6px;
}

/* 笔记范围 Tab */
.note-scope-tabs {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.scope-tab {
  padding: 4px 14px;
  font-size: 12px;
  background: var(--paper-warm);
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.scope-tab:hover { background: var(--paper-deep); }
.scope-tab.active {
  background: var(--cinnabar);
  color: #fff;
  font-weight: 600;
}

/* 右侧大纲 */
.side-outline {
  position: sticky;
  top: 80px;
  height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 0 32px 0 20px;
  border-left: 1px solid var(--line-soft);
}
.side-outline .ol-label {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-light);
  letter-spacing: 2px;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.side-outline .ol-link {
  display: block;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-radius: 4px;
  line-height: 1.5;
  border-left: 2px solid transparent;
  transition: all .15s;
}
.side-outline .ol-link:hover { color: var(--cinnabar); background: var(--paper-warm); }
.side-outline .ol-link.active {
  color: var(--cinnabar);
  font-weight: 700;
  background: var(--cinnabar-pale);
  border-left: 3px solid var(--cinnabar);
  padding-left: 9px;
}
.side-outline .ol-link.lvl3 { padding-left: 22px; font-size: 12px; }
.side-outline .note-count {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
}
.side-outline .note-count .nc-num {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--cinnabar);
}
.side-outline .note-count .nc-label {
  font-size: 12px;
  color: var(--ink-light);
}

/* 章节导航 */
.ch-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  gap: 20px;
}
.ch-nav a {
  flex: 1;
  padding: 18px 24px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: all .2s;
}
.ch-nav a:hover {
  border-color: var(--cinnabar);
  background: #fff;
  transform: translateY(-2px);
}
.ch-nav a.next { text-align: right; }
.ch-nav a.disabled { opacity: 0.4; pointer-events: none; }
.ch-nav .nav-label { font-size: 12px; color: var(--ink-light); margin-bottom: 4px; }
.ch-nav .nav-title { font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--ink); }

/* ===== 阅读工作台：文档感来自排版和边界，不使用突兀装饰 ===== */
.blog-layout {
  align-items: start;
}
.blog-post {
  background: var(--paper);
  border-inline: 1px solid var(--line-soft);
}
.post-header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.post-title {
  max-width: 22ch;
  line-height: 1.16;
  letter-spacing: 0;
}
.post-content {
  font-size: 16px;
  line-height: 1.85;
}
.post-content .para.body {
  max-width: 76ch;
}
.blog-toc {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}
.blog-toc .toc-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-light);
}

/* ===== 笔记中心 ===== */
.notes-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}
.notes-header {
  margin-bottom: 32px;
}
.notes-header h1 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.notes-header .sub {
  color: var(--ink-light);
  font-size: 14px;
}
.notes-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.notes-toolbar .scope-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--r-sm);
}
.notes-toolbar .scope-tab.active {
  background: var(--ink);
  color: var(--paper);
}
.notes-toolbar .stat {
  background: var(--paper-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.notes-toolbar .btn-export {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.notes-toolbar .btn-export:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.notes-toolbar .search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.notes-toolbar .search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
  transition: border-color .2s;
}
.notes-toolbar .search-box input:focus {
  outline: none;
  border-color: var(--cinnabar);
}
.notes-toolbar .search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}
.notes-toolbar select {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.notes-toolbar .stat {
  font-size: 13px;
  color: var(--ink-light);
  padding: 8px 14px;
  background: var(--cinnabar-pale);
  border-radius: 6px;
  color: var(--cinnabar);
  font-weight: 600;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 组合方案的收束层：保留现有布局，只统一表面和状态色。 */
.notes-toolbar .stat { background: var(--paper-soft); color: var(--ink-soft); }
.notes-toolbar .search-box input,
.notes-toolbar select { background: var(--paper); }
.notes-toolbar .search-box input:focus,
.notes-toolbar select:focus { border-color: var(--ink); }
.nc-chapter-group { border-radius: var(--r-md); background: var(--paper); }
.nc-group-header { background: var(--paper-soft); }
.nc-group-header:hover { background: var(--paper-deep); }
.note-card, .note-item { border-color: var(--line); box-shadow: var(--shadow); }
.note-card:hover, .note-item:hover { border-color: var(--line-strong); }

/* 章节分组 */
.nc-chapter-group {
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.nc-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--paper-warm);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.nc-group-header:hover { background: var(--paper-deep); }
.nc-group-toggle {
  font-size: 12px;
  color: var(--ink-light);
  transition: transform .2s;
  width: 14px;
  text-align: center;
}
.nc-chapter-group.collapsed .nc-group-toggle { transform: rotate(-90deg); }
.nc-group-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  flex: 1;
}
.nc-group-title:hover { color: var(--cinnabar); }
.nc-group-count {
  font-size: 12px;
  color: var(--ink-light);
  background: var(--paper);
  padding: 2px 10px;
  border-radius: 10px;
}
.nc-group-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nc-chapter-group.collapsed .nc-group-body { display: none; }

/* 笔记卡片（可折叠） */
.note-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 20px;
  transition: all .2s;
  position: relative;
  cursor: pointer;
}
.note-card:hover {
  box-shadow: 0 4px 12px var(--shadow);
  border-color: var(--cinnabar);
}
.note-card .nc-toggle {
  font-size: 10px;
  color: var(--ink-light);
  transition: transform .2s;
  width: 12px;
  text-align: center;
  display: inline-block;
}
.note-card.collapsed .nc-toggle { transform: rotate(0); }
.note-card:not(.collapsed) .nc-toggle { transform: rotate(90deg); }
.note-card .nc-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
}
.note-card.collapsed .nc-body { display: none; }
.note-card .nc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 16px;
}
.note-card .nc-loc {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.note-card .nc-chapter {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--cinnabar);
}
.note-card .nc-section {
  font-size: 12px;
  color: var(--ink-light);
  background: var(--paper-warm);
  padding: 2px 8px;
  border-radius: 4px;
}
.note-card .nc-type {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}
.note-card .nc-type.annotation { background: var(--cinnabar); color: #fff; }
.note-card .nc-type.position { background: var(--jade); color: #fff; }
.note-card .nc-anchor {
  font-size: 13px;
  color: var(--ink-light);
  font-style: italic;
  background: var(--cinnabar-pale);
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  border-left: 2px solid var(--cinnabar);
}
.note-card .nc-content {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.8;
  white-space: pre-wrap;
}
.note-card .nc-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.4;
}
.note-card .nc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.note-card .nc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.note-card .nc-tag {
  font-size: 11px;
  color: var(--gold);
  background: rgba(176, 141, 60, 0.1);
  padding: 2px 8px;
  border-radius: 8px;
}
.note-card .nc-time { font-size: 12px; color: var(--ink-light); }
.note-card .nc-actions { display: flex; gap: 14px; }
.note-card .nc-actions button {
  background: none;
  border: none;
  color: var(--ink-light);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all .15s;
}
.note-card .nc-actions button:hover { color: var(--cinnabar); background: var(--cinnabar-pale); }
.note-card .nc-actions button.del:hover { color: #fff; background: var(--cinnabar); }
.note-card .nc-author {
  font-size: 12px;
  color: var(--ink-light);
  margin-left: auto;
}
.note-card .nc-mine-badge {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--cinnabar);
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: auto;
}
.note-card .nc-readonly {
  font-size: 11px;
  color: var(--ink-light);
  opacity: 0.6;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-light);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state .title { font-family: var(--serif); font-size: 20px; color: var(--ink-soft); margin-bottom: 8px; }
.empty-state .desc { font-size: 14px; }

/* ===== 笔记编辑弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  animation: slideUp .25s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
  font-weight: 700;
}
.modal-header .close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--ink-light);
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 24px 28px; }
.modal-body .field { margin-bottom: 18px; }
.modal-body .field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 6px;
}
.modal-body .field input,
.modal-body .field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
  resize: vertical;
}
.modal-body .field textarea { min-height: 120px; line-height: 1.7; }
.modal-body .field input:focus,
.modal-body .field textarea:focus {
  outline: none;
  border-color: var(--cinnabar);
}
.modal-body .anchor-preview {
  font-size: 13px;
  color: var(--ink-light);
  font-style: italic;
  background: var(--cinnabar-pale);
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 2px solid var(--cinnabar);
}
.modal-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--sans);
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary {
  background: var(--cinnabar);
  color: #fff;
}
.btn-primary:hover { background: var(--cinnabar-soft); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--paper-warm); }

/* 图片放大 */
.img-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.92);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}
.img-lightbox.show { display: flex; }
.img-lightbox img {
  max-width: 92%;
  max-height: 92%;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* 移动端抽屉按钮 */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
}

/* 文本选中批注浮层 */
.selection-popup {
  animation: fadeIn .15s;
}
.selection-popup button {
  font-family: var(--sans);
}

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
  .read-layout { grid-template-columns: 1fr; }
  .side-toc, .side-outline { display: none; }
  .reader { padding: 0 24px; max-width: 100%; }
  .para .add-note-btn { right: 4px; opacity: 1; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 18px; }
  .topbar nav { gap: 16px; }
  .topbar nav a { font-size: 13px; }
  .hero { padding: 40px 18px 24px; }
  .hero .book-cover { padding: 32px 28px; }
  .hero .book-cover h1 { font-size: 26px; }
  .chapter-grid { padding: 0 18px 40px; grid-template-columns: 1fr; }
  .reader .ch-header h1 { font-size: 26px; }
  .para { font-size: 15px; }
  .notes-page { padding: 24px 18px 60px; }
  .notes-header h1 { font-size: 24px; }
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--paper-warm); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-light); }

/* ===== 阅读体验增强 ===== */
/* 进度条 */
.progress-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 1000;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cinnabar), var(--gold));
  transition: width .1s linear;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

/* 阅读工具栏 */
.reading-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}
.tool-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--ink-light);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--sans);
  transition: all .15s;
  white-space: nowrap;
}
.tool-btn:hover {
  background: var(--paper-warm);
  color: var(--cinnabar);
  border-color: var(--line);
}
.tool-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
}

/* 浮动选区工具栏 */
.sel-toolbar {
  position: absolute;
  display: flex;
  gap: 2px;
  background: var(--ink);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(26,26,46,0.3);
  z-index: 9999;
  animation: selFadeIn .15s ease;
}
@keyframes selFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.sel-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 13px;
  font-family: var(--sans);
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.sel-btn:hover { background: rgba(255,255,255,0.15); }
.sel-btn:first-child { background: var(--cinnabar); }
.sel-btn:first-child:hover { background: #a0392b; }

/* Toast 提示 */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 28px;
  border-radius: 24px;
  font-size: 14px;
  font-family: var(--sans);
  box-shadow: 0 8px 32px rgba(15, 15, 15, 0.3);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--jade); }
.toast.error { background: var(--cinnabar); }

/* 段落悬停高亮 */
.para.text:hover {
  background: rgba(176, 141, 60, 0.04);
  border-radius: 4px;
}

/* 确认弹窗按钮 */
#confirmModal .btn-primary { background: var(--cinnabar); }
#confirmModal .btn-ghost { color: var(--ink-light); }

/* 响应式工具栏 */
@media (max-width: 768px) {
  .reading-tools { display: none; }
  .blog-toc { display: none; }
  .blog-layout { grid-template-columns: 1fr; grid-template-areas: "nav" "post"; }
  .blog-post { padding: 0; }
  .post-nav { grid-template-columns: 1fr; }
}

/* 回到顶部按钮 */
.back-top {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: all .3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 900;
  box-shadow: 0 4px 16px rgba(26,26,46,0.3);
}
.back-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-top:hover {
  background: var(--cinnabar);
  transform: translateY(-3px) scale(1.05);
}

/* 进度百分比 */
.progress-pct {
  position: fixed;
  right: 32px;
  bottom: 88px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-family: var(--sans);
  padding: 4px 10px;
  border-radius: 12px;
  opacity: 0;
  transition: opacity .3s;
  z-index: 900;
  pointer-events: none;
}
.progress-pct.visible { opacity: 0.8; }

/* 快捷键表格 */
.shortcut-table {
  width: 100%;
  border-collapse: collapse;
}
.shortcut-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.shortcut-table td:first-child { width: 120px; }
.shortcut-table kbd {
  display: inline-block;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 1px 0 var(--line);
}

/* 阅读模式：夜间护眼（Vercel 暗色 - 纯黑 canvas） */
body.mode-night {
  --primary: #ededed;
  --primary-pressed: #ffffff;
  --primary-pale: #1a1a1a;
  --primary-soft: #a1a1a1;
  --ink: #ededed;
  --ink-soft: #a1a1a1;
  --ink-light: #888888;
  --ink-muted: #666666;
  --paper: #0a0a0a;
  --paper-warm: #111111;
  --paper-soft: #1a1a1a;
  --paper-deep: #262626;
  --line: #262626;
  --line-soft: #1a1a1a;
  --line-strong: #404040;
  --link: #3291ff;
  --link-deep: #5aa9ff;
  --cinnabar: #ededed;
  --cinnabar-soft: #ffffff;
  --cinnabar-pale: #1a1a1a;
  --gold: #f5a623;
  --jade: #3291ff;
  --shadow: 0px 1px 1px rgba(0,0,0,0.3), 0px 2px 2px rgba(0,0,0,0.4);
  --shadow-deep: 0px 4px 8px rgba(0,0,0,0.4), 0px 8px 16px rgba(0,0,0,0.5);
  --shadow-xl: 0px 12px 24px rgba(0,0,0,0.5), 0px 24px 48px rgba(0,0,0,0.6);
  background: var(--paper);
  color: var(--ink);
}
body.mode-night .topbar { background: rgba(10, 10, 10, 0.92); border-color: var(--line); }
body.mode-night .para.code {
  background: #000000;
  border-color: var(--line);
}
body.mode-night .modal { background: var(--paper-warm); }
body.mode-night .ctx-menu { background: var(--paper-warm); }
body.mode-night .note-card { background: var(--paper-warm); }
body.mode-night .chapter-card { background: var(--paper-warm); }
body.mode-night .recent-item { background: var(--paper-warm); }
body.mode-night .dash-card { background: var(--paper-warm); }
body.mode-night .dash-progress { background: var(--paper-warm); }
body.mode-night .nc-group-header { background: var(--paper-warm); }
body.mode-night .nc-group-header:hover { background: var(--paper-deep); }
body.mode-night .notes-toolbar { background: var(--paper-warm); }
body.mode-night .scope-tab { background: var(--paper-deep); }
body.mode-night .chapter-select { background: var(--paper-warm); }
body.mode-night .btn-export { background: var(--paper-warm); }
body.mode-night .ch-nav a { background: var(--paper-warm); }
body.mode-night .ch-nav a:hover { background: var(--paper-soft); }
body.mode-night .cmd-box { background: var(--paper-warm); }
body.mode-night .glossary-panel { background: var(--paper-warm); }
body.mode-night .gp-search input { background: var(--paper-deep); }
body.mode-night .search-highlight { background: #b8860b; color: #fff; }

/* 阅读模式：护眼 */
body.mode-sepia {
  --paper: #f0e6d2;
  --paper-warm: #e8dcc4;
  --paper-deep: #ddd0b4;
  --ink: #3d2e1e;
  --ink-soft: #5a4530;
  --ink-light: #7a6448;
  --line: #c9b896;
  --line-soft: #d4c5a8;
  background: var(--paper);
  color: var(--ink);
}

/* ===== 命令面板 (Ctrl+K) ===== */
.cmd-palette { display: none; position: fixed; inset: 0; z-index: 10000; }
.cmd-palette.show { display: block; }
.cmd-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); }
.cmd-box {
  position: relative; max-width: 640px; margin: 12vh auto 0;
  background: var(--paper); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3); overflow: hidden;
  animation: cmdSlide .2s ease;
}
@keyframes cmdSlide { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.cmd-input-wrap { display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line-soft); }
.cmd-icon { font-size: 18px; opacity: 0.5; }
.cmd-input-wrap input {
  flex: 1; border: none; outline: none; padding: 18px 12px;
  font-size: 16px; font-family: var(--sans); background: transparent; color: var(--ink);
}
.cmd-esc { font-size: 11px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-light); }
.cmd-results { max-height: 400px; overflow-y: auto; padding: 8px 0; }
.cmd-group { font-size: 12px; color: var(--ink-light); padding: 8px 20px 4px; font-weight: 600; letter-spacing: 1px; }
.cmd-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  cursor: pointer; transition: background .1s; font-family: var(--sans); font-size: 14px; color: var(--ink);
}
.cmd-item:hover { background: var(--paper-warm); }
.ci-icon { font-size: 16px; opacity: 0.7; width: 20px; text-align: center; }
.ci-cat { font-size: 11px; color: var(--ink-light); margin-left: auto; }
.cmd-search-page { color: #2563eb; font-weight: 500; }
.cmd-empty { padding: 32px; text-align: center; color: var(--ink-light); font-size: 14px; }

/* ===== 术语浏览面板 ===== */
.glossary-panel {
  position: fixed; top: 0; right: -380px; width: 360px; height: 100vh;
  background: var(--paper); box-shadow: -8px 0 32px rgba(0,0,0,0.15);
  z-index: 9990; transition: right .3s ease; display: flex; flex-direction: column;
}
.glossary-panel.open { right: 0; }
.gp-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid var(--line-soft);
  font-family: var(--serif); font-size: 18px; font-weight: 700;
}
.gp-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--ink-light); }
.gp-search { padding: 12px 20px; }
.gp-search input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--sans); font-size: 14px; background: var(--paper-warm); color: var(--ink); outline: none;
}
.gp-search input:focus { border-color: var(--cinnabar); }
.gp-list { flex: 1; overflow-y: auto; padding: 0 0 20px; }
.gp-cat { font-size: 12px; font-weight: 700; color: var(--ink-light); padding: 12px 20px 6px; letter-spacing: 1px; }
.gp-item { padding: 10px 20px; cursor: pointer; transition: all .1s; font-family: var(--sans); font-size: 14px; }
.gp-item:hover { background: var(--paper-warm); color: var(--cinnabar); padding-left: 24px; }
.gp-term { font-weight: 500; }

/* ===== 代码块复制按钮 ===== */
.code-copy-btn {
  position: absolute; top: 8px; right: 8px;
  padding: 4px 12px; font-size: 12px; font-family: var(--sans);
  background: rgba(255,255,255,0.1); color: #8899aa;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.para.code:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ===== 页内搜索高亮 ===== */
.search-highlight { background: #ffd700; color: #000; padding: 1px 2px; border-radius: 3px; }
body.mode-night .search-highlight { background: #b8860b; color: #fff; }

/* ===== 滚动监听目录高亮 ===== */
.ol-link.active { color: var(--cinnabar); font-weight: 600; border-left: 3px solid var(--cinnabar); padding-left: 8px; }

/* ===== 博客TOC链接样式增强 ===== */
.ol-link {
  display: block; padding: 5px 0 5px 11px; font-size: 13px; color: var(--ink-soft);
  text-decoration: none; border-left: 3px solid transparent; transition: all .15s;
  font-family: var(--sans); line-height: 1.5;
}
.ol-link:hover { color: var(--cinnabar); }

/* ===== 灯箱控件（缩放/重置/关闭） ===== */
.img-lightbox img {
  cursor: grab;
  transition: transform .05s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-controls {
  position: fixed;
  top: 24px;
  right: 32px;
  display: flex;
  gap: 8px;
  z-index: 2001;
}
.lb-controls button {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.lb-controls button:hover {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  transform: scale(1.08);
}
.lb-hint {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.3);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  z-index: 2001;
}

/* ===== 书签按钮 ===== */
.bookmark-btn {
  position: absolute;
  top: -8px;
  right: 38px;
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink-light);
  opacity: 0;
  transition: all .2s;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.para { position: relative; }
.para:hover .bookmark-btn { opacity: 0.7; }
.bookmark-btn:hover { opacity: 1 !important; background: var(--paper-warm); transform: scale(1.15); }
.bookmark-btn.active {
  opacity: 1 !important;
  color: var(--gold);
  animation: bookmarkPop .35s ease;
}
@keyframes bookmarkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.35) rotate(-8deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ===== 命令面板选中状态 ===== */
.cmd-item.active {
  background: var(--cinnabar-pale);
  color: var(--cinnabar);
  border-left: 3px solid var(--cinnabar);
  padding-left: 17px;
}
.cmd-item.active .ci-icon { opacity: 1; }

/* ===== 笔记导出按钮 ===== */
.btn-export {
  padding: 7px 14px;
  font-size: 13px;
  font-family: var(--sans);
  background: var(--paper-warm);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
  white-space: nowrap;
}
.btn-export:hover {
  background: var(--cinnabar);
  color: #fff;
  border-color: var(--cinnabar);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ===== 首页阅读统计仪表盘 ===== */
.dashboard {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 32px 40px;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.dash-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all .25s;
}
.dash-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cinnabar);
}
.dash-card.read::before { background: var(--jade); }
.dash-card.notes::before { background: var(--gold); }
.dash-card.bookmarks::before { background: #6b8e9e; }
.dash-card.time::before { background: var(--cinnabar-soft); }
.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px var(--shadow-deep);
  background: #fff;
}
.dash-card .icon { font-size: 22px; margin-bottom: 8px; }
.dash-card .num {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.dash-card .label {
  font-size: 12px;
  color: var(--ink-light);
  margin-top: 6px;
  letter-spacing: 1px;
}
.dash-progress {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.dash-progress .ring {
  width: 72px; height: 72px;
  flex-shrink: 0;
  position: relative;
}
.dash-progress .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dash-progress .ring circle { fill: none; stroke-width: 8; }
.dash-progress .ring .bg { stroke: var(--line-soft); }
.dash-progress .ring .fg { stroke: var(--cinnabar); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.dash-progress .ring .pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.dash-progress .info { flex: 1; }
.dash-progress .info .t {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.dash-progress .info .s {
  font-size: 13px;
  color: var(--ink-light);
  line-height: 1.6;
}
.dash-continue {
  margin-left: auto;
  padding: 10px 22px;
  background: var(--cinnabar);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
  white-space: nowrap;
}
.dash-continue:hover { background: var(--cinnabar-soft); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }

/* ===== 移动端响应式布局 ===== */
@media (max-width: 1024px) {
  .blog-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "nav" "post";
    padding: 12px 16px;
  }
  .blog-toc { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar .brand { font-size: 16px; }
  .topbar nav { gap: 14px; }
  .reading-tools .tool-btn { padding: 5px 8px; font-size: 12px; }
}
@media (max-width: 768px) {
  .hero { padding: 40px 18px 24px; }
  .hero .book-cover { padding: 32px 28px; }
  .hero .book-cover h1 { font-size: 26px; letter-spacing: 2px; }
  .hero .meta { gap: 22px; }
  .hero .meta .num { font-size: 24px; }
  .chapter-grid { grid-template-columns: 1fr; padding: 0 16px 40px; }
  .recent-notes { padding: 0 16px 60px; }
  .dashboard { padding: 0 16px 30px; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dash-card { padding: 18px 12px; }
  .dash-card .num { font-size: 22px; }
  .dash-progress { flex-wrap: wrap; padding: 18px; }
  .dash-continue { margin-left: 0; width: 100%; text-align: center; }
  .topbar nav a { font-size: 13px; }
  .reading-tools { display: none; }
  .post-title { font-size: 22px !important; }
  .post-header { padding-bottom: 16px !important; margin-bottom: 20px !important; }
  .para { font-size: 15px !important; padding: 8px 0 !important; }
  .para.heading { font-size: 18px !important; }
  .notes-toolbar { flex-wrap: wrap; gap: 8px; }
  .notes-toolbar .search-box { width: 100%; order: -1; }
  .notes-toolbar select { flex: 1; min-width: 0; }
  .notes-toolbar .btn-export { width: 100%; }
  .lb-controls { top: 16px; right: 16px; }
  .lb-controls button { width: 36px; height: 36px; font-size: 16px; }
  .lb-hint { font-size: 10px; padding: 6px 12px; bottom: 16px; }
  .cmd-box { max-width: 92%; margin: 8vh auto 0; }
  .modal { max-width: 92% !important; }
  .glossary-panel { width: 100%; right: -100%; }
  .glossary-panel.open { right: 0; }
}
@media (max-width: 480px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .blog-nav-bar { flex-direction: column; gap: 10px; align-items: stretch; }
  .chapter-select { max-width: 100%; }
  .blog-nav-links { justify-content: space-between; }
  .post-nav { flex-direction: column; gap: 10px; }
}

/* 段落标记优化 */
.para-mark {
  position: absolute;
  top: -4px;
  right: 4px;
  width: 18px; height: 18px;
  background: var(--cinnabar);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.para { position: relative; }
.ol-link.lvl3 { padding-left: 24px; font-size: 12px; }
