/* ============================================================
   墨阅 Moyue Reader · 设计系统
   ============================================================ */
:root {
  --bg: #f6f4ef;
  --bg-elevated: #ffffff;
  --bg-sunken: #efece4;
  --text: #2b2a26;
  --text-2: #6f6c64;
  --text-3: #a3a099;
  --accent: #b0542a;
  --accent-soft: rgba(176, 84, 42, 0.1);
  --accent-hover: #97461f;
  --line: #e6e2d8;
  --shadow: 0 1px 2px rgba(40, 35, 25, .05), 0 8px 24px rgba(40, 35, 25, .07);
  --shadow-lg: 0 12px 48px rgba(40, 35, 25, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 208px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-read: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --transition: .22s cubic-bezier(.4, 0, .2, 1);
}
html[data-app-theme="dark"] {
  --bg: #17171a;
  --bg-elevated: #1f1f24;
  --bg-sunken: #101013;
  --text: #e8e6e1;
  --text-2: #a8a49b;
  --text-3: #6b6862;
  --accent: #d9714a;
  --accent-soft: rgba(217, 113, 74, .14);
  --accent-hover: #e88a63;
  --line: #2e2e34;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, .5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
img { display: block; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 4px; opacity: .5; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 应用框架 ============ */
/* 100dvh：移动浏览器地址栏收起/展开时 100vh 会算错，底部按钮被切掉 */
.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  transition: background var(--transition);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: var(--accent); }
.logo-text b { display: block; font-size: 17px; color: var(--text); letter-spacing: 1px; }
.logo-text small { font-size: 10px; color: var(--text-3); letter-spacing: .5px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; text-align: left;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-sunken); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-footer { margin-top: auto; }
.engine-status {
  margin-top: 10px; padding: 8px 12px; font-size: 11px; color: var(--text-3);
  border-radius: var(--radius-sm); background: var(--bg-sunken); line-height: 1.5;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.search-box {
  flex: 1; max-width: 640px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  color: var(--text-3);
  transition: all var(--transition);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box input {
  flex: 1; border: none; outline: none; background: none;
  font-size: 14px; color: var(--text);
}
.search-box select {
  border: none; background: none; outline: none; font-size: 12px;
  color: var(--text-2); max-width: 130px; cursor: pointer;
}
.topbar-right { margin-left: auto; }
.source-badge {
  font-size: 12px; color: var(--text-2);
  background: var(--bg-elevated); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px;
}

.content { flex: 1; overflow-y: auto; padding: 28px; scroll-behavior: smooth; }
.view { animation: fadeUp .3s ease; max-width: 1080px; margin: 0 auto; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ 书架 ============ */
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 18px; }
.section-title h2 { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.section-title .muted { font-size: 12px; }

.continue-card {
  display: flex; gap: 22px; align-items: center;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-sunken));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 30px;
  box-shadow: var(--shadow);
}
.continue-cover {
  width: 92px; height: 124px; border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow); flex-shrink: 0;
  background: linear-gradient(160deg, var(--accent), #7a3520);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700; text-align: center; padding: 8px;
}
.continue-cover img { width: 100%; height: 100%; object-fit: cover; }
.continue-label { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: 1px; margin-bottom: 6px; }
.continue-name { font-size: 21px; font-weight: 700; margin-bottom: 4px; }
.continue-chapter { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }

.btn {
  padding: 8px 18px; border-radius: 999px; font-size: 13px;
  background: var(--bg-elevated); border: 1px solid var(--line); color: var(--text);
  transition: all var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.danger { border-color: rgba(192, 57, 43, .45); color: #c0392b; }
.btn.danger:hover { border-color: #c0392b; color: #c0392b; background: rgba(192, 57, 43, .08); }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 22px 18px;
}
.book-card { cursor: pointer; position: relative; }
.book-cover {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow);
  background: linear-gradient(160deg, var(--accent), #7a3520);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.book-card:hover .book-cover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover .cover-title {
  color: #fff; font-size: 15px; font-weight: 700; text-align: center;
  padding: 10px; line-height: 1.4; writing-mode: horizontal-tb;
  text-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.book-cover .cover-source {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 10px; color: rgba(255,255,255,.92);
  background: rgba(0,0,0,.45); padding: 2px 7px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.book-card .book-name {
  margin-top: 8px; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-card .book-author { font-size: 11px; color: var(--text-3); margin-top: 2px; }
/* 书库卡片上的「读至 N 章」：条 + 百分比。进度条比纯数字更容易扫一眼就知道读到哪。 */
.book-card .book-progress { margin-top: 5px; }
.book-card .book-progress-bar {
  height: 3px; border-radius: 2px; overflow: hidden;
  background: var(--border, rgba(0, 0, 0, .08));
}
.book-card .book-progress-bar > i {
  display: block; height: 100%; border-radius: 2px;
  background: var(--accent, #c0392b);
}
.book-card .book-progress > span { font-size: 10.5px; color: var(--text-3); }
html[data-app-theme="dark"] .book-card .book-progress-bar { background: rgba(255, 255, 255, .12); }
/* 原版目录里标出「上次读到这一章」，回来接着读不用自己找 */
.chapter-row.chapter-row-last { background: rgba(192, 57, 43, .08); }
.chapter-row.chapter-row-last .ch-idx { color: var(--accent, #c0392b); font-weight: 700; }
.chapter-row.chapter-row-last::after {
  content: "上次读到"; margin-left: 8px; font-size: 10.5px;
  color: var(--accent, #c0392b);
}
/* 书源已被移除的书：卡片压暗 + 一条提示，点开给「重新找 / 移除」的出路 */
.book-card.stale .book-cover { filter: grayscale(.55) opacity(.75); }
.book-card .shelf-warn {
  margin-top: 4px; font-size: 11px; color: #b9770e;
  background: rgba(243, 156, 18, .12); border-radius: 3px;
  padding: 1px 5px; display: inline-block;
}
.book-card .book-progress {
  margin-top: 6px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden;
}
.book-card .book-progress i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.book-card .card-menu {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--transition);
}
.book-card:hover .card-menu { opacity: 1; }

.empty-state {
  text-align: center; padding: 70px 20px; color: var(--text-2);
}
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-state p { margin: 4px 0; }

/* ============ 发现 ============ */
.discover-hero {
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent) 0%, #8a3d1d 60%, #5c2a15 100%);
  color: #fff; padding: 36px 34px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.discover-hero h1 { font-size: 27px; letter-spacing: 1px; margin-bottom: 8px; }
.discover-hero p { opacity: .85; font-size: 13px; letter-spacing: .5px; }
.discover-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.discover-cats button {
  padding: 6px 15px; border-radius: 999px; font-size: 12.5px;
  background: var(--bg-elevated); border: 1px solid var(--line); color: var(--text-2);
  transition: all var(--transition);
}
.discover-cats button:hover, .discover-cats button.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ============ 搜索结果 ============ */
.search-results { display: flex; flex-direction: column; gap: 12px; }
.result-item {
  display: flex; gap: 16px; padding: 16px;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer;
  transition: all var(--transition);
}
.result-item:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.result-cover {
  width: 64px; height: 86px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(160deg, var(--accent), #7a3520);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; text-align: center; padding: 6px;
  overflow: hidden;
}
.result-cover img { width: 100%; height: 100%; object-fit: cover; }
.result-info { flex: 1; min-width: 0; }
.result-name { font-size: 15.5px; font-weight: 700; margin-bottom: 5px; }
.result-meta { font-size: 12px; color: var(--text-2); display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.result-meta .src-tag {
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 8px; border-radius: 999px; font-size: 11px;
}
.result-intro {
  font-size: 12.5px; color: var(--text-2); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.result-latest { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }

/* ============ 书籍详情 ============ */
.book-detail-hero {
  display: flex; gap: 26px;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-sunken));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.detail-cover {
  width: 148px; height: 198px; border-radius: 10px; flex-shrink: 0;
  box-shadow: var(--shadow-lg); overflow: hidden;
  background: linear-gradient(160deg, var(--accent), #7a3520);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 700; text-align: center; padding: 12px;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; min-width: 0; }
.detail-name { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.detail-meta { display: flex; gap: 14px; color: var(--text-2); font-size: 13px; margin-bottom: 14px; flex-wrap: wrap; }
.detail-intro {
  font-size: 13px; color: var(--text-2); line-height: 1.8;
  max-height: 96px; overflow: hidden; position: relative; margin-bottom: 18px;
}
.detail-intro.expanded { max-height: none; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.detail-actions .btn { padding: 9px 22px; }
.chapters-panel {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.chapters-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.chapters-head h3 { font-size: 15px; }
.chapters-list { max-height: 480px; overflow-y: auto; }
.chapter-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 20px; font-size: 13.5px; cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition);
}
.chapter-row:hover { background: var(--bg-sunken); }
.chapter-row.current { color: var(--accent); font-weight: 600; }
.chapter-row .ch-idx { color: var(--text-3); font-size: 12px; margin-right: 12px; }

/* ============ 导入 ============ */
.import-panel {
  max-width: 560px; margin: 40px auto;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow);
}
.import-panel h2 { margin-bottom: 8px; }
.import-panel .muted { font-size: 13px; margin-bottom: 22px; }
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 46px 20px; text-align: center; cursor: pointer;
  transition: all var(--transition); color: var(--text-2);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 38px; margin-bottom: 10px; }
.import-result { margin-top: 20px; }

/* ============ 书源管理 ============ */
.sources-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.sources-header h2 { margin-bottom: 6px; }
.sources-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sources-table {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.source-row {
  display: grid; grid-template-columns: 26px 1.4fr 1.6fr 90px 150px;
  gap: 12px; align-items: center;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.source-row:last-child { border-bottom: none; }
.source-row.head { background: var(--bg-sunken); color: var(--text-2); font-size: 12px; font-weight: 600; }
.source-row .s-name { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.source-row .s-host { color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-2); white-space: nowrap;
}
.tag.ok { background: rgba(39, 174, 96, .12); color: #1e8e4e; }
.tag.js { background: rgba(243, 156, 18, .14); color: #b9770e; }
.tag.user { background: var(--accent-soft); color: var(--accent); }
.tag.legit { background: rgba(41, 128, 185, .12); color: #1f6fa8; }
.source-ops { display: flex; gap: 6px; justify-content: flex-end; }
.source-ops button {
  font-size: 11.5px; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--text-2);
  transition: all var(--transition);
}
.source-ops button:hover { border-color: var(--accent); color: var(--accent); }
.source-ops button.on { color: #1e8e4e; border-color: rgba(30, 142, 78, .4); }
.switch { position: relative; width: 34px; height: 19px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line); transition: var(--transition); cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  left: 2px; top: 2px; background: #fff; transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(15px); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 18, 14, .5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(3px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(560px, 92vw); max-height: 84vh; overflow: auto;
  background: var(--bg-elevated); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); animation: popIn .25s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 22px; font-size: 13.5px; line-height: 1.7; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.modal-body textarea {
  width: 100%; min-height: 180px; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-sunken); color: var(--text);
  padding: 12px; font-size: 12px; font-family: ui-monospace, Consolas, monospace;
  outline: none;
}
.modal-body textarea:focus { border-color: var(--accent); }
.modal-body input[type="text"], .modal-body input[type="url"] {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-sunken); color: var(--text);
  padding: 10px 12px; font-size: 13px; outline: none;
}
.modal-body input:focus { border-color: var(--accent); }
.learn-steps { margin: 14px 0; }
.learn-steps li { margin: 6px 0; font-size: 13px; list-style: none; }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 9px 20px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
}
.toast.err { background: #c0392b; color: #fff; }
.toast.ok { background: #1e8e4e; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ============ 骨架屏 ============ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--line) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  :root { --sidebar-w: 62px; }
  .logo-text, .nav-item span:not(.nav-icon), .engine-status { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 18px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 12px; }
  .source-row { grid-template-columns: 26px 1fr 120px; }
  .source-row .s-host, .source-row .source-ops { display: none; }
}

/* ============ 手机：侧边栏改底部导航 ============
   原来手机上侧边栏只是被压成 62px 竖条，仍常驻占宽 —— 390px 的屏等于白白切掉 1/6，
   正文区只剩 328px，读一章要滑几十屏。这里改成横屏底栏：内容占满宽度，导航在下方拇指可达。 */
@media (max-width: 640px) {
  .app { flex-direction: column; }

  .sidebar {
    order: 2;
    width: 100%;
    flex-direction: row;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 0px));
    border-right: none;
    border-top: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .logo, .sidebar-footer { display: none; }

  .nav { flex-direction: row; gap: 0; width: 100%; justify-content: space-around; }
  .nav-item {
    flex: 1 0 auto; min-width: 54px;
    flex-direction: column; gap: 2px;
    padding: 6px 4px; font-size: 10.5px; line-height: 1.2;
    border-radius: 8px;
  }
  /* 底栏必须显示文字：纯图标没人猜得出「原版 / 书源 / 求书」 */
  .nav-item span:not(.nav-icon) { display: block; font-size: 10px; white-space: nowrap; }
  .nav-icon { width: auto; font-size: 17px; }

  .main { order: 1; flex: 1; min-height: 0; }
  .topbar { padding: 9px 12px; gap: 8px; }
  .search-box { padding: 8px 14px; }
  .content { padding: 14px 12px; }

  .book-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 10px; }
}

/* ============================================================
   阅读器
   ============================================================ */
.reader-layer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--reader-bg, #f6f1e7);
  color: var(--reader-text, #3a352c);
  transition: background .3s, color .3s;
}
.reader-layer[data-theme="paper"]   { --reader-bg: #f6f1e7; --reader-text: #3a352c; --reader-ui: rgba(60,52,40,.75); }
.reader-layer[data-theme="green"]   { --reader-bg: #cce8cf; --reader-text: #2d3b2e; --reader-ui: rgba(40,60,45,.75); }
.reader-layer[data-theme="night"]   { --reader-bg: #16161a; --reader-text: #b8b4ab; --reader-ui: rgba(200,196,188,.7); }
.reader-layer[data-theme="pink"]    { --reader-bg: #f7e3e6; --reader-text: #4a3236; --reader-ui: rgba(90,55,60,.75); }
.reader-layer[data-theme="grey"]    { --reader-bg: #d8d8d3; --reader-text: #33322e; --reader-ui: rgba(50,50,48,.75); }

.reader-topbar, .reader-bottombar {
  position: absolute; left: 0; right: 0; z-index: 20;
  background: color-mix(in srgb, var(--reader-bg) 86%, transparent);
  backdrop-filter: blur(12px);
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
}
.reader-topbar { top: 0; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid rgba(128,120,100,.15); }
.reader-bottombar { bottom: 0; padding: 10px 16px 14px; border-top: 1px solid rgba(128,120,100,.15); }
.reader-layer.hide-ui .reader-topbar { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.reader-layer.hide-ui .reader-bottombar { transform: translateY(100%); opacity: 0; pointer-events: none; }
.reader-title { flex: 1; text-align: center; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-top-actions { display: flex; gap: 2px; }
.rbtn {
  width: 36px; height: 36px; border-radius: 50%; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  color: var(--reader-ui, var(--text)); transition: background .2s;
}
.rbtn:hover { background: rgba(128,120,100,.14); }

.reader-stage { position: absolute; inset: 0; overflow: hidden; }
.reader-pages {
  height: 100%;
  font-family: var(--reader-font, var(--font-read));
  font-size: var(--reader-size, 18px);
  line-height: var(--reader-lh, 1.8);
  color: var(--reader-text);
  transition: font-size .15s;
}
.reader-pages p { margin: 0 0 .6em; text-align: justify; }
.reader-pages .ch-title {
  font-size: 1.25em; font-weight: 700; text-align: center;
  margin: .4em 0 1.1em; letter-spacing: 1px;
}
/* 滚动模式 */
.reader-pages.scroll-mode {
  height: 100%; overflow-y: auto;
  padding: 64px calc(var(--reader-margin, 24px) + 4vw) 90px;
  max-width: 820px; margin: 0 auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;   /* iOS 惯性滚动 */
  overscroll-behavior-y: contain;      /* 滚到顶/底别再拖整页，iOS 橡皮筋会让正文跳 */
  touch-action: pan-y;                 /* 明确告诉浏览器：这块允许纵向滑动 */
}
/* 翻页模式 */
.reader-pages.paged-mode {
  column-width: var(--page-w, 100vw);
  column-gap: 0; height: 100%;
  padding: 64px var(--reader-margin, 24px) 90px;
  overflow: hidden;
}
.reader-tap-left, .reader-tap-right, .reader-tap-center { position: absolute; top: 0; bottom: 0; z-index: 10; }
.reader-tap-left { left: 0; width: 30%; }
.reader-tap-right { right: 0; width: 30%; }
.reader-tap-center { left: 30%; width: 40%; }

/* 触屏：热区必须「放行」手指滑动。
   这三层热区加起来铺满整个阅读区且 z-index 在正文之上，鼠标端只吃 click 没问题，
   但手指一按就落在热区上，滚动容器收不到 touch → 正文滑不动（手机上等于读不了）。
   所以触屏一律让热区不接收指针事件，点击改由 reader.js 在 .reader-pages 上按横坐标三分区判定
   （浏览器会自己区分「滑动」和「点击」，滑完不会触发 click，不会误翻页）。 */
@media (hover: none) and (pointer: coarse) {
  .reader-tap-left, .reader-tap-right, .reader-tap-center { pointer-events: none; }
}

.reader-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.reader-slider {
  flex: 1; -webkit-appearance: none; appearance: none; height: 3px;
  background: rgba(128,120,100,.3); border-radius: 2px; outline: none;
}
.reader-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.reader-tools { display: flex; justify-content: space-around; }
.rtool {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 18px; color: var(--reader-ui, var(--text-2));
  padding: 4px 14px; border-radius: 8px; transition: background .2s;
}
.rtool span { font-size: 10.5px; }
.rtool:hover, .rtool.active { background: rgba(128,120,100,.14); color: var(--accent); }
/* 正版站禁止朗读的书：按钮置灰但仍可点（点了会说明原因，比无声无息好） */
.rtool.disabled { opacity: .38; cursor: not-allowed; }

/* ============ 手机：阅读器适配 ============
   1) 上下工具栏要避开刘海与 home 指示条，否则「返回」和「朗读」会被切掉；
   2) 7 个工具按钮在 390px 宽必然挤爆 → 横向可滚动，按钮不再压缩；
   3) 正文左右留白在手机上再减一点，每屏能多看两行。 */
@media (max-width: 640px) {
  .reader-topbar {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
  }
  .reader-bottombar {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .reader-tools {
    overflow-x: auto;
    justify-content: flex-start;
    gap: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .reader-tools::-webkit-scrollbar { display: none; }
  .rtool { flex: 0 0 auto; padding: 4px 9px; font-size: 16px; }
  .rtool span { font-size: 10px; }
  .reader-progress-row { gap: 8px; margin-bottom: 8px; }

  .reader-pages.scroll-mode,
  .reader-pages.paged-mode {
    padding: 56px 18px 84px;
  }
  .reader-pop { bottom: 88px; width: min(430px, 94vw); }
}

.reader-drawer {
  position: absolute; top: 0; bottom: 0; right: 0; z-index: 30;
  width: min(340px, 84vw);
  background: color-mix(in srgb, var(--reader-bg) 96%, #000 4%);
  box-shadow: -8px 0 32px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  animation: slideIn .25s cubic-bezier(.4,0,.2,1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; font-weight: 700; font-size: 15px;
  border-bottom: 1px solid rgba(128,120,100,.2);
}
.drawer-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.drawer-item {
  padding: 11px 20px; font-size: 13.5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 3px solid transparent; color: var(--reader-text);
}
.drawer-item:hover { background: rgba(128,120,100,.12); }
.drawer-item.current { border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.drawer-item .d-meta { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }

.reader-pop {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%);
  z-index: 30; width: min(430px, 92vw);
  background: color-mix(in srgb, var(--reader-bg) 96%, #000 4%);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 16px 20px; animation: popIn .2s ease;
}
.pop-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; }
.pop-row label { font-size: 13px; color: var(--reader-ui, var(--text-2)); font-weight: 600; }
.theme-swatches { display: flex; gap: 9px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.font-options, .seg { display: flex; gap: 6px; }
.font-options button, .seg button {
  padding: 5px 13px; font-size: 12.5px; border-radius: 999px;
  border: 1px solid rgba(128,120,100,.35); color: var(--reader-ui, var(--text-2));
}
.font-options button.active, .seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button {
  width: 30px; height: 30px; border-radius: 50%; font-size: 13px;
  border: 1px solid rgba(128,120,100,.35); color: var(--reader-ui, var(--text));
}
.stepper span { min-width: 30px; text-align: center; font-size: 13px; }

.cache-body { padding: 18px; }
.cache-tip { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; }
.cache-range { display: flex; gap: 8px; flex-wrap: wrap; }
.cache-range button {
  padding: 8px 16px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid rgba(128,120,100,.35); color: var(--reader-text);
}
.cache-range button:hover { border-color: var(--accent); color: var(--accent); }
.cache-progress { margin-top: 16px; font-size: 12px; }
.cache-bar { height: 5px; background: rgba(128,120,100,.25); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.cache-bar > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

/* ============================================================
   程序化封面：任何一本书都有「图」，不再是一片纯文字
   ============================================================ */
.book-cover, .result-cover, .detail-cover, .continue-cover { position: relative; overflow: hidden; }

.cover-art {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  padding: 14px 10px;
  background:
    radial-gradient(125% 85% at 12% 0%, hsla(var(--h), 68%, 66%, .95), transparent 62%),
    linear-gradient(168deg, hsl(var(--h), 40%, 36%) 0%, hsl(calc(var(--h) + 28), 42%, 17%) 100%);
  color: #fff;
}
.cover-art::before {
  content: ""; position: absolute; inset: 7px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 4px;
  pointer-events: none;
}
.cover-art::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(118deg, rgba(255,255,255,.05) 0 1px, transparent 1px 8px);
}
.cover-art .ca-title {
  position: relative; z-index: 1;
  font-family: var(--font-read);
  font-size: 15px; font-weight: 700; letter-spacing: 1.6px; line-height: 1.45;
  text-align: center; padding: 0 4px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 2px 10px rgba(0,0,0,.45);
}
.cover-art .ca-author {
  position: relative; z-index: 1;
  font-size: 10px; letter-spacing: 1px; opacity: .82;
  max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cover-art .ca-line {
  position: relative; z-index: 1;
  width: 20px; height: 1px; background: rgba(255,255,255,.55); flex-shrink: 0;
}
.cover-art .ca-mark {
  position: absolute; top: 11px; left: 12px; z-index: 1;
  font-size: 9px; letter-spacing: 3px; opacity: .5;
}
.cover-img {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .25s ease;
}
.has-img .cover-img { opacity: 1; }

.detail-cover .cover-art .ca-title { font-size: 20px; letter-spacing: 2px; }
.detail-cover .cover-art .ca-author { font-size: 11px; }
.result-cover .cover-art .ca-title { font-size: 11px; letter-spacing: .5px; -webkit-line-clamp: 3; }
.result-cover .cover-art .ca-author, .result-cover .cover-art .ca-mark,
.result-cover .cover-art .ca-line { display: none; }
.continue-cover .cover-art .ca-title { font-size: 15px; }

/* ============================================================
   发现页：书源 + 分类两级选择
   ============================================================ */
.discover-cats { display: block; margin-bottom: 22px; }
.cat-source-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cat-source {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  background: var(--bg-elevated); border: 1px solid var(--line);
  color: var(--text-2); transition: all var(--transition);
}
.cat-source i {
  font-style: normal; font-size: 10.5px; padding: 0 6px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-3);
}
.cat-source:hover { border-color: var(--accent); color: var(--accent); }
.cat-source.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-source.active i { background: rgba(255,255,255,.22); color: #fff; }
.cat-chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.cat-chip {
  padding: 5px 14px; border-radius: 999px; font-size: 12.5px;
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  transition: all var(--transition);
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }
.cat-chip.active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

/* ============================================================
   目录分片加载
   ============================================================ */
.chapter-search {
  margin-left: auto; width: 190px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-sunken); font-size: 12.5px; outline: none;
}
.chapter-search:focus { border-color: var(--accent); }
.chap-more {
  padding: 12px 20px; text-align: center; font-size: 12.5px;
  color: var(--accent); cursor: pointer; background: var(--bg-sunken);
  border-bottom: 1px solid var(--line); user-select: none;
}
.chap-more:hover { background: var(--accent-soft); }

.drawer-search { padding: 10px 14px 0; }
.drawer-search input {
  width: 100%; padding: 8px 12px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid rgba(128,120,100,.35); background: rgba(128,120,100,.1);
  color: var(--reader-text); outline: none;
}
.drawer-search input:focus { border-color: var(--accent); }

/* ============================================================
   朗读条（edge-tts）
   ============================================================ */
.tts-bar {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 30; display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--reader-bg) 90%, #000 10%);
  border: 1px solid rgba(128,120,100,.3);
  border-radius: 999px; padding: 7px 14px;
  box-shadow: var(--shadow-lg); color: var(--reader-text);
  max-width: min(680px, calc(100% - 40px));
}
.tts-btn {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--reader-text);
  background: rgba(128,120,100,.14); transition: all var(--transition);
}
.tts-btn:hover { background: var(--accent); color: #fff; }
.tts-btn.main { background: var(--accent); color: #fff; width: 34px; height: 34px; font-size: 15px; }
.tts-meta { display: flex; flex-direction: column; gap: 4px; min-width: 92px; }
.tts-meta span { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.tts-mini-bar { height: 3px; border-radius: 2px; background: rgba(128,120,100,.28); overflow: hidden; }
.tts-mini-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.tts-select {
  font-size: 11.5px; padding: 5px 8px; border-radius: 999px;
  border: 1px solid rgba(128,120,100,.35); background: transparent;
  color: var(--reader-text); outline: none; max-width: 168px;
}
.reader-layer.tts-on .reader-pages { padding-bottom: 104px; }
#reader-pages p.tts-active {
  background: var(--accent-soft);
  border-radius: 4px;
  box-shadow: -6px 0 0 var(--accent-soft), 6px 0 0 var(--accent-soft);
  transition: background .2s;
}

/* ============================================================
   导出面板
   ============================================================ */
.export-box { display: flex; flex-direction: column; gap: 14px; }
.export-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.export-row > label { font-size: 12.5px; color: var(--text-2); width: 62px; flex-shrink: 0; }
.export-box .seg { flex-wrap: wrap; }
.export-box .seg button { padding: 6px 14px; font-size: 12.5px; }

/* ============================================================
   原版类（权威书源）
   ============================================================ */
.auth-hero { padding-bottom: 4px; }
.auth-hero strong { color: var(--accent); font-weight: 700; }
.auth-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.auth-pill {
  font-size: 11.5px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elevated);
  color: var(--text-2); white-space: nowrap;
}
.auth-pill.ok { color: #2f7a4d; border-color: rgba(47,122,77,.3); background: rgba(47,122,77,.08); }
.auth-pill.lock { color: #a8621c; border-color: rgba(168,98,28,.3); background: rgba(168,98,28,.08); }
.auth-pill.merge { color: var(--accent); border-color: rgba(176,84,42,.28); background: var(--accent-soft); }
html[data-app-theme="dark"] .auth-pill.ok { color: #74c79a; background: rgba(116,199,154,.1); }
html[data-app-theme="dark"] .auth-pill.lock { color: #e0a765; background: rgba(224,167,101,.1); }

.auth-note {
  font-size: 11.5px; color: var(--text-3); margin: 10px 0 2px;
  padding-left: 2px; line-height: 1.6;
}

/* 榜单名次徽标 */
.auth-card { position: relative; }
.rank-badge {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  min-width: 22px; height: 22px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  border-radius: 7px; color: #fff;
  background: rgba(30, 28, 24, .62); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .18);
}
.rank-badge.top1 { background: linear-gradient(135deg, #e0a33a, #b8721c); border-color: rgba(255,255,255,.35); }
.rank-badge.top2 { background: linear-gradient(135deg, #9aa3ad, #6d7681); border-color: rgba(255,255,255,.3); }
.rank-badge.top3 { background: linear-gradient(135deg, #c08457, #8e5c33); border-color: rgba(255,255,255,.28); }

.auth-tag { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* 免费/收费比例条 */
.auth-free-bar {
  margin: 14px 0 4px; padding: 12px 14px;
  background: var(--bg-sunken); border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.afb-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; font-size: 12px; color: var(--text-2); flex-wrap: wrap;
}
.afb-nums b { color: var(--text); font-variant-numeric: tabular-nums; }
.afb-nums b.lock { color: #a8621c; }
.afb-track {
  margin-top: 9px; height: 6px; border-radius: 999px;
  background: rgba(168, 98, 28, .16); overflow: hidden;
}
.afb-track > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #4f9d6d, #2f7a4d);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
/* 免费占比：≥30% 不吭声，低于 30% 才提醒一句（用户自己决定读不读） */
.afb-note { margin-top: 7px; font-size: 11.5px; color: var(--text-2); }
.afb-note b { color: var(--text); font-variant-numeric: tabular-nums; }
.afb-note.thin { color: #a8621c; }

/* 章节行的免费标记 */
.ch-free {
  font-size: 10.5px; color: #2f7a4d; background: rgba(47,122,77,.1);
  border-radius: 999px; padding: 2px 7px; flex-shrink: 0;
}

/* 收费分界线 */
.paywall-divider {
  margin: 18px 0 8px; padding: 18px 16px;
  text-align: center; border-radius: var(--radius-sm);
  border: 1px dashed rgba(168, 98, 28, .4);
  background: linear-gradient(180deg, rgba(168,98,28,.06), transparent);
  display: flex; flex-direction: column; gap: 6px;
}
.paywall-divider span { font-size: 12.5px; color: #a8621c; font-weight: 600; }
.paywall-divider small { font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
html[data-app-theme="dark"] .paywall-divider span { color: #e0a765; }

.auth-free-tag {
  display: inline-block; margin-top: 4px;
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  color: #2f7a4d; background: rgba(47, 122, 77, .1);
  border: 1px solid rgba(47, 122, 77, .18);
}
html[data-app-theme="dark"] .auth-free-tag { color: #74c79a; background: rgba(116,199,154,.12); }

/* ============================================================
   书库全文搜索 / 求书点单 / 书源健康（第十四轮新增）
   ============================================================ */

/* ---- 书库全文搜索 ---- */
.lib-search { display: flex; gap: 8px; margin-bottom: 10px; }
.lib-search input {
  flex: 1; min-width: 0; padding: 10px 14px; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elevated); outline: none;
  transition: border-color var(--transition);
}
.lib-search input:focus { border-color: var(--accent); }
.lib-search-meta { font-size: 12px; margin-bottom: 10px; min-height: 16px; }
.lib-search-results { display: flex; flex-direction: column; gap: 10px; }
.lib-hit {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.lib-hit-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.lib-hit-head b { font-size: 14px; }
.lib-hit-head .muted { font-size: 11.5px; }
.lib-hit-line {
  display: flex; gap: 10px; padding: 7px 8px; border-radius: 7px;
  cursor: pointer; transition: background var(--transition); align-items: flex-start;
}
.lib-hit-line:hover { background: var(--accent-soft); }
.lib-hit-ch {
  flex: 0 0 auto; max-width: 34%; font-size: 11.5px; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-hit-snip { font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.lib-empty { padding: 24px; text-align: center; color: var(--text-2); font-size: 13px; }

/* ---- 求书点单 ---- */
.wish-form {
  display: grid; grid-template-columns: 1.2fr 0.8fr 1.2fr auto;
  gap: 8px; margin: 4px 0 12px;
}
.wish-form input {
  padding: 10px 14px; font-size: 13.5px; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elevated); outline: none;
  transition: border-color var(--transition);
}
.wish-form input:focus { border-color: var(--accent); }
.wish-stats { font-size: 12px; margin-bottom: 12px; }
.wish-list { display: flex; flex-direction: column; gap: 10px; }
.wish-item {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 14px;
  align-items: center; padding: 13px 16px;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.wish-votes {
  display: flex; flex-direction: column; align-items: center;
  color: var(--accent); line-height: 1.15;
}
.wish-votes b { font-size: 18px; }
.wish-votes span { font-size: 10.5px; color: var(--text-3); }
.wish-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wish-author { font-weight: 400; font-size: 12px; color: var(--text-2); }
.wish-note { font-size: 12px; margin-top: 4px; }
.wish-hits { font-size: 11.5px; color: #1e8e4e; margin-top: 5px; }
.wish-ops { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.wish-ops button {
  font-size: 11.5px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--text-2);
  transition: all var(--transition);
}
.wish-ops button:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 书源健康 ---- */
.health-block { margin-top: 26px; }
.health-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.health-head h3 { font-size: 15px; }
.health-ops { display: flex; gap: 8px; flex-wrap: wrap; }
.health-tip { font-size: 12px; margin: 8px 0 12px; line-height: 1.7; }
.health-table {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.health-row {
  display: grid; grid-template-columns: 1.3fr 76px 90px 92px 92px 1.6fr;
  gap: 10px; align-items: center; padding: 11px 16px;
  border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.health-row:last-child { border-bottom: none; }
.health-row.head {
  background: var(--bg-sunken); color: var(--text-2);
  font-size: 11.5px; font-weight: 600;
}
.health-row .h-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-row .h-num { color: var(--text-2); font-variant-numeric: tabular-nums; }
.health-row .h-err {
  color: var(--text-3); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.health-cfg { padding: 10px 16px; font-size: 11.5px; border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .wish-form { grid-template-columns: 1fr; }
  .wish-item { grid-template-columns: 44px 1fr; }
  .wish-ops { grid-column: 1 / -1; justify-content: flex-start; }
  .health-row { grid-template-columns: 1fr 70px 80px; }
  .health-row > div:nth-child(4),
  .health-row > div:nth-child(5),
  .health-row > div:nth-child(6) { display: none; }
}

/* ---------------- 同名书跨源聚合（第十五轮） ---------------- */
.result-group { align-items: flex-start; }
.src-count {
  display: inline-block; margin-left: 8px; vertical-align: 2px;
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.src-toggle {
  margin-top: 8px; padding: 4px 12px;
  background: transparent; color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; cursor: pointer;
  transition: all var(--transition);
}
.src-toggle:hover { border-color: var(--accent); background: var(--accent-soft); }
.src-list {
  margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 4px;
  display: flex; flex-direction: column;
}
.src-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-2); cursor: pointer;
  transition: background var(--transition);
}
.src-row:hover { background: var(--bg-sunken); color: var(--text); }
.src-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.src-dot.ok { background: #3f9c5a; }
.src-dot.warn { background: #c99a2e; }
.src-dot.bad { background: #b5443a; }
.src-name { color: var(--text); font-weight: 600; }
.src-best {
  background: var(--accent); color: #fff;
  padding: 0 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700;
}
.src-latest {
  margin-left: auto; max-width: 42%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-3); font-size: 11.5px;
}
@media (max-width: 860px) {
  .src-latest { display: none; }
  .src-count { font-size: 10.5px; }
}

/* ---------------- 书签与笔记（第十五轮） ---------------- */
.rbtn.active { background: var(--accent-soft); color: var(--accent); }
.notes-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.notes-cur {
  padding: 10px 18px 6px; font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notes-input {
  margin: 0 18px; padding: 9px 11px; resize: vertical; min-height: 62px;
  border: 1px solid rgba(128,120,100,.28); border-radius: var(--radius-sm);
  background: rgba(128,120,100,.06); color: var(--reader-text, var(--text));
  font-family: inherit; font-size: 13px; line-height: 1.55;
}
.notes-input:focus { outline: none; border-color: var(--accent); }

/* 书友纠错 */
.feedback-tip {
  margin: 0 18px 10px; font-size: 11.5px; line-height: 1.6;
  color: var(--text-2); opacity: .85;
}
.feedback-label {
  display: block; margin: 0 18px 5px; font-size: 11.5px;
  font-weight: 600; color: var(--text-2);
}
.feedback-kind {
  display: block; margin: 0 18px 9px; padding: 7px 9px;
  border: 1px solid rgba(128,120,100,.28); border-radius: var(--radius-sm);
  background: rgba(128,120,100,.06); color: var(--reader-text, var(--text));
  font-family: inherit; font-size: 13px;
}
.feedback-kind:focus { outline: none; border-color: var(--accent); }
.feedback-status {
  margin-left: auto; padding: 1px 6px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700;
  background: rgba(128,120,100,.18); color: var(--text-2);
}
.feedback-status.accepted { background: var(--accent-soft); color: var(--accent); }
.feedback-status.applied { background: rgba(58,160,110,.16); color: #2f8f5f; }
.feedback-status.rejected { background: rgba(160,80,80,.12); color: #a05050; }
.notes-actions { display: flex; gap: 8px; padding: 9px 18px 12px; }
.notes-btn {
  flex: 1; padding: 7px 10px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 600;
  transition: opacity .2s;
}
.notes-btn:hover { opacity: .88; }
.notes-btn.ghost {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent);
}
.notes-item {
  padding: 9px 18px; cursor: pointer; border-left: 3px solid transparent;
  transition: background .18s;
}
.notes-item:hover { background: rgba(128,120,100,.12); border-left-color: var(--accent); }
.notes-item-head { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.notes-kind {
  padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700;
  background: rgba(128,120,100,.18); color: var(--text-2);
}
.notes-kind.bookmark { background: var(--accent-soft); color: var(--accent); }
.notes-ch { color: var(--text-2); }
.notes-ct {
  flex: 1; color: var(--text-3); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.notes-del {
  color: var(--text-3); font-size: 12px; padding: 2px 4px; border-radius: 4px;
  opacity: 0; transition: opacity .18s;
}
.notes-item:hover .notes-del { opacity: 1; }
.notes-del:hover { color: #c0453a; background: rgba(192,69,58,.12); }
.notes-text {
  margin-top: 5px; font-size: 13px; line-height: 1.6;
  color: var(--reader-text, var(--text)); word-break: break-word;
}
.notes-empty {
  padding: 28px 22px; text-align: center;
  font-size: 12.5px; line-height: 1.8; color: var(--text-3);
}
@media (max-width: 560px) {
  .rtool { padding: 4px 9px; }
}

/* ---------------- 设置与运维（第十五轮） ---------------- */
.set-block {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
}
.set-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap; margin-bottom: 6px;
}
.set-head h2 { font-size: 15.5px; font-weight: 700; }
.set-head-actions { display: flex; gap: 8px; }
.set-head-actions .btn { padding: 6px 14px; font-size: 12.5px; }
.set-meta { font-size: 12.5px; margin-bottom: 14px; }

.cache-table { display: flex; flex-direction: column; gap: 2px; }
.cache-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 76px 92px 72px;
  align-items: center; gap: 10px;
  padding: 10px 4px; border-top: 1px solid var(--line);
  font-size: 13px;
}
.cache-row:first-child { border-top: none; }
.cache-name { min-width: 0; font-weight: 600; }
.cache-note {
  display: block; font-weight: 400; font-size: 11.5px;
  color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cache-size { font-variant-numeric: tabular-nums; font-weight: 600; }
.cache-files, .cache-age { font-size: 12px; color: var(--text-2); }
.cache-clear {
  padding: 4px 10px; font-size: 12px; justify-self: end;
}
.cache-clear[disabled] { opacity: .4; cursor: not-allowed; }
.cache-clear[disabled]:hover { border-color: var(--line); color: var(--text); }

.sys-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.sys-cell {
  background: var(--bg-sunken); border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.sys-k { font-size: 11.5px; color: var(--text-2); margin-bottom: 4px; }
.sys-v { font-size: 13.5px; font-weight: 600; }

@media (max-width: 860px) {
  .cache-row { grid-template-columns: minmax(0, 1fr) 84px 64px; }
  .cache-age, .cache-files { display: none; }
  .cache-row .cache-clear { grid-column: 3; }
}

/* 导出记录（第十五轮） */
.export-row { grid-template-columns: minmax(0, 1fr) 74px 160px 68px; }
.exp-status { font-size: 12px; font-weight: 600; color: var(--text-2); }
.exp-status.ok { color: #3f9c5a; }
.exp-status.warn { color: #c99a2e; }
.exp-status.bad { color: #b5443a; }
.export-row .cache-files {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.export-row .btn.small { justify-self: end; }
@media (max-width: 860px) {
  .export-row { grid-template-columns: minmax(0, 1fr) 66px 60px; }
  .export-row .cache-files { display: none; }
}

/* 低置信度聚合：只靠书名撞上的组，不替用户做选择 */
.src-count.warn {
  background: rgba(201, 154, 46, .16);
  color: #a8791c;
}
.result-warn {
  margin-top: 6px; padding: 5px 9px;
  background: rgba(201, 154, 46, .12);
  border-left: 3px solid #c99a2e;
  border-radius: 4px;
  font-size: 11.5px; line-height: 1.5; color: var(--text-2);
}
