:root {
  --navy: #071b2d;
  --navy-2: #0b2942;
  --gold: #d6a74b;
  --paper: #f8f4eb;
  --ink: #f9f6ef;
  --scale: 1;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 18%, rgba(42, 82, 111, .45), transparent 38%),
    linear-gradient(145deg, #061522, var(--navy) 52%, #03101b);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { font: inherit; }

.reader { min-height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.toolbar, .footer {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px clamp(16px, 3vw, 42px);
  background: rgba(4, 18, 30, .76); backdrop-filter: blur(14px);
  border-color: rgba(214, 167, 75, .22); z-index: 20;
}
.toolbar { border-bottom: 1px solid rgba(214, 167, 75, .22); }
.footer { border-top: 1px solid rgba(214, 167, 75, .18); color: #b7c2cd; font-size: 13px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--gold);
  border-radius: 50%; color: var(--gold); font-family: Georgia, serif; font-weight: 700;
}
.brand div { display: grid; gap: 1px; }
.brand strong { font-family: Georgia, serif; letter-spacing: .04em; color: #f3d38b; }
.brand span:last-child { color: #aebbc6; font-size: 12px; }
.actions { display: flex; align-items: center; gap: 8px; }
.actions button, .download {
  min-height: 38px; padding: 8px 12px; border: 1px solid rgba(214, 167, 75, .35);
  border-radius: 8px; color: #f4e1b3; background: rgba(255, 255, 255, .045);
  text-decoration: none; cursor: pointer;
}
.actions button:hover, .download:hover { background: rgba(214, 167, 75, .14); border-color: var(--gold); }

.stage { min-height: 0; position: relative; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 10px; padding: 10px 12px; }
.book-wrap { min-width: 0; height: 100%; display: grid; place-items: center; perspective: 2400px; }
.mobile-page { display: none; max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; filter: drop-shadow(0 18px 28px rgba(0,0,0,.4)); }
.book {
  --book-h: min(calc(100dvh - 128px), calc((100vw - 150px) / .707));
  position: relative; width: calc(var(--book-h) * .707 * var(--scale));
  height: calc(var(--book-h) * var(--scale)); max-height: 100%; transform-style: preserve-3d;
  filter: drop-shadow(0 24px 34px rgba(0,0,0,.42)); transition: width .2s, height .2s;
}
.sheet { position: absolute; inset: 0; transform-origin: left center; transform-style: preserve-3d; transition: transform .72s cubic-bezier(.2,.72,.16,1); }
.sheet.turned { transform: rotateY(-180deg); }
.page {
  position: absolute; inset: 0; backface-visibility: hidden; overflow: hidden;
  background: transparent; border-radius: 0;
  box-shadow: inset 12px 0 24px rgba(0,0,0,.08), inset 0 0 0 1px rgba(255,255,255,.25);
}
.page.back { transform: rotateY(180deg); border-radius: 0; box-shadow: inset -12px 0 24px rgba(0,0,0,.08); }
.page img { display: block; width: 100%; height: 100%; object-fit: fill; background: transparent; user-select: none; -webkit-user-drag: none; }
.nav {
  width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid rgba(214, 167, 75, .48); color: #f4d58b; background: rgba(3, 16, 27, .68);
  font-family: Georgia, serif; font-size: 36px; cursor: pointer; z-index: 12;
}
.nav:hover:not(:disabled) { background: rgba(214, 167, 75, .16); transform: translateY(-1px); }
.nav:disabled { opacity: .22; cursor: default; }
.progress { flex: 1; max-width: 420px; height: 3px; overflow: hidden; background: rgba(255,255,255,.12); border-radius: 4px; }
.progress span { display: block; width: 10%; height: 100%; background: var(--gold); transition: width .35s ease; }

@media (min-width: 1000px) {
  .book.spread { --book-h: min(calc(100dvh - 128px), calc((100vw - 150px) / 1.414)); width: calc(var(--book-h) * 1.414 * var(--scale)); height: calc(var(--book-h) * var(--scale)); }
  .book.spread .sheet { width: 50%; left: 50%; }
  .book.spread .sheet.turned { transform: rotateY(-180deg); }
  .book.spread::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: rgba(0,0,0,.25); box-shadow: 0 0 14px rgba(0,0,0,.45); z-index: 20; pointer-events: none; }
}

@media (max-width: 999px) {
  .book { display: none; }
  .mobile-page { display: block; width: auto; height: 100%; }
}

@media (max-width: 720px) {
  .reader { grid-template-rows: auto minmax(0, 1fr) auto; }
  .toolbar { padding: 10px 12px; }
  .brand-mark { width: 34px; height: 34px; font-size: 13px; }
  .brand span:last-child { display: none; }
  .actions button { display: none; }
  .download { padding: 8px 10px; font-size: 13px; }
  .stage { display: block; min-height: 0; padding: 6px 10px; overflow: hidden; }
  .book-wrap { width: 100%; height: 100%; min-height: 0; overflow: hidden; }
  .mobile-page { width: 100%; height: 100%; object-fit: contain; }
  .nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px; font-size: 28px;
    background: rgba(3, 16, 27, .88);
  }
  .nav:hover:not(:disabled) { transform: translateY(-50%); }
  .previous { left: 12px; }
  .next { right: 12px; }
  .footer { padding: 10px 14px; }
  .footer > span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) { .sheet, .progress span { transition-duration: .01ms; } }
