:root {
  --navy: #064d78;
  --blue: #0f75bd;
  --sky: #2897d3;
  --pale: #e2f0f9;
  --ink: #173b52;
  --muted: #647f91;
  --white: #fff;
  --shadow: 0 30px 90px rgba(0, 31, 53, .28);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { min-width: 320px; margin: 0; color: var(--ink); background: linear-gradient(145deg, #043a5c 0%, var(--navy) 48%, #0a679f 115%); font-family: "Avenir Next", "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.skip-link { position: fixed; z-index: 100; left: 12px; top: 12px; transform: translateY(-160%); padding: 10px 14px; border-radius: 8px; background: white; color: var(--navy); font-weight: 800; }
.skip-link:focus { transform: translateY(0); }

.catalog-header { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; min-height: 82px; padding: 9px max(24px, calc((100vw - 1440px) / 2)); border-bottom: 1px solid rgba(255,255,255,.12); background: rgba(4, 61, 96, .94); color: white; box-shadow: 0 12px 34px rgba(0,25,42,.16); backdrop-filter: blur(16px); }
.catalog-brand { display: inline-flex; text-decoration: none; }
.logo-window { position: relative; display: block; width: 205px; height: 60px; overflow: hidden; border-radius: 8px; background: white; box-shadow: 0 8px 24px rgba(0, 25, 42, .2); }
.logo-window img { position: absolute; width: 240px; height: 240px; max-width: none; left: -18px; top: -90px; }
.catalog-title { display: grid; gap: 2px; min-width: 0; }
.catalog-title span { color: #8bd4f2; font-size: .69rem; font-weight: 800; letter-spacing: .16em; }
.catalog-title strong { overflow: hidden; color: rgba(255,255,255,.95); font-size: .96rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.catalog-title small { overflow: hidden; color: rgba(255,255,255,.68); font-size: .72rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.catalog-actions { display: flex; align-items: center; gap: 8px; }
.catalog-actions a { display: inline-flex; align-items: center; min-height: 42px; padding: 0 15px; border: 1px solid rgba(255,255,255,.24); border-radius: 99px; color: rgba(255,255,255,.84); font-size: .86rem; font-weight: 700; text-decoration: none; transition: background .2s, border .2s, color .2s; }
.catalog-actions a:hover, .catalog-actions a:focus-visible { border-color: white; color: white; }
.catalog-actions .download-link { border-color: white; background: white; color: var(--blue); }
.catalog-actions .download-link:hover, .catalog-actions .download-link:focus-visible { background: var(--pale); color: var(--navy); }

.catalog-reader { min-height: calc(100vh - 82px); padding: 26px 24px 32px; }
.reader-shell { width: min(1180px, 100%); margin: 0 auto; }
.reader-heading { display: flex; align-items: end; justify-content: space-between; gap: 35px; margin-bottom: 18px; color: white; }
.reader-kicker { color: #8bd4f2; font-size: .7rem; font-weight: 800; letter-spacing: .16em; }
.reader-heading h1 { margin: 7px 0 0; font-size: clamp(1.7rem, 3vw, 2.55rem); line-height: 1.08; letter-spacing: -.035em; }
.reader-heading p { max-width: 420px; margin: 0 0 3px; color: rgba(255,255,255,.68); font-size: .93rem; line-height: 1.5; }

.book-stage { position: relative; display: grid; place-items: center; min-height: min(66vh, 700px); padding: 18px 70px; border: 1px solid rgba(255,255,255,.14); border-radius: 22px 22px 9px 9px; background: radial-gradient(circle at 50% 25%, rgba(40,151,211,.16), transparent 42%), rgba(1, 31, 51, .38); box-shadow: inset 0 1px 0 rgba(255,255,255,.06); overflow: hidden; touch-action: pan-y; }
.book-stage::before { content: ""; position: absolute; width: 440px; height: 440px; right: -260px; top: -290px; border: 1px solid rgba(139,212,242,.13); border-radius: 50%; box-shadow: 0 0 0 55px rgba(139,212,242,.025), 0 0 0 110px rgba(139,212,242,.018); pointer-events: none; }
.page-frame { position: relative; max-width: 100%; border-radius: 3px; background: white; box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.24); transform-origin: center center; transition: opacity .18s ease, transform .22s ease; }
.page-frame.turn-next { opacity: .28; transform: perspective(1100px) rotateY(-7deg) translateX(-12px) scale(.985); }
.page-frame.turn-previous { opacity: .28; transform: perspective(1100px) rotateY(7deg) translateX(12px) scale(.985); }
#pdf-canvas { display: block; max-width: 100%; height: auto; border-radius: 3px; background: white; }
.paper-edge { position: absolute; inset: 0 0 0 auto; width: 8px; border-left: 1px solid rgba(0,0,0,.06); background: linear-gradient(90deg, transparent, rgba(0,0,0,.045)); pointer-events: none; }

.loading-state { display: grid; justify-items: center; gap: 15px; color: rgba(255,255,255,.82); font-size: .95rem; }
.loading-ring { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: #8bd4f2; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { position: relative; z-index: 3; max-width: 430px; padding: 30px; border-radius: 14px; background: white; text-align: center; box-shadow: var(--shadow); }
.error-state strong { color: var(--navy); font-size: 1.15rem; }
.error-state p { color: var(--muted); line-height: 1.55; }
.error-state a { display: inline-flex; padding: 11px 18px; border-radius: 8px; background: var(--blue); color: white; font-weight: 800; text-decoration: none; }

.page-zone { position: absolute; z-index: 4; top: 50%; display: grid; place-items: center; width: 46px; height: 72px; margin-top: -36px; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; background: rgba(4, 61, 96, .72); color: white; cursor: pointer; backdrop-filter: blur(10px); transition: background .2s, transform .2s, opacity .2s; }
.page-zone:hover:not(:disabled), .page-zone:focus-visible { background: var(--blue); transform: scale(1.05); }
.page-zone:disabled { opacity: .2; cursor: default; }
.page-zone span { margin-top: -5px; font-family: Georgia, serif; font-size: 2.5rem; line-height: 1; }
.page-zone-previous { left: 15px; }
.page-zone-next { right: 15px; }

.reader-toolbar { display: grid; grid-template-columns: 1fr auto auto 1fr; align-items: center; gap: 12px; min-height: 70px; padding: 11px 14px; border-radius: 0 0 14px 14px; background: white; box-shadow: 0 15px 38px rgba(0,25,42,.18); }
.toolbar-button { display: flex; align-items: center; gap: 9px; width: max-content; min-height: 44px; padding: 0 15px; border: 0; border-radius: 8px; background: #eaf5fb; color: var(--navy); font-weight: 800; cursor: pointer; transition: background .2s, color .2s; }
.toolbar-button:last-child { justify-self: end; }
.toolbar-button:hover:not(:disabled), .toolbar-button:focus-visible { background: var(--blue); color: white; }
.toolbar-button:disabled { opacity: .42; cursor: default; }
.page-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .87rem; font-weight: 700; }
.page-control input { width: 64px; height: 42px; border: 1px solid #c8deeb; border-radius: 8px; color: var(--navy); background: white; text-align: center; font-weight: 800; }
.page-control input:focus { outline: 3px solid rgba(40,151,211,.23); border-color: var(--blue); }
.zoom-control { display: flex; align-items: center; overflow: hidden; border: 1px solid #d2e5ef; border-radius: 8px; }
.zoom-control button { width: 38px; height: 40px; border: 0; background: #f2f8fb; color: var(--navy); font-size: 1.2rem; cursor: pointer; }
.zoom-control button:hover:not(:disabled), .zoom-control button:focus-visible { background: var(--pale); }
.zoom-control output { min-width: 58px; color: var(--muted); text-align: center; font-size: .78rem; font-weight: 800; }
.keyboard-note { margin: 14px 0 0; color: rgba(255,255,255,.58); text-align: center; font-size: .79rem; line-height: 1.5; }
.keyboard-note span { display: inline-block; margin-right: 7px; padding: 3px 7px; border: 1px solid rgba(255,255,255,.2); border-radius: 5px; color: rgba(255,255,255,.8); }
.reader-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 860px) {
  .catalog-header { grid-template-columns: auto 1fr; gap: 14px; padding-inline: 14px; }
  .catalog-title { display: none; }
  .catalog-actions { justify-self: end; }
  .catalog-actions a { min-height: 40px; padding-inline: 12px; font-size: .78rem; }
  .logo-window { width: 183px; height: 54px; }
  .logo-window img { width: 216px; height: 216px; left: -16px; top: -81px; }
  .reader-heading { align-items: start; flex-direction: column; gap: 8px; }
  .reader-heading p { max-width: none; }
  .book-stage { min-height: 62vh; }
}

@media (max-width: 620px) {
  .catalog-header { min-height: 68px; }
  .logo-window { width: 155px; height: 46px; }
  .logo-window img { width: 184px; height: 184px; left: -15px; top: -69px; }
  .catalog-actions a:first-child { display: none; }
  .catalog-actions a { min-height: 38px; padding-inline: 11px; }
  .catalog-reader { min-height: calc(100vh - 68px); padding: 20px 11px 26px; }
  .reader-heading { padding: 0 5px; }
  .reader-heading h1 { font-size: 1.65rem; }
  .reader-heading p { font-size: .86rem; }
  .book-stage { min-height: 58vh; padding: 12px 40px; border-radius: 15px 15px 7px 7px; }
  .page-zone { width: 34px; height: 58px; margin-top: -29px; border-radius: 9px; }
  .page-zone-previous { left: 4px; }
  .page-zone-next { right: 4px; }
  .reader-toolbar { grid-template-columns: 1fr auto 1fr; gap: 5px; min-height: 64px; padding: 8px; }
  .toolbar-button { min-height: 42px; padding: 0 10px; }
  .toolbar-button span:not([aria-hidden="true"]) { display: none; }
  .page-control { gap: 5px; font-size: .75rem; }
  .page-control label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .page-control input { width: 50px; height: 40px; }
  .zoom-control { display: none; }
  .keyboard-note { padding-inline: 15px; }
}

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