:root {
  color-scheme: light;
  --ink: #171717;
  --paper: #fffefa;
  --accent: #b44a32;
  --book-scale: 1;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  color: #202226;
  background: #e9ebee;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(#f8f9fa 0 58%, #dfe2e6 58%);
}

button { font: inherit; }

.topbar {
  height: 88px;
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: white;
  border-bottom: 1px solid #d6d9dd;
}

.eyebrow { margin: 0 0 3px; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; opacity: .7; }
h1 { margin: 0; font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.format-chip { padding: 7px 11px; border: 1px solid #d2d5d9; border-radius: 99px; font-size: 11px; color: #222; background: #f4f5f6; }
.icon-button { width: 34px; height: 34px; border: 1px solid #d2d5d9; border-radius: 50%; color: #222; background: #f4f5f6; cursor: pointer; }

.stage {
  position: relative;
  z-index: 2;
  height: calc(100vh - 162px);
  min-height: 420px;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 2200px;
  isolation: isolate;
}

.book {
  position: relative;
  display: inline-flex;
  height: min(69vh, 705px);
  max-height: calc(100vh - 205px);
  transform: scale(var(--book-scale));
  transform-style: preserve-3d;
  filter: drop-shadow(0 16px 26px rgba(32,37,43,.2));
  transition: transform .28s ease;
}

.paper {
  position: relative;
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 1 / 1.4142;
  overflow: hidden;
  background: var(--paper);
  backface-visibility: hidden;
}

.paper img { width: 100%; height: 100%; object-fit: fill; display: block; }
.left-page { border-radius: 4px 0 0 4px; box-shadow: inset -18px 0 24px -24px rgba(0,0,0,.9); }
.right-page { border-radius: 0 4px 4px 0; box-shadow: inset 18px 0 24px -24px rgba(0,0,0,.9); }
.book.cover .left-page, .book.cover .spine { display: none; }
.book.cover .right-page { border-radius: 3px 8px 8px 3px; box-shadow: 7px 7px 0 #d4d0c7, 12px 11px 16px rgba(0,0,0,.22); }

.spine {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.16) 47%, rgba(255,255,255,.22) 52%, transparent);
}

.page-label {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 9px;
  color: rgba(0,0,0,.38);
  opacity: 1;
}

.turning-page {
  display: none;
  position: absolute;
  z-index: 8;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .58s cubic-bezier(.3,.05,.2,1), filter .58s ease;
}
.turning-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.28);
}
.turning-face.back { transform: rotateY(180deg); }
.turning-face img { width: 100%; height: 100%; object-fit: fill; display: block; }
.turning-page.next { display: block; right: 0; transform-origin: left center; transform: rotateY(0); }
.turning-page.next.active { transform: rotateY(-178deg); filter: brightness(.8); }
.turning-page.previous { display: block; left: 0; transform-origin: right center; transform: rotateY(0); }
.turning-page.previous.active { transform: rotateY(178deg); filter: brightness(.8); }

.page-zone {
  position: absolute;
  z-index: 10;
  top: 50%;
  width: 54px;
  height: 86px;
  transform: translateY(-50%);
  border: 1px solid #cdd1d5;
  border-radius: 14px;
  color: #222;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(8px);
  font-size: 42px;
  cursor: pointer;
  opacity: .68;
  transition: opacity .2s, transform .2s;
}
.page-zone:hover { opacity: 1; transform: translateY(-50%) scale(1.04); }
.previous-zone { left: 22px; }
.next-zone { right: 22px; }
.page-zone:disabled { opacity: .16; cursor: default; }

.reader-controls {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto minmax(190px, 270px) auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(22,15,12,.84);
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  backdrop-filter: blur(16px);
}
.reader-controls button { border: 0; border-radius: 9px; padding: 9px 12px; color: white; background: rgba(255,255,255,.1); cursor: pointer; }
.reader-controls button:hover { background: rgba(255,255,255,.18); }
.readout { text-align: center; line-height: 1.1; }
.readout strong { display: block; font-size: 12px; }
.readout span { display: block; margin-top: 3px; font-size: 9px; opacity: .62; }
.progress { height: 2px; margin-top: 7px; overflow: hidden; border-radius: 2px; background: rgba(255,255,255,.18); }
.progress i { display: block; width: 2%; height: 100%; background: #e5b063; transition: width .35s; }
.zoom-controls { display: flex; gap: 4px; }
.zoom-controls button { width: 31px; padding-inline: 0; }

@media (max-width: 860px) {
  .topbar { padding: 14px 16px; }
  .format-chip { display: none; }
  .book { height: min(61vh, 560px); }
  .reader-controls { grid-template-columns: auto minmax(120px, 180px) auto; bottom: 12px; }
  .zoom-controls { display: none; }
  .page-zone { width: 42px; }
}

@media (max-width: 620px) {
  h1 { font-size: 17px; }
  .book { height: min(48vh, 440px); }
  .reader-controls button { font-size: 0; }
  .reader-controls button::first-letter { font-size: 15px; }
  .page-zone { top: 78%; height: 50px; }
}
