:root {
  --bg: #15171a;
  --panel: rgba(24, 27, 31, .88);
  --text: #f3f5f7;
  --muted: #b5bbc2;
  --line: rgba(255,255,255,.14);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.viewer { position: relative; width: 100%; height: 100dvh; background: radial-gradient(circle at 50% 42%, #262a2f 0%, #181b1f 48%, #111315 100%); }
.stage { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; display: flex; align-items: center; justify-content: center; padding: 22px 60px 76px; }
.book { position: relative; display: flex; align-items: center; justify-content: center; gap: 3px; transform-origin: center center; transition: transform .16s ease; min-width: min-content; }
.page { display: block; width: auto; max-width: calc((100vw - 130px) / 2); max-height: calc(100dvh - 112px); height: auto; object-fit: contain; background: #fff; box-shadow: 0 14px 42px rgba(0,0,0,.36); user-select: none; -webkit-user-drag: none; }
.book.cover .page { max-width: min(760px, calc(100vw - 120px)); }
.page.loading { opacity: .2; }
.hit { position: fixed; z-index: 3; top: 0; bottom: 68px; width: 18%; max-width: 260px; border: 0; background: transparent; cursor: pointer; opacity: 0; }
.hit-left { left: 0; }
.hit-right { right: 0; }
.controls { position: fixed; z-index: 10; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 5px; min-height: 48px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(0,0,0,.28); transition: opacity .25s ease, transform .25s ease; }
.controls.auto-hide { opacity: .12; transform: translateX(-50%) translateY(6px); }
.controls.auto-hide:hover, .controls:focus-within { opacity: 1; transform: translateX(-50%); }
.icon-btn, .tool-btn { height: 35px; min-width: 35px; border: 0; border-radius: 10px; color: var(--text); background: transparent; cursor: pointer; display: grid; place-items: center; }
.icon-btn { font-size: 28px; line-height: 1; }
.tool-btn { font-size: 18px; }
.icon-btn:hover, .tool-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn:disabled { color: #697078; cursor: default; }
.pager { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; white-space: nowrap; padding: 0 3px; }
.pager input { width: 50px; height: 32px; border: 1px solid var(--line); border-radius: 8px; outline: none; text-align: center; color: var(--text); background: rgba(255,255,255,.06); }
.pager input:focus { border-color: rgba(255,255,255,.45); }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.zoom-label { min-width: 54px; font-size: 12px; color: var(--muted); }
.fullscreen { font-size: 21px; }
@media (max-width: 820px) {
  .stage { padding: 10px 8px 68px; align-items: center; }
  .book { gap: 0; }
  .page { max-width: calc(100vw - 16px); max-height: calc(100dvh - 88px); box-shadow: 0 8px 28px rgba(0,0,0,.32); }
  .book.cover .page { max-width: calc(100vw - 16px); }
  .page.secondary { display: none; }
  .hit { bottom: 60px; width: 28%; }
  .controls { max-width: calc(100vw - 12px); padding: 5px 7px; border-radius: 14px; }
  .divider:nth-of-type(2), #zoomOut, #zoomReset, #zoomIn { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .book, .controls { transition: none; }
}
