/* 《礼记》全本详注典藏版 — 东方古籍美学样式表 */

:root {
  /* 宣纸素笺（默认） */
  --bg: #f6f1e7;
  --bg-elev: #fcf9f2;
  --bg-card: #fffdf8;
  --bg-soft: #efe8d8;
  --bg-hover: #ebe2ce;
  --border: #e3d9c5;
  --border-strong: #cfc1a4;
  --ink: #241f1a;
  --ink-secondary: #53493e;
  --ink-muted: #827668;
  --seal: #9e2f25;       /* 朱砂印泥 */
  --seal-soft: rgba(158, 47, 37, 0.08);
  --seal-border: rgba(158, 47, 37, 0.24);
  --jade: #2e5955;       /* 黛青竹韵 */
  --jade-soft: rgba(46, 89, 85, 0.09);
  --gold: #8c6229;       /* 泥金 */
  --gold-soft: rgba(140, 98, 41, 0.09);
  --highlight-bg: rgba(158, 47, 37, 0.07);
  --highlight-border: rgba(158, 47, 37, 0.42);
  --shadow-sm: 0 1px 3px rgba(36, 31, 26, 0.05);
  --shadow-md: 0 8px 28px rgba(36, 31, 26, 0.12);
  --shadow-lg: 0 18px 48px rgba(36, 31, 26, 0.18);

  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --font-kai: "Kaiti SC", "STKaiti", "LXGW WenKai", "KaiTi", "Songti SC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --text-scale: 1;
  --sidebar-w: 288px;
  --toc-w: 236px;
  --topbar-h: 58px;
}

[data-theme="bamboo"] {
  --bg: #ecf2eb;
  --bg-elev: #f4f8f3;
  --bg-card: #f9fcf8;
  --bg-soft: #e0eae0;
  --bg-hover: #d5e2d5;
  --border: #cddbc9;
  --border-strong: #b4c8b1;
  --ink: #1d2922;
  --ink-secondary: #3f5246;
  --ink-muted: #687c70;
  --seal: #99382b;
  --seal-soft: rgba(153, 56, 43, 0.08);
  --seal-border: rgba(153, 56, 43, 0.24);
  --jade: #245c4c;
  --jade-soft: rgba(36, 92, 76, 0.09);
  --gold: #7c5c26;
  --gold-soft: rgba(124, 92, 38, 0.09);
  --highlight-bg: rgba(36, 92, 76, 0.09);
  --highlight-border: rgba(36, 92, 76, 0.48);
}

[data-theme="ink"] {
  --bg: #151412;
  --bg-elev: #1c1a17;
  --bg-card: #22201c;
  --bg-soft: #2b2823;
  --bg-hover: #332f29;
  --border: #332e27;
  --border-strong: #4a4238;
  --ink: #e7dfd2;
  --ink-secondary: #bfb4a3;
  --ink-muted: #8a7f70;
  --seal: #d96b5c;
  --seal-soft: rgba(217, 107, 92, 0.14);
  --seal-border: rgba(217, 107, 92, 0.35);
  --jade: #6fb2a8;
  --jade-soft: rgba(111, 178, 168, 0.13);
  --gold: #d4a85e;
  --gold-soft: rgba(212, 168, 94, 0.12);
  --highlight-bg: rgba(217, 107, 92, 0.16);
  --highlight-border: rgba(217, 107, 92, 0.52);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 54px rgba(0, 0, 0, 0.65);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.65;
  overflow: hidden;
}

/* 顶部工具栏 */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding-right: 8px;
}

.brand-seal {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  background: var(--seal);
  color: #fffaf5;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  display: grid;
  place-items: center;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1.5px rgba(255, 250, 245, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--ink-muted);
  border: 1px solid var(--border-strong);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-secondary);
  height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--ink);
}

.icon-btn.active {
  background: var(--seal-soft);
  border-color: var(--seal-border);
  color: var(--seal);
  font-weight: 600;
}

.mode-group {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mode-btn:hover { color: var(--ink); }

.mode-btn.active {
  background: var(--bg-card);
  color: var(--seal);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.search-trigger {
  min-width: 190px;
  justify-content: space-between;
  color: var(--ink-muted);
}

.kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--ink-muted);
}

/* 三栏主体布局 */
.layout {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
  overflow: hidden;
}

/* 左侧目录栏 */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.22s ease;
}

.sidebar.collapsed {
  margin-left: calc(var(--sidebar-w) * -1);
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-search {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.sidebar-search:focus {
  border-color: var(--seal);
}

.sidebar-tabs {
  display: flex;
  gap: 4px;
}

.sidebar-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-secondary);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-tab.active {
  background: var(--seal);
  border-color: var(--seal);
  color: #fffaf5;
  font-weight: 600;
}

.chapter-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.group-heading {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--jade);
  padding: 10px 8px 4px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.14s ease;
  border: 1px solid transparent;
}

.chapter-item:hover {
  background: var(--bg-hover);
}

.chapter-item.active {
  background: var(--seal-soft);
  border-color: var(--seal-border);
}

.chapter-num {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--ink-muted);
  font-family: var(--font-serif);
  font-size: 11.5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chapter-item.active .chapter-num {
  background: var(--seal);
  color: #fffaf5;
}

.chapter-item-body {
  min-width: 0;
  flex: 1;
}

.chapter-item-title {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.chapter-item.active .chapter-item-title {
  color: var(--seal);
}

.chapter-item-meta {
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jade);
  flex-shrink: 0;
}

.status-dot.pending {
  background: var(--border-strong);
}

/* 中央阅读主区 */
.reader-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 28px 32px 96px;
}

.reader-container {
  max-width: 860px;
  margin: 0 auto;
  transition: max-width 0.2s ease;
}

body.view-split .reader-container {
  max-width: 1180px;
}

/* 首页总览封面 */
.cover-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cover-hero::before {
  content: "禮";
  position: absolute;
  right: 24px;
  top: -12px;
  font-family: var(--font-serif);
  font-size: 180px;
  color: var(--seal);
  opacity: 0.055;
  pointer-events: none;
  line-height: 1;
}

.cover-badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--seal);
  background: var(--seal-soft);
  border: 1px solid var(--seal-border);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 14px;
}

.cover-title {
  font-family: var(--font-serif);
  font-size: 36px;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.cover-desc {
  color: var(--ink-secondary);
  font-size: 15px;
  max-width: 680px;
  line-height: 1.85;
  margin-bottom: 22px;
}

.cover-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}

.stat-pill {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 120px;
}

.stat-val {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--seal);
  line-height: 1.2;
}

.stat-lbl {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.cover-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.cover-group-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--jade);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.cover-chapter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ch-chip {
  font-family: var(--font-serif);
  font-size: 13.5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.14s ease;
}

.ch-chip:hover {
  background: var(--seal);
  border-color: var(--seal);
  color: #fffaf5;
}

/* 篇章头部 */
.chapter-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.chapter-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chapter-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--seal);
  margin-bottom: 6px;
}

.chapter-kicker .tag {
  background: var(--jade-soft);
  color: var(--jade);
  padding: 1px 8px;
  border-radius: 4px;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: calc(30px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ink);
  line-height: 1.25;
}

.chapter-one-line {
  font-family: var(--font-kai);
  font-size: calc(16px * var(--text-scale));
  color: var(--seal);
  margin-top: 8px;
}

.chapter-metrics {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 10px;
  flex-wrap: wrap;
}

.chapter-intro-box {
  margin-top: 18px;
  padding: 16px 20px;
  background: var(--bg-elev);
  border-left: 3px solid var(--seal);
  border-radius: 0 8px 8px 0;
  font-size: calc(14.5px * var(--text-scale));
  color: var(--ink-secondary);
  line-height: 1.85;
}

.chapter-intro-label {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--seal);
  font-size: 14px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

/* 名物礼制卡片 */
.concepts-wrap {
  margin-top: 18px;
}

.concepts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.concepts-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--jade);
  letter-spacing: 1px;
}

.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.concept-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  transition: border-color 0.15s ease;
}

.concept-card:hover {
  border-color: var(--jade);
}

.concept-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.concept-term {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}

.concept-pinyin {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-left: 4px;
  font-weight: 400;
}

.concept-cat {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gold-soft);
  color: var(--gold);
  white-space: nowrap;
}

.concept-detail {
  font-size: 12.8px;
  color: var(--ink-secondary);
  line-height: 1.65;
}

/* 段落卡片 */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 20px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.section-card.flash-highlight {
  border-color: var(--seal);
  box-shadow: 0 0 0 3px var(--seal-soft);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sec-num {
  font-family: var(--font-serif);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--seal-soft);
  color: var(--seal);
  border: 1px solid var(--seal-border);
  white-space: nowrap;
}

.sec-heading {
  font-family: var(--font-serif);
  font-size: calc(17px * var(--text-scale));
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.5px;
}

.sec-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.mini-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.mini-btn:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.mini-btn.bookmarked {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

/* 经文与注译布局 */
.section-body {
  display: block;
}

body.view-split .section-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 24px;
  align-items: start;
}

.original-block {
  font-family: var(--font-serif);
  font-size: calc(20px * var(--text-scale));
  line-height: 2.1;
  color: var(--ink);
  letter-spacing: 0.8px;
  margin-bottom: 18px;
  text-align: justify;
}

body.view-split .original-block {
  position: sticky;
  top: 12px;
  margin-bottom: 0;
  padding-right: 14px;
  border-right: 1px dashed var(--border-strong);
}

body.view-plain .original-block {
  margin-bottom: 0;
}

/* 行内高亮词汇 */
.gloss-term {
  background: var(--highlight-bg);
  border-bottom: 1.5px dotted var(--highlight-border);
  border-radius: 3px;
  padding: 0 1px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.gloss-term:hover, .gloss-term.active-term {
  background: var(--seal-soft);
  border-bottom: 1.5px solid var(--seal);
  color: var(--seal);
}

/* 详注面板 */
.annotations-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 18px;
  margin-bottom: 14px;
}

.block-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.label-notes { color: var(--seal); }
.label-trans { color: var(--jade); }
.label-comm  { color: var(--gold); }

.notes-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.note-item {
  font-size: calc(14px * var(--text-scale));
  line-height: 1.75;
  color: var(--ink-secondary);
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.note-item:hover {
  background: var(--bg-soft);
}

.note-idx {
  display: inline-block;
  font-size: 11px;
  font-family: var(--font-serif);
  color: var(--seal);
  margin-right: 5px;
  font-weight: 700;
}

.note-term {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.note-term:hover {
  color: var(--seal);
  text-decoration: underline;
}

.note-pinyin {
  font-size: 12.5px;
  color: var(--jade);
  margin: 0 5px 0 3px;
  font-family: var(--font-sans);
}

/* 白话今译 */
.translation-block {
  background: var(--jade-soft);
  border-left: 3px solid var(--jade);
  border-radius: 0 9px 9px 0;
  padding: 13px 18px;
  margin-bottom: 14px;
  font-size: calc(15px * var(--text-scale));
  line-height: 1.85;
  color: var(--ink);
}

/* 义理与礼制阐发 */
.commentary-block {
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  border-radius: 0 9px 9px 0;
  padding: 13px 18px;
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.85;
  color: var(--ink-secondary);
}

/* 阅读视图显隐控制 */
body.view-plain .annotations-block,
body.view-plain .translation-block,
body.view-plain .commentary-block {
  display: none;
}

body.view-notes .translation-block,
body.view-notes .commentary-block {
  display: none;
}

/* 右侧篇内大纲 */
.toc-panel {
  width: var(--toc-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toc-title {
  padding: 12px 14px;
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-secondary);
  border-bottom: 1px solid var(--border);
  letter-spacing: 1px;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.toc-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  cursor: pointer;
  line-height: 1.45;
  margin-bottom: 2px;
}

.toc-item:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

.toc-item.active {
  background: var(--seal-soft);
  color: var(--seal);
  font-weight: 600;
}

.toc-num {
  font-size: 11px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

/* 篇章底部翻页 */
.chapter-pager {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.pager-btn {
  flex: 1;
  max-width: 48%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.pager-btn.next { text-align: right; }

.pager-btn:hover {
  border-color: var(--seal);
  background: var(--seal-soft);
}

.pager-dir {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.pager-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

/* 行内词汇浮窗 Popover */
.gloss-popover {
  position: fixed;
  z-index: 500;
  width: min(380px, calc(100vw - 24px));
  background: var(--bg-card);
  border: 1px solid var(--seal-border);
  border-top: 3px solid var(--seal);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  display: none;
}

.gloss-popover.open { display: block; }

.pop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.pop-term {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--seal);
}

.pop-pinyin {
  font-size: 13px;
  color: var(--jade);
  margin-left: 6px;
}

.pop-close {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.pop-body {
  font-size: 13.8px;
  line-height: 1.75;
  color: var(--ink-secondary);
}

/* 全书搜索 / 书签弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 15, 12, 0.52);
  backdrop-filter: blur(3px);
  z-index: 600;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
}

.modal-backdrop.open { display: flex; }

.modal-box {
  width: min(720px, calc(100vw - 28px));
  max-height: 78vh;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.search-meta {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.search-hit {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--bg-elev);
  transition: border-color 0.14s ease;
}

.search-hit:hover {
  border-color: var(--seal);
  background: var(--seal-soft);
}

.search-hit-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--seal);
  margin-bottom: 4px;
}

.search-hit-snippet {
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.6;
}

.search-hit mark {
  background: rgba(158, 47, 37, 0.2);
  color: var(--seal);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* 加载提示 */
.loading-box {
  text-align: center;
  padding: 72px 24px;
  color: var(--ink-muted);
  font-family: var(--font-serif);
  font-size: 16px;
}

/* 响应式 */
@media (max-width: 1120px) {
  .toc-panel { display: none; }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .reader-scroll { padding: 18px 14px 80px; }
  .chapter-header, .section-card { padding: 18px 16px; }
  body.view-split .section-body { grid-template-columns: 1fr; }
  body.view-split .original-block { position: static; border-right: none; padding-right: 0; margin-bottom: 14px; }
  .brand-sub, .search-trigger .kbd { display: none; }
  .search-trigger { min-width: auto; }
}

/* 打印 / 导出 PDF 优化 */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; color: #000; }
  .topbar, .sidebar, .toc-panel, .chapter-pager, .sec-actions, .gloss-popover, .modal-backdrop { display: none !important; }
  .layout { position: static; display: block; overflow: visible; }
  .reader-scroll { padding: 0; overflow: visible; }
  .reader-container { max-width: 100%; }
  .section-card, .chapter-header { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .gloss-term { background: none; border-bottom: 1px dotted #999; }
}
