/* ============ 基础 ============ */
:root {
  --bg: #0f1115;
  --bg-soft: #14171d;
  --surface: #171b22;
  --card: #1a1f27;
  --card-hi: #222833;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ecf2;
  --text-2: #c3c9d4;
  --dim: #98a1b0;
  --faint: #6d7686;
  --accent: #e0a45c;
  --accent-hi: #edb877;
  --accent-soft: rgba(224, 164, 92, 0.14);
  --danger: #e26d6d;
  --ok: #6fbf8f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-read: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-soft: #efece4;
  --surface: #fbf9f4;
  --card: #ffffff;
  --card-hi: #f6f3ec;
  --line: rgba(24, 28, 38, 0.09);
  --line-strong: rgba(24, 28, 38, 0.18);
  --text: #23262d;
  --text-2: #3d424c;
  --dim: #6f7683;
  --faint: #9aa1ad;
  --accent: #b4772e;
  --accent-hi: #a4681f;
  --accent-soft: rgba(180, 119, 46, 0.12);
  --danger: #c9504f;
  --ok: #2f8f5b;
  --shadow: 0 10px 28px rgba(60, 48, 30, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
textarea { resize: vertical; }
.sprite { position: fixed; width: 0; height: 0; overflow: hidden; }
.ic { width: 22px; height: 22px; display: block; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--text-2); transition: background 0.15s, color 0.15s; flex: none;
}
.icon-btn:active { background: var(--card-hi); }
.icon-btn[disabled] { opacity: 0.35; pointer-events: none; }
.icon-btn.on { color: var(--accent); }
.hidden, [hidden] { display: none !important; }

/* ============ 布局 ============ */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  position: relative;
}
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 4px;
  padding: calc(6px + var(--safe-t)) 10px 6px 10px;
  min-height: 56px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-title {
  font-size: 19px; font-weight: 700; letter-spacing: 0.02em;
  flex: 1; min-width: 0; padding-left: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 2px; }
.main { flex: 1; padding-bottom: calc(78px + var(--safe-b)); }
.view { padding: 6px 16px 24px; animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 5px 8px calc(5px + var(--safe-b));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-top: 1px solid var(--line);
  max-width: 760px; margin: 0 auto;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0 4px; border-radius: 12px; color: var(--faint);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  transition: color 0.15s;
}
.tab .ic { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }
.tab:active { background: var(--card-hi); }

/* ============ 通用组件 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: transform 0.12s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: #1a1206; }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn .ic { width: 18px; height: 18px; }

.input, .textarea, .select {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; outline: none; font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); background: var(--card-hi); }
.textarea { font-size: 13px; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 6px; font-weight: 600; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 6px; line-height: 1.5; }

.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--dim); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 2px 10px; font-size: 15px; font-weight: 700;
}
.section-title .sub { font-size: 12px; color: var(--faint); font-weight: 500; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.empty {
  padding: 54px 24px; text-align: center; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty .empty-ic {
  width: 66px; height: 66px; border-radius: 22px; display: grid; place-items: center;
  background: var(--card); color: var(--accent); border: 1px solid var(--line);
}
.empty .empty-ic .ic { width: 30px; height: 30px; }
.empty h3 { font-size: 16px; color: var(--text-2); }
.empty p { font-size: 13px; max-width: 280px; line-height: 1.7; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--card-hi); color: var(--dim); white-space: nowrap;
  border: 1px solid transparent;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.outline { background: transparent; border-color: var(--line-strong); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip .spinner { width: 11px; height: 11px; border-width: 1.5px; }
.chip.ok { background: rgba(111, 191, 143, 0.12); color: var(--ok); border-color: transparent; }
.chip.fail { background: rgba(226, 109, 109, 0.12); color: var(--danger); border-color: transparent; }
.source-chips { gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }

.cover {
  position: relative; border-radius: 9px; overflow: hidden; flex: none;
  background: linear-gradient(160deg, #3a4358, #1d2230);
  display: flex; align-items: flex-end; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 4px 12px rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.9);
  isolation: isolate;
}
.cover::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 42%, rgba(0, 0, 0, 0.3));
}
.cover span {
  position: relative; font-family: var(--font-read); font-weight: 700;
  font-size: 26px; line-height: 1; padding-bottom: 10px; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.02em;
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .badge {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  padding: 1px 5px; border-radius: 5px; font-size: 9.5px; font-weight: 700;
  background: rgba(0, 0, 0, 0.5); color: #fff; backdrop-filter: blur(4px);
}

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong);
  transition: background 0.2s;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hi) 37%, var(--card) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ============ 书架 ============ */
.hero {
  position: relative; margin: 8px 0 4px; padding: 18px;
  border-radius: 20px; overflow: hidden;
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(224, 164, 92, 0.28), transparent 58%),
    linear-gradient(140deg, #242b3a, #151922 62%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; gap: 14px; align-items: center; color: #f3eee6;
  box-shadow: var(--shadow);
}
.hero .cover { width: 62px; height: 86px; border-radius: 8px; }
.hero-info { flex: 1; min-width: 0; }
.hero-kicker { font-size: 10.5px; letter-spacing: 0.16em; color: var(--accent); font-weight: 700; text-transform: uppercase; }
.hero-title { font-family: var(--font-read); font-size: 20px; font-weight: 700; margin: 3px 0 4px; }
.hero-sub { font-size: 12px; color: rgba(243, 238, 230, 0.66); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-progress { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.hero-progress .bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.hero-progress .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.hero-progress b { font-size: 11px; font-weight: 600; color: rgba(243, 238, 230, 0.75); }
.hero .play {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--accent); color: #1a1206; display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(224, 164, 92, 0.3);
}
.hero .play .ic { width: 20px; height: 20px; margin-left: 2px; }

.shelf-tools { display: flex; gap: 8px; margin: 16px 0 12px; align-items: center; }
.shelf-tools .input { height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: 999px; background: var(--card); }
.sort-btn { flex: none; }

.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 18px 14px; margin-top: 14px;
}
.book-grid > .empty { grid-column: 1 / -1; }
.book-cell { position: relative; }
.book-cell .cover { width: 100%; aspect-ratio: 3 / 4.15; height: auto; }
.book-cell .cover span { font-size: 30px; }
.book-cell .name {
  margin-top: 8px; font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-cell .meta { margin-top: 3px; font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-cell .progress { margin-top: 6px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.book-cell .progress i { display: block; height: 100%; background: var(--accent); }
.book-cell .cell-menu {
  position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.42); color: #fff; display: grid; place-items: center;
  opacity: 0; transition: opacity 0.15s;
}
.book-cell .cell-menu .ic { width: 16px; height: 16px; }
.book-cell:active .cover { transform: scale(0.97); }
.book-cell .cover { transition: transform 0.15s; }

/* ============ 搜索 ============ */
.search-box {
  display: flex; gap: 8px; align-items: center; margin: 8px 0 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 15px;
  padding: 4px 4px 4px 13px; transition: border-color 0.15s, background 0.15s;
}
.search-box:focus-within { border-color: var(--accent); background: var(--card-hi); }
.search-box .ic { color: var(--faint); width: 19px; height: 19px; flex: none; }
.search-box input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  height: 42px; font-size: 15px;
}
.search-box input::placeholder { color: var(--faint); font-size: 14px; }
.search-box .btn { height: 38px; border-radius: 11px; padding: 0 15px; }
.search-box .clear { width: 30px; height: 30px; border-radius: 8px; display: none; place-items: center; color: var(--faint); }
.search-box.has-value .clear { display: grid; }

.source-status { display: flex; gap: 7px; flex-wrap: wrap; margin: 2px 0 12px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
  padding: 5px 9px; border-radius: 8px; background: var(--card); color: var(--dim);
  border: 1px solid var(--line);
}
.status-pill.ok { color: var(--ok); border-color: rgba(111, 191, 143, 0.25); }
.status-pill.fail { color: var(--danger); border-color: rgba(226, 109, 109, 0.25); }
.status-pill.busy { color: var(--accent); border-color: rgba(224, 164, 92, 0.25); }
.status-pill .spinner { width: 10px; height: 10px; border-width: 1.5px; }

.result-list { display: flex; flex-direction: column; gap: 10px; }
.result {
  display: flex; gap: 12px; padding: 12px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
  transition: transform 0.12s, background 0.15s;
}
.result:active { transform: scale(0.99); background: var(--card-hi); }
.result .cover { width: 52px; height: 72px; }
.result .cover span { font-size: 19px; padding-bottom: 7px; }
.result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.result-title { font-size: 15px; font-weight: 650; line-height: 1.35; display: flex; align-items: center; gap: 6px; }
.result-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-author { font-size: 12px; color: var(--dim); margin-top: 2px; }
.result-intro { font-size: 12px; color: var(--faint); line-height: 1.5; margin-top: 5px; }
.result-foot { display: flex; align-items: center; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.source-count {
  font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
}

.hot-words { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.hot-words .chip { padding: 7px 12px; font-size: 12.5px; cursor: pointer; background: var(--card); border-color: var(--line); }

.search-hint { text-align: center; color: var(--faint); font-size: 12.5px; padding: 8px 0 2px; }

/* ============ 书源 ============ */
.source-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; margin-bottom: 10px;
}
.source-head { display: flex; align-items: center; gap: 10px; }
.source-avatar {
  width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px;
  font-family: var(--font-read);
}
.source-name { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.source-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-actions { display: flex; gap: 4px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.source-actions .btn { height: 30px; padding: 0 9px; font-size: 12px; border-radius: 8px; background: transparent; color: var(--dim); border-color: transparent; }
.source-actions .btn:active { background: var(--card-hi); }
.source-actions .btn.danger { margin-left: auto; }
.badge-builtin {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; padding: 1px 5px;
  border-radius: 4px; background: rgba(111, 191, 143, 0.14); color: var(--ok);
}
.repo-list { max-height: 46vh; overflow-y: auto; margin-top: 10px; -webkit-overflow-scrolling: touch; }
.repo-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.repo-item:last-child { border-bottom: 0; }
.repo-item .repo-name { font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.repo-item .repo-sub { font-size: 11px; color: var(--faint); margin-top: 3px; line-height: 1.5; }
.repo-item .btn { flex: none; align-self: center; }
.repo-item .chip { font-size: 9.5px; padding: 1px 5px; }

/* 书源工坊 */
.forge-log {
  display: none; margin-top: 10px; padding: 8px 10px; max-height: 150px; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  font: 11px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--dim);
  white-space: pre-wrap; word-break: break-all;
}
.forge-line { padding: 1px 0; }
.forge-line.warn { color: var(--accent); }
.forge-line.err { color: var(--danger); }
.forge-line.ok { color: var(--ok); }
.forge-panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.forge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.forge-grid .field { margin: 0; }
.forge-actions { display: flex; gap: 8px; margin-top: 12px; }
.forge-actions .btn { flex: 1; }
@media (max-width: 420px) { .forge-grid { grid-template-columns: 1fr; } }

/* ============ 我的 / 设置 ============ */
.profile-card {
  display: flex; align-items: center; gap: 14px; padding: 18px;
  border-radius: 18px; background:
    radial-gradient(100% 120% at 0% 0%, rgba(224, 164, 92, 0.16), transparent 55%),
    var(--card);
  border: 1px solid var(--line); margin: 8px 0 16px;
}
.profile-avatar {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), #8f5a22); color: #1a1206;
  font-family: var(--font-read); font-size: 26px; font-weight: 700;
}
.group {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; margin-bottom: 14px;
}
.group-head { padding: 12px 15px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; color: var(--faint); text-transform: uppercase; }
.setting-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  border-top: 1px solid var(--line); min-height: 50px;
}
.group .setting-row:first-of-type { border-top: 0; }
.setting-row .label { flex: 1; min-width: 0; font-size: 14px; }
.setting-row .label small { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; line-height: 1.4; }
.setting-row .value { color: var(--faint); font-size: 12.5px; }
.seg {
  display: inline-flex; background: var(--bg-soft); border-radius: 10px; padding: 3px; gap: 2px;
  border: 1px solid var(--line);
}
.seg button {
  padding: 5px 11px; border-radius: 7px; font-size: 12px; color: var(--dim); font-weight: 600;
}
.seg button.active { background: var(--card-hi); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }

/* ============ 书目详情 ============ */
.book-hero { display: flex; gap: 16px; padding: 8px 0 2px; }
.book-hero .cover { width: 96px; height: 132px; border-radius: 10px; }
.book-hero .cover span { font-size: 36px; padding-bottom: 14px; }
.book-hero-info { flex: 1; min-width: 0; padding-top: 2px; }
.book-hero-title { font-family: var(--font-read); font-size: 22px; font-weight: 700; line-height: 1.3; }
.book-hero-author { color: var(--dim); font-size: 12.5px; margin-top: 5px; }
.book-hero-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.book-actions { display: flex; gap: 8px; margin: 16px 0 4px; }
.book-actions .btn { flex: 1; height: 44px; }
.intro-card { margin-top: 14px; }
.intro-card .intro-text { font-size: 13px; line-height: 1.75; color: var(--text-2); }
.intro-card .fold { margin-top: 6px; font-size: 12px; color: var(--accent); }
.chapter-tools { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; }
.chapter-tools .sub { font-size: 12px; color: var(--faint); }
.chapter-list { display: grid; grid-template-columns: 1fr; gap: 0; }
.chapter-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--text-2);
}
.chapter-item .idx { width: 30px; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; flex: none; }
.chapter-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-item .cached { color: var(--ok); font-size: 10.5px; flex: none; }
.chapter-item:active { background: var(--card-hi); }

/* ============ 弹层 ============ */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.overlay .mask {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px); opacity: 0; transition: opacity 0.2s;
}
.overlay.show .mask { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: 620px; max-height: 88vh;
  background: var(--surface); border-radius: 22px 22px 0 0;
  border: 1px solid var(--line); border-bottom: 0;
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.3, 0.9, 0.3, 1);
  display: flex; flex-direction: column; padding-bottom: var(--safe-b);
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.35);
}
.overlay.show .sheet { transform: none; }
.overlay.center { align-items: center; }
.overlay.center .sheet {
  border-radius: 20px; border-bottom: 1px solid var(--line); max-height: 84vh;
  transform: scale(0.94); opacity: 0; transition: transform 0.2s, opacity 0.2s;
  margin: 16px;
}
.overlay.center.show .sheet { transform: none; opacity: 1; }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px 8px; flex: none; }
.sheet-title { font-size: 16px; font-weight: 700; flex: 1; min-width: 0; }
.sheet-body { padding: 8px 18px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-actions { display: flex; flex-direction: column; gap: 4px; padding: 2px 12px 14px; }
.sheet-actions .act {
  display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 12px;
  font-size: 14.5px; text-align: left; width: 100%;
}
.sheet-actions .act:active { background: var(--card-hi); }
.sheet-actions .act .ic { width: 19px; height: 19px; color: var(--dim); }
.sheet-actions .act.danger { color: var(--danger); }
.sheet-actions .act.danger .ic { color: var(--danger); }

.toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(92px + var(--safe-b));
  z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 20px;
}
.toast {
  max-width: 100%; background: rgba(30, 34, 43, 0.96); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transform: translateY(10px); opacity: 0; transition: all 0.22s;
  border: 1px solid rgba(255, 255, 255, 0.1); text-align: center; line-height: 1.45;
}
html[data-theme="light"] .toast { background: rgba(35, 38, 45, 0.94); }
.toast.show { transform: none; opacity: 1; }
.toast.err { background: rgba(150, 45, 48, 0.96); }

/* ============ 阅读器 ============ */
.reader {
  --r-bg: #f2ece0; --r-text: #2f2a22; --r-dim: #8a806f; --r-line: rgba(47, 42, 34, 0.1);
  --r-font: 18px; --r-lh: 1.9; --r-font-family: var(--font-read);
  position: fixed; inset: 0; z-index: 80; background: var(--r-bg); color: var(--r-text);
  display: flex; flex-direction: column;
  max-width: 760px; margin: 0 auto; overflow: hidden;
}
.reader[data-theme="paper"] { --r-bg: #f4efe4; --r-text: #302b23; --r-dim: #8c8271; --r-line: rgba(48, 43, 35, 0.1); }
.reader[data-theme="sepia"] { --r-bg: #e9dfc8; --r-text: #3b3223; --r-dim: #8d7f61; --r-line: rgba(59, 50, 35, 0.12); }
.reader[data-theme="night"] { --r-bg: #15171c; --r-text: #b9c0cc; --r-dim: #6b7382; --r-line: rgba(255, 255, 255, 0.08); }
.reader[data-theme="green"] { --r-bg: #e3ebdd; --r-text: #2b352a; --r-dim: #7b8879; --r-line: rgba(43, 53, 42, 0.11); }
.reader[data-font="sans"] { --r-font-family: var(--font-sans); }

.reader-top {
  display: flex; align-items: center; gap: 2px; padding: calc(6px + var(--safe-t)) 8px 6px;
  background: var(--r-bg); border-bottom: 1px solid var(--r-line);
  transition: transform 0.22s, opacity 0.22s; z-index: 3;
}
.reader.chrome-hidden .reader-top { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.reader.chrome-hidden .reader-bottom { transform: translateY(100%); opacity: 0; pointer-events: none; }
.reader .icon-btn { color: var(--r-text); opacity: 0.82; }
.reader-titles { flex: 1; min-width: 0; text-align: center; padding: 0 4px; }
.reader-book { font-size: 10.5px; color: var(--r-dim); letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-chapter-title { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reader-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; scroll-behavior: smooth; }
.reader-content {
  max-width: 680px; margin: 0 auto; padding: 22px 22px 90px;
  font-family: var(--r-font-family); font-size: var(--r-font); line-height: var(--r-lh);
  color: var(--r-text); word-break: break-word;
}
.reader.paged #reader-body {
  overflow: hidden; padding: 22px 24px; touch-action: none;
}
.reader.paged #reader-content {
  height: 100%; max-width: none; margin: 0; padding: 0;
  column-width: var(--page-w, 320px); column-gap: 64px; column-fill: auto;
  transition: transform 0.18s ease-out; will-change: transform;
}
.reader.paged #reader-content .chapter-heading { margin-top: 0; }
.reader.paged #reader-content .reader-end { break-inside: avoid; }
.reader-content .chapter-heading {
  font-family: var(--r-font-family); font-size: 1.32em; font-weight: 700; line-height: 1.5;
  margin: 6px 0 20px; text-align: center; letter-spacing: 0.02em;
}
.reader-content p { margin: 0 0 0.62em; text-indent: 2em; }
.reader-content .chapter-body div { margin: 0 0 0.62em; }
.reader-content .chapter-body p { margin: 0 0 0.62em; }
.reader-content h2, .reader-content h3 { font-size: 1.06em; margin: 1.4em 0 0.5em; font-weight: 700; }
.reader-content blockquote { margin: 1em 0; padding: 4px 0 4px 14px; border-left: 2px solid var(--r-line); color: var(--r-dim); }
.reader-content blockquote p { text-indent: 0; }
.reader-content img { max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 4px; }
.reader-content hr { border: 0; height: 1px; background: var(--r-line); margin: 24px 0; }
.reader-content .note { font-size: 0.82em; color: var(--r-dim); text-indent: 0; }
.reader-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--r-dim); font-size: 13px; background: var(--r-bg);
}
.reader-end {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--r-line);
  text-align: center; color: var(--r-dim); font-size: 12px;
}
.reader-end .btn { margin-top: 10px; color: var(--r-text); border-color: var(--r-line); background: transparent; }

.reader-bottom {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--r-bg) 92%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--r-line);
  transition: transform 0.22s, opacity 0.22s; z-index: 3;
}
.reader-progress-wrap { flex: 1; min-width: 0; padding: 0 4px; }
.reader-progress-label { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--r-dim); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.reader-progress { height: 16px; display: flex; align-items: center; cursor: pointer; position: relative; }
.reader-progress::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; margin-top: -1.5px;
  height: 3px; border-radius: 2px; background: var(--r-line);
}
.reader-progress-bar { position: relative; height: 3px; border-radius: 2px; background: var(--accent); min-width: 0; transition: width 0.08s linear; }
.reader-progress .knob {
  position: absolute; right: -5px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* 阅读设置 */
.reader-settings { display: flex; flex-direction: column; gap: 18px; }
.rs-group .rs-label { font-size: 11.5px; font-weight: 700; color: var(--faint); letter-spacing: 0.08em; margin-bottom: 9px; }
.theme-swatches { display: flex; gap: 10px; }
.theme-swatch {
  flex: 1; height: 54px; border-radius: 12px; border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.theme-swatch.active { border-color: var(--accent); }
.theme-swatch[data-theme="paper"] { background: #f4efe4; color: #302b23; }
.theme-swatch[data-theme="sepia"] { background: #e9dfc8; color: #3b3223; }
.theme-swatch[data-theme="night"] { background: #15171c; color: #b9c0cc; }
.theme-swatch[data-theme="green"] { background: #e3ebdd; color: #2b352a; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 38px; height: 34px; border-radius: 9px; background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 17px; color: var(--text-2);
}
.stepper .val { min-width: 52px; text-align: center; font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* 进度弹层 */
.progress-bar-lg { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 10px 0; }
.progress-bar-lg i { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.dl-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }

.bookmark-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.bookmark-item .bm-t { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.bookmark-item .bm-x { font-size: 12px; color: var(--faint); margin-top: 4px; line-height: 1.55; }

.kbd {
  font-family: ui-monospace, monospace; font-size: 11px; padding: 1px 5px;
  background: var(--card-hi); border: 1px solid var(--line); border-radius: 4px; color: var(--text-2);
}

@media (max-width: 360px) {
  .view { padding-left: 12px; padding-right: 12px; }
  .book-grid { grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
  .book-cell .name { font-size: 12px; }
}
@media (min-width: 640px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .view { padding-left: 22px; padding-right: 22px; }
}
