:root {
  --bg: #FBF8F2;
  --surface: #FFFFFF;
  --surface-2: #F4EDE2;
  --ink: #2A2622;
  --ink-soft: #6E655A;
  --ink-faint: #A89C8C;
  --line: #EAE1D3;
  --accent: #B5654A;
  --accent-deep: #9A5038;
  --accent-soft: #F1E2D8;
  --sage: #7E8C6E;
  --gold: #C9A24B;
  --danger: #C0504D;
  --shadow: 0 6px 22px rgba(70, 52, 38, 0.08);
  --shadow-lg: 0 16px 48px rgba(70, 52, 38, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--ink); }
img { display: block; max-width: 100%; }

/* ---------- App Bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(251, 248, 242, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  max-width: 720px; margin: 0 auto;
  height: 56px; padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  align-self: center; box-shadow: 0 2px 6px rgba(181,101,74,.35);
}
.brand-name { font-family: var(--font-serif); font-size: 21px; font-weight: 700; letter-spacing: 2px; }
.brand-sub { font-size: 12px; color: var(--ink-faint); letter-spacing: 3px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--ink-soft); transition: background .15s;
}
.icon-btn:active { background: var(--surface-2); }
.count-badge {
  min-width: 44px; height: 36px; padding: 0 12px; border-radius: 18px;
  display: grid; place-items: center; font-family: var(--font-serif); font-weight: 700;
  font-size: 19px; color: #fff; letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 12px rgba(181,101,74,.35); cursor: pointer;
}
.count-badge:active { filter: brightness(.95); }

/* ---------- View / Layout ---------- */
.view { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }
.section-title {
  font-family: var(--font-serif); font-size: 17px; font-weight: 700;
  margin: 22px 4px 12px; display: flex; align-items: center; justify-content: space-between;
}
.section-title .hint { font-family: var(--font-sans); font-size: 12px; color: var(--ink-faint); font-weight: 400; }

/* ---------- Cards / Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; min-height: 104px;
}
.stat-card::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px;
  background: var(--accent-soft); border-radius: 50%; opacity: .6;
}
/* 首页四板块：整块 = 中国风背景图 + 点击进入（高度比传统 stat-card 矮约 1/4，宽度不变）
   注意：不能用 aspect-ratio + min-height，iOS Safari 在 repeat(2,1fr) 网格下会算错轨道尺寸导致卡片重叠。
   改用响应式固定高度，跨浏览器稳定，且宽度比始终贴近 2.2:1（背景图按 2.2:1 制作即以 cover 全幅铺满）。 */
.stats .stat-card{
  background-color: #7A4F2E;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  padding: 0; min-height: 0; border: 1px solid #6B4423;
  height: clamp(68px, 21vw, 148px);   /* 手机≈72px / 桌面≈148px，比例稳定在 ~2.1–2.3:1 */
  min-width: 0;                        /* 防止 1fr 轨道被 min-content 撑开 */
  display: block;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.stats .stat-card::after{ display: none; }
.stats .stat-card:active{ transform: translateY(1px); box-shadow: var(--shadow-lg); }
.stats .stat-card[data-sub="stats"]    { background-image: url(/img/stat-stats.jpg); }
.stats .stat-card[data-sub="shelf"]    { background-image: url(/img/stat-shelf.jpg); }
.stats .stat-card[data-sub="category"] { background-image: url(/img/stat-category.jpg); }
.stats .stat-card[data-sub="tag"]      { background-image: url(/img/stat-tag.jpg); }
.stat-num { font-family: var(--font-serif); font-size: 30px; font-weight: 700; color: var(--accent-deep); line-height: 1; }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
/* 藏书统计：大数字 */
.stat-hero-num { font-family: var(--font-serif); font-size: 38px; font-weight: 700; color: var(--accent-deep); line-height: 1; }
/* 艺术字标题（四板块通用） */
.art-title {
  font-family: var(--font-serif); font-weight: 700; letter-spacing: 3px; font-size: 18px; margin-top: 10px;
  background: linear-gradient(120deg, var(--accent-deep), var(--gold));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
/* 书架 / 分类 / 标签：图标 + 艺术字，不展示数量 */
.stat-art { align-items: flex-start; }
.stat-art-ico { font-size: 26px; line-height: 1; }
.stat-art .art-title { margin-top: 12px; }

/* ---------- Search ---------- */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 14px; box-shadow: var(--shadow); margin: 14px 0 4px;
}
.search-bar svg { color: var(--ink-faint); flex: none; }
.search-bar input { border: none; outline: none; flex: 1; background: transparent; }
.search-bar .clear { color: var(--ink-faint); }

/* ---------- Book Grid ---------- */
.book-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.book-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.book-card:active { transform: translateY(1px); box-shadow: var(--shadow-lg); }
.book-cover {
  aspect-ratio: 3/4; background: var(--surface-2); display: grid; place-items: center;
  position: relative; overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover .ph { color: var(--ink-faint); font-family: var(--font-serif); font-size: 13px; text-align: center; padding: 8px; }
.book-badge {
  position: absolute; bottom: 6px; right: 6px; background: rgba(42,38,34,.72); color: #fff;
  font-size: 11px; padding: 2px 7px; border-radius: 8px; backdrop-filter: blur(4px); font-weight: 600;
}
/* 分类：置于封面上层右上角，盖在封面之上 */
.book-cat-cover {
  position: absolute; top: 6px; right: 6px; z-index: 3; cursor: pointer;
  background: rgba(42,38,34,.72); color: #fff; backdrop-filter: blur(4px);
  font-size: 10px; padding: 2px 7px; border-radius: 8px; white-space: nowrap;
  max-width: 62%; overflow: hidden; text-overflow: ellipsis; transition: filter .15s;
}
.book-cat-cover:active { filter: brightness(.92); }
/* 读过邮戳：左下角，邮票底图 + 动态年份/日期叠加（中心词画死进底图） */
.read-stamp {
  position: absolute;
  left: 4px;
  bottom: 4px;
  width: 60px;
  height: 60px;
  z-index: 4;
  pointer-events: none; /* 让点击穿透到封面，不干扰打开详情 */
}
.read-stamp img {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.read-stamp .stamp-year {
  position: absolute;
  left: 0; right: 0;
  top: 15.8%;
  text-align: center;
  font-family: Didot, "Bodoni MT", "Bodoni 72", "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .5px;
  line-height: 1;
}
.read-stamp.own .stamp-year { color: #A32D2D; }
.read-stamp.other .stamp-year { color: #21435f; }
/* 中心词「已读过/已读他版」已画死进底图，无需动态叠加 */
.read-stamp .stamp-date {
  position: absolute;
  left: 0; right: 0;
  top: 63.5%;
  text-align: center;
  font-family: Didot, "Bodoni MT", "Bodoni 72", "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: .5px;
  line-height: 1;
}
.read-stamp.own .stamp-date { color: #A32D2D; }
.read-stamp.other .stamp-date { color: #21435f; }
.book-meta { padding: 7px 7px 9px; }
.book-title { font-family: var(--font-serif); font-size: 12px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 32px; }
.book-author { font-size: 11px; color: var(--ink-soft); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-author-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; }
.book-author-line .book-author { margin-top: 0; flex: 1; }
.book-cat {
  flex: none; cursor: pointer; font-size: 10px; color: var(--accent-deep); background: var(--accent-soft);
  padding: 1px 6px; border-radius: 7px; white-space: nowrap; max-width: 50%;
  overflow: hidden; text-overflow: ellipsis; transition: filter .15s;
}
.book-cat:active { filter: brightness(.95); }
.shelf-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 7px;
  font-size: 11px; color: var(--sage); background: #EEF1E9; padding: 2px 8px; border-radius: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px; border-radius: 12px; font-size: 15px; font-weight: 600; transition: filter .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(181,101,74,.28); }
.btn-primary:active { filter: brightness(.95); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-line { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-block { width: 100%; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #EBC9C8; }
.btn-read-active { background: #fff; color: #a32d2d; border: 1px solid #E8C5C5; }

/* ---------- Scan View ---------- */
.tabs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 14px 0; }
.tabs button { flex: 1; padding: 9px; border-radius: 9px; font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.tabs button.active { background: var(--surface); color: var(--accent-deep); box-shadow: var(--shadow); }

.scan-stage {
  background: #15110E; border-radius: var(--radius); overflow: hidden; position: relative;
  min-height: 300px;
}
.scan-stage #reader { position: absolute; inset: 0; }
.scan-stage #reader video, .scan-stage #reader canvas { width: 100% !important; height: 100% !important; object-fit: cover; }
.scan-stage .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #cfc4b6; text-align: center; padding: 30px; font-size: 14px; line-height: 1.7; z-index: 2; }
.scan-stage .ph > div:first-child { font-weight: 600; }
/* 摄像头扫描框 + 状态提示 */
.scan-frame {
  display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 72%; height: 30%; border: 2px solid rgba(255,255,255,.85); border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.28); z-index: 3; pointer-events: none;
}
.scan-frame::before, .scan-frame::after {
  content: ""; position: absolute; width: 22px; height: 22px; border: 3px solid var(--gold);
}
.scan-frame::before { left: -3px; top: -3px; border-right: none; border-bottom: none; border-top-left-radius: 12px; }
.scan-frame::after { right: -3px; bottom: -3px; border-left: none; border-top: none; border-bottom-right-radius: 12px; }
.scan-status {
  display: none; position: absolute; left: 0; right: 0; bottom: 12px; z-index: 4;
  text-align: center; color: #fff; font-size: 13px; padding: 6px 12px;
  background: rgba(0,0,0,.45); margin: 0 16px; border-radius: 10px; backdrop-filter: blur(4px);
}
.cam-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; z-index: 3; }
.scan-switch { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px; }
.switch { position: relative; width: 46px; height: 27px; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(19px); }

.isbn-input { display: flex; gap: 8px; margin: 10px 0; }
.isbn-input input { flex: 1; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); outline: none; }
.isbn-input input:focus { border-color: var(--accent); }

/* ---------- Form ---------- */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); outline: none; transition: border .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.cover-preview { width: 76px; height: 100px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }
.cover-row { display: flex; gap: 12px; align-items: flex-start; }

/* ---------- Shelves ---------- */
.shelf-list { display: flex; flex-direction: column; gap: 12px; }
.shelf-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
}
.shelf-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-deep);
  display: grid; place-items: center; flex: none; }
.shelf-info { flex: 1; min-width: 0; }
.shelf-name { font-family: var(--font-serif); font-size: 16px; font-weight: 700; }
.shelf-loc { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.shelf-count { font-family: var(--font-serif); font-size: 20px; color: var(--accent-deep); }

/* 书架三联选择（类型 / 组 / 层） */
.shelf-pick-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.shelf-pick-label { width: 28px; flex: none; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.shelf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.shelf-chip {
  padding: 6px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; transition: background .1s, border-color .1s;
  user-select: none;
}
.shelf-chip:active { transform: translateY(1px); }
.shelf-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.shelf-preview { margin-top: 10px; font-size: 13px; color: var(--ink-soft); }
.shelf-preview b { color: var(--accent-deep); font-family: var(--font-serif); font-size: 15px; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30,24,20,.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s;
}
@media (min-width: 560px) { .modal-mask { align-items: center; } .modal { max-width: 480px; } }
.modal {
  background: var(--bg); width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: slideup .22s ease; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-family: var(--font-serif); font-size: 18px; margin: 0; }
.modal-close { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-soft); }
/* 编辑藏书等表单：取消/保存固定底部，不随内容滚动 */
.form-footer {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 10px; margin-top: 16px;
  padding: 12px 0 2px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 16px -10px rgba(0,0,0,.35);
}
.form-footer .btn { margin: 0; }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Detail ---------- */
.detail-cover { width: 110px; height: 150px; border-radius: 10px; object-fit: cover; background: var(--surface-2); box-shadow: var(--shadow); flex: none; }
.detail-cover-wrap { position: relative; flex: none; }
.detail-cover-wrap .read-stamp { width: 62px; height: 62px; }
.detail-head { display: flex; gap: 16px; }
.detail-title { font-family: var(--font-serif); font-size: 20px; font-weight: 700; line-height: 1.3; }
.detail-sub { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 16px; }
.detail-grid .k { font-size: 12px; color: var(--ink-faint); }
.detail-grid .v { font-size: 14px; color: var(--ink); margin-top: 1px; word-break: break-word; }
.detail-block { margin-top: 16px; }
.detail-block h4 { font-size: 13px; color: var(--ink-soft); margin: 0 0 6px; font-weight: 700; }
.detail-block p { margin: 0; font-size: 14px; line-height: 1.7; white-space: pre-wrap; color: #3a342e; }
.child-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.child-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }

/* ---------- Empty / Toast ---------- */
/* 书名匹配候选列表 */
.match-body { max-height: 62vh; overflow-y: auto; margin: 0 -2px; padding: 6px 2px; }
.match-item { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .1s; }
.match-item:active { background: var(--accent-soft); }
.match-cover { width: 44px; height: 62px; object-fit: cover; border-radius: 4px; background: var(--line); flex: 0 0 auto; }
.match-info { flex: 1; min-width: 0; }
.match-title { font-family: var(--font-serif); font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.match-sub { font-size: 12px; color: var(--ink-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { text-align: center; color: var(--ink-faint); padding: 50px 20px; font-size: 14px; }
.empty .big { font-family: var(--font-serif); font-size: 16px; color: var(--ink-soft); margin-bottom: 6px; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(42,38,34,.94); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px;
  z-index: 80; opacity: 0; pointer-events: none; transition: .25s; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { text-align: center; color: var(--ink-faint); padding: 30px; font-size: 14px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- 分类 / 标签 chips ---------- */
.cat-tag {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 7px;
  font-size: 11px; color: var(--accent-deep); background: var(--accent-soft); padding: 2px 8px; border-radius: 8px;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--sage);
  background: #EEF1E9; padding: 2px 8px; border-radius: 8px; cursor: pointer; transition: filter .15s;
}
.tag-chip:active { filter: brightness(.94); }
.tag-chip b { color: var(--ink-faint); font-weight: 700; }
.tag-chip.editable { cursor: pointer; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip-row.tagline { margin-top: 6px; }

/* 标签云 */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.tag-cloud .tg {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: .15s;
}
.tag-cloud .tg:active { background: var(--accent-soft); }
.tag-cloud .tg i { font-style: normal; font-size: 11px; color: var(--ink-faint); }

/* 筛选 pill */
.filter-pill {
  font-family: var(--font-sans); font-size: 12px; font-weight: 500; color: var(--accent-deep);
  background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; cursor: pointer;
}
.hint.link { color: var(--accent); cursor: pointer; font-weight: 500; }

/* 多选 */
.select-box {
  position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(42,38,34,.35); display: none; z-index: 4; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.book-card { position: relative; }
.book-grid.selecting .select-box,
.book-list.selecting .select-box { display: block; }
.book-card.selected, .book-row.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.book-card.selected .select-box, .book-row.selected .select-box { background: var(--accent); border-color: #fff; }
.book-card.selected .select-box::after, .book-row.selected .select-box::after { content: "✓"; color: #fff; font-size: 13px; display: grid; place-items: center; height: 100%; }
.book-row { position: relative; }

/* 查看方式切换按钮（二级图书列表页） */
.view-toggle {
  font-size: 12px; color: var(--accent-deep); background: var(--accent-soft);
  padding: 3px 11px; border-radius: 999px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; transition: filter .15s;
}
.view-toggle:active { filter: brightness(.95); }

/* 图书详情列表视图（纵向；第一行书名+分类，第二行作者/出版社/出版年） */
.book-list { display: flex; flex-direction: column; }
.book-row {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 11px; margin-bottom: 6px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s, box-shadow .1s; overflow: hidden;
}
.book-row:active { transform: translateY(1px); box-shadow: var(--shadow-lg); }
.book-row .br-line1, .book-row .br-line2 { display: flex; align-items: center; min-width: 0; }
.book-row .br-line1 { gap: 8px; }
.book-row .br-line2 { gap: 6px; margin-top: 3px; font-size: 12px; color: var(--ink-soft); }
.book-row .br-title {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-serif); font-size: 14px; font-weight: 600; color: var(--ink);
  line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-row .br-cat {
  flex: 0 0 auto; white-space: nowrap;
  font-size: 11px; color: #fff; background: var(--accent); padding: 1px 8px; border-radius: 6px;
}
.book-row .br-author, .book-row .br-pub {
  flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-row .br-year {
  flex: 0 0 auto; white-space: nowrap; color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
/* 多选态：左上角圆圈让出空间，避免遮挡书名 */
.book-list.selecting .book-row { padding-left: 34px; }

/* 批量操作栏 */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 56px; z-index: 40; display: flex; align-items: center; gap: 8px;
  max-width: 720px; margin: 0 auto; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(42,38,34,.96); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg);
}
.ab-count { color: #fff; font-size: 13px; flex: 1; }
.ab-btn { padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; background: #fff; color: var(--ink); }
.ab-btn.primary { background: var(--accent); color: #fff; }

/* 分类选择弹窗 */
.cat-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cat-pick { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; }
.cat-pick.none { color: var(--ink-faint); }
.cat-pick:active { background: var(--accent-soft); }

/* 批量二级分类弹窗：逐本点选清单 */
.subcat-jump { display: flex; justify-content: flex-end; margin: 4px 2px 10px; }
.bsub-list { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 6px; background: var(--surface); }
.bsub-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-top: 1px dashed var(--line); cursor: pointer; }
.bsub-row:first-child { border-top: none; }
.bsub-row:hover { background: var(--surface-2); }
.bsub-check { width: 18px; height: 18px; flex: 0 0 auto; }
.bsub-title { flex: 1; min-width: 0; font-size: 14px; color: var(--ink); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bsub-sub { flex: 0 0 auto; font-size: 12px; color: var(--ink-faint); max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 标签编辑器 */
.tag-editor { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; padding: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.tag-add { display: flex; gap: 8px; margin-top: 8px; }
.tag-add input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none; }
.tag-add input:focus { border-color: var(--accent); }

/* 分类管理项 */
.cat-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
}
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-family: var(--font-serif); font-size: 16px; font-weight: 700; }
.cat-desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- 首页四区块卡片可点击 ---------- */
.stat-card.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat-card.clickable:active { transform: translateY(1px); box-shadow: var(--shadow-lg); }
.stat-go { position: absolute; right: 12px; bottom: 12px; font-size: 12px; color: var(--accent); font-weight: 600; }

/* ---------- 二级页头部 ---------- */
.sub-head { display: flex; align-items: center; gap: 8px; margin: 2px 2px 12px; }
.sub-back { font-size: 15px; color: var(--accent-deep); font-weight: 600; padding: 6px 6px; border-radius: 10px; flex: none; }
.sub-back:active { background: var(--surface-2); }
.sub-title { font-family: var(--font-serif); font-size: 18px; font-weight: 700; }
.sub-head .hint { margin-left: auto; }

/* ---------- 指标网格（统计页） ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 6px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px; box-shadow: var(--shadow); text-align: center;
}
.metric-num { font-family: var(--font-serif); font-size: 21px; font-weight: 700; color: var(--accent-deep); line-height: 1.1; word-break: break-all; }
.metric-label { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }

/* ---------- 分组列表（书架/分类/标签值） ---------- */
.group-list { display: flex; flex-direction: column; gap: 10px; }
.group-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; transition: transform .12s;
}
.group-item:active { transform: translateY(1px); }
.group-main { flex: 1; min-width: 0; }
.group-name { font-family: var(--font-serif); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-bar { height: 6px; background: var(--surface-2); border-radius: 999px; margin-top: 7px; overflow: hidden; }
.group-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 999px; }
.group-count { font-family: var(--font-serif); font-size: 19px; color: var(--accent-deep); flex: none; min-width: 28px; text-align: right; }

/* ---------- 横向占比条（统计页） ---------- */
.bar-list { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 1fr 2.2fr auto; align-items: center; gap: 10px; }
.bar-label { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--sage), var(--gold)); border-radius: 999px; }
.bar-val { font-size: 13px; color: var(--ink-soft); font-weight: 600; min-width: 28px; text-align: right; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(251,248,242,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav { display: flex; max-width: 720px; margin: 0 auto; }
.nav-item { flex: 1; padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-faint); font-size: 11px; }
.nav-item.active { color: var(--accent); }
.nav-item svg { stroke: currentColor; }

/* ---------- 手动录入入口 ---------- */
.manual-entry {
  background: linear-gradient(135deg, var(--accent-soft), #fff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.manual-entry-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.manual-entry-head strong { font-family: var(--font-serif); font-size: 16px; color: var(--accent-deep); }
.manual-entry-sub { font-size: 12px; color: var(--ink-soft); }

/* ---------- 封面：拍照 / 选图 ---------- */
.cover-actions { display: flex; gap: 10px; margin: 10px 0 2px; }
.cover-actions .btn { flex: 1; }

/* ---------- 拍照添加封面浮层 ---------- */
.cam-capture {
  position: relative; background: #15110E; border-radius: var(--radius);
  overflow: hidden; min-height: 320px; display: flex; align-items: center; justify-content: center;
}
.cam-capture video, .cam-capture img { width: 100%; max-height: 62vh; object-fit: contain; background: #15110E; display: block; }
.cam-capture img { display: none; }
.cam-cap-status {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: #fff;
  font-size: 13px; padding: 6px 12px; background: rgba(0,0,0,.45); margin: 0 16px;
  border-radius: 10px; backdrop-filter: blur(4px);
}
.cam-cap-actions { display: flex; gap: 10px; margin-top: 14px; }
.cam-cap-actions .btn { flex: 1; }
.cam-cap-actions .btn:disabled { opacity: .5; }

/* ---------- 科研文库（首页入口卡） ---------- */
.stats .stat-card[data-sub="topic"] {
  background-image: url('/images/research-library-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #7a4e6d;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}
.stat-card[data-sub="topic"] .stat-home-ico {
  display: none; /* 背景图已含主题，隐藏图标避免冲突 */
}
.stat-card[data-sub="topic"] .stat-home-title {
  display: none; /* 背景图已含“科研文库”书法字 */
}
.stat-home-ico { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.stat-home-title { font-family: var(--font-serif); font-weight: 700; letter-spacing: 2px; font-size: 17px; color: #fff; margin-top: 8px; text-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* ---------- 主题卡片墙 ---------- */
.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.topic-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column; gap: 8px; min-height: 104px; position: relative; overflow: hidden;
}
.topic-card:active { transform: translateY(1px); box-shadow: var(--shadow-lg); }
.topic-card.new { align-items: center; justify-content: center; border-style: dashed; cursor: pointer; }
.topic-home-new { font-family: var(--font-serif); font-size: 15px; font-weight: 700; color: var(--accent); }
.topic-title { font-family: var(--font-serif); font-size: 16px; font-weight: 700; line-height: 1.35; color: var(--ink); }
.topic-problem {
  font-size: 13px; color: var(--ink-soft); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.topic-meta { display: flex; align-items: center; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.topic-progress {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: #fff;
  background: var(--ink-faint);
}
.topic-progress.p0 { background: #A89C8C; }
.topic-progress.p1 { background: var(--sage); }
.topic-progress.p2 { background: var(--gold); color: #4A3A12; }
.topic-progress.p3 { background: var(--accent); }
.topic-count { font-size: 12px; color: var(--ink-faint); }

/* ---------- 主题详情 ---------- */
.topic-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.topic-detail-title { font-family: var(--font-serif); font-size: 19px; font-weight: 700; line-height: 1.3; flex: 1; min-width: 0; }
.topic-field { margin-top: 12px; }
.topic-field-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 4px; }
.topic-field-val { font-size: 14px; line-height: 1.7; color: #3a342e; white-space: pre-wrap; }

/* 文献列表 */
.topic-book-list { display: flex; flex-direction: column; gap: 10px; }
.topic-book-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; transition: transform .1s;
}
.topic-book-row:active { transform: translateY(1px); }
.tb-info { flex: 1; min-width: 0; }
.tb-title { font-family: var(--font-serif); font-size: 15px; font-weight: 600; line-height: 1.3; }
.tb-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.tb-note { font-size: 12px; color: var(--ink-faint); margin-top: 4px; line-height: 1.5; }
.tb-anno, .tb-rm { padding: 7px 12px; font-size: 13px; flex: none; }

/* 打点时间线 */
.anno-list { display: flex; flex-direction: column; gap: 10px; }
.anno-item {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 13px; box-shadow: var(--shadow); transition: transform .1s;
}
.anno-item:active { transform: translateY(1px); }
.anno-item.flagged { border-left-color: var(--danger); }
.anno-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.anno-book { font-family: var(--font-serif); font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; min-width: 0; }
.anno-page { font-size: 12px; color: var(--accent-deep); font-weight: 600; background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; }
.anno-title { margin: 7px 0 0; font-family: var(--font-serif); font-size: 15px; font-weight: 700; color: var(--accent-deep); line-height: 1.5; white-space: pre-wrap; }
.anno-flag { font-size: 11px; font-weight: 600; color: var(--danger); background: #F6E0DF; padding: 1px 8px; border-radius: 999px; }
.anno-quote {
  margin: 8px 0 0; padding: 8px 11px; background: var(--surface-2); border-radius: 10px;
  font-size: 13.5px; line-height: 1.7; color: #4a423a; white-space: pre-wrap;
  border-left: 3px solid var(--gold);
}
.anno-comment { margin: 8px 0 0; font-size: 14px; line-height: 1.7; color: #3a342e; white-space: pre-wrap; }

/* 文献 / 打点弹窗中的小元素 */
.anno-book-ref {
  background: var(--accent-soft); border-radius: 10px; padding: 9px 12px;
  font-size: 13.5px; color: var(--accent-deep); font-weight: 600; line-height: 1.5;
}
.book-pick-results { margin-top: 10px; max-height: 46vh; overflow-y: auto; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); margin-top: 10px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

/* 加载失败兜底 */
.error-box {
  margin: 18vh auto 0; max-width: 420px; padding: 28px 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 6px 24px rgba(120, 90, 60, 0.08);
}
.error-ico { font-size: 40px; line-height: 1; }
.error-title { margin: 12px 0 6px; font-size: 17px; font-weight: 700; color: var(--ink); }
.error-msg {
  margin: 0 0 18px; font-size: 13px; color: var(--ink-soft); line-height: 1.6; word-break: break-word;
  background: var(--surface-2); border-radius: 10px; padding: 10px 12px; text-align: left;
}

/* 我的书架：分类标签栏 + 层展开 */
/* 我的书架：纵向标签栏（每行一个分类）+ 点击展开下拉层菜单（手风琴，仅一个展开） */
.cat-rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cat-row {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer;
  border-bottom: 1px solid var(--line); background: var(--surface); transition: background .15s ease;
}
.cat-row:hover { background: var(--surface-2); }
.cat-row.open { background: var(--accent-soft); }
.cat-row-name { flex: 1; font-size: 15px; font-weight: 600; color: var(--ink); }
.cat-row-count { font-size: 13px; color: var(--ink-faint); }
.cat-row-chev { font-size: 13px; color: var(--ink-faint); transition: transform .2s ease; }
.cat-row.open .cat-row-chev { transform: rotate(180deg); color: var(--accent-deep); }
.cat-dropdown { display: none; padding: 14px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cat-dropdown.open { display: block; animation: panelIn .18s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.layer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.layer-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 6px; text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center;
}
.layer-btn:active { transform: translateY(1px); background: var(--accent-soft); }
.layer-code { font-family: var(--font-serif); font-size: 18px; font-weight: 700; color: var(--accent-deep); line-height: 1.1; }
.layer-ce { font-size: 12px; color: var(--ink-faint); }

/* ---------- 录入去重提示（独立 overlay，盖在录入表单之上） ---------- */
#dup-overlay { z-index: 90; }
.dup-modal { max-width: 420px; }
.dup-modal .modal-head h3 { color: var(--accent-deep); }
.dup-body { display: flex; gap: 14px; align-items: flex-start; margin: 4px 0 2px; }
.dup-cover {
  width: 76px; height: 104px; object-fit: cover; border-radius: var(--radius-sm);
  background: var(--surface-2); box-shadow: var(--shadow); flex: 0 0 auto;
}
.dup-info { flex: 1; min-width: 0; }
.dup-title { font-family: var(--font-serif); font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.35; }
.dup-sub { font-size: 13px; color: var(--ink-soft); margin-top: 5px; word-break: break-all; }
.dup-tip { color: var(--ink-soft); font-size: 13px; line-height: 1.65; margin: 10px 2px 14px; }

/* ---------- 全局检索结果（文库 / 打点）---------- */
.search-group { display: flex; flex-direction: column; gap: 10px; margin: 4px 2px 6px; }
.search-topic, .search-anno {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 13px; box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s;
}
.search-topic:active, .search-anno:active { transform: translateY(1px); }
.search-topic { border-left-color: var(--gold); }
.st-title { font-family: var(--font-serif); font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.5; }
.st-sub { margin-top: 6px; font-size: 13px; color: var(--ink-soft); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sa-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sa-book { font-family: var(--font-serif); font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; min-width: 0; }
.sa-page { font-size: 12px; color: var(--accent-deep); font-weight: 600; background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; }
.sa-title { margin: 7px 0 0; font-family: var(--font-serif); font-size: 14.5px; font-weight: 700; color: var(--accent-deep); line-height: 1.5; }
.sa-quote {
  margin: 8px 0 0; padding: 8px 11px; background: var(--surface-2); border-radius: 10px;
  font-size: 13.5px; line-height: 1.7; color: #4a423a; white-space: pre-wrap; border-left: 3px solid var(--gold);
}
.sa-comment { margin: 8px 0 0; font-size: 14px; line-height: 1.7; color: #3a342e; white-space: pre-wrap; }
mark { background: #FFE9A8; color: inherit; padding: 0 1px; border-radius: 3px; }

/* ===================== 标签索引 · 新版 ===================== */
/* 自定义标签 chips（①）：紧凑、自动宽度、按册排序 */
.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-family: var(--font-sans); font-size: 13px; color: var(--ink-soft);
  cursor: pointer; white-space: nowrap; transition: transform .1s, border-color .1s, background .1s;
}
.tag-chip:active { transform: translateY(1px); border-color: var(--accent); background: var(--accent-soft); }
.tag-chip .c { font-family: var(--font-serif); font-weight: 700; font-size: 14px; color: var(--accent-deep); }

/* 板块小标题（标题 + 查看全部按钮）② ③ ⑤ */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 12px; }
.section-head .t { font-family: var(--font-serif); font-size: 17px; font-weight: 700; }
.see-all {
  font-family: var(--font-sans); font-size: 13px; color: var(--accent); background: none;
  border: 1px solid var(--accent); border-radius: 999px; padding: 4px 13px; cursor: pointer;
}
.see-all:active { filter: brightness(.95); }

/* 出版社 LOGO 网格（一行 4 个）② */
.pub-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.pub-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: transform .1s;
}
.pub-card:active { transform: translateY(1px); }
.pub-logo {
  width: 54px; height: 54px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 700; font-size: 21px; color: #fff; overflow: hidden;
}
/* 真实 LOGO 图：白底承载，加载失败回退色块 */
.pub-logo-img-wrap { position: relative; padding: 0; }
.pub-logo-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pub-logo-fb {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 700; font-size: 21px; color: #fff;
}
.pub-logo-img-wrap.no-logo .pub-logo-fb { display: flex; }
.pub-name { font-family: var(--font-sans); font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.pub-count { font-family: var(--font-serif); font-size: 13px; color: var(--accent-deep); font-weight: 700; }

/* 丛书卡片（含封面横排）③ ④ */
.series-grid { display: flex; flex-direction: column; gap: 14px; }
.series-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  padding: 12px; cursor: pointer; transition: transform .1s;
}
.series-card:active { transform: translateY(1px); }
.series-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.series-name { font-family: var(--font-serif); font-size: 15px; font-weight: 600; color: var(--ink); }
.series-count { font-family: var(--font-serif); font-size: 14px; color: var(--accent-deep); font-weight: 700; }
.series-covers { display: flex; gap: 5px; }
/* 每个丛书固定 6 个等宽槽位；有封面显示封面，无封面留空（不拉伸、不塌缩） */
.series-covers .cover-slot { flex: 1 1 0; min-width: 0; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 5px; background: var(--surface-2); }
.series-covers .cover-empty { background: transparent; border: 1px dashed var(--line); }

