:root {
  color-scheme: dark;
  --chrome: #111820;
  --chrome-raised: #1d2933;
  --chrome-line: rgba(255, 255, 255, 0.12);
  --paper: #fbfaf7;
  --shadow: rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: #0b1015;
  color: #f6f3ee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}
button { font: inherit; }
.reader {
  display: flex;
  flex-direction: column;
  width: 100%; height: 100%;
  background: radial-gradient(circle at 50% 42%, #253540 0, #121c24 48%, #0b1015 100%);
}
.toolbar {
  z-index: 5; display: flex; align-items: center; gap: 8px;
  min-height: 52px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: rgba(12, 18, 24, 0.9);
  border-bottom: 1px solid var(--chrome-line);
  backdrop-filter: blur(12px);
}
.tool-button, .zoom-label {
  display: inline-grid; place-items: center;
  height: 34px; min-width: 34px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 5px;
  color: #f6f3ee; background: transparent; cursor: pointer;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.tool-button { font-size: 25px; line-height: 1; }
.fullscreen-button { font-size: 20px; }
.zoom-label { min-width: 52px; font-size: 12px; color: #c8d1d6; }
.tool-button:hover, .zoom-label:hover, .tool-button:focus-visible, .zoom-label:focus-visible {
  background: var(--chrome-raised); border-color: var(--chrome-line); outline: none;
}
.tool-button:disabled { opacity: 0.35; cursor: default; }
.toolbar-spacer { flex: 1; }
.page-counter { min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; color: #dfe6e9; font-size: 13px; }
.counter-divider { margin: 0 4px; color: #87949b; }
.book-viewport {
  position: relative; display: grid; flex: 1; place-items: center; min-height: 0;
  overflow: hidden; outline: none; touch-action: none; overscroll-behavior: none;
}
.book-stage {
  position: relative; flex: none; aspect-ratio: 1.463 / 1;
  perspective: 1800px;
  transform: translate3d(var(--pan-x, 0px), var(--pan-y, 0px), 0) scale(var(--zoom, 1));
  transform-origin: center;
  will-change: transform;
}
.page-layer {
  position: absolute; inset: 0; overflow: hidden; background: var(--paper);
  border-radius: 2px; box-shadow: 0 14px 35px var(--shadow), 0 2px 5px rgba(0, 0, 0, 0.35);
  transform-style: preserve-3d; backface-visibility: hidden;
}
.page-under { z-index: 1; }
.page-current { z-index: 2; transform-origin: left center; }
.page-current.flip-next {
  transform-origin: left center; transform: rotateY(-180deg);
  transition: transform 680ms cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: -18px 12px 24px rgba(0, 0, 0, 0.16);
}
.page-current.flip-prev {
  transform-origin: right center; transform: rotateY(180deg);
  transition: transform 680ms cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: 18px 12px 24px rgba(0, 0, 0, 0.16);
}
.page-layer img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.loading {
  position: absolute; padding: 8px 12px; border-radius: 4px;
  color: #c8d1d6; background: rgba(9, 14, 18, 0.78); font-size: 13px; pointer-events: none;
}
.loading.is-hidden { display: none; }
@media (max-width: 560px) {
  .toolbar { min-height: 46px; padding-top: 5px; padding-bottom: 5px; }
  .tool-button, .zoom-label { height: 32px; min-width: 32px; }
  .fullscreen-button { display: none; }
  .page-counter { min-width: 48px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .page-current.flip-next, .page-current.flip-prev { transition-duration: 1ms; }
}
