.ebook-reader-page {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.ebook-reader-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.ebook-reader-heading h1 {
  max-width: 1050px;
  margin: 8px 0 0;
  color: #08213b;
  font-size: clamp(1.35rem, 1.8vw, 2rem);
  line-height: 1.16;
}

.ebook-back-link { flex: 0 0 auto; }

.ebook-reader {
  overflow: hidden;
  border: 1px solid #153a5d;
  border-radius: 24px;
  background: #071b2e;
  box-shadow: 0 28px 70px rgba(5, 26, 46, .22);
}

.ebook-toolbar,
.ebook-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: #0b2944;
  color: #fff;
}

.ebook-toolbar { border-bottom: 1px solid rgba(255, 255, 255, .12); }
.ebook-navigation { border-top: 1px solid rgba(255, 255, 255, .12); }

.ebook-source-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ebook-source-control label {
  color: #b8d7ec;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ebook-source-control select {
  width: min(520px, 48vw);
  min-height: 42px;
  padding: 8px 36px 8px 12px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  background: #fff;
  color: #102a43;
  font: inherit;
}

.ebook-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ebook-tool-button,
.ebook-nav-button {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: inherit;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.ebook-tool-button:hover,
.ebook-tool-button:focus-visible,
.ebook-nav-button:hover,
.ebook-nav-button:focus-visible {
  border-color: #7dd3fc;
  background: rgba(125, 211, 252, .18);
  color: #fff;
}

.ebook-tool-button:active,
.ebook-nav-button:active { transform: translateY(1px); }

.ebook-nav-button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.ebook-stage {
  position: relative;
  display: grid;
  min-height: clamp(500px, 72vh, 1020px);
  place-items: center;
  overflow: hidden;
  padding: clamp(20px, 3vw, 44px);
  background:
    radial-gradient(circle at 50% 22%, rgba(37, 99, 135, .55), transparent 46%),
    linear-gradient(145deg, #0a243b 0%, #061726 68%, #04111d 100%);
}

.ebook-stage::after {
  position: absolute;
  right: 6%;
  bottom: 22px;
  left: 6%;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .42);
  content: "";
  filter: blur(20px);
  pointer-events: none;
}

.ebook-book {
  position: relative;
  z-index: 2;
  margin: 0 auto;
  opacity: 0;
  transition: opacity .25s ease;
}

.ebook-reader.is-ready .ebook-book { opacity: 1; }

.ebook-page {
  overflow: hidden;
  border: 1px solid #d9e2e9;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(8, 33, 59, .04);
}

.ebook-page::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(110deg, #eef3f6 8%, #f9fbfc 18%, #eef3f6 33%);
  background-size: 200% 100%;
  color: #557086;
  content: "Loading page " attr(data-pdf-page) "…";
  font-size: .9rem;
  animation: ebook-page-loading 1.4s linear infinite;
}

.ebook-page.is-rendered::before { display: none; }

.ebook-page img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  -webkit-user-drag: none;
  user-select: none;
}

.ebook-status {
  position: absolute;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(520px, calc(100% - 40px));
  padding: 15px 19px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  background: rgba(4, 17, 29, .9);
  color: #e8f5ff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .28);
  backdrop-filter: blur(12px);
}

.ebook-reader.is-ready .ebook-status { display: none; }
.ebook-reader.has-error .ebook-status { border-color: #fda4af; color: #fff1f2; }

.ebook-spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #7dd3fc;
  border-radius: 50%;
  animation: ebook-spin .8s linear infinite;
}

.ebook-reader.has-error .ebook-spinner { display: none; }

.ebook-page-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #c9e4f5;
  white-space: nowrap;
}

.ebook-page-control input {
  width: 70px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 9px;
  background: #fff;
  color: #102a43;
  font: inherit;
  font-weight: 800;
  text-align: center;
}

.ebook-help {
  margin: 0;
  padding: 10px 18px 13px;
  background: #0b2944;
  color: #a8c7dc;
  font-size: .82rem;
  text-align: center;
}

.ebook-error { margin: 0; padding: 16px; color: #fff1f2; }

.ebook-reader:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.ebook-reader:fullscreen .ebook-stage {
  min-height: calc(100vh - 142px);
}

@keyframes ebook-spin { to { transform: rotate(360deg); } }
@keyframes ebook-page-loading { to { background-position-x: -200%; } }

@media (max-width: 760px) {
  .ebook-reader-page { width: min(100% - 20px, 1600px); padding-top: 22px; }
  .ebook-reader-heading { display: block; }
  .ebook-back-link { display: inline-flex; margin-top: 16px; }
  .ebook-reader { border-radius: 16px; }
  .ebook-toolbar { align-items: stretch; flex-direction: column; }
  .ebook-source-control { align-items: stretch; flex-direction: column; gap: 6px; }
  .ebook-source-control select { width: 100%; }
  .ebook-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .ebook-tool-button { display: inline-flex; align-items: center; justify-content: center; }
  .ebook-stage { min-height: 66vh; padding: 18px 10px; }
  .ebook-navigation { gap: 8px; padding: 11px 10px; }
  .ebook-nav-button { padding-inline: 10px; font-size: .86rem; }
  .ebook-page-control { gap: 5px; font-size: .8rem; }
  .ebook-page-control input { width: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .ebook-book,
  .ebook-tool-button,
  .ebook-nav-button { transition: none; }
  .ebook-page::before,
  .ebook-spinner { animation-duration: .01ms; animation-iteration-count: 1; }
}

.a11y-high-contrast .ebook-reader { border-color: #fff; }
.a11y-high-contrast .ebook-toolbar,
.a11y-high-contrast .ebook-navigation,
.a11y-high-contrast .ebook-help { background: #000; }
.a11y-high-contrast .ebook-stage { background: #111; }
