/* novel-kb-cf —— 单页样式（深浅双主题） */

/* 字体与字号：全站一套尺度，靠「字号 + 颜色」拉开层级，正文一律不加粗 */
:root {
  --font-ui: -apple-system, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
             "Segoe UI", system-ui, sans-serif;
  /* 正文一律用标准宋体：Windows 的 SimSun(宋体) 优先，其次 macOS 宋体-简、
     再退到思源/Noto 宋体；不带任何「黑体/思源黑」候选，避免出现无衬线或伪粗体 */
  --font-serif: "SimSun", "宋体", "Songti SC", "Songti TC", "STSong",
                "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-caption: 12px;   /* 角标、时间、极次要信息 */
  --fs-small: 13px;     /* 辅助说明、表格、元信息 */
  --fs-body: 15px;      /* 正文、导航、按钮 */
  --fs-lead: 16px;      /* 卡片标题、区块小标题 */
  --fs-h3: 18px;        /* 页面内小节标题 */
  --fs-h2: 20px;        /* 页面标题 */
  --fs-h1: 26px;        /* 阅读页书名 */
  --fs-num: 28px;       /* 统计数字 */

  --lh-tight: 1.4;
  --lh-body: 1.7;

  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel2: #efeeea;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e2e0da;
  --accent: #7f77dd;
  --accent2: #534ab7;
  --good: #1d9e75;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --reader-fs: 18px;   /* 阅读页正文字号，由「A− / A+」写回 html 的 inline style */
}
html.dark {
  --bg: #12141a;
  --panel: #1a1d26;
  --panel2: #22262f;
  --text: #e6e6e3;
  --muted: #9aa0ab;
  --border: #2c303b;
  --accent: #8f88ec;
  --accent2: #aFA9EC;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg); color: var(--text);
  font-size: var(--fs-body); line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
/* 全站不加粗：需要强调时用字号、颜色和背景，而不是字重 */
b, strong, th, h1, h2, h3, h4 { font-weight: 400; }

/* 站点页脚：版权与侵权反馈 */
/* 纵向 flex 只为「内容不足一屏时页脚贴底」；正文比一屏长时必须让布局按内容撑开，
   否则 .layout 会被压到视口高，长正文溢出到页脚下面（会看到页脚悬在正文中间） */
body { display: flex; flex-direction: column; height: auto; min-height: 100%; }
.site-footer {
  flex: none;
  border-top: 1px solid var(--border); background: var(--panel);
  padding: 18px 16px 26px; text-align: center;
  font-size: var(--fs-caption); color: var(--muted); line-height: 1.9;
}
.site-footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--accent); }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
/* 搜索框有 max-width，宽屏下右侧会剩一大片空白；把账号与工具按钮贴到右边
   （搜索框仍是唯一搜索入口，右侧只放账号/繁/主题，不让空白堆在中间） */
.topbar-user { margin-left: auto; }
.logo {
  font-size: var(--fs-h3); line-height: 1.2; cursor: pointer;
  white-space: nowrap; letter-spacing: .04em;
}
.logo-sub { font-size: 10px; color: var(--accent); margin-left: 5px; vertical-align: super; letter-spacing: 0; }
.menu-btn {
  display: none; background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 16px; padding: 3px 9px; cursor: pointer;
}
.searchbox { flex: 1; display: flex; gap: 6px; max-width: 640px; min-width: 0; }
.searchbox input {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel2); color: var(--text); outline: none;
  font-family: inherit; font-size: var(--fs-body);
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox input:focus { border-color: var(--accent); }
.searchbox select {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); padding: 0 8px;
  font-family: inherit; font-size: var(--fs-small);
}
.searchbox button.go {
  flex: none; width: 38px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--accent); border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; line-height: 1;
}
.searchbox button.go svg { display: block; }
.searchbox button.go:hover { filter: brightness(1.08); }
.searchbox button.go:active { transform: translateY(1px); }
.icon-btn { background: none; border: none; font-size: 17px; cursor: pointer; color: var(--text); }
/* 繁简切换按钮：小字更协调 */
.script-btn { font-family: var(--font-serif); font-size: 15px; min-width: 26px; }

/* layout */
/* flex-basis:auto + 不收缩：按内容高度走，内容短时再由 flex:1 撑满一屏 */
.layout { display: flex; flex: 1 0 auto; width: 100%; min-height: calc(100vh - 53px); }
.sidebar {
  width: 190px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); padding: 10px 10px 12px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
/* 侧栏分组标题：阅读 / 互动 / 管理 */
.nav-group {
  font-size: 11px; color: var(--muted); letter-spacing: .14em;
  padding: 14px 12px 3px; user-select: none;
}
.nav-group + .nav-group, .nav-group:first-child { padding-top: 6px; }
.sidebar > .nav-group:not(:first-child) {
  margin-top: 8px; padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.nav-item {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--text); cursor: pointer; font-size: var(--fs-body);
}
.nav-item:hover { background: var(--panel2); }
.nav-item.active { background: var(--accent); color: #fff; }
/* display:block 会盖过 hidden 属性，这里补上 */
.nav-item[hidden], .nav-group[hidden] { display: none; }
.sidebar-footer { margin-top: auto; padding-top: 10px; font-size: var(--fs-caption); color: var(--muted); line-height: 1.6; }
.contact-link { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-link:hover { color: var(--accent); }
.sidebar-overlay { display: none; }
.main { flex: 1; padding: 22px; max-width: 980px; }

/* 页面标题：全站统一一档，比正文大三档 */
.page-title { margin: 0 0 16px; font-size: var(--fs-h2); line-height: var(--lh-tight); letter-spacing: .01em; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s;
  display: flex; flex-direction: column; min-height: 112px;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: var(--fs-lead); line-height: 1.45;
  min-height: 2.9em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta {
  color: var(--muted); font-size: var(--fs-small); line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .meta:last-child { margin-top: auto; padding-top: 4px; }
/* auto-fit 才会让少量卡片铺满整行；auto-fill 会留空轨道 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat b {
  display: block; font-size: var(--fs-num); line-height: 1.2;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.stat span { color: var(--muted); font-size: var(--fs-small); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); cursor: pointer; font-size: var(--fs-small); color: var(--text);
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 藏书页工具条：找书 + 排序 */
.lib-tools { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.lib-tools .lib-search { flex: 1 1 220px; min-width: 0; }
.lib-tools .lib-search,
.lib-tools select {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: var(--fs-body); font-family: inherit;
}
.lib-tools select { flex: 0 0 auto; cursor: pointer; font-size: var(--fs-small); }
.lib-tools .lib-search:focus,
.lib-tools select:focus { outline: none; border-color: var(--accent); }
h2.sec { font-size: var(--fs-h3); margin: 26px 0 12px; line-height: var(--lh-tight); letter-spacing: .01em; }

/* search results */
.result {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.result:hover { border-color: var(--accent); }
.result .r-title { font-size: var(--fs-lead); line-height: 1.45; margin-bottom: 4px; }
.result .r-book { color: var(--muted); font-size: var(--fs-small); margin-bottom: 6px; }
.result .r-excerpt {
  color: var(--text); font-size: 14px; line-height: 1.85;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
/* 命中词不加粗，用颜色 + 淡淡底色标记 */
.result .r-excerpt em, .hl {
  color: var(--accent2); font-style: normal; font-weight: 400;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 3px; padding: 0 1px;
}
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; margin-left: 8px; vertical-align: 1px; }
.tag.keyword { background: #e6f1fb; color: #185fa5; }
.tag.semantic { background: #e1f5ee; color: #0f6e56; }
html.dark .tag.keyword { background: #0c447c33; color: #85b7eb; }
html.dark .tag.semantic { background: #08504133; color: #5dcaa5; }

/* reader */
.back-bar { max-width: 760px; margin: 0 auto 10px; }
.back-bar:empty { display: none; }
.back-link { display: inline-block; font-size: var(--fs-small); color: var(--muted); }
.back-link:hover { color: var(--accent); }
.reader {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 40px 48px 28px; max-width: 760px; margin: 0 auto;
}
.reader-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding-bottom: 18px; margin-bottom: 26px; border-bottom: 1px solid var(--border);
}
.reader h1 { font-size: var(--fs-h1); margin: 0 0 8px; line-height: var(--lh-tight); letter-spacing: .01em; }
.reader .r-meta { color: var(--muted); font-size: var(--fs-small); }
.reader-tools { display: flex; gap: 6px; flex-shrink: 0; }
.reader-tools button {
  min-width: 34px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); cursor: pointer;
  font-family: var(--font-serif); font-size: 14px; line-height: 1;
}
.reader-tools button:hover { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.reader-tools button.on { border-color: var(--accent); color: var(--accent); background: var(--panel); font-weight: 600; }

/* 书籍排印：宋体、2em 首行缩进、两端对齐、行长约 40 字 */
.reader-body {
  font-family: var(--font-serif);
  font-weight: 400;
  /* 字体缺粗体时浏览器会「描粗」模拟，这里禁止，保证是干净的宋体本体 */
  font-synthesis-weight: none;
  font-synthesis: none;
  font-size: var(--reader-fs);
  line-height: 2;
  letter-spacing: .015em;
  text-align: justify;
  text-justify: inter-ideograph;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.reader-body p { margin: 0 0 1.05em; text-indent: 2em; }
.reader-body p:last-child { margin-bottom: 0; }
.reader-body p:first-of-type { margin-top: 0; }

.reader-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); gap: 10px;
}
.reader-pos { color: var(--muted); font-size: var(--fs-small); }
.reader-nav .btn { white-space: nowrap; }

/* ---------- 阅读页双栏：左正文 + 右白话译文 ---------- */
.read-cols { display: grid; grid-template-columns: minmax(0, 760px); justify-content: center; gap: 18px; }
.read-cols:not(.solo) {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  max-width: 1160px; margin: 0 auto;
}
.read-cols:not(.solo) .reader { max-width: 100%; }
@media (max-width: 1280px) {
  .read-cols:not(.solo) .reader { padding: 30px 26px 24px; }
}

.tr-panel {
  position: sticky; top: 68px;
  max-height: calc(100vh - 96px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.tr-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--panel2);
}
.tr-title { font-size: var(--fs-small); font-weight: 600; }
.tr-idx { font-size: var(--fs-caption); color: var(--muted); margin-left: auto; white-space: nowrap; }
.tr-close {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 3px 5px; border-radius: 5px;
}
.tr-close:hover { color: var(--text); background: var(--border); }
.tr-body {
  padding: 12px 14px; overflow-y: auto;
  font-family: var(--font-serif); font-size: 15px; line-height: 1.95; color: var(--text);
}
.tr-body p { margin: 0 0 .8em; text-indent: 0; }
.tr-body p:last-child { margin-bottom: 0; }
.tr-hint { color: var(--muted); font-size: var(--fs-small); }
.tr-err { color: #e24b4a; font-size: var(--fs-small); line-height: 1.7; }
.tr-retry { margin-top: 8px; padding: 4px 12px; font-size: var(--fs-small); }
.tr-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); background: var(--panel2); line-height: 1.5;
}
.tr-all { flex-shrink: 0; padding: 3px 10px; font-size: 11px; line-height: 1.6; }
.tr-all:disabled { opacity: 0.5; cursor: default; }
.tr-allstat { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-note { margin-left: auto; flex-shrink: 0; opacity: 0.75; }

/* 正在读的那一段：左侧一道竖线，不打断阅读 */
.reader-body p.tr-cur {
  background: var(--panel2);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  box-shadow: inset 2px 0 0 var(--accent);
  border-radius: 4px;
}

/* 窄屏：译文改成贴底抽屉，不挤正文 */
@media (max-width: 900px) {
  .read-cols:not(.solo) { grid-template-columns: minmax(0, 1fr); max-width: none; }
  .tr-panel {
    position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto;
    max-height: 46vh; z-index: 70; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  }
}
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer;
  font-size: var(--fs-body); font-family: inherit; line-height: 1.5;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.danger { color: #e24b4a; border-color: #e24b4a55; }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: var(--fs-small); color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); outline: none;
  font-family: inherit; font-size: var(--fs-body);
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.panel-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.progress { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.muted { color: var(--muted); font-size: var(--fs-small); line-height: 1.65; }
.warn { color: #ba7517; font-size: var(--fs-small); }

/* ai */
.chat-log { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.bubble { max-width: 92%; padding: 12px 14px; border-radius: 12px; line-height: 1.75; white-space: pre-wrap; font-size: var(--fs-body); }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; }
.bubble.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.bubble .src { display: block; margin-top: 8px; font-size: var(--fs-caption); color: var(--muted); line-height: 1.6; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; line-height: 1.9; font-size: var(--fs-body); }
.pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 18px 0; }

/* AI 提问行：输入框与按钮同一高度、同一字体 */
.ai-row { display: flex; gap: 8px; }
.ai-input {
  flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); outline: none;
  font-family: inherit; font-size: var(--fs-body);
}
.ai-input:focus { border-color: var(--accent); }

/* 提示条（检索降级等） */
.notice {
  background: #fdf3e7; border: 1px solid #f0d5b0; color: #8a5a12;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: var(--fs-small); line-height: 1.7;
}
html.dark .notice { background: #3a2c18; border-color: #5a4423; color: #e8c48a; }

/* 章节目录条目 */
.toc-head { margin: 0 0 12px; font-size: var(--fs-lead); display: flex; align-items: baseline; gap: 10px; }
.toc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.toc-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 8px; border-radius: 7px; color: var(--text);
  font-size: 14px; border: 1px solid transparent;
}
.toc-item:hover { background: var(--panel2); border-color: var(--border); }
.toc-idx { color: var(--muted); font-size: var(--fs-caption); min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.toc-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-len { color: var(--muted); font-size: var(--fs-caption); flex-shrink: 0; min-width: 62px; text-align: right; font-variant-numeric: tabular-nums; }

/* 解锁弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 24px; width: 100%; max-width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.22);
}
.modal h3 { margin: 0 0 6px; font-size: var(--fs-h3); }
.modal p { margin: 0 0 14px; }
.modal input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); outline: none;
  font-family: inherit; font-size: var(--fs-body);
}
.modal input:focus { border-color: var(--accent); }
.modal .warn { min-height: 18px; margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* 后台管理 */
.admin-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-head h2 { margin: 0; font-size: var(--fs-h2); line-height: var(--lh-tight); }
.admin-tabs { display: flex; gap: 4px; background: var(--panel2); border-radius: 9px; padding: 3px; }
.admin-tabs .tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 14px; border-radius: 7px; font-size: var(--fs-small); font-family: inherit;
}
.admin-tabs .tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.admin-who { margin-left: auto; font-size: var(--fs-caption); color: var(--muted); }
.admin-h { font-size: var(--fs-lead); margin: 0 0 10px; line-height: var(--lh-tight); }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left; color: var(--muted); font-size: var(--fs-small);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: var(--panel2); }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table a { color: var(--text); text-decoration: none; }
.admin-table a:hover { color: var(--accent); text-decoration: underline; }
.row-sub { color: var(--muted); font-size: var(--fs-caption); margin-top: 2px; }

.btn.tiny { padding: 3px 10px; font-size: var(--fs-small); white-space: nowrap; }
.btn.danger { color: var(--danger, #c0392b); border-color: var(--border); }
.btn.danger:hover { border-color: var(--danger, #c0392b); }
.code {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--panel2); padding: 2px 6px; border-radius: 5px;
}
.admin-table th.num { text-align: right; }

/* 书目核对 */
.tag {
  display: inline-block; padding: 0 6px; border-radius: 4px;
  font-size: var(--fs-caption); line-height: 1.6;
}
.tag.st-flag { color: #a8620f; background: color-mix(in srgb, #e0a33e 18%, transparent); }
.tag.st-off { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.tag.st-ok { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.admin-table tr.row-flagged td { opacity: .72; }
.rv-reason { font-size: var(--fs-small); color: var(--muted); line-height: 1.6; }
.rv-ops-cell, .rv-ops-head { width: 1px; white-space: nowrap; }
.rv-ops { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.admin-table th.rv-ops-head { text-align: right; }
@media (max-width: 760px) {
  .rv-ops-cell, .rv-ops-head { width: auto; }
  .rv-ops { justify-content: flex-start; flex-wrap: wrap; }
}
.admin-table td:last-child, .admin-table th:last-child { width: 74px; white-space: nowrap; }
.admin-table td.num { white-space: nowrap; }
#adminPw {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); outline: none;
  font-family: inherit; font-size: var(--fs-body);
}
#adminPw:focus { border-color: var(--accent); }

/* responsive */
@media (max-width: 760px) {
  .menu-btn { display: block; }
  /* 窄屏顶栏改成两行：第一行 菜单/标题/账号/繁/主题，第二行 搜索框独占整行。
     挤在一行时输入框只剩几十像素（加搜索按钮后几乎看不见），必须换行。 */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .searchbox { order: 10; flex: 1 0 100%; max-width: none; }
  /* 顶栏变高了，抽屉改为从屏幕最顶开始盖（层级高于顶栏），遮罩也铺满全屏 */
  .sidebar { position: fixed; left: -230px; top: 0; bottom: 0; z-index: 40; padding-top: 14px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0 0 0 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { padding: 14px; }
  .searchbox select { display: none; }
  .reader { padding: 24px 18px 18px; border-radius: 10px; }
  .reader-head { flex-direction: column; gap: 10px; margin-bottom: 18px; }
  .reader h1 { font-size: var(--fs-h2); }
  .reader-body { line-height: 1.95; }
  .stat b { font-size: 24px; }
}

@media (max-width: 640px) {
  /* 顶栏收窄：藏副标、缩间距，已登录只留 昵称 · 退出 */
  .logo-sub { display: none; }
  .topbar { gap: 7px; padding: 9px 10px; }
  .searchbox button.go { width: 34px; font-size: 13px; }
  .user-cta { padding: 5px 10px; }
  .topbar-user .ub-sep, .topbar-user a[href="javascript:go('notes')"] { display: none; }
  .admin-table .col-opt, .admin-table .col-time { display: none; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
  .admin-table td .row-sub { font-size: 11px; }
  .admin-head { gap: 8px; }
  .admin-who { margin-left: 0; }
  .admin-table { font-size: 13px; }
  /* 章节翻页：窄屏下两个按钮占满一行，页码居中放到下一行 */
  .reader-nav { flex-wrap: wrap; gap: 8px; }
  .reader-nav .btn { flex: 1 1 0; text-align: center; padding: 8px 10px; font-size: var(--fs-small); }
  .reader-pos { flex: 1 0 100%; order: 3; text-align: center; font-size: var(--fs-caption); }
}

/* 首页「继续阅读」 */
.resume {
  display: block; background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 10px;
  padding: 14px 16px; margin: 16px 0 4px; cursor: pointer;
}
.resume:hover { border-color: var(--accent); }
.resume-tag { font-size: var(--fs-caption); color: var(--accent); margin-bottom: 4px; letter-spacing: .04em; }
.resume-title { font-size: var(--fs-lead); line-height: 1.45; margin-bottom: 4px; }

/* 阅读进度条：贴在顶栏下沿 */
.read-progress {
  position: sticky; top: 53px; z-index: 10; height: 2px;
  background: transparent; margin: 0 auto 8px; max-width: 760px;
}
.read-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

/* 复制引用后的轻提示 */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 8px);
  background: var(--text); color: var(--bg); font-size: var(--fs-small);
  padding: 8px 16px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 目录工具行与筛选框 */
.toc-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toc-top .toc-head { margin: 0; }
.toc-filter {
  flex: 1 1 220px; min-width: 0; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  outline: none; font-family: inherit; font-size: var(--fs-small);
}
.toc-filter:focus { border-color: var(--accent); }

/* AI 回答里的来源可点 */
.bubble .src a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.bubble .src a:hover { color: var(--accent); }

/* ---------------------------- 后台：访客统计 ---------------------------- */
.vchart { display: flex; align-items: flex-end; gap: 6px; height: 112px; margin: 4px 0 6px;
          border-bottom: 1px solid var(--border); }
.vbar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column;
        justify-content: flex-end; gap: 5px; }
.vbar i { display: block; width: 100%; max-width: 38px; margin: 0 auto;
          min-height: 3px;
          border-radius: 3px 3px 0 0; transition: background .15s;
          background: color-mix(in srgb, var(--accent) 45%, transparent); }
/* 零值日留一段极淡的基座，否则 14 根里只有有数据那根看得见，像图坏了 */
.vbar.zero i { min-height: 6px; background: color-mix(in srgb, var(--muted) 42%, transparent); }
.vbar:hover i { background: var(--accent); }
.vbar span { font-size: var(--fs-caption); color: var(--muted); text-align: center; line-height: 1;
            font-variant-numeric: tabular-nums; }

.vgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 14px; }
.vgrid h4, .vsub { font-size: var(--fs-small); color: var(--muted); margin: 0 0 6px; }
.vsub { margin-top: 16px; }
.vlist { display: flex; flex-direction: column; font-size: var(--fs-small); }
.vlist a, .vlist .vrow { display: flex; justify-content: space-between; gap: 10px;
                         padding: 4px 0; color: var(--text); text-decoration: none;
                         border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.vlist a:hover { color: var(--accent2); }
.vlist a span:first-child, .vlist .vrow span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vlist .n { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .vgrid { grid-template-columns: 1fr; gap: 14px; }
  .vchart { height: 88px; gap: 4px; }
  .vchart .vbar span { display: none; }
}

/* ------------------------------ 读者留言 ------------------------------ */
/* 阅读页的留言区要和正文卡片同宽同轴，否则左边会错开一截 */
.cmt-block { max-width: 760px; margin: 0 auto; }
.cmt-head { display: flex; align-items: baseline; justify-content: space-between;
            gap: 12px; margin: 32px 0 12px; }
.cmt-head h2.sec { margin: 0; }
.cmt-head .muted { font-size: var(--fs-small); }
.cmt-all { font-size: var(--fs-small); color: var(--accent2); text-decoration: none; white-space: nowrap; }
.cmt-all:hover { text-decoration: underline; }

.cmt-list { display: flex; flex-direction: column; gap: 8px; }
.cmt-item { padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
            border-radius: 10px; box-shadow: var(--shadow); }
.cmt-meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
            font-size: var(--fs-small); color: var(--muted); margin-bottom: 6px; }
.cmt-name { color: var(--text); }
.cmt-time { font-variant-numeric: tabular-nums; }
.cmt-book { color: var(--accent2); text-decoration: none; }
.cmt-book:hover { text-decoration: underline; }
.cmt-tag { font-size: var(--fs-caption); padding: 1px 6px; border-radius: 4px;
           background: var(--panel2); color: var(--muted); }
.cmt-body { font-size: var(--fs-body); line-height: var(--lh-body);
            white-space: pre-wrap; word-break: break-word; }
.cmt-empty { color: var(--muted); font-size: var(--fs-small); padding: 18px 0; }

.cmt-form { margin-top: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px;
            background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.cmt-form input, .cmt-form textarea {
  width: 100%; font-family: var(--font-ui); font-size: var(--fs-body); color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
.cmt-form textarea { resize: vertical; min-height: 76px; line-height: var(--lh-body); }
.cmt-form input:focus, .cmt-form textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: -1px; border-color: var(--accent);
}
.cmt-name-input { max-width: 280px; }
/* 蜜罐：真读者看不见，自动脚本会填 —— 填了服务端直接丢弃 */
.cmt-hp { position: absolute; left: -9999px; width: 1px; height: 1px;
          opacity: 0; pointer-events: none; }
.cmt-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cmt-hint { font-size: var(--fs-caption); color: var(--muted); line-height: 1.5; flex: 1 1 200px; }
.cmt-more { margin-top: 14px; text-align: center; }

/* 后台留言表 */
.admin-table .cmt-cell { max-width: 460px; min-width: 200px; white-space: pre-wrap; word-break: break-word;
                         font-size: var(--fs-small); line-height: 1.6; }
.cmt-ops { white-space: nowrap; text-align: right; padding-left: 16px !important; }
.cmt-ops .btn + .btn { margin-left: 6px; }
tr.cmt-off td { opacity: .55; }

@media (max-width: 720px) {
  .cmt-name-input { max-width: 100%; }
  .admin-table .cmt-cell { max-width: 200px; }
}

/* ---------------------------- 读者账号 ---------------------------- */
/* 顶栏用户区：未登录是「登录 / 注册」按钮，已登录是 昵称 · 批注 · 退出 */
.topbar-user { flex-shrink: 0; font-size: var(--fs-small); color: var(--muted); white-space: nowrap; }
.topbar-user a { color: var(--muted); text-decoration: none; }
.topbar-user a:hover { color: var(--accent); }
.topbar-user .ub-name { color: var(--text); }
.topbar-user .ub-sep { margin: 0 4px; color: var(--border); }
.user-cta {
  display: inline-block; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--accent); color: var(--accent) !important;
  font-size: var(--fs-small); line-height: 1.3;
}
.user-cta:hover { background: var(--accent); color: #fff !important; }
#userBox { font-size: var(--fs-small); color: var(--muted); margin-bottom: 6px; }
#userBox a { color: var(--accent2); text-decoration: none; }
#userBox a:hover { text-decoration: underline; }
.ub-name { color: var(--text); }

.auth-box { max-width: 430px; }
.auth-tabs { display: flex; gap: 4px; background: var(--panel2); border-radius: 9px;
             padding: 3px; margin-bottom: 16px; width: fit-content; }
.auth-tabs .tab { border: 0; background: transparent; color: var(--muted); cursor: pointer;
                  padding: 6px 16px; border-radius: 7px; font-size: var(--fs-small); font-family: inherit; }
.auth-tabs .tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
#authForm { display: flex; flex-direction: column; gap: 10px; }
#authForm input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
                  background: var(--bg); color: var(--text); font-family: inherit;
                  font-size: var(--fs-body); outline: none; }
#authForm input:focus { border-color: var(--accent); }
.auth-tip { margin-top: 12px; font-size: var(--fs-caption); line-height: 1.6; color: var(--muted); }
.auth-who { font-size: var(--fs-body); }
.auth-links { margin-top: 10px; font-size: var(--fs-small); display: flex; justify-content: flex-end; }
.auth-links a { color: var(--muted); text-decoration: none; }
.auth-links a:hover { color: var(--accent); }
/* 邮箱 + 获取验证码 一行 */
#authForm .mail-row { display: flex; gap: 8px; }
#authForm .mail-row input { flex: 1; min-width: 0; }
#authForm .mail-row .btn { flex-shrink: 0; white-space: nowrap; padding: 8px 12px; font-size: var(--fs-small); }
/* display 会盖过 hidden，这里统一兜住（input / 行容器 / 按钮） */
#authForm [hidden] { display: none !important; }

/* ------------------------------ 批注 ------------------------------ */
.anno-block { max-width: 760px; margin: 0 auto; }
.anno-list { display: flex; flex-direction: column; gap: 10px; }
.anno-item { padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
             border-radius: 10px; box-shadow: var(--shadow); }
.anno-meta { display: flex; align-items: baseline; gap: 10px; font-size: var(--fs-small);
             color: var(--muted); margin-bottom: 8px; }
.anno-book { color: var(--accent2); text-decoration: none; }
.anno-book:hover { text-decoration: underline; }
.anno-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.anno-del { border: 0; background: transparent; color: var(--muted); cursor: pointer;
            font-size: var(--fs-caption); padding: 0 4px; font-family: inherit; }
.anno-del:hover { color: #e24b4a; }
.anno-quote { margin: 0; padding: 8px 12px; border-left: 2px solid var(--accent);
              background: color-mix(in srgb, var(--accent) 7%, transparent);
              border-radius: 0 6px 6px 0; font-family: var(--font-serif);
              font-size: var(--fs-body); line-height: var(--lh-body);
              cursor: pointer; color: var(--text); }
.anno-note { margin-top: 8px; font-size: var(--fs-body); line-height: var(--lh-body);
             white-space: pre-wrap; word-break: break-word; }
.anno-empty { color: var(--muted); font-size: var(--fs-small); padding: 16px 0; }
.anno-empty a { color: var(--accent2); }

/* 选中正文后浮出来的小按钮 */
.sel-btn { position: absolute; z-index: 70; border: 0; border-radius: 999px;
           padding: 6px 12px; font-size: var(--fs-small); font-family: inherit;
           cursor: pointer; background: var(--accent); color: #fff;
           box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.sel-btn:hover { background: var(--accent2); }

.anno-modal { max-width: 520px; }
.anno-modal textarea { width: 100%; margin-top: 12px; padding: 10px 12px;
                       border: 1px solid var(--border); border-radius: 8px;
                       background: var(--panel2); color: var(--text); font-family: inherit;
                       font-size: var(--fs-body); line-height: var(--lh-body); resize: vertical; }
.anno-modal textarea:focus { border-color: var(--accent); outline: none; }
.anno-modal .anno-quote { max-height: 140px; overflow: auto; cursor: default; }

@media (max-width: 720px) {
  .anno-block { max-width: 100%; }
  .anno-modal { max-width: 100%; }
}

/* 后台：访客足迹 */
.vfbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.vdays { display: flex; align-items: center; gap: 6px; }
.vdays .tab { border: 1px solid var(--border); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 5px 10px; font-size: var(--fs-small); cursor: pointer; }
.vdays .tab.active { border-color: var(--accent); color: var(--accent); }
.vfdate, .vfsearch {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); font-family: inherit; font-size: var(--fs-small); outline: none;
}
.vfsearch { flex: 1 1 200px; min-width: 140px; max-width: 320px; }
.vfdate:focus, .vfsearch:focus { border-color: var(--accent); }

.vstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.vstat { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.vstat span { display: block; font-size: var(--fs-caption); color: var(--muted); margin-bottom: 4px; }
.vstat b { font-size: var(--fs-h3); font-variant-numeric: tabular-nums; }

.vfacet { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; background: var(--panel2); }
.vline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0; }
.vk { color: var(--muted); font-size: var(--fs-caption); width: 48px; flex: none; }
.vchip { border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 999px; padding: 3px 10px; font-size: var(--fs-caption); cursor: pointer; }
.vchip b { color: var(--accent); margin-left: 3px; font-variant-numeric: tabular-nums; }
.vchip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.vtag { border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: var(--fs-caption); color: var(--muted); }
.vtag b { color: var(--text); margin-left: 3px; }

.vmeta { font-size: var(--fs-caption); color: var(--muted); margin: 0 0 8px; }
.vtable td { vertical-align: top; font-size: var(--fs-small); }
.vtable td:nth-child(1), .vtable td:nth-child(4), .vtable td:nth-child(7) { white-space: nowrap; }
.vtable .vrow { cursor: pointer; }
.vtable .vrow:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.vtable .vrow.on td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.vip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.vbook { color: var(--muted); }

#visitTimeline { margin-top: 14px; }
.vtl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.vtl-head .btn { margin-left: auto; }
.vtl { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.vtl li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0 6px 12px; position: relative; }
.vtl li::before {
  content: ""; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
.vtl-t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; width: 92px; }
.vtl-p { flex: 1; min-width: 0; }
.vtl-d { color: var(--muted); font-size: 12px; flex: none; }
