:root {
  --bg1: #1c120b;
  --bg2: #2e1c10;
  --accent: #c98a4b;
  --pay-green: #09bb07;
  --pay-green-d: #07a006;
  --text-main: #f3e9dc;
  --text-dim: #b8a68f;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg2) 0%, var(--bg1) 70%);
  color: var(--text-main);
  display: flex; flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  z-index: 5;
}
.topbar-title { font-size: 16px; letter-spacing: 2px; color: var(--text-main); }
.topbar-pageno { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- 书区 ---------- */
#bookWrap {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: 0 8px;
}
#book { position: relative; }

#book .page {
  background: #fff;
  color: #222;
  font-size: 12px;
  overflow: hidden;
}
#book .page img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* ---------- 第 20 页 整页付款墙 ---------- */
.paywall { background: #fff; overflow: hidden; }
.paywall .pw-inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fff 0%, #fff7ef 60%, #ffeede 100%);
  padding: 4% 6%;
  text-align: center;
}
.paywall .pw-head {
  font-size: 3.4vmin; font-weight: 700; color: #7a4a1e;
  letter-spacing: 1px; margin-bottom: 3%;
}
.paywall .pw-qr {
  display: block;
  width: 62%;
  max-width: 520px;
  background: #fff;
  border: 3px solid var(--pay-green);
  border-radius: 14px;
  box-shadow: 0 8px 26px rgba(0,0,0,.18);
  padding: 10px;
  cursor: pointer;
}
.paywall .pw-qr img {
  width: 100%; height: auto; display: block; border-radius: 6px;
  pointer-events: none;
}
.paywall .pw-tip {
  margin-top: 3.2%;
  font-size: 2.9vmin; color: #8a6a4a; line-height: 1.6;
}
.paywall .pw-hint {
  margin-top: 1.2%;
  font-size: 2.4vmin; color: var(--pay-green); font-weight: 700;
}
.paywall .pw-continue { margin-top: 3%; }

/* 通用「我已付款，继续阅读」按钮 */
.continue-btn {
  display: inline-block;
  white-space: nowrap;
  background: var(--pay-green);
  color: #fff; font-weight: 700; font-size: 3vmin; letter-spacing: 1px;
  border: none; border-radius: 24px;
  padding: 2.2% 7%;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(9,187,7,.35);
  transition: background .15s, transform .1s;
}
.continue-btn:active { transform: scale(.96); background: var(--pay-green-d); }

/* ---------- 底部工具栏 ---------- */
.toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 5;
}
.tbtn {
  min-width: 44px; height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 20px;
  background: rgba(255,255,255,.07);
  color: var(--text-main);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.tbtn:active { transform: scale(.94); }
.tbtn:hover { background: rgba(255,255,255,.16); }
.tbtn-pay {
  background: var(--pay-green);
  border-color: var(--pay-green);
  color: #fff; font-weight: 700; letter-spacing: 2px;
  padding: 0 22px;
}
.tbtn-pay:hover { background: #0ac70a; }

/* ---------- 弹窗通用 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.modal-card {
  position: relative;
  background: #fff; color: #333;
  border-radius: 16px;
  padding: 22px 22px 18px;
  width: min(86vw, 360px);
  text-align: center;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 6px; right: 10px;
  border: none; background: none;
  font-size: 28px; color: #999; cursor: pointer; line-height: 1;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--pay-green); margin-bottom: 14px; }
.modal-qr { width: min(70vw, 280px); display: block; margin: 0 auto; border-radius: 8px; }
.modal-tip { margin-top: 12px; font-size: 13px; color: #777; line-height: 1.7; }
.modal .continue-btn { margin-top: 16px; }
.modal-note { margin-top: 10px; font-size: 12px; color: #999; }

/* ---------- 解锁提示 ---------- */
#toast {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  z-index: 70;
  background: rgba(9,187,7,.95);
  color: #fff; font-size: 16px; font-weight: 700;
  padding: 18px 28px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  animation: pop .2s ease-out;
}
#toast[hidden] { display: none; }

/* ---------- 放大阅读 ---------- */
#zoomView {
  position: fixed; inset: 0; z-index: 60;
  background: #111;
  display: flex; flex-direction: column;
}
#zoomView[hidden] { display: none; }
.zoom-top, .zoom-bottom {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  color: #ddd; font-size: 14px;
  z-index: 2;
}
.zoom-bottom { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.zoom-hint { font-size: 12px; color: #888; }
.zbtn {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: #eee; border-radius: 18px;
  padding: 7px 16px; font-size: 14px; cursor: pointer;
}
.zbtn:active { transform: scale(.94); }
#zoomStage {
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
  touch-action: none;
}
#zoomInner {
  position: absolute; left: 50%; top: 50%;
  transform-origin: center center;
  will-change: transform;
}
#zoomImg {
  display: block;
  height: 100vh;
  max-height: none;
  transform: translateY(-50%) translateX(-50%);
  position: relative; left: 50%; top: 50%;
  user-select: none; -webkit-user-drag: none;
  pointer-events: none;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .topbar-title { font-size: 14px; letter-spacing: 1px; }
  .toolbar { gap: 6px; }
  .tbtn { min-width: 38px; height: 36px; padding: 0 10px; font-size: 13px; }
  .tbtn-pay { padding: 0 16px; letter-spacing: 1px; }
  .continue-btn { font-size: 16px; padding: 12px 26px; }
}
