/* ==========================================================================
   墨阅书库 — 样式表
   设计基调：纸质暖白 + 朱砂点睛 + 宋体标题，克制、安静、耐读。
   ========================================================================== */

:root {
  --paper: #f7f3ec;
  --paper-deep: #efe8dc;
  --surface: #fffdf8;
  --surface-2: #f9f5ee;
  --ink: #211d18;
  --ink-2: #57503f;
  --ink-3: #8d8578;
  --line: #e4dacb;
  --line-soft: #eee7db;
  --accent: #9c3a2e;
  --accent-hover: #862f24;
  --accent-soft: #f6e6e1;
  --gold: #b1904f;
  --ok: #3f7a5a;
  --warn: #b4712a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(51, 40, 25, .05), 0 2px 8px -4px rgba(51, 40, 25, .12);
  --shadow-md: 0 12px 32px -18px rgba(51, 40, 25, .35), 0 2px 6px rgba(51, 40, 25, .05);
  --font-ui: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

html[data-theme="night"] {
  --paper: #14161a;
  --paper-deep: #101215;
  --surface: #1b1e23;
  --surface-2: #212429;
  --ink: #d9d4c9;
  --ink-2: #a29c90;
  --ink-3: #6f6a61;
  --line: #2b2f35;
  --line-soft: #24272c;
  --accent: #c26456;
  --accent-hover: #d07264;
  --accent-soft: #2b2224;
  --gold: #9c8552;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 16px 40px -20px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }

::selection { background: var(--accent-soft); color: var(--accent); }

/* ---------- 应用外壳 ---------- */

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  position: relative;
  box-shadow: 0 0 0 1px var(--line-soft);
}

@media (min-width: 800px) {
  body { padding: 0 0 0 0; }
  .app { min-height: 100vh; }
}

.page {
  padding: 0 18px 96px;
  animation: pageIn .32s var(--ease);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 12px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}

.topbar.scrolled { border-bottom-color: var(--line-soft); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .06em;
}

.brand-seal {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff8f3;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-family: var(--font-serif);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}

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

.nav-link {
  font-size: 13px;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: 999px;
  transition: background .16s, color .16s;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- 通用组件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: transform .12s var(--ease), background .16s, border-color .16s, opacity .16s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: scale(.977); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff8f4; box-shadow: 0 6px 16px -10px var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-3); }

.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: transparent; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--accent-soft); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.field { display: block; margin-bottom: 14px; }
.field > .label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .04em;
  margin-bottom: 7px;
}

.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--ink);
  transition: border-color .16s, box-shadow .16s, background .16s;
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.textarea { resize: vertical; min-height: 92px; line-height: 1.7; }
.select { appearance: none; background-image: none; }

.hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }
.error-text { color: var(--accent); font-size: 13px; margin: -6px 0 12px; min-height: 18px; }

.divider { height: 1px; background: var(--line-soft); margin: 22px 0; border: 0; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  margin: 26px 0 12px;
}
.section-title .count { font-family: var(--font-ui); font-size: 12px; color: var(--ink-3); font-weight: 400; letter-spacing: 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  transition: all .16s;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
html[data-theme="night"] .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11px;
  letter-spacing: .04em;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--line-soft);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-color: transparent; }

/* ---------- 登录 / 邀请 ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 22px 56px;
  max-width: 420px;
  margin: 0 auto;
}

.auth-mark {
  text-align: center;
  margin-bottom: 30px;
}
.auth-mark .seal {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff8f3;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 27px;
  margin: 0 auto 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2), 0 12px 26px -16px var(--accent);
}
.auth-mark h1 {
  font-family: var(--font-serif);
  font-size: 25px;
  letter-spacing: .16em;
  margin: 0 0 8px;
  font-weight: 700;
  text-indent: .16em;
}
.auth-mark p { margin: 0; font-size: 13px; color: var(--ink-3); letter-spacing: .06em; }

.auth-card { padding: 22px 20px 20px; }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line-soft); margin-bottom: 20px; }
.tab {
  padding: 0 0 10px;
  font-size: 14.5px;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .16s, border-color .16s;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.auth-foot { margin-top: 18px; text-align: center; font-size: 13px; color: var(--ink-3); }
.auth-foot a { color: var(--accent); }

.notice {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  line-height: 1.65;
  margin-bottom: 16px;
}
.notice-neutral { background: var(--surface-2); color: var(--ink-2); }

/* ---------- 书库 ---------- */

.shelf-head { padding: 12px 0 4px; }
.shelf-head h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  margin: 6px 0 4px;
  letter-spacing: .04em;
  font-weight: 700;
}
.shelf-head .sub { font-size: 13px; color: var(--ink-3); }

.continue-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  margin: 18px 0 6px;
  border-radius: var(--radius);
  background: linear-gradient(118deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.continue-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -50px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--gold) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.continue-card .cc-main { flex: 1; min-width: 0; }
.continue-card .cc-label { font-size: 11.5px; letter-spacing: .12em; color: var(--gold); margin-bottom: 4px; }
.continue-card .cc-title {
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.continue-card .cc-meta { font-size: 12.5px; color: var(--ink-3); margin-bottom: 9px; }
.continue-card .cc-actions { display: flex; gap: 8px; align-items: center; }

.bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s var(--ease); }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 16px 0 4px;
}
.search-box { position: relative; flex: 1; }
.search-box .input { padding-left: 36px; height: 40px; background: var(--surface-2); border-color: transparent; }
.search-box .input:focus { background: var(--surface); border-color: var(--accent); }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .45; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 14px;
  margin-top: 14px;
}
@media (min-width: 560px) { .book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 720px) { .book-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.book-card { display: block; width: 100%; text-align: left; animation: cardIn .3s var(--ease) backwards; }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.book-card .cover { margin-bottom: 8px; }
.book-card h3 {
  font-size: 13px;
  font-weight: 500;
  margin: 0 0 3px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
}
.book-card .meta {
  font-size: 11.5px;
  color: var(--ink-3);
  display: block;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-card .meta .dot {
  display: inline-block;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  margin: 0 5px;
}

/* 书封 */
.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 3px 9px 9px 3px;
  background: linear-gradient(155deg, hsl(var(--hue, 24) 34% 44%), hsl(calc(var(--hue, 24) + 18) 38% 26%));
  box-shadow:
    inset 7px 0 9px -7px rgba(0, 0, 0, .65),
    inset 0 0 0 1px rgba(255, 255, 255, .14),
    0 8px 18px -12px rgba(40, 30, 18, .6);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12% 12%;
  isolation: isolate;
}
.cover::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, .22);
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 85% 8%, rgba(255, 255, 255, .18), transparent 60%);
  mix-blend-mode: soft-light;
}
.cover .ct {
  font-family: var(--font-serif);
  font-size: clamp(11px, 3.4vw, 15px);
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.5;
  color: rgba(255, 252, 245, .95);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.cover .cb {
  position: absolute;
  left: 0; right: 0; bottom: 9%;
  text-align: center;
  font-size: 8.5px;
  letter-spacing: .2em;
  color: rgba(255, 250, 240, .62);
  font-family: var(--font-serif);
}
.cover .prog {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, .22);
}
.cover .prog i { display: block; height: 100%; background: rgba(255, 250, 240, .85); }
.cover.cover-lg { aspect-ratio: 3 / 4; width: 118px; border-radius: 4px 12px 12px 4px; }
.cover.cover-lg .ct { font-size: 15px; }
.cover.cover-sm { width: 52px; border-radius: 2px 7px 7px 2px; }
.cover.cover-sm .ct { font-size: 9px; -webkit-line-clamp: 3; }
.cover.cover-sm .cb { display: none; }

/* 空状态 */
.empty {
  text-align: center;
  padding: 56px 20px 60px;
  color: var(--ink-3);
}
.empty .glyph {
  width: 62px; height: 62px;
  margin: 0 auto 16px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  font-family: var(--font-serif);
  font-size: 26px;
  color: var(--ink-3);
}
.empty h3 { font-family: var(--font-serif); font-size: 16px; color: var(--ink-2); margin: 0 0 6px; font-weight: 600; }
.empty p { font-size: 13px; margin: 0 0 18px; line-height: 1.7; }

/* ---------- 浮动按钮 ---------- */

.fab {
  position: fixed;
  right: max(18px, calc(50vw - 380px + 18px));
  bottom: calc(24px + env(safe-area-inset-bottom));
  height: 48px;
  padding: 0 20px 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8f4;
  font-size: 14.5px;
  font-weight: 500;
  box-shadow: 0 14px 30px -14px rgba(120, 40, 30, .8), 0 2px 6px rgba(0, 0, 0, .12);
  z-index: 30;
  transition: transform .16s var(--ease);
}
.fab:active { transform: scale(.96); }

/* ---------- 书籍详情 ---------- */

.detail-hero {
  display: flex;
  gap: 16px;
  padding: 8px 0 4px;
  align-items: flex-start;
}
.detail-hero .info { flex: 1; min-width: 0; padding-top: 2px; }
.detail-hero h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.35;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: .02em;
}
.detail-hero .author { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.detail-hero .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.detail-hero .numbers { display: flex; gap: 18px; margin-top: 12px; }
.detail-hero .numbers div { font-size: 12px; color: var(--ink-3); }
.detail-hero .numbers strong { display: block; font-size: 15px; color: var(--ink); font-weight: 600; font-family: var(--font-serif); }

.intro-box {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.intro-box.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-more { font-size: 12.5px; color: var(--accent); margin-top: 6px; display: inline-block; }

.toc-list { margin-top: 4px; border-top: 1px solid var(--line-soft); }
.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--ink-2);
  transition: color .14s, background .14s;
}
.toc-item:hover { color: var(--ink); background: var(--surface-2); }
.toc-item .idx {
  flex: 0 0 auto;
  min-width: 26px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.toc-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item.reading { color: var(--accent); font-weight: 600; }

/* ---------- 上传 ---------- */

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 34px 20px;
  text-align: center;
  transition: border-color .18s, background .18s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .ico {
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--accent);
  border: 1px solid var(--line-soft);
}
.dropzone h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.dropzone p { font-size: 12.5px; color: var(--ink-3); margin: 0; line-height: 1.7; }

.progress-line {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin: 14px 0 8px;
}
.progress-line > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s var(--ease); }

.parse-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.stat-pill {
  flex: 1 1 100px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.stat-pill b { display: block; font-family: var(--font-serif); font-size: 17px; font-weight: 700; }
.stat-pill span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; }

.chapter-preview {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
}
.chapter-preview .cp-row {
  display: flex;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
}
.chapter-preview .cp-row:last-child { border-bottom: 0; }
.chapter-preview .cp-row .n { color: var(--ink-3); font-size: 11px; min-width: 24px; font-variant-numeric: tabular-nums; }
.chapter-preview .cp-row .w { margin-left: auto; color: var(--ink-3); font-size: 11px; }

/* ---------- 我的 / 后台 ---------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  margin-top: 10px;
}
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff8f4;
  font-family: var(--font-serif);
  font-size: 21px;
  flex: 0 0 auto;
}
.profile-card .pname { font-family: var(--font-serif); font-size: 18px; font-weight: 700; }
.profile-card .pmeta { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

.list-card { overflow: hidden; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  text-align: left;
  color: var(--ink);
  transition: background .14s;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .lr-label { flex: 1; }
.list-row .lr-desc { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.list-row .lr-value { font-size: 13px; color: var(--ink-3); }
.list-row.danger .lr-label { color: var(--accent); }

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 9px;
  border: 1px solid var(--line-soft);
}
.segmented button {
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-3);
  transition: all .16s;
}
.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin: 16px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs button {
  flex: 0 0 auto;
  padding: 8px 15px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid transparent;
}
.admin-tabs button.active { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

/* 总后台 · 全站藏书 */
.admin-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin-filters .select { font-size: 14px; padding: 9px 12px; }
.admin-sum {
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.7;
  margin: 10px 0 12px;
}
.admin-sum b { color: var(--ink); font-weight: 600; }

.admin-book {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  margin-bottom: 8px;
}
.ab-cover {
  flex: 0 0 auto;
  width: 34px;
  height: 46px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 15px;
  color: #fffdf8;
  background: linear-gradient(155deg, hsl(var(--hue, 24) 38% 46%), hsl(var(--hue, 24) 44% 32%));
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, .18);
}
.ab-main { flex: 1 1 auto; min-width: 0; }
.ab-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 3px;
}
.ab-title .badge { flex: 0 0 auto; }
.ab-sub {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ab-acts { flex: 0 0 auto; display: flex; gap: 4px; align-items: center; }
.ab-acts .btn-sm { padding: 5px 8px; font-size: 12px; }

/* 三个按钮并排会把书名挤成多行，窄屏下让操作区单独占一行 */
@media (max-width: 520px) {
  .admin-book { flex-wrap: wrap; }
  .ab-acts { flex: 0 0 100%; justify-content: flex-end; margin-top: 7px; }
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-grid .stat {
  padding: 14px 15px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}
.stat-grid .stat b { display: block; font-family: var(--font-serif); font-size: 22px; font-weight: 700; letter-spacing: .01em; }
.stat-grid .stat span { font-size: 12px; color: var(--ink-3); }

.user-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.user-row:last-child { border-bottom: 0; }
.user-row .u-main { flex: 1; min-width: 0; }
.user-row .u-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.user-row .u-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.user-row .u-acts { display: flex; gap: 6px; flex: 0 0 auto; }

/* 窄屏：成员行的操作按钮单独占一行，避免把信息挤成一列 */
@media (max-width: 480px) {
  .user-row { flex-wrap: wrap; row-gap: 9px; }
  .user-row .u-acts { flex: 0 0 calc(100% - 49px); margin-left: 49px; flex-wrap: wrap; }
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.invite-row:last-child { border-bottom: 0; }
.invite-row .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--ink);
}
.invite-row .i-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.invite-row .i-acts { margin-left: auto; display: flex; gap: 6px; }

/* ---------- 阅读器 ---------- */

.reader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--rd-bg);
  color: var(--rd-text);
  overscroll-behavior: none;
  transition: background .25s;
}

.reader[data-theme="paper"] { --rd-bg: #f7f3ec; --rd-text: #26221c; --rd-dim: #8d8578; --rd-line: rgba(0, 0, 0, .07); }
.reader[data-theme="warm"]  { --rd-bg: #f3e7cf; --rd-text: #34291b; --rd-dim: #8b7a5e; --rd-line: rgba(80, 60, 30, .1); }
.reader[data-theme="green"] { --rd-bg: #dfe8d4; --rd-text: #26301f; --rd-dim: #6f7d62; --rd-line: rgba(40, 60, 30, .1); }
.reader[data-theme="night"] { --rd-bg: #14161a; --rd-text: #b7b2a8; --rd-dim: #6b6760; --rd-line: rgba(255, 255, 255, .07); }
.reader[data-theme="white"] { --rd-bg: #ffffff; --rd-text: #1b1b1b; --rd-dim: #8a8a8a; --rd-line: rgba(0, 0, 0, .06); }

.reader[data-family="serif"] .rd-body { font-family: var(--font-serif); }
.reader[data-family="sans"] .rd-body { font-family: var(--font-ui); }

.rd-top, .rd-foot {
  flex: 0 0 auto;
  transition: transform .28s var(--ease), opacity .2s;
}
.rd-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--rd-line);
  background: color-mix(in srgb, var(--rd-bg) 92%, transparent);
  backdrop-filter: blur(12px);
}
.rd-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--rd-dim);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}
.rd-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--rd-text);
  opacity: .82;
}
.rd-btn:hover { background: var(--rd-line); opacity: 1; }

.rd-stage {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  perspective: 2200px;
  perspective-origin: 100% 50%;
  -webkit-user-select: none;
  user-select: none;
}

.rd-page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--rd-bg);
  will-change: transform;
}
.rd-page[data-hidden="1"] { visibility: hidden; }
.rd-page.animating { transition: transform .5s cubic-bezier(.32, .72, .28, 1); }

.rd-viewport {
  position: absolute;
  top: 20px;
  bottom: 14px;
  left: 22px;
  right: 22px;
  overflow: hidden;
}

.rd-flow {
  height: 100%;
  column-fill: auto;
  column-gap: 0;
  will-change: transform;
}
.rd-body {
  font-size: var(--rd-font, 19px);
  line-height: var(--rd-lh, 1.9);
  color: var(--rd-text);
  letter-spacing: .012em;
  text-align: justify;
  text-justify: inter-ideograph;
  overflow-wrap: break-word;
  word-break: normal;
}
.rd-body p {
  margin: 0 0 .62em;
  text-indent: 2em;
}
.rd-body p:last-child { margin-bottom: 0; }

.rd-chapter-head {
  margin-bottom: 1.1em;
  padding-bottom: .7em;
  border-bottom: 1px solid var(--rd-line);
}
.rd-chapter-head h2 {
  font-family: var(--font-serif);
  font-size: 1.24em;
  font-weight: 700;
  letter-spacing: .03em;
  margin: 0;
  text-indent: 0;
  color: var(--rd-text);
}

/* 翻页阴影 */
.rd-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to left, rgba(0, 0, 0, .22), rgba(0, 0, 0, .04) 42%, rgba(0, 0, 0, 0));
}
.rd-page.turning .rd-shade { opacity: 1; transition: opacity .5s ease; }

/* 上下滑动模式 */
.rd-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 18px 22px 40px;
  scrollbar-width: none;
}
.rd-scroll::-webkit-scrollbar { display: none; }
.rd-scroll .rd-sec { padding-bottom: 34px; }
.rd-scroll .rd-end {
  text-align: center;
  font-size: 12px;
  color: var(--rd-dim);
  padding: 26px 0 40px;
  letter-spacing: .08em;
}

.rd-foot {
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rd-line);
  background: color-mix(in srgb, var(--rd-bg) 92%, transparent);
  backdrop-filter: blur(12px);
}
.rd-foot-row { display: flex; align-items: center; gap: 12px; }
.rd-foot .page-ind {
  font-size: 11.5px;
  color: var(--rd-dim);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: center;
}
.rd-foot .rd-nav {
  height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 7px;
  color: var(--rd-text);
  opacity: .8;
}
.rd-foot .rd-nav:disabled { opacity: .3; }
.rd-foot .rd-nav:hover:not(:disabled) { background: var(--rd-line); }

.rd-bar {
  width: 100%;
  height: 3px;
  background: var(--rd-line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
  cursor: pointer;
}
.rd-bar > i { display: block; height: 100%; background: var(--rd-text); opacity: .45; }

.reader.hide-ui .rd-top { transform: translateY(-104%); opacity: 0; pointer-events: none; }
.reader.hide-ui .rd-foot { transform: translateY(112%); opacity: 0; pointer-events: none; }

/* 自动翻页浮标 */
.auto-pill {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  background: rgba(28, 26, 22, .82);
  color: #f6f1e6;
  font-size: 12px;
  letter-spacing: .04em;
  z-index: 70;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .8);
  animation: pillIn .3s var(--ease);
}
@keyframes pillIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.auto-pill button {
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 11.5px;
}
.auto-pill .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: #e2b25c;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .28; } }

/* 设置面板 */
.rd-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  background: var(--surface);
  color: var(--ink);
  border-radius: 18px 18px 0 0;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 40px -24px rgba(0, 0, 0, .5);
  transform: translateY(102%);
  transition: transform .3s var(--ease);
  max-width: 760px;
  margin: 0 auto;
}
.rd-sheet.open { transform: none; }
.rd-sheet .sheet-grab {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 0 auto 14px;
}
.sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.sheet-row:last-child { border-bottom: 0; }
.sheet-row .s-label { flex: 0 0 58px; font-size: 13px; color: var(--ink-3); }
.sheet-row .s-body { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.stepper button { width: 34px; height: 30px; border-radius: 6px; font-size: 16px; color: var(--ink-2); }
.stepper button:hover { background: var(--surface); color: var(--ink); }
.stepper span { min-width: 40px; text-align: center; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }

.theme-dots { display: flex; gap: 9px; }
.theme-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  position: relative;
  transition: transform .14s;
}
.theme-dot:active { transform: scale(.93); }
.theme-dot.active::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
}
.theme-dot[data-theme="paper"] { background: #f7f3ec; }
.theme-dot[data-theme="warm"] { background: #f3e7cf; }
.theme-dot[data-theme="green"] { background: #dfe8d4; }
.theme-dot[data-theme="white"] { background: #ffffff; }
.theme-dot[data-theme="night"] { background: #14161a; }

/* 目录抽屉 */
.rd-toc {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 18, 14, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s;
}
.rd-toc.open { opacity: 1; pointer-events: auto; }
.rd-toc-panel {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: min(86%, 360px);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 14px 0 40px -20px rgba(0, 0, 0, .5);
  transform: translateX(-102%);
  transition: transform .28s var(--ease);
  display: flex;
  flex-direction: column;
}
.rd-toc.open .rd-toc-panel { transform: none; }
.rd-toc-head {
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.rd-toc-head h3 { margin: 0 0 3px; font-family: var(--font-serif); font-size: 16px; font-weight: 700; }
.rd-toc-head p { margin: 0; font-size: 11.5px; color: var(--ink-3); }
.rd-toc-list { flex: 1; overflow-y: auto; padding: 4px 0 calc(20px + env(safe-area-inset-bottom)); }
.rd-toc-item {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-soft);
}
.rd-toc-item .n { font-size: 11px; color: var(--ink-3); min-width: 24px; font-variant-numeric: tabular-nums; }
.rd-toc-item.current { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- 轻提示 & 弹窗 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(30, 27, 22, .92);
  color: #f8f4ec;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s var(--ease);
  max-width: 78vw;
  text-align: center;
  line-height: 1.5;
  backdrop-filter: blur(6px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(24, 20, 16, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .18s;
}
.modal-layer[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6);
  animation: modalIn .24s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 8px; font-family: var(--font-serif); font-size: 17px; font-weight: 700; }
.modal p { margin: 0 0 18px; font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.modal .m-acts { display: flex; gap: 9px; justify-content: flex-end; }

/* 载入 */
.loading {
  display: grid;
  place-items: center;
  min-height: 46vh;
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: .1em;
}
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 380px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shelf-head h1 { font-size: 23px; }
}
