
:root {
  --namal-green: #008a4a;
  --namal-green-dark: #006838;
  --namal-gold: #f7a800;
  --ink: #1f2430;
  --muted: #687180;
  --paper: #fffdf7;
  --surface: #f4f6f2;
  --surface-dark: #1c1f28;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius: 22px;
  --panel-radius: 20px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(247, 168, 0, 0.16), transparent 24rem),
    radial-gradient(circle at 88% 0%, rgba(0, 138, 74, 0.18), transparent 26rem),
    linear-gradient(135deg, #f8faf5 0%, #ebefe7 100%);
}
button, input, a { font: inherit; }
button, .control-link { cursor: pointer; }
a { text-decoration: none; }
.app-shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.4rem); background: rgba(255,255,255,0.92);
  border-bottom: 1px solid rgba(0,0,0,0.08); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30; flex-wrap: wrap;
}
.brand-block { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.brand-mark {
  width: 3rem; height: 3rem; border-radius: 0.9rem; display: grid; place-items: center;
  color: #ffdb65; background: linear-gradient(145deg, var(--namal-green), var(--namal-green-dark));
  font-size: 1.75rem; font-weight: 900; box-shadow: 0 12px 30px rgba(0,104,56,0.22);
}
h1 { margin: 0; font-size: clamp(1rem, 2vw, 1.35rem); line-height: 1.2; }
.topbar p { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.9rem; }
.top-actions, .controls, .footer-actions, .modal-actions, .zoom-toolbar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.control-btn, .primary-control, .secondary-control, .control-link {
  border: 0; border-radius: 999px; padding: 0.78rem 1rem; background: #ffffff; color: var(--ink);
  box-shadow: 0 8px 22px rgba(0,0,0,0.1);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
  white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
}
.control-btn:hover, .primary-control:hover, .secondary-control:hover, .control-link:hover {
  transform: translateY(-1px); box-shadow: 0 12px 28px rgba(0,0,0,0.16);
}
.control-btn[aria-pressed="true"], .primary-control { background: var(--namal-green); color: #fff; }
.secondary-control { background: #fff; color: var(--ink); }
.donate-link, .floating-donate { background: var(--namal-gold); color: #211300; font-weight: 700; }
.primary-control:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.book-stage {
  position: relative; flex: 1 1 auto; display: grid; place-items: center;
  padding: clamp(1rem, 3vw, 2rem); overflow: hidden; min-height: 0;
}
.book {
  width: min(94vw, 1120px); height: min(72vh, 780px); display: grid; grid-template-columns: 1fr 1fr;
  perspective: 2200px; filter: drop-shadow(0 26px 40px rgba(0,0,0,0.28)); transition: transform 0.28s ease;
}
.book.single { width: min(92vw, 560px); grid-template-columns: 1fr; }
.book.single .page-left { display: none; }
.page-slot {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0;
  background: var(--paper); overflow: hidden; border: 1px solid rgba(0,0,0,0.08); transform-style: preserve-3d;
}
.page-left { border-radius: var(--radius) 0 0 var(--radius); border-right: 1px solid rgba(0,0,0,0.16); }
.page-right { border-radius: 0 var(--radius) var(--radius) 0; border-left: 1px solid rgba(255,255,255,0.45); }
.book.single .page-right { border-radius: var(--radius); }
.page-slot::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.page-left::after { background: linear-gradient(90deg, transparent 82%, rgba(0,0,0,0.12)); }
.page-right::after { background: linear-gradient(270deg, transparent 84%, rgba(0,0,0,0.12)); }
.page-image-wrap { width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; }
.page-slot img { display: block; width: 100%; height: 100%; object-fit: contain; background: white; user-select: none; -webkit-user-drag: none; cursor: zoom-in; }
.page-placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; color: #8c96a6;
  background: linear-gradient(90deg, rgba(0,0,0,0.04), transparent 10%), var(--paper);
  text-align: center; padding: 2rem;
}
.page-number {
  position: absolute; bottom: 0.6rem; right: 0.8rem; z-index: 4; color: rgba(31,36,48,0.7);
  background: rgba(255,255,255,0.76); border-radius: 999px; padding: 0.2rem 0.55rem; font-size: 0.76rem;
}
.nav-zone { position: absolute; top: 50%; transform: translateY(-50%); width: 42%; height: 75%; border: 0; background: transparent; z-index: 5; }
.nav-left { left: 0; } .nav-right { right: 0; }
.nav-zone:focus-visible, .page-slot:focus-visible, .panel-close:focus-visible, .thumb:focus-visible, .toc-item:focus-visible {
  outline: 3px solid var(--namal-gold); outline-offset: -6px; border-radius: var(--radius);
}
.controls {
  justify-content: space-between; padding: 1rem clamp(1rem, 3vw, 2.4rem) 1.25rem;
  background: rgba(255,255,255,0.72); border-top: 1px solid rgba(0,0,0,0.05); backdrop-filter: blur(10px);
}
.status-block { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.jump-label { font-size: 0.94rem; color: var(--muted); }
#pageJump {
  width: 4.8rem; padding: 0.6rem 0.75rem; border-radius: 0.85rem; border: 1px solid rgba(0,0,0,0.14);
  background: #fff; box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.panel-drawer {
  position: fixed; right: 1rem; bottom: 1rem; width: min(92vw, 360px); max-height: min(70vh, 680px); overflow: auto;
  background: rgba(255,255,255,0.97); border-radius: var(--panel-radius); box-shadow: var(--shadow);
  padding: 1rem; transform: translateY(12px); opacity: 0; pointer-events: none; transition: 0.22s ease;
  z-index: 35;
}
.panel-drawer.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.thumb-drawer { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 0.75rem; }
.thumb {
  border: 1px solid rgba(0,0,0,0.1); background: #fff; border-radius: 1rem; padding: 0.4rem; text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.thumb img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 0.65rem; display: block; }
.thumb span { display: block; margin-top: 0.35rem; font-size: 0.82rem; color: var(--muted); }
.thumb.active { border-color: var(--namal-green); box-shadow: 0 0 0 2px rgba(0,138,74,0.18), 0 10px 22px rgba(0,0,0,0.1); }
.panel-header, .modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem;
}
.panel-header h2, .modal-header h2 { margin: 0; font-size: 1.15rem; }
.panel-close {
  border: 0; background: #eef1f5; color: var(--ink); border-radius: 999px; padding: 0.62rem 0.9rem; cursor: pointer;
}
.toc-list { display: grid; gap: 0.55rem; }
.toc-item {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 0.95rem;
  border-radius: 1rem; background: #f7f9fb; color: var(--ink); border: 1px solid rgba(0,0,0,0.06);
}
.toc-item small { color: var(--muted); font-size: 0.82rem; display: block; margin-top: 0.15rem; }
.modal {
  width: min(96vw, 1000px); max-width: 1000px; border: 0; border-radius: 1.2rem; padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow); background: rgba(255,255,255,0.98); color: var(--ink);
}
.modal::backdrop { background: rgba(18, 22, 31, 0.7); backdrop-filter: blur(2px); }
.modal-card { max-width: 520px; }
.qr-body { text-align: center; }
.qr-image { width: min(100%, 260px); display: block; margin: 0 auto 1rem; border-radius: 1rem; background: #fff; padding: 0.6rem; box-shadow: 0 8px 20px rgba(0,0,0,0.08); }
.url-field {
  width: 100%; border: 1px solid rgba(0,0,0,0.12); background: #fff; border-radius: 0.85rem; padding: 0.85rem 0.95rem; margin: 0.4rem 0 1rem;
}
.zoom-modal {
  width: min(96vw, 1220px); max-width: 1220px; background: rgba(20, 23, 30, 0.98); color: #fff;
}
.zoom-hint { color: rgba(255,255,255,0.72); font-size: 0.92rem; margin-bottom: 0.7rem; }
.zoom-toolbar .secondary-control, .zoom-toolbar .panel-close { box-shadow: none; }
.zoom-toolbar .secondary-control { background: #2b3240; color: #fff; }
.zoom-toolbar .panel-close { background: #f2f4f7; color: #111; }
.zoom-viewport {
  position: relative; height: min(80vh, 860px); border-radius: 1rem; overflow: hidden; background: #11161f; cursor: grab; touch-action: none;
}
.zoom-viewport.dragging { cursor: grabbing; }
#zoomImage {
  position: absolute; top: 50%; left: 50%; max-width: none; max-height: none; transform-origin: center center;
  user-select: none; -webkit-user-drag: none;
}
.floating-donate {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 34; padding: 0.95rem 1.15rem; border-radius: 999px;
  box-shadow: 0 16px 34px rgba(0,0,0,0.2);
}
body.has-open-panel .floating-donate { bottom: 5.5rem; }
@media (max-width: 860px) {
  .topbar { align-items: flex-start; }
  .top-actions { width: 100%; }
  .control-btn, .control-link { padding: 0.72rem 0.92rem; }
  .book { height: min(66vh, 700px); }
  .controls { gap: 0.75rem; justify-content: center; }
  .nav-zone { width: 30%; height: 65%; }
}
@media (max-width: 640px) {
  .top-actions { gap: 0.55rem; }
  .book-stage { padding: 0.8rem 0.8rem 1rem; }
  .book { width: min(96vw, 560px); height: min(64vh, 620px); }
  .controls { padding-bottom: 5rem; }
  .floating-donate { left: 50%; right: auto; transform: translateX(-50%); }
  .panel-drawer { left: 0.7rem; right: 0.7rem; width: auto; bottom: 5.6rem; }
  .zoom-viewport { height: min(68vh, 640px); }
}


.book {
  position: relative;
  transform-style: preserve-3d;
}

.book.flip-animating {
  pointer-events: none;
}

.flip-sheet {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 12;
  display: none;
  pointer-events: none;
  transform-style: preserve-3d;
  will-change: transform;
}

.flip-sheet.active {
  display: block;
}

.flip-sheet.next-turn {
  right: 0;
  transform-origin: left center;
  animation: pageFlipNext 780ms cubic-bezier(0.22, 0.7, 0.15, 1) forwards;
}

.flip-sheet.prev-turn {
  left: 0;
  transform-origin: right center;
  animation: pageFlipPrev 780ms cubic-bezier(0.22, 0.7, 0.15, 1) forwards;
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.flip-sheet.next-turn .flip-front,
.flip-sheet.next-turn .flip-back {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.flip-sheet.prev-turn .flip-front,
.flip-sheet.prev-turn .flip-back {
  border-radius: var(--radius) 0 0 var(--radius);
}

.flip-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flip-front::after {
  background: linear-gradient(90deg, rgba(255,255,255,0.12), rgba(0,0,0,0.06) 64%, rgba(0,0,0,0.18));
}

.flip-back {
  transform: rotateY(180deg);
}

.flip-back::after {
  background: linear-gradient(90deg, rgba(0,0,0,0.16), rgba(255,255,255,0.04) 44%, rgba(255,255,255,0.1));
}

.flip-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
}

.flip-sheet-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 46px;
  background: linear-gradient(90deg, rgba(0,0,0,0.22), rgba(0,0,0,0.08), transparent);
  filter: blur(10px);
  opacity: 0.55;
}

.flip-sheet.next-turn .flip-sheet-shadow {
  left: -10px;
}

.flip-sheet.prev-turn .flip-sheet-shadow {
  right: -10px;
  transform: scaleX(-1);
}

.book.flip-animating .page-left,
.book.flip-animating .page-right {
  transition: filter 180ms ease;
}

.book.flip-next-stage .page-left,
.book.flip-next-stage .page-right,
.book.flip-prev-stage .page-left,
.book.flip-prev-stage .page-right {
  filter: saturate(0.98) brightness(0.99);
}

@keyframes pageFlipNext {
  0% {
    transform: perspective(2400px) rotateY(0deg);
  }
  18% {
    transform: perspective(2400px) rotateY(-18deg) translateX(-2px);
  }
  52% {
    transform: perspective(2400px) rotateY(-92deg) translateX(-10px);
  }
  100% {
    transform: perspective(2400px) rotateY(-180deg) translateX(0);
  }
}

@keyframes pageFlipPrev {
  0% {
    transform: perspective(2400px) rotateY(0deg);
  }
  18% {
    transform: perspective(2400px) rotateY(18deg) translateX(2px);
  }
  52% {
    transform: perspective(2400px) rotateY(92deg) translateX(10px);
  }
  100% {
    transform: perspective(2400px) rotateY(180deg) translateX(0);
  }
}

@media (max-width: 860px) {
  .flip-sheet {
    width: 100%;
  }

  .flip-sheet.next-turn,
  .flip-sheet.prev-turn {
    left: 0;
    right: auto;
    transform-origin: left center;
  }

  .flip-sheet.next-turn .flip-front,
  .flip-sheet.next-turn .flip-back,
  .flip-sheet.prev-turn .flip-front,
  .flip-sheet.prev-turn .flip-back {
    border-radius: var(--radius);
  }
}


/* Deluxe upgrades */
html, body {
  height: 100dvh;
}

body {
  overflow: hidden;
}

.app-shell {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  padding: 0.7rem clamp(0.75rem, 2.2vw, 1.5rem);
  gap: 0.75rem;
}

.topbar p {
  font-size: 0.84rem;
}

.control-btn, .primary-control, .secondary-control, .control-link {
  padding: 0.68rem 0.92rem;
}

.brand-mark {
  width: 2.8rem;
  height: 2.8rem;
}

.book-stage {
  padding: 0.35rem clamp(0.45rem, 1.5vw, 0.9rem) 0.55rem;
}

.book {
  width: min(98vw, 1320px);
  height: min(900px, calc(100dvh - 158px));
  max-height: calc(100dvh - 158px);
  filter: drop-shadow(0 26px 42px rgba(0,0,0,0.28));
}

.book.single {
  width: min(97vw, 680px);
  height: min(900px, calc(100dvh - 158px));
}

.controls {
  padding: 0.75rem clamp(0.75rem, 2vw, 1.4rem) 0.95rem;
  gap: 0.65rem;
}

.status-block {
  gap: 0.65rem;
}

.book::before {
  content: "";
  position: absolute;
  top: 1.5%;
  bottom: 1.5%;
  left: calc(50% - 18px);
  width: 36px;
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(0,0,0,0.22), rgba(255,255,255,0.12) 24%, rgba(0,0,0,0.12) 48%, rgba(255,255,255,0.1) 72%, rgba(0,0,0,0.24));
  box-shadow: inset 0 0 10px rgba(0,0,0,0.16), 0 0 22px rgba(0,0,0,0.12);
  opacity: 0.8;
  z-index: 3;
  pointer-events: none;
}

.book.single::before {
  display: none;
}

.page-slot,
.flip-face {
  background-color: var(--paper);
}

.page-slot::before,
.flip-face::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    radial-gradient(circle at 20% 16%, rgba(255,255,255,0.9), rgba(255,255,255,0) 28%),
    radial-gradient(circle at 78% 82%, rgba(0,0,0,0.11), rgba(0,0,0,0) 30%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.035) 0 1px, rgba(255,255,255,0.02) 1px 3px);
  mix-blend-mode: multiply;
  z-index: 1;
}

.page-image-wrap,
.flip-face img {
  position: relative;
  z-index: 0;
}

.page-left::after {
  background: linear-gradient(90deg, rgba(255,255,255,0.02), transparent 70%, rgba(0,0,0,0.16));
}

.page-right::after {
  background: linear-gradient(270deg, rgba(255,255,255,0.02), transparent 70%, rgba(0,0,0,0.16));
}

.book.book-opening .page-right {
  transform-origin: left center;
  animation: hardCoverOpen 1100ms cubic-bezier(0.2, 0.8, 0.15, 1) both;
  box-shadow: -18px 14px 35px rgba(0,0,0,0.24);
}

.book.book-opening .page-left {
  animation: insidePageReveal 1100ms ease both;
}

@keyframes hardCoverOpen {
  0% {
    transform: perspective(2400px) rotateY(-104deg);
    filter: brightness(0.95) saturate(0.95);
  }
  45% {
    transform: perspective(2400px) rotateY(-28deg);
    filter: brightness(0.99);
  }
  100% {
    transform: perspective(2400px) rotateY(0deg);
    filter: brightness(1);
  }
}

@keyframes insidePageReveal {
  0% { opacity: 0.82; }
  100% { opacity: 1; }
}

.flip-sheet {
  filter: drop-shadow(0 14px 24px rgba(0,0,0,0.18));
}

.flip-sheet.next-turn {
  animation: pageFlipNextDeluxe 880ms cubic-bezier(0.18, 0.68, 0.15, 1) forwards;
}

.flip-sheet.prev-turn {
  animation: pageFlipPrevDeluxe 880ms cubic-bezier(0.18, 0.68, 0.15, 1) forwards;
}

.flip-front::after {
  background:
    linear-gradient(90deg, rgba(255,255,255,0.22), rgba(255,255,255,0.02) 14%, rgba(0,0,0,0.08) 52%, rgba(0,0,0,0.26)),
    radial-gradient(180% 100% at 100% 50%, rgba(255,255,255,0.08), rgba(0,0,0,0.18) 48%, rgba(0,0,0,0.28) 100%);
}

.flip-back::after {
  background:
    linear-gradient(90deg, rgba(0,0,0,0.26), rgba(0,0,0,0.08) 30%, rgba(255,255,255,0.02) 62%, rgba(255,255,255,0.12)),
    radial-gradient(180% 100% at 0% 50%, rgba(0,0,0,0.26), rgba(0,0,0,0.08) 48%, rgba(255,255,255,0.04) 100%);
}

.flip-sheet-shadow {
  width: 74px;
  filter: blur(14px);
  opacity: 0.72;
}

@keyframes pageFlipNextDeluxe {
  0% {
    transform: perspective(2600px) rotateY(0deg) skewY(0deg);
  }
  16% {
    transform: perspective(2600px) rotateY(-18deg) skewY(0.6deg) translateX(-2px);
  }
  38% {
    transform: perspective(2600px) rotateY(-56deg) skewY(1.3deg) translateX(-8px);
  }
  62% {
    transform: perspective(2600px) rotateY(-118deg) skewY(-1deg) translateX(-12px);
  }
  100% {
    transform: perspective(2600px) rotateY(-180deg) skewY(0deg) translateX(0);
  }
}

@keyframes pageFlipPrevDeluxe {
  0% {
    transform: perspective(2600px) rotateY(0deg) skewY(0deg);
  }
  16% {
    transform: perspective(2600px) rotateY(18deg) skewY(-0.6deg) translateX(2px);
  }
  38% {
    transform: perspective(2600px) rotateY(56deg) skewY(-1.3deg) translateX(8px);
  }
  62% {
    transform: perspective(2600px) rotateY(118deg) skewY(1deg) translateX(12px);
  }
  100% {
    transform: perspective(2600px) rotateY(180deg) skewY(0deg) translateX(0);
  }
}

@media (max-width: 980px) {
  .book,
  .book.single {
    height: min(840px, calc(100dvh - 165px));
    max-height: calc(100dvh - 165px);
  }
}

@media (max-width: 860px) {
  .topbar {
    padding: 0.6rem 0.8rem;
  }

  .book,
  .book.single {
    width: min(98vw, 720px);
    height: min(76vh, calc(100dvh - 198px));
    max-height: calc(100dvh - 198px);
  }

  .controls {
    padding-bottom: 4.75rem;
  }
}

@media (max-width: 640px) {
  .book,
  .book.single {
    width: min(98vw, 640px);
    height: min(73vh, calc(100dvh - 212px));
    max-height: calc(100dvh - 212px);
  }

  .control-btn, .primary-control, .secondary-control, .control-link {
    padding: 0.62rem 0.82rem;
  }

  .floating-donate {
    bottom: 0.85rem;
  }
}


/* 100% browser zoom viewport fix */
html,
body {
  min-height: 100svh;
  height: auto;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.app-shell {
  min-height: 100svh;
  height: auto;
  overflow: visible;
}

.topbar {
  position: relative;
  top: auto;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.45rem;
}

h1 {
  font-size: clamp(0.95rem, 1.65vw, 1.2rem);
}

.topbar p {
  font-size: 0.8rem;
}

.control-btn,
.primary-control,
.secondary-control,
.control-link {
  padding: 0.55rem 0.78rem;
  font-size: 0.92rem;
}

.book-stage {
  padding: 0.25rem clamp(0.3rem, 1vw, 0.7rem);
  overflow: visible;
  flex: 1 1 auto;
  min-height: auto;
  align-items: center;
}

.book {
  width: min(98vw, 1440px, calc((100svh - 128px) * 1.54545));
  height: auto;
  max-height: none;
  aspect-ratio: 34 / 22;
}

.book.single {
  width: min(97vw, 720px, calc((100svh - 128px) * 0.77273));
  height: auto;
  max-height: none;
  aspect-ratio: 17 / 22;
}

.controls {
  padding: 0.55rem clamp(0.7rem, 1.6vw, 1.1rem) 0.65rem;
  gap: 0.5rem;
}

.status-block {
  gap: 0.5rem;
}

#pageJump {
  padding: 0.48rem 0.62rem;
}

.floating-donate {
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.75rem 0.95rem;
}

@media (max-height: 820px) and (min-width: 861px) {
  .topbar {
    padding-top: 0.38rem;
    padding-bottom: 0.38rem;
  }

  .brand-mark {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.25rem;
  }

  .topbar p {
    display: none;
  }

  .control-btn,
  .primary-control,
  .secondary-control,
  .control-link {
    padding: 0.46rem 0.68rem;
    font-size: 0.88rem;
  }

  .controls {
    padding-top: 0.42rem;
    padding-bottom: 0.5rem;
  }

  .book {
    width: min(98.5vw, 1440px, calc((100svh - 102px) * 1.54545));
  }

  .book.single {
    width: min(97vw, 720px, calc((100svh - 102px) * 0.77273));
  }
}

@media (max-width: 860px) {
  .app-shell {
    min-height: 100svh;
  }

  .topbar {
    padding: 0.45rem 0.65rem;
  }

  .book,
  .book.single {
    width: min(98vw, 720px, calc((100svh - 170px) * 0.77273));
    height: auto;
    max-height: none;
    aspect-ratio: 17 / 22;
  }

  .controls {
    padding-top: 0.5rem;
    padding-bottom: 4rem;
  }
}

@media (max-width: 640px) {
  .top-actions {
    gap: 0.4rem;
  }

  .control-btn,
  .primary-control,
  .secondary-control,
  .control-link {
    padding: 0.5rem 0.68rem;
    font-size: 0.86rem;
  }

  .book,
  .book.single {
    width: min(98vw, calc((100svh - 188px) * 0.77273));
  }

  .controls {
    padding-bottom: 3.75rem;
  }
}
