/* 三段阅读器 · Apple Books 观感
   设计 token 集中在 :root，四主题只改色板，不改结构。 */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-song: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", serif;

  --r-cover: 6px;
  --r-btn: 8px;
  --r-panel: 12px;

  --dur-page: 220ms;
  --dur-panel: 200ms;
  --ease: cubic-bezier(.4, 0, .2, 1);

  --hl-yellow: #FFD60A;
  --hl-pink: #FF6482;
  --hl-purple: #BF5AF2;
  --hl-blue: #0A84FF;
  --hl-green: #30D158;

  --mx: 7%;
  --fs: 19px;
  --lh: 1.7;
  --font-body: var(--font-sans);
}

/* ---------- 四主题 ---------- */
html[data-theme="white"] {
  --bg: #FFFFFF; --fg: #1C1C1E; --muted: #8E8E93;
  --line: rgba(0, 0, 0, .09); --line-strong: rgba(0, 0, 0, .16);
  --card: #FFFFFF; --hover: rgba(0, 0, 0, .045);
  --chrome: rgba(250, 250, 250, .86);
  --glass: rgba(255, 255, 255, .28); --glass-line: rgba(255, 255, 255, .62);
  --reader-bg: #FFFFFF; --reader-fg: #1C1C1E; --reader-muted: #8E8E93;
  --seg-track: rgba(118, 118, 128, .12); --seg-thumb: #FFFFFF;
  --shadow-cover: 0 1px 4px rgba(0, 0, 0, .18);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, .16);
  --placeholder: linear-gradient(155deg, #F2F2F4, #E4E4E8);
  color-scheme: light;
}
html[data-theme="sepia"] {
  --bg: #F8F1E3; --fg: #5B4636; --muted: #9A8B78;
  --line: rgba(91, 70, 54, .14); --line-strong: rgba(91, 70, 54, .26);
  --card: #FBF6EC; --hover: rgba(91, 70, 54, .06);
  --chrome: rgba(248, 241, 227, .86);
  --glass: rgba(252, 246, 236, .28); --glass-line: rgba(255, 255, 255, .62);
  --reader-bg: #F8F1E3; --reader-fg: #5B4636; --reader-muted: #9A8B78;
  --seg-track: rgba(91, 70, 54, .12); --seg-thumb: #FDF9F1;
  --shadow-cover: 0 1px 4px rgba(70, 50, 30, .2);
  --shadow-float: 0 8px 32px rgba(70, 50, 30, .18);
  --placeholder: linear-gradient(155deg, #F3EADA, #E6D9C2);
  color-scheme: light;
}
html[data-theme="gray"] {
  --bg: #E5E5EA; --fg: #2C2C2E; --muted: #7C7C80;
  --line: rgba(0, 0, 0, .1); --line-strong: rgba(0, 0, 0, .18);
  --card: #EDEDF0; --hover: rgba(0, 0, 0, .05);
  --chrome: rgba(229, 229, 234, .88);
  --glass: rgba(238, 238, 243, .30); --glass-line: rgba(255, 255, 255, .66);
  --reader-bg: #E5E5EA; --reader-fg: #2C2C2E; --reader-muted: #7C7C80;
  --seg-track: rgba(0, 0, 0, .1); --seg-thumb: #F7F7F9;
  --shadow-cover: 0 1px 4px rgba(0, 0, 0, .16);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, .18);
  --placeholder: linear-gradient(155deg, #E9E9EE, #D8D8DE);
  color-scheme: light;
}
html[data-theme="night"] {
  --bg: #000000; --fg: #C7C7CC; --muted: #636366;
  --line: rgba(255, 255, 255, .12); --line-strong: rgba(255, 255, 255, .22);
  --card: #111112; --hover: rgba(255, 255, 255, .07);
  --chrome: rgba(18, 18, 18, .84);
  --glass: rgba(28, 28, 30, .32); --glass-line: rgba(255, 255, 255, .22);
  --reader-bg: #000000; --reader-fg: #C7C7CC; --reader-muted: #636366;
  --seg-track: rgba(255, 255, 255, .12); --seg-thumb: #3A3A3C;
  --shadow-cover: 0 1px 4px rgba(0, 0, 0, .8);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, .7);
  --placeholder: linear-gradient(155deg, #1C1C1E, #101011);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow-x: hidden; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input { font: inherit; color: inherit; }

.view[hidden], [hidden] { display: none !important; }

.icon { width: 22px; height: 22px; display: block; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 18px; height: 18px; }

/* =====================================================================
   书架
   ===================================================================== */
#library {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.lib-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(24px) brightness(1.02);
  -webkit-backdrop-filter: saturate(180%) blur(24px) brightness(1.02);
  border-bottom: .5px solid var(--glass-line);
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 40px) 10px;
}

.lib-title-row { display: flex; align-items: center; gap: 12px; }
.lib-title { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; margin: 0; flex: 1; }
.lib-actions { display: flex; align-items: center; gap: 4px; }
.lib-actions button {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--fg);
  transition: background var(--dur-panel) var(--ease);
}
.lib-actions button:hover { background: var(--hover); }

.searchbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.searchbar input {
  flex: 1; height: 40px; padding: 0 16px;
  background: var(--hover); border: 0; border-radius: 999px;
  font-size: 16px; outline: none;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar button { font-size: 15px; color: var(--muted); padding: 8px; }

/* 书架顶部三个关键数字（RIC-3565）：只给读数，不铺大屏 */
.stat-strip {
  display: flex; align-items: center; gap: clamp(18px, 4vw, 34px);
  margin-top: 14px; flex-wrap: wrap;
}
.strip-item { display: flex; flex-direction: column; gap: 1px; }
.strip-item b {
  font-size: 21px; font-weight: 600; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; color: var(--fg);
}
.strip-item span { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.strip-due {
  margin-left: auto; padding: 6px 12px; border: 0; border-radius: 999px;
  background: var(--seg-track); color: var(--fg); font-size: 12px; cursor: pointer;
}
.strip-due::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #FF9F0A; margin-right: 6px; vertical-align: 1px;
}
.strip-due:hover { background: var(--hover); }

.lib-body { flex: 1; padding: 4px clamp(18px, 4vw, 40px) 40px; }.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 26px 0 14px;
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 12px; }
.section-head h2 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; text-transform: none; color: var(--fg); margin: 0; }

/* 最近阅读：横向轨道 */
.rail {
  display: flex; gap: 18px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity;
  padding: 4px 0 8px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .book { flex: 0 0 120px; scroll-snap-align: start; }

/* 网格 */
.cat-bar{display:flex;flex-wrap:wrap;gap:8px;margin:2px 0 16px}
.cat-chip{font:inherit;font-size:12.5px;line-height:1;padding:7px 12px;border-radius:999px;
  border:1px solid var(--line);background:var(--card-bg,transparent);color:var(--fg-dim,#6b7280);
  cursor:pointer;transition:border-color .15s,color .15s,background .15s;white-space:nowrap}
.cat-chip:hover{border-color:var(--accent);color:var(--fg)}
.cat-chip.on{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}
.cat-chip i{font-style:normal;opacity:.62;margin-left:5px;font-variant-numeric:tabular-nums}
.cat-chip.on i{opacity:.85}
@media (max-width:700px){
  .cat-bar{gap:6px;margin-bottom:12px;overflow-x:auto;flex-wrap:nowrap;
    -webkit-overflow-scrolling:touch;padding-bottom:2px}
  .cat-chip{font-size:12px;padding:6px 10px;flex:0 0 auto}
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 24px 16px;
}

.book {
  display: flex; flex-direction: column; gap: 8px;
  text-align: left; min-width: 0;
  position: relative;
}
.book-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-cover);
  overflow: hidden;
  background: var(--placeholder);
  box-shadow: var(--shadow-cover);
  transition: transform var(--dur-panel) var(--ease);
}
.book:hover .book-cover { transform: translateY(-2px); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-cover .fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  font-family: var(--font-song);
  font-size: 13px; line-height: 1.35; color: rgba(0, 0, 0, .45);
  text-align: center;
  overflow: hidden;
  background: var(--placeholder);
}
html[data-theme="night"] .book-cover .fallback { color: rgba(255, 255, 255, .38); }
.book-progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(0, 0, 0, .12);
}
.book-progress > i { display: block; height: 100%; background: var(--hl-blue); border-radius: 0 2px 2px 0; }
.book-title {
  font-size: 13px; font-weight: 600; line-height: 1.35; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.book-author { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state { color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center; }

/* 底部 Tab（移动端） */
/* 底部导航：悬浮毛玻璃胶囊 */
.tabbar {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(430px, calc(100% - 32px));
  height: 62px; padding: 7px; gap: 2px;
  z-index: 30; display: none;
  border-radius: 999px;
  background: var(--glass);
  /* Apple 材质的三个要素：强模糊 + 提亮 + 高饱和 */
  backdrop-filter: saturate(185%) blur(36px) brightness(1.04);
  -webkit-backdrop-filter: saturate(185%) blur(36px) brightness(1.04);
  border: .5px solid var(--glass-line);
  box-shadow:
    0 12px 34px rgba(0, 0, 0, .18),
    0 2px 8px rgba(0, 0, 0, .06),
    inset 0 1px 0 rgba(255, 255, 255, .70),
    inset 0 -1px 0 rgba(0, 0, 0, .05);
  overflow: hidden;
}
/* 材质颗粒：苹果的毛玻璃有极细的噪声，纯色底会显得“塑料” */
.tabbar::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
/* 顶部一道极窄的镜面高光（Liquid Glass 的“边缘反光”） */
.tabbar::after {
  content: ""; position: absolute; left: 8%; right: 8%; top: 1px; height: 1px;
  border-radius: 999px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
}
html[data-theme="night"] .tabbar {
  box-shadow:
    0 12px 34px rgba(0, 0, 0, .65),
    0 2px 8px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .16),
    inset 0 -1px 0 rgba(0, 0, 0, .3);
}
html[data-theme="night"] .tabbar::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .22), transparent); }
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--muted);
  border-radius: 999px; padding: 4px 0 3px;
  transition: background var(--dur-panel, .16s) ease-out, color var(--dur-panel, .16s) ease-out;
  -webkit-tap-highlight-color: transparent;
}
.tabbar button.active {
  color: var(--hl-blue);
  background: rgba(10, 132, 255, .16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 1px 2px rgba(10, 132, 255, .18);
}
.tabbar button.active .icon { transform: scale(1.06); }
.tabbar button .icon { transition: transform 160ms cubic-bezier(.22, .9, .25, 1); }
html[data-theme="night"] .tabbar button.active {
  background: rgba(10, 132, 255, .26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 1px 2px rgba(0, 0, 0, .35);
}

@media (max-width: 700px) {
  .tabbar { display: flex; }
  /* 悬浮胶囊占位：列表底部多留 32px，避免最后一排被压住 */
  #library { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .lib-title { font-size: 30px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 20px 14px; }
  .rail .book { flex: 0 0 100px; }
}

/* =====================================================================
   阅读页
   ===================================================================== */
#reader {
  overscroll-behavior-x: contain;
  position: fixed; inset: 0;
  background: var(--reader-bg);
  color: var(--reader-fg);
  overflow: hidden;
  touch-action: pan-y;
}

/* 正文舞台：留白由 inset 控制，chrome 显隐不改变它 → 不重排 */
#read-stage iframe { background: var(--reader-bg); }
#read-stage {
  position: absolute;
  inset: max(56px, env(safe-area-inset-top)) var(--mx) max(56px, env(safe-area-inset-bottom));
  background: var(--reader-bg);
  transition: none;
}
#read-stage > iframe { border: 0; }

.pane {
  position: absolute; inset: 0;
  padding: max(56px, calc(env(safe-area-inset-top) + 8px)) var(--mx) max(64px, calc(env(safe-area-inset-bottom) + 16px));
  overflow-y: auto;
  background: var(--reader-bg);
  color: var(--reader-fg);
  z-index: 2;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease), visibility var(--dur-panel);
  -webkit-overflow-scrolling: touch;
}
.pane.on { opacity: 1; visibility: visible; pointer-events: auto; }

/* 顶栏 */
#topbar, #bottombar {
  position: absolute; left: 0; right: 0; z-index: 6;
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  transition: transform var(--dur-page) var(--ease), opacity var(--dur-page) var(--ease);
}
#topbar {
  top: 0; height: calc(44px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 6px;
  border-bottom: .5px solid var(--line);
  transform: translateY(0);
}
#bottombar {
  bottom: 0; height: calc(50px + env(safe-area-inset-bottom));
  padding: 0 16px env(safe-area-inset-bottom);
  border-top: .5px solid var(--line);
  display: flex; flex-direction: column; justify-content: center;
  transform: translateY(0);
}
#reader.chrome-hidden #topbar { transform: translateY(-100%); opacity: 0; }
#reader.chrome-hidden #bottombar { transform: translateY(100%); opacity: 0; }

/* 悬浮 Aa：只在工具栏收起时出现，直接唤起排版面板 */
#fab-type {
  position: absolute; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 7; width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(60, 60, 67, .42); color: #fff;
  font: 600 15px/1 -apple-system, "PingFang SC", sans-serif; letter-spacing: .5px;
  display: grid; place-items: center;
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  opacity: .72; transition: opacity .2s ease-out, transform .12s ease-out;
}
#fab-type:active { transform: scale(.94); opacity: 1; }
#reader:not(.chrome-hidden) #fab-type { opacity: 0; pointer-events: none; }
body.sheet-open #fab-type { opacity: 0; pointer-events: none; }
html[data-theme="night"] #fab-type { background: rgba(255, 255, 255, .20); color: #f2f2f7; }

.tb-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  transition: background var(--dur-panel) var(--ease);
}
.tb-btn:hover { background: var(--hover); }
.tb-btn.on { color: var(--hl-blue); }

/* 分段控件 */
.segmented {
  flex: 1; display: flex; align-items: center; justify-content: center;
  height: 30px;
  background: var(--seg-track);
  border-radius: 9px;
  padding: 2px;
  max-width: 260px;
  margin: 0 auto;
}
.segmented button {
  flex: 1; height: 26px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--reader-fg);
  opacity: .62;
  transition: opacity var(--dur-panel) var(--ease), background var(--dur-panel) var(--ease);
  white-space: nowrap;
}
.segmented button.active {
  background: var(--seg-thumb);
  opacity: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

/* 底栏 */
.bar-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--reader-muted);
  font-variant-numeric: tabular-nums;
}
.bar-row .pages { flex: 0 0 auto; letter-spacing: .02em; }
.bar-row .chapter { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .pct { flex: 0 0 auto; }
#progress-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; margin: 8px 0 0;
  background: var(--seg-track); border-radius: 2px; outline: none;
}
#progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--reader-fg); border: 2px solid var(--reader-bg);
  box-shadow: 0 0 0 .5px var(--line-strong);
  cursor: pointer;
}
#progress-slider::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--reader-bg);
  background: var(--reader-fg);
}

/* 选择浮动菜单 */
#sel-menu {
  position: absolute; z-index: 12;
  display: none; align-items: center; gap: 2px;
  padding: 6px;
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: .5px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-float);
}
#sel-menu.on { display: flex; }
#sel-menu button {
  padding: 7px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap;
}
#sel-menu button:hover { background: var(--hover); }
#sel-menu .swatches { display: flex; gap: 6px; padding: 0 6px; }
#sel-menu .sw {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--reader-bg);
  box-shadow: 0 0 0 .5px var(--line-strong);
}
#sel-menu .sep { width: .5px; height: 20px; background: var(--line); margin: 0 4px; }

/* 抽屉 */
.drawer {
  position: absolute; top: 0; bottom: 0; z-index: 9;
  width: min(320px, 84vw);
  background: var(--reader-bg);
  border-right: .5px solid var(--line);
  box-shadow: var(--shadow-float);
  transform: translateX(-102%);
  transition: transform var(--dur-panel) var(--ease);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.drawer.right { right: 0; left: auto; border-right: 0; border-left: .5px solid var(--line); transform: translateX(102%); }
.drawer.on { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 10px 18px;
  border-bottom: .5px solid var(--line);
  font-size: 15px; font-weight: 600;
}
.drawer-search { padding: 10px 14px; border-bottom: .5px solid var(--line); }
.drawer-search input {
  width: 100%; height: 34px; padding: 0 12px;
  background: var(--seg-track); border: 0; border-radius: 9px; outline: none; font-size: 14px;
}
.drawer-list { flex: 1; overflow-y: auto; padding: 6px 0 24px; }

.toc-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 18px 10px 18px;
  font-size: 14px; line-height: 1.4; text-align: left;
  color: var(--reader-fg); position: relative;
  border-bottom: .5px solid var(--line);
}
.toc-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item .pg { color: var(--reader-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.toc-item.current { font-weight: 600; }
.toc-item.current::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--hl-blue); border-radius: 0 2px 2px 0;
}
.toc-item.d1 { padding-left: 34px; }
.toc-item.d2 { padding-left: 50px; }
.toc-item.d3 { padding-left: 66px; }

/* Aa 面板 */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 11;
  background: color-mix(in srgb, var(--reader-bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: .5px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 8px 22px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(102%);
  transition: transform var(--dur-panel) var(--ease);
  box-shadow: var(--shadow-float);
}
.sheet.on { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 6px auto 14px; }
.sheet-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.sheet-row .k { width: 62px; flex: 0 0 auto; font-size: 12px; color: var(--reader-muted); }
.sheet-row .v { flex: 1; display: flex; gap: 8px; align-items: center; }
.chip-btn {
  min-width: 40px; height: 32px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; background: var(--seg-track);
  display: inline-flex; align-items: center; justify-content: center;
}
.chip-btn.active { background: var(--reader-fg); color: var(--reader-bg); }
.theme-dots { display: flex; gap: 12px; }
.theme-dot {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
}
.theme-dot.active { border-color: var(--hl-blue); border-width: 2px; }
.theme-dot.w { background: #fff; }
.theme-dot.s { background: #F8F1E3; }
.theme-dot.g { background: #E5E5EA; }
.theme-dot.n { background: #000; }
.font-slider { flex: 1; accent-color: var(--reader-fg); }
.fs-sample { width: 46px; text-align: right; font-variant-numeric: tabular-nums; color: var(--reader-muted); font-size: 12px; }

/* =====================================================================
   速览段
   ===================================================================== */
.seg-lead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 0 18px;
}
.seg-lead h2 { font-family: var(--font-body); font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -.005em; }
.seg-lead .meta { font-size: 12px; color: var(--reader-muted); }

.chapter-card {
  display: block; width: 100%; text-align: left;
  padding: 18px 0 20px;
  border-bottom: .5px solid var(--line);
}
.chapter-card:last-child { border-bottom: 0; }
.chapter-card h3 {
  font-family: var(--font-body);
  font-size: 16px; font-weight: 600; margin: 0 0 8px; line-height: 1.4;
  display: flex; align-items: baseline; gap: 8px;
}
.chapter-card h3 .no { font-size: 11px; color: var(--reader-muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.chapter-card p.sum {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 15px; line-height: 1.72; color: var(--reader-fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chapter-card .key {
  margin: 0; padding-left: 12px; border-left: 2px solid var(--line-strong);
  font-family: var(--font-song);
  font-size: 14px; line-height: 1.7; color: var(--reader-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 骨架屏 shimmer */
.sk { position: relative; overflow: hidden; background: var(--seg-track); border-radius: 4px; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: shimmer 1.4s infinite;
}
html[data-theme="night"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 0 0 9px; }
.sk-line.t { height: 16px; width: 46%; margin-bottom: 14px; }
.sk-line.w80 { width: 80%; } .sk-line.w60 { width: 60%; }

/* =====================================================================
   复盘段
   ===================================================================== */
.memo-strip {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin: 0 0 20px;
  background: var(--hover); border-radius: var(--r-panel);
  font-size: 13px; line-height: 1.6;
}
.memo-strip .t { flex: 1; color: var(--reader-fg); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.memo-strip button { color: var(--hl-blue); font-size: 13px; white-space: nowrap; }

.memo-group { margin: 0 0 26px; }
.memo-group > h3 {
  font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--reader-muted); margin: 0 0 12px;
}
.memo-card {
  display: block; width: 100%; text-align: left;
  padding: 12px 0 14px 14px;
  border-left: 3px solid var(--hl-yellow);
  border-bottom: .5px solid var(--line);
  margin-bottom: 2px;
}
.memo-card.c-pink { border-left-color: var(--hl-pink); }
.memo-card.c-purple { border-left-color: var(--hl-purple); }
.memo-card.c-blue { border-left-color: var(--hl-blue); }
.memo-card.c-green { border-left-color: var(--hl-green); }
.memo-card .quote {
  font-family: var(--font-body); font-size: 15px; line-height: 1.72; margin: 0 0 6px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.memo-card .note {
  font-size: 13px; line-height: 1.6; color: var(--reader-fg);
  margin: 6px 0 0; opacity: .9;
}
.memo-card .note::before { content: "✎ "; color: var(--reader-muted); }
.memo-card .time { font-size: 11px; color: var(--reader-muted); margin-top: 8px; display: block; }

.memo-empty { text-align: center; color: var(--reader-muted); padding: 56px 10px; font-size: 14px; line-height: 1.9; }
.memo-empty .icon { margin: 0 auto 14px; width: 28px; height: 28px; opacity: .5; }

/* =====================================================================
   弹层 / 其它
   ===================================================================== */
#drop-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#drop-overlay.on { display: flex; }
#drop-overlay .zone {
  width: min(640px, 82vw); height: min(360px, 60vh);
  border: 4px dashed rgba(255, 255, 255, .9);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 500; letter-spacing: .02em;
}

.dialog-mask {
  position: fixed; inset: 0; z-index: 70;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}
.dialog-mask.on { display: flex; }
.dialog {
  width: min(400px, 100%);
  background: var(--bg); color: var(--fg);
  border-radius: 16px; padding: 22px 20px 16px;
  box-shadow: var(--shadow-float);
}
.dialog h3 { margin: 0 0 8px; font-size: 17px; }
.dialog p { margin: 0 0 18px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.dialog .actions { display: flex; flex-direction: column; gap: 8px; }
.dialog .actions button {
  height: 44px; border-radius: 10px; font-size: 15px;
  background: var(--hover);
}
.dialog .actions button.primary { background: var(--hl-blue); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 80;
  max-width: min(420px, 86vw);
  padding: 10px 16px; border-radius: 10px;
  background: rgba(30, 30, 32, .92); color: #fff;
  font-size: 13px; line-height: 1.5;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease), transform var(--dur-panel) var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 导入进度卡片 */
.import-list { display: flex; flex-direction: column; gap: 8px; }
.import-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--card); border: .5px solid var(--line);
  font-size: 13px;
}
.import-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-row .st { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.import-row .bar { width: 88px; height: 3px; border-radius: 2px; background: var(--seg-track); overflow: hidden; }
.import-row .bar > i { display: block; height: 100%; background: var(--hl-blue); transition: width 120ms linear; }
.import-row.failed .st { color: #FF453A; }
.import-row button.retry { font-size: 12px; color: var(--hl-blue); }

.book.new { animation: cardIn 200ms var(--ease); }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 小屏阅读排版 */
@media (max-width: 700px) {
  #read-stage { inset: max(52px, calc(env(safe-area-inset-top) + 6px)) var(--mx) max(58px, calc(env(safe-area-inset-bottom) + 10px)); }
  .segmented { max-width: 200px; }
  .segmented button { font-size: 12px; }
  .pane { padding-left: 5%; padding-right: 5%; }
}


/* ======================================================================
   三端自适应（PC / 平板 / 手机）
   PC     ≥1180  双页并排（epub.js spread:auto），7% 页边距
   平板   >700   单页，6% 页边距，工具栏略收
   手机   ≤700   单页，5% 页边距，压缩上下 inset 争取正文高度
   ====================================================================== */

/* 平板：介于 PC 与手机之间，单页但保留舒展留白 */
@media (max-width: 1180px) {
  :root { --mx: 6%; }
  #read-stage {
    inset: max(54px, calc(env(safe-area-inset-top) + 4px))
           var(--mx)
           max(56px, calc(env(safe-area-inset-bottom) + 8px));
  }
  .segmented { max-width: 260px; }
  /* 双页转单页时，书脊阴影会变成一条突兀的竖线，隐藏掉 */
  #read-stage .epub-container { box-shadow: none !important; }
}

/* 手机：优先正文高度，收紧上下留白 */
@media (max-width: 700px) {
  :root { --mx: 5%; }
  #read-stage {
    inset: max(50px, calc(env(safe-area-inset-top) + 4px))
           var(--mx)
           max(54px, calc(env(safe-area-inset-bottom) + 6px));
  }
  .segmented { max-width: 190px; }
  .segmented button { font-size: 12px; padding: 5px 8px; }
  #topbar, #bottombar { height: 48px; }
  .tb-btn { width: 38px; height: 38px; }
}

/* PC 双页：中间留一道窄书脊，读起来知道是两页 */
@media (min-width: 1181px) {
  #read-stage .epub-container { column-gap: 0; }
}

/* 横屏手机：高度受限，进一步压 inset，避免正文只剩几行 */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  #read-stage {
    inset: max(44px, calc(env(safe-area-inset-top) + 2px))
           6%
           max(46px, calc(env(safe-area-inset-bottom) + 2px));
  }
  #topbar, #bottombar { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 高亮（注入 iframe 内的样式由 JS 写入，这里给页面内高亮预览用） */
mark.hl { border-radius: 2px; }

/* =====================================================================
   统计页
   ===================================================================== */
/* 统计页 v2：hero + 7 天柱状 + 指标 + 最近在读 */
.stats-wrap { display: flex; flex-direction: column; gap: 16px; }
.stats-sub { font-size: 12px; color: var(--muted); }

.hero {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 20px; border-radius: var(--r-panel);
  border: .5px solid var(--line);
  background: linear-gradient(155deg, rgba(10, 132, 255, .12), rgba(10, 132, 255, .02)), var(--card);
}
.hero-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hero-main .k { font-size: 12px; color: var(--muted); }
.hero-main b { font-size: 32px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-main .sub { font-size: 12px; color: var(--muted); }
.hero-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 8px; min-width: 104px; }
.streak {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255, 159, 10, .14); color: #b26a00; font-size: 12px;
}
html[data-theme="night"] .streak { background: rgba(255, 159, 10, .18); color: #ffb340; }
.streak b { font-size: 15px; font-variant-numeric: tabular-nums; }
.streak .fl { font-size: 13px; }
.hero-goal { width: 100%; height: 4px; border-radius: 2px; background: rgba(128, 128, 128, .18); overflow: hidden; }
.hero-goal i { display: block; height: 100%; background: var(--hl-blue); border-radius: 2px; }
.hero-goal-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

.card {
  background: var(--card); border: .5px solid var(--line);
  border-radius: var(--r-panel); padding: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head span { font-size: 12px; color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 104px; }
.bar-day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar-day .v { font-size: 12px; color: transparent; white-space: nowrap; }
.bar-day.is-today .v { color: var(--muted); }
.bar-day i {
  width: 100%; max-width: 30px; min-height: 3px;
  border-radius: 6px 6px 3px 3px;
  background: var(--hl-blue); opacity: .22;
}
.bar-day.is-today i { opacity: 1; box-shadow: 0 4px 12px rgba(10, 132, 255, .28); }
.bar-day .d { font-size: 12px; color: var(--muted); }
.bar-day.is-today .d { color: var(--hl-blue); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tile {
  background: var(--card); border: .5px solid var(--line); border-radius: var(--r-md);
  padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tile b { font-size: 20px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.accent-warn b { color: #ff9f0a; }

.reading-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.read-item { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.read-item:active { opacity: .72; }
.cov {
  width: 36px; height: 48px; flex: 0 0 auto; border-radius: 4px;
  object-fit: cover; background: var(--placeholder);
}
.cov.ph { display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--muted); }
.read-item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.read-item .t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.read-item .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbar { height: 4px; border-radius: 2px; background: rgba(128, 128, 128, .18); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--hl-blue); border-radius: 2px; }
.pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

.stat-note { margin: 4px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted); }

/* =====================================================================
   添加书籍：托盘 / 重复弹窗
   ===================================================================== */
#import-tray {
  position: fixed; left: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 55;
  width: min(380px, calc(100vw - 36px));
  background: var(--card);
  border: .5px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-float);
  padding: 10px 12px 12px;
}
.tray-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; letter-spacing: .04em; color: var(--muted);
  padding: 2px 2px 8px;
}
.tray-head button { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.tray-head button:hover { background: var(--hover); }
.import-list { max-height: 190px; overflow-y: auto; }
.import-row + .import-row { margin-top: 6px; }

/* =====================================================================
   阅读页内浮层：高亮操作 / 更多菜单 / 笔记编辑器 / 载入遮罩
   ===================================================================== */
#hl-menu {
  position: absolute; left: 50%; bottom: calc(66px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 14;
  width: min(420px, calc(100vw - 28px));
  padding: 14px 16px 12px;
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: .5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-float);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease), transform var(--dur-panel) var(--ease), visibility var(--dur-panel);
}
#hl-menu.on { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
#hl-menu .hl-quote {
  margin: 0 0 12px; font-size: 13px; line-height: 1.65;
  color: var(--reader-muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#hl-menu .hl-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
#hl-menu .hl-actions > .swatches { display: flex; gap: 8px; padding: 0 6px 0 0; }
#hl-menu .sw,
#sel-menu .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--reader-bg); box-shadow: 0 0 0 .5px var(--line-strong); }
#hl-menu button[data-act] { padding: 7px 12px; border-radius: 8px; font-size: 13px; }
#hl-menu button[data-act]:hover { background: var(--hover); }
#hl-menu button.danger { color: #FF453A; }

#more-menu {
  position: absolute; z-index: 16;
  min-width: 168px; padding: 6px;
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: .5px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-float);
  display: none;
}
#more-menu.on { display: block; }
#more-menu button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 8px; font-size: 14px;
}
#more-menu button:hover { background: var(--hover); }

#note-editor textarea {
  width: 100%; margin: 0 0 14px;
  padding: 12px; border-radius: 10px;
  border: .5px solid var(--line);
  background: var(--card); color: var(--fg);
  font: inherit; font-size: 14px; line-height: 1.6;
  resize: vertical; outline: none;
}
#note-editor textarea:focus { border-color: var(--hl-blue); }
#note-editor p.quote {
  margin: 0 0 12px; padding-left: 10px; border-left: 3px solid var(--hl-yellow);
  font-size: 13px; line-height: 1.65; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}

#loading-mask {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: var(--reader-bg);
  color: var(--reader-muted); font-size: 13px; letter-spacing: .04em;
}
#loading-mask[hidden] { display: none !important; }
.loading-inner { display: flex; align-items: center; gap: 10px; }
.loading-inner i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); border-top-color: var(--reader-muted);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 载入失败：文字 + 重试按钮（别再让用户对着白屏） */
.loading-inner.load-error {
  flex-direction: column; gap: 14px; padding: 0 24px; text-align: center;
  color: var(--reader-fg); font-size: 14px; letter-spacing: 0;
}
.load-retry {
  min-width: 96px; height: 36px; padding: 0 18px; border-radius: 18px;
  border: 1px solid var(--line-strong); background: var(--hover);
  color: var(--reader-fg); font-size: 14px;
}
.load-retry:active { transform: scale(.97); }

/* 抽屉遮罩 */
.drawer-scrim {
  position: absolute; inset: 0; z-index: 8;
  background: rgba(0, 0, 0, .18);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease);
}
body.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
body:not(.drawer-open) .drawer-scrim { opacity: 0; pointer-events: none; }

.sheet-scrim {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(0, 0, 0, .12);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease);
}
body.sheet-open .sheet-scrim { opacity: 1; pointer-events: auto; }

@media (max-width: 700px) {
  .tb-btn { width: 34px; }
  .segmented { max-width: 176px; }
  #hl-menu { bottom: calc(58px + env(safe-area-inset-bottom)); }
}

/* 速览卡片：目录页标记 */
.chapter-card h3 .tag {
  font-size: 10px; font-weight: 500; letter-spacing: .04em;
  color: var(--reader-muted); border: .5px solid var(--line-strong);
  border-radius: 4px; padding: 1px 5px; align-self: center;
}


/* ---------- 添加到主屏幕（standalone）时的安全区修正 ----------
   主屏打开时网页铺到状态栏下面；如果 env() 取不到值，顶栏/正文会钻到灵动岛底下。
   这里给一个 52px 下限（14 Pro 灵动岛底部约 54，取 52 再加正文自身 18px 间距）。 */
body.standalone { --safe-top: max(env(safe-area-inset-top, 0px), 52px); }
body.standalone #read-stage {
  top: max(72px, calc(var(--safe-top) + 18px));
}
body.standalone .pane {
  padding-top: max(72px, calc(var(--safe-top) + 18px));
}
body.standalone #topbar {
  height: calc(48px + var(--safe-top));
  padding-top: var(--safe-top);
}
body.standalone #library {
  padding-top: var(--safe-top);
}
body.standalone #fab-type { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }

/* 悬浮 Aa：闲置 5 秒自动淡到几乎不可见，碰一下恢复 */
#fab-type.idle { opacity: .14; }
#reader.fab-off #fab-type { display: none; }

/* 「跟随系统」主题 chip（与四个色点并排） */
.theme-chip {
  height: 28px; padding: 0 10px; margin-right: 2px;
  border-radius: 999px; border: .5px solid var(--line);
  background: var(--hover); color: var(--muted);
  font-size: 12px; line-height: 1;
}
.theme-chip.active { background: var(--hl-blue); color: #fff; border-color: transparent; }


/* 格式筛选（EPUB / PDF）：比分类更高一层，用分段控件的样子 */
.fmt-bar {
  display: inline-flex; gap: 2px; padding: 3px; margin: 2px 0 10px;
  background: var(--seg-track); border-radius: 999px;
}
.fmt-chip {
  font: inherit; font-size: 12.5px; line-height: 1; padding: 7px 14px;
  border-radius: 999px; border: 0; background: transparent; color: var(--muted);
  transition: background 160ms ease, color 160ms ease;
}
.fmt-chip i {
  font-style: normal; opacity: .6; margin-left: 5px;
  font-variant-numeric: tabular-nums;
}
.fmt-chip.on {
  background: var(--seg-thumb); color: var(--fg); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
html[data-theme="night"] .fmt-chip.on { box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }

/* 封面角标：PDF 用强调色，EPUB 低调 */
.fmt-badge {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  font-size: 9.5px; line-height: 1; letter-spacing: .04em;
  padding: 3px 5px; border-radius: 5px;
  background: rgba(255, 255, 255, .82); color: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.fmt-badge.pdf { background: rgba(255, 149, 0, .92); color: #fff; }
html[data-theme="night"] .fmt-badge { background: rgba(0, 0, 0, .55); color: rgba(255, 255, 255, .7); }
html[data-theme="night"] .fmt-badge.pdf { background: rgba(255, 149, 0, .85); color: #1c1c1e; }


/* 底部胶囊导航：选中态「玻璃滑块 + 放大」 */
.tabbar { position: fixed; }          /* 保持原有定位 */
.tab-thumb {
  position: absolute; top: 7px; bottom: 7px; left: 7px; width: 0; z-index: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9),
              0 2px 10px rgba(0, 0, 0, .10);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  transition: transform 300ms cubic-bezier(.26, .9, .24, 1), width 300ms cubic-bezier(.26, .9, .24, 1);
  pointer-events: none;
}
html[data-theme="night"] .tab-thumb {
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 2px 12px rgba(0, 0, 0, .45);
}
.tabbar button { position: relative; z-index: 1; }
.tabbar button .icon {
  transition: transform 280ms cubic-bezier(.22, .9, .25, 1), color 200ms ease;
}
.tabbar button.active .icon { transform: scale(1.16) translateY(-1px); }
.tabbar button.active { color: var(--hl-blue); background: transparent; }
.tabbar button:active .icon { transform: scale(.92); }
@media (prefers-reduced-motion: reduce) {
  .tab-thumb, .tabbar button .icon { transition: none; }
}

/* 翻页接缝阴影（真实滚动时贴在移动边缘） */
#seam-shadow {
  position: absolute; top: 0; bottom: 0; width: 42px; z-index: 4;
  pointer-events: none; opacity: 0; transition: opacity 160ms ease-out;
    left: 0;
}

/* 复盘 · 复习卡片 */
.rv-card { margin-bottom: 12px; }
.rv-card .memo-card { width: 100%; }
.rv-card.rv-due .memo-card { box-shadow: inset 3px 0 0 var(--hl-blue); }
.rv-actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 6px;
}
.rv-actions button {
  font: inherit; font-size: 12px; line-height: 1; padding: 8px 0;
  border-radius: 8px; border: .5px solid var(--line);
  background: var(--hover); color: var(--muted);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.rv-actions button:active { transform: scale(.97); }
.rv-actions button[data-rv="good"] { color: var(--hl-blue); border-color: var(--hl-blue); }
.rv-actions button[data-rv="easy"] { color: #30a14e; border-color: #30a14e; }
.rv-actions button[data-rv="again"] { color: #d9534f; border-color: #d9534f; }
.memo-group h3 .rv-group-due { color: var(--hl-blue); }
