:root { color-scheme: dark; font-family: Arial, Helvetica, sans-serif; background: #0c0d10; color: #f3f4f6; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #0c0d10; }
button { min-height: 42px; padding: 0 .75rem; border: 1px solid #41444a; border-radius: .4rem; background: #1b1d22; color: inherit; font: inherit; cursor: pointer; }
button:hover { background: #282b31; }
button:focus-visible { outline: 3px solid #e5e7eb; outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.viewer-shell { min-height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: #0c0d10; }
.book-area { min-height: 0; padding: max(.5rem, env(safe-area-inset-top)) max(.5rem, env(safe-area-inset-right)) .5rem max(.5rem, env(safe-area-inset-left)); display: grid; place-items: center; overflow: hidden; }
#flipbook { width: min(100%, calc((100dvh - 64px) * .71625)); aspect-ratio: 573 / 800; filter: drop-shadow(0 14px 22px rgb(0 0 0 / .45)); }
.page { background: #fff; overflow: hidden; }
.page img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.controls-area { min-height: 64px; padding: .5rem max(.6rem, env(safe-area-inset-right)) max(.6rem, env(safe-area-inset-bottom)) max(.6rem, env(safe-area-inset-left)); display: flex; justify-content: center; align-items: center; gap: .45rem; border-top: 1px solid #292c32; background: #121419; }
#page-counter { min-width: 4.6rem; text-align: center; font-variant-numeric: tabular-nums; }
.thumbnails-panel[hidden] { display: none; }
.thumbnails-panel { position: fixed; z-index: 5; inset: 0; display: grid; place-items: end center; background: rgb(0 0 0 / .62); }
.thumbnails-sheet { width: min(920px, 100%); max-height: 76dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); border: 1px solid #3d4148; border-radius: .8rem .8rem 0 0; background: #15171c; }
.thumbnails-sheet header { min-height: 54px; padding: .35rem .65rem .35rem 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #30333a; }
.thumbnails-sheet h1 { margin: 0; font-size: 1rem; }
.thumbnails { overflow: auto; padding: .75rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; }
.thumbnail { min-height: 0; padding: 0; display: grid; border-radius: .25rem; overflow: hidden; }
.thumbnail[aria-current="page"] { outline: 2px solid #e5e7eb; outline-offset: 1px; }
.thumbnail img { width: 100%; height: auto; aspect-ratio: 573 / 800; object-fit: cover; background: #fff; }
.thumbnail span { padding: .2rem; font-size: .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (min-width: 760px) {
  #flipbook { width: min(96vw, calc((100dvh - 76px) * 1.4325)); aspect-ratio: 1146 / 800; }
  .controls-area { min-height: 76px; }
  .thumbnails-panel { place-items: center; }
  .thumbnails-sheet { border-radius: .8rem; }
  .thumbnails { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
