/* —— Immersive reader —— */
.reader {
  --r-bg: #f3efe6;
  --r-fg: #1c1915;
  --r-muted: #6b645a;
  --r-chrome: rgba(243, 239, 230, 0.96);
  --r-line: rgba(28, 25, 21, 0.1);
  --r-font: 1.125rem;
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: 0fr 1fr auto 0fr;
  background: var(--r-bg);
  color: var(--r-fg);
  overflow: hidden;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.reader[data-theme="paper"] {
  --r-bg: #f3efe6;
  --r-fg: #1c1915;
  --r-muted: #6b645a;
  --r-chrome: rgba(243, 239, 230, 0.96);
  --r-line: rgba(28, 25, 21, 0.1);
}
.reader[data-theme="eye"] {
  --r-bg: #c7d4b8;
  --r-fg: #1a2414;
  --r-muted: #4d5c42;
  --r-chrome: rgba(199, 212, 184, 0.96);
  --r-line: rgba(26, 36, 20, 0.12);
}
.reader[data-theme="night"] {
  --r-bg: #12151a;
  --r-fg: #d5dae0;
  --r-muted: #8a93a0;
  --r-chrome: rgba(18, 21, 26, 0.96);
  --r-line: rgba(213, 218, 224, 0.12);
}
.reader.is-chrome {
  grid-template-rows: auto 1fr auto auto;
}
.reader-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--r-chrome);
  backdrop-filter: blur(14px);
  z-index: 5;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-height 0.28s var(--ease), opacity 0.28s var(--ease), padding 0.28s var(--ease);
}
.reader.is-chrome .reader-chrome {
  max-height: 80px;
  opacity: 1;
  pointer-events: auto;
  overflow: visible;
}
.reader-top {
  border-bottom: 1px solid var(--r-line);
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
}
.reader-bottom {
  border-top: 1px solid var(--r-line);
  padding-bottom: calc(0.55rem + var(--safe-bottom));
}
.reader-meta { text-align: center; min-width: 0; flex: 1; }
.reader-book {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-chapter {
  color: var(--r-muted);
  font-size: 0.75rem;
  margin-top: 0.1rem;
}
.reader-bar-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}
.chrome-btn {
  min-width: 40px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--r-fg);
  font-size: 1.25rem;
  line-height: 1;
  border-radius: var(--radius);
}
.chrome-btn.text {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 0.55rem;
  min-width: auto;
}
.chrome-btn:hover { background: rgba(0, 0, 0, 0.06); }
.reader[data-theme="night"] .chrome-btn:hover { background: rgba(255, 255, 255, 0.08); }

.reader-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.reader-viewport {
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  overflow: hidden;
  /* 内边距放到文字上，避免列宽 > 可视宽度导致裁字 */
  padding: 0;
  box-sizing: border-box;
  /* 裁掉多列翻页时亚像素缝，避免右侧竖线 */
  contain: paint;
}
.reader-flow {
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  column-fill: auto;
  column-gap: 0;
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}
/* 换章只用透明度，不碰 transform（transform 留给同章翻页） */
.reader-flow.is-chapter-in {
  animation: chapter-in 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes chapter-in {
  from { opacity: 0.2; }
  to { opacity: 1; }
}
.reader-chapter-title {
  margin: 0 0 1rem;
  padding: 1.15rem clamp(1rem, 4vw, 1.75rem) 0;
  break-inside: avoid;
  font-family: var(--font-display);
  font-size: calc(var(--r-font) * 1.12);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.04em;
}
.reader-text {
  margin: 0;
  padding: 0 clamp(1rem, 4vw, 1.75rem) 1.35rem;
  font-family: var(--font-read);
  font-size: var(--r-font);
  line-height: 1.9;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  text-align: start;
  box-sizing: border-box;
}

.tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  border: 0;
  background: transparent;
  padding: 0;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-shadow: none;
}
.tap-zone:focus,
.tap-zone:focus-visible,
.tap-zone:active {
  outline: none !important;
  box-shadow: none !important;
  border: 0;
  background: transparent;
}
.tap-prev { left: 0; width: 28%; cursor: w-resize; }
.tap-mid { left: 28%; width: 44%; cursor: pointer; }
.tap-next { right: 0; width: 28%; cursor: e-resize; }
@media (min-width: 861px) {
  .tap-prev { width: 30%; }
  .tap-mid { left: 30%; width: 40%; }
  .tap-next { width: 30%; }
}

.page-indicator {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  min-width: 7rem;
}
#pageIndicator {
  font-size: 0.78rem;
  color: var(--r-muted);
  font-variant-numeric: tabular-nums;
}
.page-track {
  width: min(140px, 28vw);
  height: 2px;
  background: var(--r-line);
  position: relative;
  overflow: hidden;
}
.page-thumb {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20%;
  background: var(--accent);
  transition: left 0.2s var(--ease), width 0.2s var(--ease);
}

.reader-continue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--r-line);
  background: var(--r-chrome);
  z-index: 4;
}
.continue-copy { display: grid; gap: 0.15rem; min-width: 0; }
.continue-copy strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
}
.continue-copy span { color: var(--r-muted); font-size: 0.8rem; }
.continue-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.reader-panel {
  position: absolute;
  left: 50%;
  bottom: calc(4.5rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 6;
  width: min(360px, calc(100% - 1.5rem));
  padding: 0.95rem 1rem;
  border: 1px solid var(--r-line);
  background: var(--r-chrome);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: rise 0.22s var(--ease);
}
.panel-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}
.panel-label {
  width: 2.5rem;
  font-size: 0.78rem;
  color: var(--r-muted);
}
.theme-swatch {
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 0;
}
.theme-swatch[data-theme="paper"] { background: #f3efe6; border-color: #c9c2b4; }
.theme-swatch[data-theme="eye"] { background: #c7d4b8; border-color: #9aab88; }
.theme-swatch[data-theme="night"] { background: #12151a; border-color: #3a4250; }
.theme-swatch.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.panel-toggle {
  min-width: 3.2rem;
  font-variant-numeric: tabular-nums;
}
.panel-toggle[aria-pressed="false"] {
  opacity: 0.72;
}
/* 关闭翻页动画 */
.reader[data-anim="off"] .reader-flow {
  transition: none !important;
  animation: none !important;
}
.reader[data-anim="off"] .page-thumb {
  transition: none !important;
}
.panel-tip {
  margin: 0;
  font-size: 0.72rem;
  color: var(--r-muted);
  line-height: 1.45;
}

.cats-block { margin-bottom: 0.35rem; }
.cats-block-full .chip-list {
  max-height: none;
  overflow: visible;
}
.cats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0.35rem 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.cats-count {
  font-weight: 500;
  color: var(--ink-mute);
  font-size: 0.75rem;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 220px;
  overflow: auto;
  padding-bottom: 0.25rem;
}
.chip.is-active {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 600;
}
