:root {
  color-scheme: dark;
  --ink: #1c293f;
  --paper: #f3f0eb;
  --accent: #c7d1dc;
  --muted: #b8c1cb;
  --line: rgba(243, 240, 235, .17);
  --page-ratio: 1.2941176;
  --zoom-scale: 1;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  min-height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, rgba(89, 110, 139, .30), transparent 43%), linear-gradient(145deg, #293952 0%, #1c293f 58%, #111a29 100%);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }
.topbar {
  height: 68px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px;
  padding: 0 clamp(18px, 3vw, 44px); border-bottom: 1px solid var(--line);
  background: rgba(21, 31, 48, .82); backdrop-filter: blur(18px); position: relative; z-index: 20;
}
.brand { display: inline-flex; width: max-content; flex-direction: column; line-height: 1; }
.brand-mark { font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; letter-spacing: .20em; }
.brand-sub { margin-top: 5px; font-size: .49rem; letter-spacing: .15em; color: var(--accent); }
.catalog-title { font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; letter-spacing: .04em; }
.catalog-title span { color: var(--accent); margin-left: .45em; }
.icon-button, .page-arrow, .control-button, .zoom-button, .zoom-readout {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .055); cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .2s ease, opacity .2s ease;
}
.icon-button:hover, .page-arrow:hover, .control-button:hover, .zoom-button:hover, .zoom-readout:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); }
.icon-button:focus-visible, .page-arrow:focus-visible, .control-button:focus-visible, .zoom-button:focus-visible, .zoom-readout:focus-visible, .page-status input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.icon-button { justify-self: end; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; }
.icon-button svg, .page-arrow svg, .control-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.reader-shell { height: calc(100dvh - 140px); min-height: 280px; display: grid; place-items: center; padding: 16px 20px; overflow: auto; }
.reader { width: 100%; height: 100%; display: grid; grid-template-columns: 50px minmax(0, 1fr) 50px; align-items: center; gap: clamp(8px, 1.4vw, 22px); }
.book-wrap { display: grid; place-items: center; min-width: 0; min-height: 0; height: 100%; perspective: 2200px; }
.book { position: relative; width: min(100%, calc((100dvh - 194px) * var(--page-ratio))); aspect-ratio: var(--page-ratio); filter: drop-shadow(0 25px 28px rgba(0,0,0,.42)); transform: scale(var(--zoom-scale)); transform-origin: center; transform-style: preserve-3d; cursor: pointer; user-select: none; touch-action: pan-y; }
.page, .flip-face { background-color: var(--paper); background-repeat: no-repeat; background-position: center; background-size: 100% 100%; }
.page { position: absolute; inset: 0; overflow: hidden; border-radius: 3px; box-shadow: 0 14px 35px rgba(0,0,0,.24), inset -10px 0 18px -19px #000; }
.hotspots { position: absolute; inset: 0; }
.hotspot-link { position: absolute; display: grid; place-items: center; color: #fff; text-decoration: none; }
.hotspot-link::after { content: "+"; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.8); border-radius: 50%; background: rgba(28,41,63,.68); font-size: 19px; line-height: 1; opacity: 0; transform: scale(.85); transition: opacity .18s ease, transform .18s ease; }
.hotspot-link:hover::after, .hotspot-link:focus-visible::after { opacity: 1; transform: scale(1); }
.hotspot-link:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.flip-sheet { display: none; position: absolute; inset: 0; z-index: 10; transform-style: preserve-3d; will-change: transform; }
.flip-sheet.forward { display: block; transform-origin: left center; animation: turnForward .68s cubic-bezier(.45,.04,.2,1) forwards; }
.flip-sheet.backward { display: block; transform-origin: right center; animation: turnBackward .68s cubic-bezier(.45,.04,.2,1) forwards; }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 3px; }
.flip-front { box-shadow: inset 13px 0 25px -20px #000, 8px 0 22px rgba(0,0,0,.19); }
.flip-back { transform: rotateY(180deg); box-shadow: inset -13px 0 25px -20px #000, -8px 0 22px rgba(0,0,0,.19); }
@keyframes turnForward { 0% { transform: rotateY(0deg); filter: brightness(1); } 43% { filter: brightness(.72); } 100% { transform: rotateY(-180deg); filter: brightness(1); } }
@keyframes turnBackward { 0% { transform: rotateY(0deg); filter: brightness(1); } 43% { filter: brightness(.72); } 100% { transform: rotateY(180deg); filter: brightness(1); } }
.page-arrow { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; }
.page-arrow:active { transform: scale(.96); }
.page-arrow[disabled], .control-button[disabled], .zoom-button[disabled] { opacity: .26; cursor: default; pointer-events: none; }
.controls { height: 72px; display: flex; justify-content: center; align-items: center; gap: 12px; padding: 0 18px max(0px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(21, 31, 48, .92); backdrop-filter: blur(18px); position: relative; z-index: 20; }
.control-button { min-width: 112px; height: 38px; padding: 0 13px; border-radius: 999px; display: inline-flex; justify-content: center; align-items: center; gap: 7px; font-size: .8rem; letter-spacing: .02em; }
.page-status { min-width: 105px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: .82rem; }
.page-status input { width: 48px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.06); text-align: center; appearance: textfield; }
.page-status input::-webkit-outer-spin-button, .page-status input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.control-divider { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.zoom-button, .zoom-readout { height: 34px; border-radius: 7px; display: grid; place-items: center; }
.zoom-button { width: 34px; font-size: 1.15rem; line-height: 1; }
.zoom-readout { width: 54px; font-size: .76rem; font-variant-numeric: tabular-nums; }
.loading { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; justify-content: center; align-items: center; background: #1c293f; transition: opacity .5s ease, visibility .5s ease; }
.loading.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-mark { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; letter-spacing: .22em; }
.loading-line { width: 150px; height: 1px; margin-top: 20px; overflow: hidden; background: rgba(255,255,255,.18); }
.loading-line span { display: block; width: 45%; height: 100%; background: var(--accent); animation: load 1.2s ease-in-out infinite; }
.loading p { margin: 13px 0 0; color: var(--muted); font-size: .78rem; letter-spacing: .08em; }
@keyframes load { from { transform: translateX(-110%); } to { transform: translateX(330%); } }
.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 (max-width: 760px) {
  .topbar { height: 58px; grid-template-columns: 1fr auto; padding: 0 14px; }
  .brand-mark { font-size: 1.05rem; }
  .brand-sub { font-size: .43rem; }
  .catalog-title { display: none; }
  .reader-shell { height: calc(100dvh - 122px); min-height: 260px; padding: 10px 7px; }
  .reader { grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 2px; }
  .page-arrow { width: 36px; height: 36px; border: 0; background: transparent; }
  .book { width: min(100%, calc((100dvh - 164px) * var(--page-ratio))); }
  .controls { height: 64px; gap: 6px; padding-inline: 7px; }
  .control-button { min-width: 38px; width: 38px; padding: 0; border: 0; background: transparent; }
  .control-button span { display: none; }
  .page-status { min-width: 92px; gap: 5px; font-size: .76rem; }
  .control-divider { margin: 0 1px; }
  .zoom-button { width: 31px; }
  .zoom-readout { width: 48px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
