/* ============================================================
   一堆古书 · 在线阅读 — 样式
   ============================================================ */
:root {
  --paper: #f6f1e4;        /* 纸色 */
  --paper-light: #fdfaf2;
  --ink: #3a3226;          /* 墨色 */
  --ink-soft: #6b6152;
  --accent: #9e2b25;       /* 朱红 */
  --accent-dark: #7d1f1a;
  --gold: #b48a3c;
  --line: #d8cfba;
  --shadow: 0 2px 10px rgba(60, 50, 30, 0.08);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-serif);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.8;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶栏 ---------- */
.site-header {
  background: linear-gradient(180deg, #e8dcc0, #dfd1b0);
  border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-top: 16px;
  padding-bottom: 14px;
}

.brand {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 2px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  margin-right: 6px;
  vertical-align: middle;
  object-fit: cover;
  background: #fff8ec;
}

.tagline {
  color: var(--ink-soft);
  font-size: 14px;
}

/* 顶栏右侧操作区：副标题 + 作者手记链接（同一行） */
.header-actions {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
}

/* 作者手记链接：字体/大小/颜色与副标题一致 */
.tagline-link {
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}
.tagline-link:hover {
  color: var(--accent);
}

/* 小屏幕（<768px）：作者手记换行到副标题下方，字号稍小，避免挤在一起 */
@media (max-width: 767px) {
  .header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .tagline-link {
    font-size: 13px;
    opacity: 0.85;
  }
}

/* ---------- 全站搜索（首页 + 所有页面头部） ---------- */
.search-box { position: relative; display: flex; align-items: center; gap: 6px; }
#search-toggle {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--ink-soft); padding: 4px 6px; line-height: 1;
}
#search-toggle:hover { color: var(--ink); }
#search-input {
  width: 0; padding: 0; border: none; border-bottom: 1px solid transparent;
  background: transparent; font-size: 14px; font-family: inherit; color: var(--ink);
  outline: none; transition: width .22s ease, padding .22s ease, border-color .22s ease;
}
#search-input.open { width: 200px; padding: 5px 8px; border-bottom-color: var(--ink-soft); }
#search-dropdown {
  position: absolute; top: 100%; right: 0; width: 340px; max-height: 340px; overflow-y: auto;
  background: var(--paper-light); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); z-index: 120;
}
#search-dropdown a {
  display: block; padding: 10px 14px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
#search-dropdown a:hover { background: var(--paper); }
.s-name { font-size: 15px; }
.s-name small { color: var(--ink-soft); font-size: 11px; margin-left: 8px; }
.s-meta { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.s-empty { padding: 14px; color: var(--ink-soft); font-size: 13px; }

/* 移动端搜索浮层 */
#search-overlay {
  position: fixed; inset: 0; background: var(--paper-light); z-index: 20000;
  display: none; flex-direction: column; padding: 24px 20px;
}
#search-overlay.open { display: flex; }
#search-overlay .ov-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
#search-input-m {
  flex: 1; padding: 10px 12px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; outline: none; color: var(--ink);
}
#search-close-m {
  border: none; background: none; color: var(--ink-soft); font-size: 14px; cursor: pointer;
  padding: 8px 6px;
}
#search-results-m { flex: 1; overflow-y: auto; }
#search-results-m a {
  display: block; padding: 12px 4px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 60px;
  padding: 18px 0 30px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

/* ---------- 标题 ---------- */
.page-title {
  font-size: 30px;
  margin: 36px 0 6px;
  letter-spacing: 3px;
}

.page-sub {
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-size: 15px;
}

.crumb {
  margin: 24px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.crumb a {
  color: var(--accent);
  text-decoration: none;
}

.crumb a:hover { text-decoration: underline; }

/* ---------- 文本说明便签 ---------- */
.book-notice {
  background: #fef9e7;               /* 淡米黄 */
  border-left: 4px solid #e67e22;    /* 左竖线装饰 */
  border-radius: 6px;
  padding: 12px 16px;
  margin: 18px 0 8px;
  font-size: 13px;
  color: #555;
  line-height: 1.9;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.book-notice strong {
  font-size: 14px;
  color: #7a4a1e;
}

.book-notice p {
  margin: 6px 0 0;
}

/* ---------- 书架 ---------- */
.book-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

.book-card {
  display: block;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  padding: 22px 18px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(60, 50, 30, 0.14);
}

.book-card-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.book-card-meta {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 12px;
}

.book-card-cats { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 分类标签 ---------- */
.cat-tag {
  display: inline-block;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 20px;
  background: #eee5d2;
  color: var(--ink-soft);
}

.cat-ji, .cat-benji { background: #f3e0d3; color: #8a3b2a; }
.cat-biao { background: #e5e8f0; color: #3c5673; }
.cat-shu  { background: #e2efe2; color: #2f6b3a; }
.cat-shijia { background: #f2ead3; color: #8a6d2f; }
.cat-liezhuan, .cat-zhuan { background: #e7e0ef; color: #5b3d86; }
.cat-zhi { background: #dfe9ea; color: #2c6b70; }
.cat-wei { background: #f0e2d2; color: #8a4a20; }
.cat-wu  { background: #e0e9f0; color: #2d4d7a; }

/* ---------- AI 阅读器入口 ---------- */
.ai-entry {
  margin: 30px 0 10px;
  text-align: center;
}

.btn-ai {
  display: inline-block;
  padding: 12px 30px;
  font-size: 17px;
  letter-spacing: 1px;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 30px;
  box-shadow: 0 3px 10px rgba(158, 43, 37, 0.28);
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-ai:hover {
  background: var(--accent-dark);
  color: #fff;
  transform: translateY(-1px);
}

/* 深度学习悬浮按钮（右下角固定，滚动不消失） */
.btn-ai-mode {
  position: fixed;
  right: 24px;
  bottom: 28px;
  z-index: 999;
  padding: 14px 30px;
  font-size: 17px;
  letter-spacing: 1px;
  border-radius: 34px;
  color: #fff;
  background: #16a085;
  border-color: #16a085;
  box-shadow: 0 4px 14px rgba(22, 160, 133, 0.35);
}

.btn-ai-mode:hover {
  background: #12806a;
  color: #fff;
  transform: translateY(-1px);
}

@media (max-width: 560px) {
  .btn-ai-mode {
    right: 16px;
    bottom: 18px;
    padding: 12px 22px;
    font-size: 15px;
  }
}

/* ---------- 提示条 ---------- */
.notice {
  padding: 22px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--paper-light);
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 20px 0;
}

.notice.error {
  color: var(--accent);
  border-color: var(--accent);
  background: #fbeee8;
}

/* ---------- 版本缺篇标注 ---------- */
.missing-notice {
  margin: 18px 0 26px;
  padding: 16px 20px;
  border: 1px solid #e3c9a6;
  border-left: 4px solid #c89b3c;
  border-radius: 8px;
  background: #fbf6ea;
  color: var(--ink);
  font-size: 14px;
}

.missing-title {
  font-weight: 700;
  font-size: 15px;
  color: #8a6d2f;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.missing-body {
  color: var(--ink-soft);
  margin-bottom: 10px;
  line-height: 1.8;
}

.missing-group,
.missing-notice details {
  margin: 6px 0;
  line-height: 1.9;
}

.missing-cat {
  display: inline-block;
  padding: 0 8px;
  margin-right: 6px;
  font-size: 12px;
  border-radius: 10px;
  background: #e8dcbe;
  color: #6d5320;
  font-weight: 600;
}

.missing-notice summary {
  cursor: pointer;
  font-weight: 600;
  color: #6d5320;
}

.missing-titles {
  color: var(--ink-soft);
  font-size: 13px;
  margin-left: 6px;
}



/* ---------- 书目页 ---------- */
.book-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 18px 0 26px;
}

#search {
  flex: 1;
  min-width: 200px;
  max-width: 380px;
  padding: 8px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 6px;
}

#search:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(180, 138, 60, 0.25);
}

.stat { color: var(--ink-soft); font-size: 14px; }

.cat-block { margin-bottom: 34px; }

.cat-block-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.cat-block-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
}

.cat-block-count {
  color: var(--ink-soft);
  font-size: 13px;
}

.section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px 20px;
}

.section-item a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;

/* ---------- 阅读器 ---------- */
.reader-wrap {
  /* 电脑端阅读区宽度：clamp 自适应，居中显示；大屏最宽 1200px，避免一行过长或挤成一条 */
  width: clamp(600px, 70vw, 1200px);
  max-width: 100%;
  margin: 0 auto;
}

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 18px;
}

.reader-tools { display: flex; gap: 8px; }

.btn {
  display: inline-block;
  padding: 6px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--accent);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover { background: #efe7d4; }

.reader {
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 40px 44px;
  box-shadow: var(--shadow);
}

.reader-head {
  text-align: center;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 18px;
  margin-bottom: 26px;
}

.reader-cat {
  display: inline-block;
  font-size: 13px;
  padding: 2px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.reader-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  margin: 0 0 8px;
}

.reader-meta {
  color: var(--ink-soft);
  font-size: 13px;
}

.reader-body p {
  margin: 0 0 12px;
  text-align: justify;
  text-indent: 2em;
  line-height: 1.85;
}

/* 句子池 anchor 跳转：目标段落短暂高亮 */
.anchor-flash {
  animation: anchorFlash 3s ease;
  border-radius: 3px;
}
@keyframes anchorFlash {
  0% { background: rgba(255, 230, 0, 0.45); }
  100% { background: transparent; }
}

/* 独立注释层：卷末注（如史記索隱述贊），与正文明显区分 */
.reader-notes {
  margin-top: 30px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.025);
  color: var(--ink-soft);
}

.reader-notes-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: 10px;
}

.reader-notes p {
  margin: 0 0 10px;
  text-align: justify;
  line-height: 1.9;
}

.reader-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
}

.reader-nav .btn {
  flex: 1;
  text-align: center;
  padding: 10px 14px;
  font-size: 15px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .reader { padding: 24px 18px; }
  .header-inner { flex-direction: column; }
  .book-shelf { grid-template-columns: 1fr; }
}

  color: var(--ink);
  padding: 5px 8px;
  border-radius: 4px;
}

.section-item a:hover {
  background: #efe7d4;
}

.section-num {
  font-size: 12px;
  color: var(--gold);
  font-family: var(--font-kai);
  flex-shrink: 0;
}

.section-source {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 400;
  margin-left: 2px;
}

/* ---------- 阅读设置：字体 / 配色 / 背景字色（与 AI 阅读器共用） ---------- */
.reading-settings{
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  padding: 10px 12px;
  margin: 0 0 14px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.rs-group{ display: flex; align-items: center; gap: 6px; }
.rs-label{ font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.rs-btn{
  width: 28px; height: 28px;
  background: #f4f4f4;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: #333;
}
.rs-btn:hover{ background: #e6e6e6; }
.rs-val{ font-size: 13px; color: #333; min-width: 22px; text-align: center; }
/* 阅读页自定义背景铺满阅读区时，设置栏标签 / 页脚文字跟随字色（--rs-fg 仅阅读页设置，顶部导航不受影响） */
.reading-settings .rs-label,
.reading-settings .rs-val,
.site-footer {
  color: var(--rs-fg, var(--ink-soft));
}
/* 简繁转换按钮：自适应宽度 */
.textmode-btn{ width: auto; height: auto; padding: 5px 10px; line-height: 1.2; }
.textmode-btn.active{ background: var(--accent); color: #fff; border-color: var(--accent); }
.scheme-btn{
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scheme-btn:hover{ border-color: #bbb; }
.scheme-btn.active{ border-color: var(--accent); box-shadow: 0 0 0 2px rgba(158, 43, 37, 0.25); }
.rs-color{ width: 34px; height: 28px; padding: 1px; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; background: #fff; }
.rs-hex{ width: 76px; padding: 4px 6px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; color: #333; }
.rs-rgb{ width: 88px; padding: 4px 6px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; color: #333; }

/* ---------- 羊皮纸材质背景（默认阅读主题，纯 CSS 渐变模拟，无需图片资源） ----------
   当背景为默认羊皮纸色 #f5ead0 时启用：阅读正文区 / 阅读卡片 / 全局 AI 助手面板共用。
   注意：JS 只设置 background-color，此纹理通过 background-image 叠加，互不冲突。 */
body.reading-paper,
.reader.reading-paper,
#gai-root.gai-paper #gai-panel {
  background-image:
    /* 边缘暗角（更真实） */
    radial-gradient(ellipse 160% 130% at 50% 50%, transparent 55%, rgba(126, 96, 56, 0.14) 100%),
    /* 细微纸纤维纹理 */
    repeating-linear-gradient(0deg, rgba(139, 107, 66, 0.045) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(139, 107, 66, 0.035) 0 1px, transparent 1px 4px),
    /* 斑驳水渍 */
    radial-gradient(ellipse 120px 90px at 15% 25%, rgba(176, 140, 92, 0.10), transparent 70%),
    radial-gradient(ellipse 110px 150px at 82% 18%, rgba(140, 105, 60, 0.08), transparent 70%),
    radial-gradient(ellipse 160px 110px at 68% 78%, rgba(196, 160, 108, 0.09), transparent 70%),
    radial-gradient(ellipse 100px 130px at 30% 72%, rgba(120, 90, 50, 0.07), transparent 70%),
    radial-gradient(ellipse 240px 180px at 50% 110%, rgba(150, 115, 70, 0.10), transparent 75%);
}

/* ---------- 支持作者 ---------- */
.support {
  margin: 0 0 18px;
  padding: 24px 20px 20px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
.support-title {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 1px;
}
.support-qr {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}
.qr-slot {
  width: 116px;
  height: 116px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}
.qr-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.qr-caption {
  font-size: 12px;
  color: var(--ink-soft);
}
.qr-ph {
  border: 2px dashed var(--line);
  background: #fffdf7;
}
.qr-label {
  font-size: 13px;
  color: var(--ink);
}
.qr-hint {
  font-size: 11px;
  color: var(--ink-soft);
}
.qr-img {
  width: 116px;
  height: 116px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.footer-note {
  color: var(--ink-soft);
  font-size: 13px;
}

/* ---------- 页脚捐助链接 ---------- */
.footer-donate {
  margin-bottom: 6px;
  font-size: 14px;
}
.footer-donate a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
  transition: color 0.15s ease, border-bottom-color 0.15s ease;
}
.footer-donate a:hover {
  color: var(--accent-dark);
  border-bottom-color: var(--accent-dark);
}

/* ========== 首页 Hero ========== */
.hero {
  text-align: center;
  padding: 64px 0 20px;
}
.hero-title {
  font-size: 38px;
  letter-spacing: 4px;
  margin: 0 0 14px;
  color: var(--ink);
}
.hero-sub {
  color: var(--ink-soft);
  font-size: 16px;
  margin: 0 0 30px;
  line-height: 1.8;
}
.hero-cta {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 620px;
  margin: 0 auto;
}
.hero-input {
  flex: 1;
  min-width: 260px;
  padding: 13px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 30px;
  outline: none;
}
.hero-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(158, 43, 37, 0.15);
}
.hero-btn {
  padding: 13px 30px;
  font-size: 15px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s ease;
}
.hero-btn:hover { background: var(--accent-dark); }

/* ========== 首页 AI 领读 Demo ========== */
.demo {
  margin: 48px auto 20px;
  max-width: 760px;
}
.demo-title {
  font-size: 22px;
  letter-spacing: 2px;
  margin: 0 0 18px;
}
.demo-card {
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.demo-original,
.demo-trans {
  padding: 22px 28px;
  border-bottom: 1px dashed var(--line);
}
.demo-words {
  padding: 22px 28px;
}
.demo-original h3,
.demo-trans h3,
.demo-words h3 {
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 1px;
  margin: 0 0 10px;
}
.demo-original p {
  font-size: 17px;
  line-height: 2.1;
  text-align: justify;
  margin: 0;
}
.demo-trans p {
  font-size: 15px;
  line-height: 2;
  color: var(--ink-soft);
  text-align: justify;
  margin: 0;
}
.demo-words ul {
  margin: 0;
  padding-left: 1.3em;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 2;
}
.demo-words b { color: var(--ink); }

/* ========== 首页 古文觀止 · AI 领读范本 ========== */
.samples {
  max-width: 760px;
  margin: 44px auto 0;
}
.samples-title {
  font-size: 22px;
  letter-spacing: 2px;
  margin: 0 0 18px;
}
.samples-hint {
  color: var(--ink-soft);
  font-size: 13px;
  margin: -8px 0 14px;
}
.samples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.sample-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.sample-item:hover {
  background: #efe7d4;
  border-color: var(--accent);
}
.sample-no {
  color: var(--gold);
  font-size: 13px;
  flex-shrink: 0;
}
.sample-title {
  font-weight: 600;
}
.sample-source {
  color: var(--ink-soft);
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
}

/* ---------- 今日一句（全站句子池） ---------- */
.daily-card {
  max-width: 640px;
  margin: 26px auto 10px;
  padding: 22px 26px 18px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.daily-loading,
.daily-empty {
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
  padding: 6px 0;
}
.daily-text {
  font-family: var(--font-kai);
  font-size: 22px;
  line-height: 1.9;
  text-align: center;
  margin: 4px 0 10px;
}
.daily-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.daily-source {
  color: var(--ink-soft);
  font-size: 13px;
}
.daily-shuffle {
  font-size: 13px;
  padding: 6px 14px;
}
@media (max-width: 560px) {
  .daily-text { font-size: 18px; }
  .daily-meta { justify-content: center; }
}

/* ---------- 首页 书架行动区 ---------- */
.shelf-cta {
  text-align: center;
  margin: 40px 0 8px;
}
.btn-primary {
  display: inline-block;
  padding: 13px 34px;
  font-size: 16px;
  letter-spacing: 2px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 30px;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--accent-dark); }
.shelf-section {
  margin-top: 44px;
}
.shelf-title {
  font-size: 24px;
  letter-spacing: 2px;
  margin: 0 0 22px;
  text-align: center;
  color: var(--ink);
}

/* ---------- 书库 · 经史子集（四大名著） ---------- */
.jsz-section {
  margin-top: 48px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.jsz-title {
  font-size: 24px;
  letter-spacing: 2px;
  margin: 0 0 8px;
  text-align: center;
  color: var(--ink);
}

.jsz-hint {
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
  margin: 0 0 22px;
}

.jsz-more {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.jsz-more:hover {
  text-decoration: underline;
}

.jsz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.jsz-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 20px 16px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.jsz-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(60, 50, 30, 0.14);
  border-color: var(--accent);
}

.jsz-name {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 6px;
  margin-top: 6px;
}

.jsz-author {
  color: var(--gold);
  font-size: 14px;
  font-family: var(--font-kai);
}

.jsz-intro {
  margin: 4px 0 8px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.9;
  flex: 1;
}

.jsz-enter {
  display: inline-block;
  align-self: flex-start;
  font-size: 14px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 5px 16px;
  transition: background 0.15s ease, color 0.15s ease;
}

.jsz-card:hover .jsz-enter {
  background: var(--accent);
  color: #fff;
}

/* 经史子集 · 四部标签 */
.cat-shi { background: #e5e8f0; color: #3c5673; }
.cat-zi  { background: #e7e0ef; color: #5b3d86; }

/* ---------- 书库 · 经史子集 独立页（library.html） ---------- */
.lib-wrap { max-width: 960px; }

.lib-title {
  font-size: 30px;
  letter-spacing: 4px;
  text-align: center;
  margin: 26px 0 6px;
}

.lib-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 28px;
}

.lib-part { margin-bottom: 40px; }

.lib-part-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.lib-part-name {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 6px;
}

.lib-part-desc {
  color: var(--ink-soft);
  font-size: 13px;
}

.lib-part-count {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}

.lib-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.lib-book {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 18px 14px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.lib-book:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(60, 50, 30, 0.14);
  border-color: var(--accent);
}

.lib-book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lib-book-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
}

.lib-book-author {
  color: var(--gold);
  font-family: var(--font-kai);
  font-size: 14px;
}

.lib-book-intro {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.9;
  flex: 1;
  margin: 4px 0 6px;
}

.lib-book-meta {
  color: var(--ink-soft);
  font-size: 13px;
}

.lib-book-enter {
  display: inline-block;
  align-self: flex-start;
  font-size: 14px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 5px 16px;
  transition: background 0.15s ease, color 0.15s ease;
}

.lib-book:hover .lib-book-enter {
  background: var(--accent);
  color: #fff;
}

.lib-empty {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.cat-lib { background: #eee5d2; color: var(--ink-soft); }

/* ---------- 分类页（/category/*） ---------- */
.cat-wrap { max-width: 960px; }
.cat-back {
  display: inline-block; margin-top: 24px; color: var(--accent);
  text-decoration: none; font-size: 14px;
}
.cat-back:hover { text-decoration: underline; }
.cat-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  border-bottom: 2px solid var(--gold); padding-bottom: 10px; margin: 14px 0 24px;
}
.cat-head h1 { font-size: 30px; letter-spacing: 6px; margin: 0; }
.cat-head .cat-desc { color: var(--ink-soft); font-size: 13px; }
.cat-empty {
  color: var(--ink-soft); padding: 56px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: 10px; font-size: 15px; letter-spacing: 1px;
  background: var(--paper-light);
}
.cat-tag.cat-dyn {
  background: var(--paper-light); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 11px;
}
.lib-part-all {
  margin-left: auto; color: var(--accent); text-decoration: none;
  font-size: 13px; white-space: nowrap;
}
.lib-part-all:hover { text-decoration: underline; }
.lib-sub-block {
  font-size: 15px; color: var(--ink-soft); letter-spacing: 2px;
  margin: 20px 0 10px; border-left: 3px solid var(--gold); padding-left: 10px;
}

/* ---------- 全局 AI 助手（global-ai.js） ---------- */
/* 主题变量默认羊皮纸（#f5ead0 / #3a3226）；global-ai.js 读取阅读页自定义模板
   （gjs:reading 的 bg/fg）后覆盖这些变量，全站通用。 */
#gai-root {
  --gai-bg: #f5ead0;
  --gai-fg: #3a3226;
  --gai-line: rgba(58, 50, 38, 0.3);
  --gai-msg-bg: #faf3e0;
  --gai-bubble-bg: #ffffff;
  --gai-bubble-fg: #3a3226;
  --gai-input-bg: rgba(255, 255, 255, 0.85);
  --gai-ctx-bg: rgba(255, 255, 255, 0.35);
  --gai-ctx-fg: #6d5320;
}

#gai-fab {
  position: fixed;
  left: 20px;
  bottom: 22px;
  z-index: 10000;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 24px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(158, 43, 37, 0.4);
  transition: transform 0.15s ease;
}
#gai-fab:hover { transform: translateY(-2px) scale(1.06); }

#gai-panel {
  position: fixed;
  left: 20px;
  bottom: 84px;
  z-index: 10000;
  width: min(380px, 92vw);
  height: min(560px, 72vh);
  display: flex;
  flex-direction: column;
  background-color: var(--gai-bg);
  color: var(--gai-fg);
  border: 1px solid var(--gai-line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(40, 30, 20, 0.25);
  overflow: hidden;
}
#gai-panel[hidden] { display: none; }

.gai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
}
.gai-title { font-weight: 700; font-size: 15px; letter-spacing: 1px; }
.gai-model {
  font-size: 11px;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: 6px;
}
.gai-close { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; }

.gai-ctx {
  padding: 7px 14px;
  font-size: 12px;
  color: var(--gai-ctx-fg);
  background: var(--gai-ctx-bg);
  border-bottom: 1px dashed var(--gai-line);
}

.gai-modes { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--gai-line); flex-wrap: wrap; }
.gai-mode {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
  border: 1px solid var(--gai-line);
  background: var(--gai-input-bg);
  color: var(--gai-fg);
  font-family: inherit;
}
.gai-mode.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.gai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--gai-msg-bg);
}
.gai-hint { font-size: 13px; color: var(--gai-fg); opacity: 0.75; line-height: 1.9; }
.gai-hint a { color: var(--accent); }
.gai-tip {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--gai-ctx-fg);
  background: var(--gai-ctx-bg);
  border-bottom: 1px dashed var(--gai-line);
}
.gai-tip[hidden] { display: none; }
.gai-tip-icon { font-size: 14px; flex-shrink: 0; line-height: 1.4; }
.gai-tip-text a { color: var(--accent); font-weight: 600; text-decoration: none; }
.gai-tip-text a:hover { text-decoration: underline; }
.gai-msg { display: flex; flex-direction: column; max-width: 100%; }
.gai-msg.gai-user { align-items: flex-end; }
.gai-ai-name { font-size: 11px; color: var(--gold); margin-bottom: 3px; }
.gai-bubble {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.85;
  background: var(--gai-bubble-bg);
  color: var(--gai-bubble-fg);
  border: 1px solid var(--gai-line);
  max-width: 100%;
  word-break: break-word;
  white-space: pre-wrap;
}
.gai-msg.gai-user .gai-bubble { background: var(--accent); color: #fff; border-color: var(--accent); }

.gai-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--gai-line); }
#gai-text {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 90px;
  border: 1px solid var(--gai-line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gai-fg);
  background: var(--gai-input-bg);
}
#gai-send {
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

/* AI 输入区按钮列：📝 保存为笔记 + 发送 */
.gai-input-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gai-input-btns #gai-send { flex: 1; }
#gai-note {
  padding: 2px 12px;
  border: 1px solid var(--gai-line);
  border-radius: 8px;
  background: var(--gai-input-bg);
  color: var(--gai-fg);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
#gai-note:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 📝 笔记编辑区（仿古黄 #F5F0E6 · 墨字 #3A3226 · 朱砂 #9E2B25） ---------- */
.gai-note {
  padding: 10px 12px;
  border-top: 1px solid #9e2b25;
  background: #f5f0e6;
  color: #3a3226;
  font-size: 13px;
}
.gai-note[hidden] { display: none; }
.gai-note-head {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  color: #9e2b25;
  margin-bottom: 4px;
}
.gai-note-label { font-size: 12px; color: #6b6152; margin: 6px 0 4px; }
.gai-note-src {
  font-size: 12px;
  line-height: 1.7;
  color: #6b6152;             /* 略灰 */
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed #c9b896;
  border-radius: 6px;
  padding: 6px 8px;
  max-height: 88px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
#gai-note-cmt {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 52px;
  max-height: 120px;
  border: 1px solid #9e2b25;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: #3a3226;
  background: #fffaf0;
  outline: none;
}
#gai-note-cmt:focus { box-shadow: 0 0 0 2px rgba(158, 43, 37, 0.18); }
.gai-note-actions { display: flex; gap: 8px; margin-top: 8px; }
.gai-note-actions button {
  padding: 4px 16px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.6;
}
#gai-note-save { background: #9e2b25; color: #fff; border: 1px solid #9e2b25; }
#gai-note-save:hover { background: #7d1f1a; border-color: #7d1f1a; }
#gai-note-cancel { background: transparent; color: #9e2b25; border: 1px solid #9e2b25; }
#gai-note-cancel:hover { background: rgba(158, 43, 37, 0.08); }

.gai-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px dashed var(--gai-line);
  font-size: 12px;
}
.gai-foot a { color: var(--gai-fg); opacity: 0.72; text-decoration: none; }
.gai-foot a:hover { color: var(--accent); opacity: 1; }
#gai-clear { margin-left: auto; border: none; background: none; color: var(--gai-fg); opacity: 0.72; font-size: 12px; cursor: pointer; font-family: inherit; }
#gai-clear:hover { color: var(--accent); opacity: 1; }

/* AI 对话框预填确认 toast */
.gai-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 13000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 82vw;
  text-align: center;
}
.gai-toast.show { opacity: 1; }

/* ---------- AI 设置 / AI 新手指南 页 ---------- */
.settings-wrap, .guide-wrap { max-width: 720px; }
.settings-title, .guide-title { font-size: 28px; text-align: center; letter-spacing: 3px; margin: 26px 0 6px; }
.settings-sub, .guide-sub { text-align: center; color: var(--ink-soft); font-size: 14px; margin: 0 0 26px; }
.settings-card, .guide-card {
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.settings-card h2, .guide-card h2 { font-size: 18px; margin: 0 0 10px; }
.settings-tip { color: var(--ink-soft); font-size: 14px; line-height: 1.9; margin: 0 0 14px; }
.settings-tip a, .guide-card a { color: var(--accent); }
.settings-tip code, .guide-card code { background: #efe7d4; padding: 1px 6px; border-radius: 4px; }
.settings-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.settings-input {
  flex: 1;
  min-width: 240px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}
.settings-status { font-size: 14px; line-height: 1.8; min-height: 22px; }
.settings-status.ok { color: #2f6b3a; }
.settings-status.err { color: var(--accent); }
.settings-list, .guide-card ul, .guide-card ol { margin: 0; padding-left: 1.4em; }
.settings-list li, .guide-card li { margin: 6px 0; line-height: 1.9; color: var(--ink); font-size: 14px; }
.settings-nav { text-align: center; margin: 24px 0 10px; display: flex; gap: 14px; justify-content: center; }

