/* 听书架 — 微信读书风格,移动端优先 */
:root {
  --bg: #faf8f5;
  --bg-elev: #ffffff;
  --fg: #1a1a1a;
  --fg-sub: #6b6b6b;
  --fg-mute: #999;
  --accent: #1a1a1a;
  --line: #ececec;
  --shadow: 0 4px 16px rgba(0,0,0,0.04);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}
[data-theme="dark"] {
  --bg: #121212;
  --bg-elev: #1e1e1e;
  --fg: #e8e8e8;
  --fg-sub: #a0a0a0;
  --fg-mute: #6a6a6a;
  --accent: #e8e8e8;
  --line: #2a2a2a;
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --bg-elev: #1e1e1e; --fg: #e8e8e8;
    --fg-sub: #a0a0a0; --fg-mute: #6a6a6a; --accent: #e8e8e8;
    --line: #2a2a2a; --shadow: 0 4px 16px rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 16px; line-height: 1.6;
  overscroll-behavior-y: none;
}
button { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
input { font: inherit; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { flex: 1; margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.5px; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--fg);
}
.iconbtn:active { background: var(--line); }
.iconbtn.back { font-size: 28px; line-height: 1; }

/* 主视图 */
.view { padding: 16px 16px 120px; min-height: calc(100vh - 60px); }

/* 搜索框 */
.search-bar { margin-bottom: 14px; }
.search-bar input {
  width: 100%; box-sizing: border-box;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px;
  font-size: 15px; color: var(--fg); box-shadow: var(--shadow);
  -webkit-appearance: none; appearance: none;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-bar input::placeholder { color: var(--fg-mute); }

/* 书架 */
.shelf {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.book-card {
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
  text-align: left;
  width: 100%;
}
.book-cover {
  aspect-ratio: 3/4;
  border-radius: 8px;
  background: linear-gradient(135deg, #d4a574 0%, #8b6f47 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; color: #fff;
  position: relative; overflow: hidden;
}
.book-cover .cover-title {
  position: absolute; inset: 0; padding: 12px;
  display: flex; align-items: flex-start; justify-content: flex-start;
  font-size: 15px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  line-height: 1.3;
}
.book-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.book-author { font-size: 12px; color: var(--fg-sub); }
.book-progress {
  font-size: 11px; color: var(--fg-mute);
  display: flex; align-items: center; gap: 6px;
}
.book-progress .bar { flex: 1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.book-progress .bar i { display: block; height: 100%; background: var(--accent); }

.empty {
  text-align: center; padding: 80px 20px;
  color: var(--fg-mute);
}
.empty h3 { color: var(--fg-sub); margin-bottom: 8px; }
.empty p { font-size: 14px; }

/* 单本书详情 */
.detail-hero {
  display: flex; gap: 16px; margin-bottom: 20px;
}
.detail-hero .book-cover { width: 110px; flex-shrink: 0; aspect-ratio: 3/4; }
.detail-meta { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.detail-meta h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.detail-meta .author { color: var(--fg-sub); font-size: 14px; }
.detail-meta .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.detail-meta .tag {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--line); color: var(--fg-sub);
}
.summary { color: var(--fg-sub); font-size: 14px; line-height: 1.7; margin: 16px 0 20px; }

.edition-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
  background: var(--bg-elev); padding: 4px; border-radius: 12px;
  box-shadow: var(--shadow);
}
.edition-tab {
  flex: 1; padding: 10px; border-radius: 8px;
  font-size: 14px; color: var(--fg-sub);
  text-align: center;
}
.edition-tab.active { background: var(--accent); color: var(--bg); font-weight: 600; }

.chapter-list { display: flex; flex-direction: column; gap: 2px; }
.chapter-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px; border-radius: 10px;
  width: 100%; text-align: left;
}
.chapter-item:active { background: var(--bg-elev); }
.chapter-item .num { color: var(--fg-mute); font-size: 13px; min-width: 28px; }
.chapter-item .ti { flex: 1; font-size: 15px; }
.chapter-item .dur { color: var(--fg-mute); font-size: 12px; }
.chapter-item.playing { background: var(--bg-elev); }
.chapter-item.playing .ti { color: var(--accent); font-weight: 600; }
.chapter-item.playing .num::before { content: "▶ "; color: var(--accent); }

/* 迷你播放条 */
.mini-player {
  position: fixed; left: 0; right: 0;
  bottom: var(--safe-bot); z-index: 20;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}
.mp-cover {
  width: 44px; height: 44px; border-radius: 8px;
  background: linear-gradient(135deg, #d4a574, #8b6f47);
  flex-shrink: 0;
}
.mp-info { flex: 1; min-width: 0; }
.mp-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-sub {
  font-size: 12px; color: var(--fg-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--fg);
}
.mp-btn.play { font-size: 22px; }
.mp-btn:active { background: var(--line); }

/* 全屏播放器 */
.full-player {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 8px) 20px calc(var(--safe-bot) + 20px);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.fp-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.fp-mode { flex: 1; text-align: center; font-size: 14px; color: var(--fg-sub); }
.fp-cover {
  width: min(72vw, 280px); aspect-ratio: 1;
  margin: 16px auto; border-radius: 20px;
  background: linear-gradient(135deg, #d4a574 0%, #8b6f47 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  position: relative; overflow: hidden;
}
.fp-cover-inner { font-size: 80px; color: rgba(255,255,255,0.7); }
.fp-title {
  text-align: center; margin: 12px 16px 4px;
  font-size: 18px; font-weight: 600; line-height: 1.3;
}
.fp-sub { text-align: center; color: var(--fg-sub); font-size: 13px; margin: 0 16px 20px; }
.fp-progress {
  display: flex; align-items: center; gap: 10px; margin: 16px 0;
}
.fp-progress input[type=range] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: var(--line); outline: none;
}
.fp-progress input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
}
.fp-time { font-size: 12px; color: var(--fg-sub); font-variant-numeric: tabular-nums; min-width: 44px; }
.fp-ctrls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.4fr 1fr 1fr 1fr;
  gap: 4px;
  align-items: center; margin-top: 12px;
}
.fp-ctrl {
  height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; border-radius: 14px;
  color: var(--fg);
}
.fp-ctrl:active { background: var(--bg-elev); }
.fp-ctrl.big {
  background: var(--accent); color: var(--bg);
  font-size: 22px; height: 64px;
}
.fp-ctrl.back15, .fp-ctrl.fwd15 { font-size: 13px; font-weight: 600; }
#fpRate { font-size: 14px; font-weight: 600; }
.fp-chapters {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg-elev);
  border-top-left-radius: 20px; border-top-right-radius: 20px;
  padding: 16px 16px calc(var(--safe-bot) + 16px);
  max-height: 70vh; overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
}
.fp-chapters h3 { margin: 4px 8px 12px; font-size: 16px; }
