:root {
  --blue-950: #021b4b;
  --blue-900: #052d78;
  --blue-800: #073f9d;
  --blue-700: #0a55c9;
  --blue-600: #0f6de8;
  --blue-500: #2487ff;
  --red: #e51e2a;
  --ink: #0c2551;
  --muted: #63728d;
  --line: rgba(7, 63, 157, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #f4f8ff; }
body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(36,135,255,.12), transparent 26%),
    radial-gradient(circle at 92% 15%, rgba(10,85,201,.10), transparent 22%),
    linear-gradient(180deg, #fbfdff 0%, #f1f6ff 100%);
}
button, input { font: inherit; }
button { cursor: pointer; }

.reader-header {
  min-height: 84px;
  padding: 10px max(20px, calc((100vw - 1320px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  border-top: 2px solid #53c4c8;
  border-bottom: 1px solid rgba(7,63,157,.08);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 34px rgba(0,34,91,.06);
}
.reader-brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}
.reader-logos {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 14px;
  background: white;
  border: 1px solid rgba(7,63,157,.09);
}
.reader-logos img { display: block; width: auto; object-fit: contain; }
.reader-logos .logo-uef { height: 39px; }
.reader-logos .logo-fit { height: 34px; }
.reader-title strong, .reader-title small { display: block; }
.reader-title strong {
  color: var(--blue-900);
  font-weight: 800;
  letter-spacing: .07em;
  font-size: 18px;
}
.reader-title small {
  color: var(--muted);
  margin-top: 2px;
  font-size: 11px;
}
.reader-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn, .home-btn {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--blue-900);
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: .2s ease;
}
.icon-btn:hover, .home-btn:hover, .tool-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(15,109,232,.30);
  box-shadow: 0 8px 20px rgba(0,55,135,.08);
}
.home-btn { padding: 0 16px; font-size: 12px; font-weight: 700; }
.zoom-value { width: 52px; text-align: center; color: var(--muted); font-size: 11px; font-weight: 700; }

.reader-main {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 46px;
}
.reader-intro {
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: end;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue-600);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .17em;
}
.reader-intro h1 {
  margin: 0;
  color: var(--blue-900);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.1;
}
.reader-status {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--blue-900);
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.book-stage {
  min-height: 690px;
  padding: 34px 64px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 34px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,.90), rgba(238,245,255,.75) 55%, rgba(218,231,251,.75)),
    linear-gradient(145deg, #eaf2ff, #dce9fb);
  border: 1px solid rgba(7,63,157,.08);
  box-shadow: inset 0 0 80px rgba(42,108,199,.06), 0 25px 80px rgba(0,40,100,.10);
}
.book-stage::before {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  top: -320px;
  right: -160px;
  border-radius: 50%;
  border: 1px solid rgba(26,115,232,.14);
  box-shadow: 0 0 0 48px rgba(26,115,232,.025), 0 0 0 96px rgba(26,115,232,.018);
}
.book-wrap {
  width: 100%;
  min-height: 620px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform .2s ease;
}
.flipbook {
  position: relative;
  margin: auto;
  z-index: 3;
  filter: drop-shadow(0 28px 30px rgba(0,23,70,.18));
}
.flipbook .page { background: white; overflow: hidden; }
.pdf-page {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  overflow: hidden;
}
.pdf-page canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  background: white;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--blue-900);
  background: rgba(237,245,255,.88);
  backdrop-filter: blur(8px);
}
.loading-overlay[hidden] { display: none; }
.loading-overlay strong { margin-top: 16px; font-size: 15px; }
.loading-overlay span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(10,85,201,.13);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-panel {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 22;
  width: min(520px, calc(100% - 36px));
  padding: 34px;
  border-radius: 24px;
  text-align: center;
  background: white;
  border: 1px solid rgba(229,30,42,.12);
  box-shadow: 0 24px 80px rgba(0,35,94,.20);
  transform: translate(-50%, -50%);
}
.error-panel[hidden] { display: none; }
.error-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--red);
  font-size: 24px;
  font-weight: 800;
}
.error-panel h2 { margin: 0; color: var(--blue-900); font-size: 22px; }
.error-panel p { color: var(--muted); font-size: 13px; }
.error-panel code { padding: 2px 6px; border-radius: 6px; color: var(--blue-900); background: #eef4ff; }
.error-note { font-size: 11px !important; }

.nav-arrow {
  width: 48px;
  height: 68px;
  position: absolute;
  top: 50%;
  z-index: 30;
  border: 0;
  border-radius: 16px;
  color: white;
  background: linear-gradient(180deg, var(--blue-800), var(--blue-600));
  box-shadow: 0 14px 30px rgba(7,63,157,.22);
  font-size: 38px;
  line-height: 1;
  transform: translateY(-50%);
  transition: .2s ease;
}
.nav-arrow:hover { transform: translateY(-50%) scale(1.04); }
.nav-prev { left: 16px; }
.nav-next { right: 16px; }

.reader-toolbar {
  margin: 18px auto 0;
  width: min(760px, 100%);
  padding: 11px 14px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255,255,255,.90);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0,40,110,.08);
}
.toolbar-group { display: flex; gap: 6px; }
.tool-btn {
  height: 38px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  color: var(--blue-900);
  background: white;
  font-size: 12px;
  font-weight: 700;
  transition: .2s ease;
}
.page-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.page-control input {
  width: 56px;
  height: 36px;
  padding: 0 6px;
  border: 1px solid rgba(7,63,157,.15);
  border-radius: 9px;
  outline: none;
  text-align: center;
  color: var(--blue-900);
  background: white;
  font-weight: 700;
}
.page-control input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(36,135,255,.10);
}
.reader-help { margin: 14px auto 0; text-align: center; color: var(--muted); font-size: 11px; }
.reader-footer {
  padding: 25px max(20px, calc((100vw - 1320px) / 2));
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: rgba(255,255,255,.70);
  background: var(--blue-950);
  font-size: 10px;
}

@media (max-width: 1000px) {
  .reader-title small { display: none; }
  .reader-main { width: min(100% - 20px, 1380px); }
  .book-stage { min-height: 610px; padding: 24px 50px; }
  .book-wrap { min-height: 550px; }
}
@media (max-width: 760px) {
  .reader-header { min-height: 72px; padding: 10px 12px; gap: 10px; }
  .reader-logos { padding: 5px 7px; gap: 5px; }
  .reader-logos .logo-uef { height: 30px; }
  .reader-logos .logo-fit { height: 26px; }
  .reader-title strong { font-size: 14px; }
  .reader-actions { gap: 5px; }
  .reader-actions .zoom-value, .home-btn { display: none; }
  .icon-btn { min-width: 36px; width: 36px; height: 36px; }
  .reader-main { padding-top: 24px; }
  .reader-intro { align-items: flex-start; flex-direction: column; gap: 12px; }
  .reader-status { white-space: normal; }
  .book-stage { min-height: 520px; padding: 18px 38px; border-radius: 24px; }
  .book-wrap { min-height: 470px; }
  .nav-arrow { width: 36px; height: 58px; border-radius: 12px; font-size: 30px; }
  .nav-prev { left: 5px; }
  .nav-next { right: 5px; }
  .reader-toolbar { gap: 8px; }
  .tool-btn span { display: none; }
  .tool-btn { padding: 0 10px; }
  .reader-footer { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
  .reader-title { display: none; }
  .reader-logos .logo-uef { height: 26px; }
  .reader-logos .logo-fit { height: 23px; }
  .reader-intro h1 { font-size: 30px; }
  .book-stage { min-height: 465px; padding: 16px 31px; }
  .book-wrap { min-height: 425px; }
  .reader-toolbar { padding: 9px; }
  .page-control { gap: 4px; }
  .page-control input { width: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* Lazy PDF page rendering */
.page-placeholder,
.page-render-error {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #6a7891;
  background: #fff;
  font-size: 12px;
}

.mini-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(10, 85, 201, .12);
  border-top-color: #0f6de8;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.page-render-error {
  padding: 20px;
  color: #b3202e;
  text-align: center;
}
