/* =====================================================================
   epub.css —— 内置 EPUB 阅读器（v1.9.19）
   ---------------------------------------------------------------------
   阅读区用接近纸张的底色，正文统一排版（见 preview/epub.js 注入的
   iframe 样式）。控件只在深色主题下换材质，不改变结构。
   ===================================================================== */
.ep {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--glass-line-soft);
}

/* ---------------- 顶栏 ---------------- */
.ep-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  background: var(--glass-modal);
  -webkit-backdrop-filter: var(--blur-float);
  backdrop-filter: var(--blur-float);
  border-bottom: 1px solid var(--glass-line-soft);
}

.ep-name {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep-btn {
  flex: 0 0 auto;
  height: 30px;
  min-width: 32px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ep-btn svg {
  width: 17px;
  height: 17px;
}

.ep-btn:active {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

/* ---------------- 目录 ---------------- */
.ep-toc {
  position: absolute;
  top: 45px;
  left: 0;
  right: 0;
  z-index: 4;
  max-height: 58vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  /* 目录必须挡住下面的正文：半透明玻璃在长文场景里会透出字，读目录很累 */
  background: rgba(252, 252, 253, .985);
  -webkit-backdrop-filter: var(--blur-modal);
  backdrop-filter: var(--blur-modal);
  border-bottom: 1px solid var(--glass-line-soft);
  box-shadow: 0 12px 26px rgba(18, 24, 48, .12);
}

.ep-toc[hidden] {
  display: none;
}

.ep-toc-i {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.ep-toc-i.on {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.ep-toc-i:active {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

/* ---------------- 正文 ---------------- */
.ep-body {
  padding: 0;
  background: var(--paper-2);
  min-height: 180px;
}

.ep-frame {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.ep-loading,
.ep-err {
  padding: 34px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.ep-err {
  color: var(--danger);
  line-height: 1.6;
}

/* ---------------- 底栏 ---------------- */
.ep-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--glass-line-soft);
  background: var(--glass-modal);
}

.ep-nav {
  flex: 1;
  height: 36px;
  border: 0;
  border-radius: 11px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.ep-nav:disabled {
  opacity: .38;
}

.ep-nav:active:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 12%, transparent);
}

.ep-pos {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* 深色下纸张底色压到比卡片更深一档，长时间读不刺眼 */
html[data-theme="dark"] .ep,
html[data-theme="dark"] .ep-body {
  background: #0E1117;
}

html[data-theme="dark"] .ep-bar,
html[data-theme="dark"] .ep-foot,
html[data-theme="dark"] .ep-toc {
  background: rgba(23, 26, 34, .94);
}

html[data-theme="dark"] .ep-toc {
  background: rgba(23, 26, 34, .985);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
}
