/* ============================================================
   书房 · 阅读器样式
   移动优先；手机 / 平板 / 桌面自适应
   ============================================================ */

:root{
  --brand:#0F766E;
  --brand-deep:#134E4A;
  --ink:#1B1B1F;
  --ink-2:#6B6B76;
  --ink-3:#A0A0AC;
  --bg:#F7F5F2;
  --surface:#FFFFFF;
  --line:rgba(0,0,0,.07);
  --shadow-s:0 1px 2px rgba(20,24,28,.06);
  --shadow-m:0 6px 20px rgba(20,24,28,.10);
  --shadow-l:0 14px 44px rgba(20,24,28,.18);
  --radius:14px;
  --sat:env(safe-area-inset-top,0px);
  --sab:env(safe-area-inset-bottom,0px);
  --ease:cubic-bezier(.22,.61,.36,1);
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}

/* hidden 属性必须压倒一切 display 声明 */
[hidden]{display:none !important}

html,body{
  margin:0;padding:0;height:100%;overflow:hidden;
  background:var(--bg);color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","HarmonyOS Sans SC","Noto Sans SC","Microsoft YaHei",sans-serif;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior:none;
}

button{font-family:inherit;border:0;background:none;color:inherit;cursor:pointer;padding:0}
img{display:block;max-width:100%}

.view{
  position:fixed;inset:0;
  display:flex;flex-direction:column;
  opacity:0;pointer-events:none;
  transition:opacity .22s var(--ease);
}
.view.active{opacity:1;pointer-events:auto}

/* ============ 书架 ============ */
.shelf-header{
  flex:none;
  padding:calc(var(--sat) + 14px) 20px 0;
  background:var(--bg);
}
.shelf-title-row{
  display:flex;align-items:center;justify-content:space-between;
  height:44px;
}
.shelf-title-row h1{
  margin:0;font-size:26px;font-weight:700;letter-spacing:-.4px;
}
.header-actions{display:flex;gap:2px}
.icon-btn{
  width:40px;height:40px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:var(--ink-2);
  transition:background .16s;
}
.icon-btn:active{background:rgba(0,0,0,.06)}

.search-bar{
  height:0;overflow:hidden;
  transition:height .22s var(--ease),margin .22s var(--ease);
}
.search-bar.open{height:46px;margin-top:8px}
.search-field{position:relative}
.search-bar input{
  width:100%;height:40px;border-radius:11px;border:none;
  background:rgba(120,120,135,.10);
  padding:0 38px 0 14px;font-size:15px;color:var(--ink);
  outline:none;
  -webkit-appearance:none;appearance:none;
}
.search-bar input::placeholder{color:var(--ink-3)}
.search-bar input::-webkit-search-cancel-button{display:none}
.search-clear{
  position:absolute;right:6px;top:50%;transform:translateY(-50%);
  width:30px;height:30px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:var(--ink-3);
  transition:background .15s;
}
.search-clear:active{background:rgba(0,0,0,.06)}

/* 分类筛选条：横向滚动，左右留出内边距，滚动时不贴边 */
.cat-bar{
  margin:0 -16px 4px;
  position:relative;
}
.cat-scroll{
  display:flex;gap:8px;
  padding:2px 16px 12px;
  overflow-x:auto;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
}
.cat-scroll::-webkit-scrollbar{display:none}
.cat-chip{
  flex:none;
  height:31px;padding:0 13px;border-radius:16px;
  display:inline-flex;align-items:center;gap:5px;
  font-size:13.5px;color:var(--ink-2);line-height:1;
  background:rgba(120,120,135,.10);
  white-space:nowrap;
  transition:background .16s var(--ease),color .16s var(--ease),transform .12s var(--ease);
}
.cat-chip:active{transform:scale(.96)}
.cat-chip em{
  font-style:normal;font-size:11.5px;opacity:.62;
  font-variant-numeric:tabular-nums;
}
.cat-chip.on{
  background:var(--brand);color:#fff;font-weight:600;
}
.cat-chip.on em{opacity:.78}

.shelf-scroll{
  flex:1;overflow-y:auto;overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  padding:0 16px;
  scrollbar-width:none;
}
.shelf-scroll::-webkit-scrollbar{display:none}

/* 继续阅读卡 */
.continue-card{
  margin:14px 0 6px;
  border-radius:16px;
  background:linear-gradient(135deg,#0F766E 0%,#134E4A 100%);
  padding:16px;
  box-shadow:0 8px 24px rgba(15,118,110,.24);
  cursor:pointer;
  transition:transform .18s var(--ease);
}
.continue-card:active{transform:scale(.985)}
.continue-inner{display:flex;gap:14px;align-items:center}
.continue-cover{
  width:54px;height:81px;border-radius:6px;object-fit:cover;
  background:rgba(255,255,255,.14);
  box-shadow:0 4px 12px rgba(0,0,0,.28);
  flex:none;
}
.continue-meta{flex:1;min-width:0}
.continue-label{
  font-size:11px;letter-spacing:1.4px;color:rgba(255,255,255,.62);
  font-weight:600;text-transform:uppercase;
}
.continue-title{
  margin:5px 0 3px;font-size:16.5px;font-weight:600;color:#fff;
  line-height:22px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.continue-sub{
  margin:0 0 10px;font-size:12.5px;color:rgba(255,255,255,.66);
  line-height:17px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.continue-progress{
  height:3px;border-radius:2px;background:rgba(255,255,255,.22);overflow:hidden;
}
.continue-progress i{
  display:block;height:100%;border-radius:2px;
  background:rgba(255,255,255,.92);
  transition:width .4s var(--ease);
}

.shelf-stat{
  font-size:12.5px;color:var(--ink-3);
  padding:18px 4px 12px;letter-spacing:.2px;
}

/* 书墙 */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(96px,1fr));
  gap:20px 16px;
}
@media(min-width:560px){ .grid{grid-template-columns:repeat(auto-fill,minmax(116px,1fr));gap:26px 22px} }
@media(min-width:900px){ .grid{grid-template-columns:repeat(auto-fill,minmax(134px,1fr));gap:30px 26px} }

.book{
  position:relative;
  display:flex;flex-direction:column;
  cursor:pointer;
  animation:bookIn .3s var(--ease) both;
}
@keyframes bookIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

.book-cover-wrap{
  position:relative;
  width:100%;aspect-ratio:2/3;
  border-radius:7px;overflow:hidden;
  background:#E7E4DE;
  box-shadow:0 2px 6px rgba(20,24,28,.13),0 1px 2px rgba(20,24,28,.08);
  transition:transform .2s var(--ease),box-shadow .2s var(--ease);
}
.book:active .book-cover-wrap{transform:scale(.96)}
.book-cover-wrap img{width:100%;height:100%;object-fit:cover}

/* 无封面兜底：生成的书名卡 */
.cover-fallback{
  position:absolute;inset:0;
  display:flex;flex-direction:column;justify-content:space-between;
  padding:12px 9px;
  background:linear-gradient(160deg,#37556B,#22333F);
}
.cover-fallback span{
  font-size:13px;line-height:1.35;font-weight:600;color:#fff;
  display:-webkit-box;-webkit-line-clamp:6;-webkit-box-orient:vertical;
  overflow:hidden;word-break:break-word;
}
.cover-fallback em{
  font-style:normal;font-size:9.5px;color:rgba(255,255,255,.55);
  letter-spacing:.4px;
}

.book-finished{
  position:absolute;top:6px;right:6px;
  background:rgba(15,118,110,.94);color:#fff;
  font-size:9.5px;padding:2px 6px;border-radius:5px;
  letter-spacing:.3px;font-weight:600;
  backdrop-filter:blur(4px);
}
.book-title{
  margin:9px 1px 0;font-size:12.5px;line-height:1.35;font-weight:500;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
  overflow:hidden;word-break:break-word;
}
.book-author{
  margin:3px 1px 0;font-size:11px;color:var(--ink-3);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* 空态 */
.empty{
  display:flex;flex-direction:column;align-items:center;
  padding:56px 20px;color:var(--ink-3);text-align:center;
}
.empty-title{margin:16px 0 6px;font-size:15.5px;color:var(--ink-2);font-weight:600}
.empty-sub{margin:0 0 22px;font-size:13px;line-height:1.6;max-width:280px}
.btn-primary{
  background:var(--brand);color:#fff;
  padding:11px 26px;border-radius:11px;
  font-size:14.5px;font-weight:600;
  box-shadow:0 4px 14px rgba(15,118,110,.28);
}
.btn-primary:active{transform:scale(.97)}

.shelf-bottom-space{height:110px}

/* 悬浮导入 */
.fab{
  position:fixed;
  right:20px;bottom:calc(var(--sab) + 22px);
  width:52px;height:52px;border-radius:50%;
  background:var(--brand);color:#fff;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 6px 20px rgba(15,118,110,.38);
  transition:transform .18s var(--ease);
  z-index:20;
}
.fab:active{transform:scale(.92)}

/* ============ 阅读器 ============ */
#reader-view{background:#fff}

.reader-topbar{
  position:absolute;top:0;left:0;right:0;z-index:30;
  height:calc(var(--sat) + 54px);
  padding:var(--sat) 8px 0;
  display:flex;align-items:center;gap:4px;
  background:rgba(255,255,255,.94);
  backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);
  border-bottom:.5px solid var(--line);
  transform:translateY(-100%);
  transition:transform .26s var(--ease);
}
.reader-topbar.show{transform:none}
.topbar-title{
  flex:1;text-align:center;
  font-size:14.5px;font-weight:600;
  line-height:20px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  padding:0 6px;
}

/* 阅读区：靠四个方向的 CSS 变量收缩到页边距以内。
   边距通过容器尺寸实现，而不是给 body 加 padding —— 后者会打乱
   epub.js 的列宽计算，导致第二列从右侧露出来 */
.reader-stage{
  position:absolute;
  top:var(--spt, 18px);
  bottom:var(--spb, 34px);
  left:var(--spx, 18px);
  right:var(--spx, 18px);
  overflow:hidden;
}
.reader-stage iframe{
  border:0;display:block;
}

/* PDF：交给浏览器原生阅读器，顶栏常驻便于返回 */
#pdf-frame{
  position:absolute;
  top:calc(var(--sat) + 54px);
  left:0;right:0;bottom:0;
  border:0;background:#fff;
  color-scheme:light;
  z-index:14;
}

/* 点击热区：叠在书页之上，坐标由父页面掌控，不受 epub.js 多列预排影响 */
.tap-zones{
  position:absolute;inset:0;z-index:12;
  display:flex;
  transition:opacity .2s;
}
.tap-zones .tz{height:100%}
.tap-zones .tz[data-zone="left"]{width:30%}
.tap-zones .tz[data-zone="center"]{width:40%}
.tap-zones .tz[data-zone="right"]{width:30%}
.tap-zones.off{pointer-events:none}
.tap-zones.hidden-zones{opacity:0;pointer-events:none}

.reader-loading{
  position:absolute;inset:0;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:14px;font-size:13px;color:var(--ink-3);
  background:#fff;z-index:25;
  transition:opacity .3s;
}
.reader-loading.hide{opacity:0;pointer-events:none}
.reader-loading i{
  width:26px;height:26px;border-radius:50%;
  border:2.4px solid rgba(15,118,110,.18);
  border-top-color:var(--brand);
  animation:spin .8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

.reader-footer{
  position:absolute;left:0;right:0;
  bottom:calc(var(--sab) + 14px);
  display:flex;justify-content:space-between;
  padding:0 30px;
  font-size:11px;color:var(--ink-3);
  letter-spacing:.2px;
  pointer-events:none;
  transition:opacity .2s;
  opacity:.85;
}
.reader-footer.hide{opacity:0}

.reader-toolbar{
  position:absolute;left:0;right:0;bottom:0;z-index:30;
  background:rgba(255,255,255,.96);
  backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);
  border-top:.5px solid var(--line);
  padding:16px 20px calc(var(--sab) + 12px);
  transform:translateY(100%);
  transition:transform .28s var(--ease);
}
.reader-toolbar.show{transform:none}

.progress-row{margin-bottom:14px}
#progress-slider{
  -webkit-appearance:none;appearance:none;
  width:100%;height:22px;background:transparent;outline:none;
}
#progress-slider::-webkit-slider-runnable-track{
  height:3px;border-radius:2px;background:rgba(120,120,135,.2);
}
#progress-slider::-webkit-slider-thumb{
  -webkit-appearance:none;appearance:none;
  width:14px;height:14px;border-radius:50%;
  background:var(--brand);margin-top:-5.5px;
  box-shadow:0 1px 5px rgba(15,118,110,.45);
}
#progress-slider::-moz-range-track{height:3px;border-radius:2px;background:rgba(120,120,135,.2)}
#progress-slider::-moz-range-thumb{width:14px;height:14px;border:0;border-radius:50%;background:var(--brand)}

.toolbar-row{display:flex;justify-content:space-around}
.tool-btn{
  display:flex;flex-direction:column;align-items:center;gap:5px;
  padding:6px 11px;border-radius:10px;
  font-size:11.5px;color:var(--ink-2);
  transition:background .16s;
}
.tool-btn:active{background:rgba(0,0,0,.05)}
.tool-btn.on{color:var(--brand)}
.tool-ico{
  font-size:17px;line-height:1;height:20px;
  display:flex;align-items:center;
}

/* 抽屉 */
.drawer{
  position:absolute;left:0;right:0;bottom:0;z-index:40;
  background:#fff;
  border-radius:18px 18px 0 0;
  box-shadow:var(--shadow-l);
  transform:translateY(102%);
  transition:transform .3s var(--ease);
  display:flex;flex-direction:column;
  max-height:78%;
  padding-bottom:var(--sab);
}
.drawer.show{transform:none}
.drawer-head{
  flex:none;
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 18px 10px;
  border-bottom:.5px solid var(--line);
}
.drawer-head h3{margin:0;font-size:15.5px;font-weight:600}
.drawer-body{
  overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:8px 0 16px;
  flex:1;
  scrollbar-width:thin;
}

.drawer-mask{
  position:absolute;inset:0;z-index:35;
  background:rgba(0,0,0,.28);
  opacity:0;pointer-events:none;
  transition:opacity .28s;
}
.drawer-mask.show{opacity:1;pointer-events:auto}

/* 目录项 */
.toc-item{
  display:flex;align-items:baseline;gap:10px;
  padding:13px 20px;
  font-size:14px;line-height:1.45;
  color:var(--ink);
  border-left:2.5px solid transparent;
}
.toc-item:active{background:rgba(0,0,0,.04)}
.toc-item.active{
  color:var(--brand);font-weight:600;
  border-left-color:var(--brand);
  background:rgba(15,118,110,.05);
}
.toc-item.sub{padding-left:36px;font-size:13.2px;color:var(--ink-2)}
.toc-item .toc-idx{
  font-size:11px;color:var(--ink-3);min-width:20px;flex:none;
  font-variant-numeric:tabular-nums;
}

/* 抽屉内页签：目录 / 书签 */
.drawer-tabs{display:flex;gap:18px;align-items:center}
.drawer-tab{
  font-size:15.5px;font-weight:600;color:var(--ink-3);
  padding:2px 0 6px;position:relative;
}
.drawer-tab.on{color:var(--ink)}
.drawer-tab.on::after{
  content:'';position:absolute;left:0;right:0;bottom:0;height:2px;
  border-radius:2px;background:var(--brand);
}
.drawer-tab em{
  font-style:normal;font-size:11px;color:var(--brand);
  margin-left:3px;font-weight:600;
}

/* 书签项 */
.bm-item{
  display:flex;align-items:flex-start;gap:12px;
  padding:14px 20px;
  border-bottom:.5px solid var(--line);
}
.bm-item:active{background:rgba(0,0,0,.04)}
.bm-main{flex:1;min-width:0}
.bm-head{
  display:flex;align-items:baseline;gap:8px;
  font-size:13px;color:var(--brand);font-weight:600;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.bm-pct{font-size:11.5px;color:var(--ink-3);font-weight:400;flex:none}
.bm-text{
  margin:5px 0 0;font-size:13.2px;line-height:1.55;color:var(--ink-2);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.bm-time{margin:5px 0 0;font-size:11px;color:var(--ink-3)}
.bm-del{
  flex:none;width:30px;height:30px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:var(--ink-3);font-size:15px;
}
.bm-del:active{background:rgba(0,0,0,.06)}
.bm-empty{
  padding:44px 28px;text-align:center;
  font-size:13.5px;color:var(--ink-3);line-height:1.7;
}
.bm-empty b{display:block;color:var(--ink-2);font-size:14.5px;margin-bottom:6px;font-weight:600}

/* 阅读记录 */
.history-panel{
  max-height:88vh;height:88vh;
  display:flex;flex-direction:column;
  padding:0;
}
.history-head{
  flex:none;display:flex;align-items:center;justify-content:space-between;
  padding:16px 18px 12px;
  border-bottom:.5px solid var(--line);
}
.history-head h3{margin:0;font-size:16px;font-weight:700}
.history-body{
  flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:0 0 calc(var(--sab) + 24px);
  scrollbar-width:none;
}
.history-body::-webkit-scrollbar{display:none}

.hist-stats{
  display:flex;gap:10px;
  padding:16px 18px 6px;
}
.hist-stat{
  flex:1;background:rgba(15,118,110,.07);
  border-radius:12px;padding:12px 10px;text-align:center;
}
.hist-stat b{
  display:block;font-size:17px;font-weight:700;color:var(--brand-deep);
  font-variant-numeric:tabular-nums;letter-spacing:-.3px;
}
.hist-stat span{display:block;margin-top:3px;font-size:11px;color:var(--ink-2)}

.hist-sec-title{
  padding:18px 20px 8px;
  font-size:12px;color:var(--ink-3);letter-spacing:.4px;
  display:flex;align-items:center;justify-content:space-between;
}
.hist-sec-title button{font-size:12px;color:var(--ink-3)}

.hist-book{
  display:flex;gap:12px;align-items:center;
  padding:11px 20px;
}
.hist-book:active{background:rgba(0,0,0,.04)}
.hist-cover{
  width:40px;height:56px;border-radius:5px;flex:none;
  object-fit:cover;background:rgba(120,120,135,.14);
  box-shadow:0 2px 6px rgba(20,24,28,.16);
}
.hist-meta{flex:1;min-width:0}
.hist-title{
  font-size:14.5px;font-weight:600;color:var(--ink);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.hist-sub{
  margin-top:4px;font-size:11.5px;color:var(--ink-3);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.hist-bar{
  margin-top:7px;height:3px;border-radius:2px;
  background:rgba(120,120,135,.16);overflow:hidden;
}
.hist-bar i{display:block;height:100%;border-radius:2px;background:var(--brand)}
.hist-go{
  flex:none;padding:7px 13px;border-radius:16px;
  background:rgba(15,118,110,.1);color:var(--brand);
  font-size:12.5px;font-weight:600;
}

.hist-item{
  display:flex;gap:12px;padding:10px 20px;
  font-size:13px;
}
.hist-dot{
  flex:none;width:7px;height:7px;border-radius:50%;
  background:var(--brand);opacity:.55;margin-top:7px;
}
.hist-line{flex:1;min-width:0}
.hist-line b{font-weight:600;color:var(--ink)}
.hist-line em{
  font-style:normal;color:var(--ink-3);font-size:11.5px;margin-left:6px;
  font-variant-numeric:tabular-nums;
}
.hist-line p{margin:3px 0 0;font-size:11.5px;color:var(--ink-3)}

.hist-empty{padding:40px 28px;text-align:center;color:var(--ink-3);font-size:13px;line-height:1.7}

/* 样式面板 */
.panel-section{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 20px;
  border-bottom:.5px solid var(--line);
}
.panel-section:last-child{border-bottom:0}
.panel-label{font-size:14px;color:var(--ink-2);flex:none}
.stepper{
  display:flex;align-items:center;gap:2px;
  background:rgba(120,120,135,.09);border-radius:9px;
  padding:3px;
}
.stepper button{
  width:42px;height:32px;border-radius:7px;
  font-size:15px;color:var(--ink);font-weight:500;
}
.stepper button:active{background:rgba(0,0,0,.07)}
.stepper span{
  min-width:46px;text-align:center;font-size:14px;font-weight:600;
  font-variant-numeric:tabular-nums;
}
.chip-row{display:flex;gap:8px;flex-wrap:wrap}
.chip{
  padding:8px 15px;border-radius:9px;
  background:rgba(120,120,135,.09);
  font-size:13px;color:var(--ink-2);
  transition:all .16s;
}
.chip.on{background:var(--brand);color:#fff;font-weight:600}
.theme-row{display:flex;gap:12px}
.theme-dot{
  width:34px;height:34px;border-radius:50%;
  background:var(--dot-bg);
  border:1.5px solid rgba(0,0,0,.13);
  position:relative;
  transition:transform .16s;
}
.theme-dot::after{
  content:'A';position:absolute;inset:0;
  display:flex;align-items:center;justify-content:center;
  font-size:14px;color:var(--dot-fg);font-weight:600;
}
.theme-dot.on{
  border-color:var(--brand);
  box-shadow:0 0 0 2px rgba(15,118,110,.28);
  transform:scale(1.06);
}

/* 进度面板 */
.big-progress{display:flex;justify-content:center;padding:22px 0 8px}
.big-ring{
  width:112px;height:112px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:conic-gradient(var(--brand) 0deg, rgba(120,120,135,.14) 0deg);
  position:relative;
}
.big-ring::before{
  content:'';position:absolute;inset:9px;border-radius:50%;background:#fff;
}
.big-ring span{
  position:relative;font-size:23px;font-weight:700;
  color:var(--brand);font-variant-numeric:tabular-nums;
}
.progress-detail{
  text-align:center;font-size:13px;color:var(--ink-2);
  margin:4px 0 18px;line-height:1.6;
}

/* Toast */
.toast{
  position:fixed;left:50%;bottom:calc(var(--sab) + 90px);
  transform:translate(-50%,14px);
  background:rgba(28,28,32,.92);color:#fff;
  padding:11px 20px;border-radius:11px;
  font-size:13.5px;white-space:nowrap;
  opacity:0;pointer-events:none;
  transition:opacity .22s,transform .22s var(--ease);
  z-index:100;
  backdrop-filter:blur(10px);
  max-width:82vw;white-space:normal;text-align:center;line-height:1.5;
}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* 抽屉或面板打开时，toast 移到顶部，别压住列表 */
body.ui-modal .toast{bottom:auto;top:calc(var(--sat) + 62px);transform:translate(-50%,-12px)}
body.ui-modal .toast.show{transform:translate(-50%,0)}

/* 底部菜单 */
.sheet{
  position:fixed;inset:0;z-index:90;
  background:rgba(0,0,0,.32);
  display:flex;align-items:flex-end;
  opacity:0;pointer-events:none;
  transition:opacity .24s;
}
.sheet.show{opacity:1;pointer-events:auto}
.sheet-panel{
  width:100%;background:#fff;
  border-radius:18px 18px 0 0;
  padding:8px 0 calc(var(--sab) + 8px);
  transform:translateY(100%);
  transition:transform .28s var(--ease);
}
.sheet.show .sheet-panel{transform:none}
.sheet-title{
  text-align:center;font-size:12.5px;color:var(--ink-3);
  padding:12px 0 8px;letter-spacing:.4px;
}
.sheet-item{
  display:block;width:100%;text-align:center;
  padding:15px;font-size:15.5px;color:var(--ink);
  border-top:.5px solid var(--line);
}
.sheet-item:active{background:rgba(0,0,0,.04)}
.sheet-item.on{color:var(--brand);font-weight:600}
.sheet-cancel{
  display:block;width:100%;text-align:center;
  padding:15px;margin-top:8px;font-size:15.5px;
  color:var(--ink-2);
  border-top:8px solid rgba(0,0,0,.05);
}

/* 深色模式下的 UI 外壳（书页主题由 epub.js 控制） */
body.ui-dark{background:#111}
body.ui-dark .shelf-header,body.ui-dark .shelf-scroll{background:#141517}
body.ui-dark .shelf-title-row h1{color:#EDEDED}
body.ui-dark .icon-btn{color:#9A9AA2}
body.ui-dark .book-title{color:#DCDCDC}
body.ui-dark .book-author{color:#7A7A82}
body.ui-dark .reader-topbar,
body.ui-dark .reader-toolbar{background:rgba(22,23,26,.96);border-color:rgba(255,255,255,.09)}
body.ui-dark .topbar-title{color:#E4E4E4}
body.ui-dark .drawer{background:#1A1B1E}
body.ui-dark .drawer-head h3{color:#E8E8E8}
body.ui-dark .panel-section{border-color:rgba(255,255,255,.09)}
body.ui-dark .panel-label{color:#A8A8B0}
body.ui-dark .stepper{background:rgba(255,255,255,.09)}
body.ui-dark .stepper button{color:#E0E0E0}
body.ui-dark .chip{background:rgba(255,255,255,.09);color:#B4B4BC}
body.ui-dark .toc-item{color:#D8D8D8}
body.ui-dark .toc-item.active{color:#4FD1C5;background:rgba(79,209,197,.1)}
body.ui-dark .big-ring::before{background:#1A1B1E}
body.ui-dark .big-ring span{color:#4FD1C5}
body.ui-dark .progress-detail{color:#9A9AA2}
body.ui-dark .sheet-panel{background:#1A1B1E}
body.ui-dark .sheet-item{color:#E0E0E0;border-color:rgba(255,255,255,.09)}
body.ui-dark .sheet-cancel{color:#9A9AA2;border-color:rgba(255,255,255,.07)}
body.ui-dark .cat-chip{background:rgba(255,255,255,.09);color:#B4B4BC}
body.ui-dark .cat-chip.on{background:#0F766E;color:#fff}
body.ui-dark .search-bar input{background:rgba(255,255,255,.09);color:#E8E8E8}
body.ui-dark .search-bar input::placeholder{color:#6E6E78}
body.ui-dark .shelf-stat{color:#7A7A82}
body.ui-dark .grid-empty-tip{color:#8A8A94}
body.ui-dark .grid-empty-tip span{color:#6A6A72}

/* 新增面板的深色适配 */
body.ui-dark .drawer-tab{color:#7A7A82}
body.ui-dark .drawer-tab.on{color:#EDEDED}
body.ui-dark .bm-item{border-color:rgba(255,255,255,.08)}
body.ui-dark .bm-text{color:#A9A9B0}
body.ui-dark .bm-time,body.ui-dark .bm-pct{color:#75757D}
body.ui-dark .bm-empty{color:#75757D}
body.ui-dark .bm-empty b{color:#C9C9CF}
body.ui-dark .history-head{border-color:rgba(255,255,255,.08)}
body.ui-dark .history-head h3{color:#EDEDED}
body.ui-dark .hist-stat{background:rgba(79,209,197,.1)}
body.ui-dark .hist-stat b{color:#5FD8CB}
body.ui-dark .hist-stat span{color:#8E8E96}
body.ui-dark .hist-title{color:#E0E0E0}
body.ui-dark .hist-sub,body.ui-dark .hist-line p{color:#75757D}
body.ui-dark .hist-item{color:#C2C2C8}
body.ui-dark .hist-line b{color:#E0E0E0}
body.ui-dark .hist-line em{color:#75757D}
body.ui-dark .hist-empty{color:#75757D}
body.ui-dark .hist-go{background:rgba(79,209,197,.14);color:#5FD8CB}
body.ui-dark .bm-del:active{background:rgba(255,255,255,.1)}

/* 搜索无结果 */
.grid-empty-tip{
  grid-column:1/-1;text-align:center;
  color:var(--ink-3);font-size:14px;line-height:2;
  padding:40px 12px;
}
.grid-empty-tip span{font-size:12.5px;color:var(--ink-3);opacity:.72}

/* ============================================================
   离线下载
   ============================================================ */

/* 断网提示条 */
.net-tip{
  flex:none;
  display:flex;align-items:center;justify-content:center;gap:6px;
  margin:9px 20px 0;padding:7px 12px;
  background:rgba(176,118,28,.11);color:#8A5A12;
  border-radius:9px;font-size:11.5px;letter-spacing:.1px;
  animation:netIn .28s var(--ease) both;
}
@keyframes netIn{from{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:none}}

/* 统计条右侧的离线入口 */
.shelf-stat-row{
  display:flex;align-items:flex-end;justify-content:space-between;gap:10px;
}
.shelf-stat-row .shelf-stat{padding-right:0}
.stat-offline{
  flex:none;display:inline-flex;align-items:center;gap:4px;
  margin-bottom:11px;padding:5px 10px 5px 8px;
  border-radius:100px;background:rgba(15,118,110,.075);
  color:var(--brand);font-size:11.5px;line-height:1;
  transition:transform .16s var(--ease),background .2s;
}
.stat-offline b{font-weight:600;font-variant-numeric:tabular-nums;letter-spacing:.2px}
.stat-offline.all-done{background:rgba(15,118,110,.15)}
.stat-offline:active{transform:scale(.94)}

/* 书卡右下角的下载状态角标 */
.book-offline{
  position:absolute;right:5px;bottom:5px;
  width:18px;height:18px;border-radius:100%;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 1px 4px rgba(10,14,18,.28);
  transition:opacity .2s;
}
.book-offline.on{background:rgba(15,118,110,.95);color:#fff}
.book-offline.off{
  background:rgba(26,30,34,.55);color:rgba(255,255,255,.95);
  -webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);
  box-shadow:0 1px 3px rgba(10,14,18,.18);
}

/* 离线管理面板 */
.offline-sheet{z-index:95}
.offline-panel{
  max-height:84vh;display:flex;flex-direction:column;
  padding-top:0;
}
.offline-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:15px 16px 5px;flex:none;
}
.offline-head h3{margin:0 0 0 2px;font-size:16.5px;font-weight:650;letter-spacing:-.2px}
.offline-hint{
  margin:0 18px 12px;font-size:11.8px;line-height:1.6;color:var(--ink-3);
  flex:none;
}
.offline-summary{
  flex:none;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  margin:0 18px 4px;padding:10px 13px;border-radius:11px;
  background:rgba(15,118,110,.06);
}
.offline-summary .os-num{
  font-size:13px;color:var(--brand-deep);font-weight:500;
  font-variant-numeric:tabular-nums;
}
.offline-summary .os-num b{font-size:16px;font-weight:700;margin-right:1px}
.offline-summary .os-space{
  display:block;margin-top:3px;font-size:11px;color:var(--ink-3);
}
.mini-btn{
  flex:none;padding:7px 13px;border-radius:100px;
  background:var(--brand);color:#fff;font-size:12px;font-weight:600;
  letter-spacing:.2px;transition:opacity .2s,transform .16s var(--ease);
}
.mini-btn:active{transform:scale(.95)}
.mini-btn[disabled]{opacity:.45}

.offline-list{
  flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:6px 12px calc(var(--sab) + 10px);
}
.offline-item{
  display:flex;align-items:center;gap:11px;
  padding:10px 6px;border-bottom:.5px solid var(--line);
}
.offline-item:last-child{border-bottom:0}
.offline-cv{
  width:33px;height:47px;flex:none;border-radius:4px;overflow:hidden;
  background:#E7E4DE;
  box-shadow:0 0 0 .5px rgba(20,24,28,.10),0 1px 3px rgba(20,24,28,.14);
}
.offline-cv img{width:100%;height:100%;object-fit:cover}
.offline-cv .cover-fallback{padding:5px 4px;border-radius:4px}
.offline-cv .cover-fallback span{font-size:7.5px;-webkit-line-clamp:4}
.offline-cv .cover-fallback em{display:none}
.offline-meta{flex:1;min-width:0}
.offline-name{
  font-size:13.5px;font-weight:500;line-height:1.35;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.offline-sub{
  margin-top:3px;font-size:11px;color:var(--ink-3);
  display:flex;align-items:center;gap:6px;white-space:nowrap;
}
.offline-sub em{font-style:normal;color:rgba(15,118,110,.9);font-weight:500}
.offline-prog{
  height:3px;border-radius:2px;background:rgba(0,0,0,.07);
  margin-top:6px;overflow:hidden;
}
.offline-prog i{
  display:block;height:100%;width:0;border-radius:2px;
  background:var(--brand);transition:width .25s var(--ease);
}
.offline-btn{
  flex:none;padding:6.5px 13px;border-radius:100px;
  font-size:12px;font-weight:600;letter-spacing:.2px;
  background:rgba(15,118,110,.09);color:var(--brand);
  transition:transform .16s var(--ease),background .2s;
}
.offline-btn:active{transform:scale(.94)}
.offline-btn.done{background:rgba(0,0,0,.045);color:var(--ink-2);font-weight:500}
.offline-btn[disabled]{opacity:.45}
.offline-empty{
  padding:34px 20px;text-align:center;font-size:12.5px;color:var(--ink-3);
  line-height:1.7;
}

/* 书卡长按菜单：带图标的那几项改为左对齐行 */
.sheet-item.with-ico{
  display:flex;align-items:center;justify-content:center;gap:8px;
}
.sheet-item.with-ico svg{opacity:.72;flex:none}
.sheet-item.danger{color:#C0392B}
.sheet-title.strong{
  font-size:14px;color:var(--ink);font-weight:600;letter-spacing:0;
  padding:16px 20px 10px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* 深色 */
body.ui-dark .net-tip{background:rgba(200,142,52,.16);color:#E0AE6A}
body.ui-dark .stat-offline{background:rgba(79,209,197,.13);color:#4FD1C5}
body.ui-dark .stat-offline.all-done{background:rgba(79,209,197,.22)}
body.ui-dark .offline-head h3{color:#EDEDED}
body.ui-dark .offline-hint{color:#8A8A94}
body.ui-dark .offline-summary{background:rgba(79,209,197,.1)}
body.ui-dark .offline-summary .os-num{color:#7FDCD2}
body.ui-dark .offline-summary .os-space{color:#75757D}
body.ui-dark .offline-item{border-color:rgba(255,255,255,.08)}
body.ui-dark .offline-name{color:#DCDCDC}
body.ui-dark .offline-sub{color:#75757D}
body.ui-dark .offline-prog{background:rgba(255,255,255,.1)}
body.ui-dark .offline-btn{background:rgba(79,209,197,.13);color:#4FD1C5}
body.ui-dark .offline-btn.done{background:rgba(255,255,255,.07);color:#9A9AA2}
body.ui-dark .offline-empty{color:#75757D}
body.ui-dark .sheet-title.strong{color:#EDEDED}
body.ui-dark .sheet-item.danger{color:#E8776A}
