:root {
  --navy-950: #061127;
  --navy-900: #081634;
  --navy-850: #0b1a3d;
  --navy-800: #0e214b;
  --orange: #f15b2a;
  --orange-soft: #ff7b42;
  --paper: #f8f8f6;
  --ink: #f6f8ff;
  --muted: #a9b4c9;
  --line: rgba(255,255,255,.11);
  --shadow: rgba(1, 7, 20, .55);
  --page-ratio: 0.71251855;
  --topbar-h: 74px;
  --bottombar-h: 58px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--navy-950); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { display: block; width: 100%; height: 100%; fill: currentColor; }

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr) var(--bottombar-h);
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(circle at 23% 22%, rgba(241, 91, 42, .06), transparent 34%),
    radial-gradient(circle at 76% 72%, rgba(54, 89, 160, .11), transparent 36%),
    linear-gradient(135deg, #07142e 0%, #061127 55%, #081633 100%);
}

.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(155px, 220px) 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 15, 35, .8);
  backdrop-filter: blur(18px);
}

.brand { height: 64px; overflow: visible; display: flex; align-items: center; min-width: 0; }
.brand img {
  width: 154px;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.catalog-title { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.catalog-title strong { font-size: 15px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-title span { color: var(--orange-soft); font-weight: 700; font-size: 13px; }

.toolbar { display: flex; align-items: center; gap: 6px; }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #dfe6f6;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .18s ease, color .18s ease;
}
.icon-button svg { width: 20px; height: 20px; }
.icon-button:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.09); color: white; transform: translateY(-1px); }
.icon-button:active { transform: translateY(0) scale(.96); }
.icon-button[aria-pressed="true"] { color: var(--orange-soft); background: rgba(241,91,42,.12); }
.icon-button:focus-visible, .text-button:focus-visible, .small-nav:focus-visible, input:focus-visible, .edge-button:focus-visible, .thumb-card:focus-visible, .zoom-control:focus-visible {
  outline: 2px solid #ff8a57;
  outline-offset: 2px;
}

.viewer {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  isolation: isolate;
}

.ambient-glow { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .22; pointer-events: none; z-index: -2; }
.glow-a { width: 380px; height: 380px; background: rgba(241,91,42,.24); left: 9%; top: 4%; animation: driftA 12s ease-in-out infinite alternate; }
.glow-b { width: 420px; height: 420px; background: rgba(33,76,153,.32); right: 4%; bottom: -8%; animation: driftB 15s ease-in-out infinite alternate; }
@keyframes driftA { to { transform: translate(45px, 30px) scale(1.08); } }
@keyframes driftB { to { transform: translate(-35px, -22px) scale(.92); } }

.book-zone { min-width: 0; min-height: 0; height: 100%; display: grid; place-items: center; padding: 18px 8px; }
.edge-button {
  justify-self: center;
  width: 46px;
  height: 74px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  color: rgba(255,255,255,.77);
  cursor: pointer;
  opacity: .72;
  transition: opacity .2s ease, background .2s ease, transform .2s ease;
}
.edge-button svg { width: 24px; margin: auto; }
.edge-button:hover { opacity: 1; background: rgba(255,255,255,.08); transform: scale(1.04); }
.edge-button:disabled { opacity: .18; pointer-events: none; }

.bottom-bar {
  position: relative;
  z-index: 25;
  display: grid;
  grid-template-columns: 120px 1fr auto 120px;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  background: rgba(5, 15, 35, .83);
  backdrop-filter: blur(18px);
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  cursor: pointer;
  transition: color .18s ease;
}
.text-button:hover { color: white; }
.page-control { justify-self: center; display: flex; align-items: center; gap: 4px; border: 1px solid rgba(255,255,255,.09); border-radius: 13px; padding: 3px 6px; background: rgba(255,255,255,.035); }
.page-control input {
  width: 46px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: rgba(255,255,255,.05);
  text-align: center;
  font-weight: 700;
  appearance: textfield;
}
.page-control input::-webkit-inner-spin-button { display: none; }
.page-total { color: var(--muted); font-size: 12px; padding-right: 3px; }
.small-nav { width: 28px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: white; cursor: pointer; font-size: 23px; line-height: 1; }
.small-nav:hover { background: rgba(255,255,255,.07); }
.spread-indicator { justify-self: end; min-width: 82px; color: #dce3f2; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottombar-h) + 18px);
  z-index: 100;
  transform: translate(-50%, 12px);
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  color: white;
  background: rgba(5,15,35,.93);
  box-shadow: 0 16px 38px rgba(0,0,0,.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.cookie-notice {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: calc(var(--bottombar-h) + 18px);
  width: min(430px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  color: #edf2ff;
  background: rgba(5,15,35,.97);
  box-shadow: 0 18px 50px rgba(0,0,0,.34);
}
.cookie-notice strong { display: block; font-size: 14px; }
.cookie-notice p { margin: 6px 0 7px; color: #c8d2e6; font-size: 13px; line-height: 1.45; }
.cookie-notice a { color: #fff; font-size: 12px; font-weight: 700; text-underline-offset: 3px; }
.cookie-notice-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.cookie-notice-dismiss, .cookie-notice-accept {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.cookie-notice-dismiss { border: 1px solid rgba(255,255,255,.16); color: #e5eaf6; background: transparent; }
.cookie-notice-accept { border: 1px solid var(--orange); color: #fff; background: var(--orange); }
.cookie-notice-dismiss:focus-visible, .cookie-notice-accept:focus-visible { outline: 2px solid #ffac85; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
