:root { --ink: #172238; --blue: #173a66; }
* { box-sizing: border-box; }
html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: #e7f5ff;
}

/* 保留原有山景和暖光，用静态渐变代替持续重绘的雾层和粒子。 */
.bg {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none;
  background: radial-gradient(circle at 82% 13%, #fff5befa 0 5%, #ffd87c94 6% 13%, #ffc45938 14% 25%, transparent 36%),
    linear-gradient(145deg, #2d85db, #78c7ff 32%, #fff2c9 69%, #f8fcff);
}
.bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 82% 18%, #ffffff57, transparent 28%), linear-gradient(0deg, #ffffffd1, #ffffff21 48%, #ffffff05);
}
.sun {
  position: absolute; right: 7%; top: 6%; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, #fffceb 0 12%, #ffd98b99 13% 32%, #ffc65c44 33% 55%, transparent 72%);
}
.mist {
  position: absolute; width: 72vw; height: 28vh; left: 8vw; bottom: 7vh; opacity: .72;
  background: radial-gradient(ellipse at center, #ffffffc7, transparent 70%);
}
.mist-b { bottom: 28vh; left: -20vw; opacity: .46; }
.mountain {
  position: absolute; bottom: 0; width: 120vw; height: 43vh; left: -10vw; opacity: .58;
  background: linear-gradient(135deg, transparent 0 28%, #002c5838 29% 39%, transparent 40%),
    linear-gradient(45deg, transparent 0 32%, #06386252 33% 47%, transparent 48%);
  clip-path: polygon(0 100%,8% 72%,17% 92%,27% 50%,39% 89%,50% 56%,64% 90%,76% 48%,88% 86%,100% 62%,100% 100%);
}
.mountain-b { bottom: -4vh; height: 31vh; opacity: .36; }

.topbar {
  position: fixed; z-index: 3; top: 0; left: 0; right: 0; height: 64px; display: flex;
  justify-content: space-between; align-items: center; padding: 12px 22px; color: #173052;
  background: linear-gradient(180deg, #ffffff85, transparent);
}
.brand, .actions, .zoom-control, .controls { display: flex; align-items: center; }
.brand { gap: 12px; }
.mark {
  width: 52px; height: 34px; border: 1px solid #ffffffe0; border-radius: 14px;
  display: grid; place-items: center; font-weight: 700; background: #ffffff80;
}
.title { font-size: 19px; font-weight: 700; letter-spacing: .08em; }
.sub { font-size: 11px; opacity: .74; letter-spacing: .12em; margin-top: 2px; }
.actions { gap: 9px; }
button {
  border: 0; border-radius: 999px; padding: 9px 14px; background: #ffffffd6; color: #163052;
  box-shadow: 0 8px 24px #0d254a29; cursor: pointer; font-weight: 600; white-space: nowrap;
}
button:hover { background: white; }
button:disabled { opacity: .55; cursor: default; }
.mobile-only { display: none; }
.zoom-control {
  gap: 6px; padding: 5px 8px; border-radius: 999px; background: #ffffff80; box-shadow: 0 8px 24px #0d254a1f;
}
.zoom-control button { width: 30px; height: 30px; padding: 0; font-size: 18px; box-shadow: none; }
.zoom-control input { width: clamp(100px, 18vw, 360px); }
.zoom-control span { font-size: 12px; font-weight: 700; min-width: 38px; text-align: center; }

.stage {
  position: relative; height: 100%; display: grid; grid-template-columns: 240px minmax(0,1fr);
  grid-template-rows: minmax(0,1fr); padding: 66px 8px 68px; gap: 10px;
}
.toc {
  width: 210px; align-self: center; max-height: 100%; overflow: auto; padding: 18px 15px;
  border: 1px solid #ffffff70; border-radius: 24px; background: #ffffff70; box-shadow: 0 28px 80px #041c3e24;
}
.toc-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; letter-spacing: .18em; }
.toc button { width: 100%; margin: 6px 0; text-align: left; background: #ffffffad; font-size: 13px; padding: 10px 12px; border-radius: 14px; box-shadow: none; }
.toc button.active { background: #183a65; color: #fff; }
.book-wrap { position: relative; min-width: 0; min-height: 0; }
.book {
  position: absolute; inset: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.book .flip-surface {
  transform: scale(var(--zoom, .952)); touch-action: none; overflow: hidden;
  background: white; border-radius: 10px; box-shadow: 0 8px 24px #02163030; cursor: pointer;
}
.flip-surface .stf__wrapper { position: relative; width: 100%; height: 100%; }
.flip-surface .sheet { background: white; }
.flip-surface .sheet img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.page-notice { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.controls {
  position: fixed; z-index: 2; left: 50%; bottom: 13px; transform: translateX(-50%); gap: 14px;
  padding: 10px 15px; border-radius: 999px; background: #ffffff96; box-shadow: 0 14px 45px #0315302b;
}
input[type=range] { accent-color: var(--blue); }
.controls input { width: min(28vw, 360px); }
.counter { min-width: 70px; text-align: center; font-weight: 700; color: #173052; }

/* 窄屏用目录抽屉，横竖屏变化只影响布局，书页和阅读位置保持不动。 */
@media (orientation: portrait), (max-width: 900px), (max-height: 500px) {
  .topbar { height: 58px; padding: 8px 10px; }
  .mark { width: 44px; height: 30px; border-radius: 12px; font-size: 13px; }
  .title { font-size: 15px; }
  .sub, .desktop-only { display: none; }
  .actions { gap: 6px; }
  .actions button, .controls button { padding: 7px 10px; font-size: 12px; }
  .mobile-only { display: inline-flex; }
  .stage { display: block; padding: 60px 4vw 58px; }
  .book-wrap { height: 100%; }
  .book .flip-surface { transform: none; }
  .toc {
    position: fixed; z-index: 4; left: 10px; top: 62px; bottom: 64px; width: min(80vw, 320px);
    transform: translateX(calc(-100% - 20px)); visibility: hidden; background: #f7fbfff5;
  }
  .nav-open .toc { transform: none; visibility: visible; }
  .toc button { font-size: 15px; padding: 12px 14px; }
  .controls { width: calc(100% - 20px); bottom: 10px; padding: 8px 10px; gap: 8px; border-radius: 20px; }
  .controls input { flex: 1; min-width: 0; }
  .counter { min-width: 54px; font-size: 12px; }
}
@media (max-width: 600px) {
  .topbar { height: 82px; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 6px 8px; }
  .brand { justify-content: center; width: 100%; gap: 8px; }
  .mark { height: 26px; }
  .title { font-size: 14px; }
  .stage { padding-top: 84px; }
  .toc { top: 84px; }
}

.download-zip{display:inline-flex;align-items:center;text-decoration:none;border-radius:999px;padding:9px 14px;background:rgba(255,255,255,.84);color:#163052;box-shadow:0 8px 24px rgba(13,37,74,.16);font-size:13px;font-weight:600;white-space:nowrap}
.download-zip:hover{background:white}
.download-zip:focus-visible{outline:2px solid #173a66;outline-offset:2px}
.offline-dialog{width:min(420px,calc(100vw - 32px));padding:24px;border:0;border-radius:22px;color:#173052;background:#f7fbff;box-shadow:0 24px 80px #08244740}
.offline-dialog:not([open]){display:none}
.offline-dialog::backdrop{background:#102e4c66}
.offline-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}
.offline-heading h2{margin:0;font-size:20px}
.offline-heading button{padding:4px 12px;font-size:24px;box-shadow:none;background:transparent}
.offline-dialog p{line-height:1.7;font-size:14px;margin:18px 0}
.offline-dialog progress{width:100%;height:8px;accent-color:#173a66;margin-bottom:16px}
.offline-actions{display:flex;flex-wrap:wrap;gap:10px}
#offlineDownload{background:#173a66;color:white}
.offline-dialog button:disabled{opacity:.65;cursor:wait;transform:none}
.offline-dialog .offline-hint{font-size:12px;color:#52677c;margin-bottom:0}
.offline-dialog [hidden]{display:none!important}
