:root {
  color-scheme: light;
  --navy: #000066;
  --accent: #feee00;
  --accent-dark: #dfd100;
  --ink: #000066;
  --muted: #505078;
  --paper: #f7f7fb;
  --surface: #ffffff;
  --line: rgba(0, 0, 102, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 102, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 22%, rgba(0, 0, 102, 0.06), transparent 28%),
    radial-gradient(circle at 88% 74%, rgba(254, 238, 0, 0.13), transparent 30%),
    var(--paper);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: 14px max(20px, calc((100vw - 1480px) / 2));
  border-bottom: 4px solid var(--accent);
  background: var(--navy);
  box-shadow: 0 8px 28px rgba(0, 0, 102, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand__logo {
  display: block;
  width: 188px;
  height: 54px;
  object-fit: cover;
  object-position: center;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.edition-chip {
  margin-right: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.action,
.control-button,
.page-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

.action {
  min-height: 42px;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 99px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.action--download {
  color: var(--navy);
  border-color: var(--accent);
  background: var(--accent);
}

.action--icon {
  width: 42px;
  padding: 0;
}

.action svg,
.control-button svg,
.page-arrow svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.action:hover,
.control-button:hover:not(:disabled) {
  transform: translateY(-2px);
  color: var(--navy);
  border-color: rgba(0, 0, 102, 0.24);
  background: var(--accent);
}

.icon-collapse {
  display: none;
}

:fullscreen .icon-expand {
  display: none;
}

:fullscreen .icon-collapse {
  display: block;
}

.reader {
  width: min(100% - 40px, 1480px);
  margin: 0 auto;
  padding: 42px 0 30px;
}

.reader__intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin: 0 auto 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 7px 11px;
  border-radius: 7px;
  color: var(--navy);
  background: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.eyebrow::before {
  display: none;
}

h1 {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: clamp(1.55rem, 3vw, 2.7rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.07;
}

.reader__intro p {
  margin: 0 0 4px;
  max-width: 380px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.reader__stage {
  position: relative;
  display: grid;
  min-height: clamp(520px, 71vh, 900px);
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 102, 0.15);
  border-top: 5px solid var(--accent);
  border-radius: 24px;
  background:
    linear-gradient(rgba(255, 253, 249, 0.92), rgba(255, 253, 249, 0.96)),
    radial-gradient(circle, rgba(0, 0, 102, 0.13) 1.5px, transparent 2px);
  background-size: auto, 38px 38px;
  box-shadow: inset 0 1px 0 white, 0 22px 65px rgba(0, 0, 102, 0.1);
  isolation: isolate;
}

.reader__stage::after {
  position: absolute;
  right: 15%;
  bottom: 3.5%;
  left: 15%;
  z-index: -1;
  height: 6%;
  border-radius: 50%;
  background: rgba(51, 29, 20, 0.18);
  filter: blur(24px);
  content: "";
}

.ambient {
  position: absolute;
  z-index: -2;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.65;
  pointer-events: none;
}

.ambient--one {
  top: -180px;
  left: -80px;
  background: radial-gradient(circle, rgba(0, 0, 102, 0.13), transparent 70%);
}

.ambient--two {
  right: -100px;
  bottom: -180px;
  background: radial-gradient(circle, rgba(254, 238, 0, 0.2), transparent 70%);
}

.stage-signature {
  position: absolute;
  top: 50%;
  left: 8%;
  z-index: -1;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  color: var(--navy);
  opacity: 0.08;
  pointer-events: none;
  transform: translateY(-50%);
}

.stage-signature img {
  width: 250px;
  height: 105px;
  object-fit: cover;
  object-position: center;
}

.stage-signature span {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.book-wrap {
  display: grid;
  width: calc(100% - 150px);
  height: clamp(470px, 67vh, 850px);
  place-items: center;
  perspective: 2200px;
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 550ms ease, transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.book-wrap.is-ready {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.book {
  margin: auto;
}

.page {
  overflow: hidden;
  background: white;
}

.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.page::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(30, 18, 13, 0.08);
  content: "";
  pointer-events: none;
}

.page-arrow {
  position: absolute;
  z-index: 12;
  top: 50%;
  width: 54px;
  height: 74px;
  border: 1px solid var(--navy);
  border-radius: 18px;
  color: var(--accent);
  background: var(--navy);
  box-shadow: 0 12px 30px rgba(0, 0, 102, 0.18);
  backdrop-filter: blur(12px);
  transform: translateY(-50%);
}

.page-arrow--prev {
  left: 24px;
}

.page-arrow--next {
  right: 24px;
}

.page-arrow:hover:not(:disabled) {
  color: var(--navy);
  background: var(--accent);
  transform: translateY(-50%) scale(1.05);
}

.page-arrow:disabled,
.control-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.loading {
  position: absolute;
  z-index: 15;
  display: flex;
  align-items: center;
  flex-direction: column;
  width: min(300px, calc(100% - 50px));
  text-align: center;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.loading.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loading__brand {
  width: 62px;
  height: 62px;
  margin-bottom: 18px;
  padding: 12px;
  border-radius: 18px;
  background: var(--navy);
  box-shadow: 0 10px 26px rgba(0, 0, 102, 0.18);
  object-fit: contain;
}

.loading strong,
.error strong {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 1rem;
}

.loading > span,
.error span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
}

.loading__track {
  width: 100%;
  height: 4px;
  margin-top: 17px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(38, 27, 23, 0.1);
}

.loading__track i {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 350ms ease;
}

.error {
  z-index: 16;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 24px;
  text-align: center;
}

.error[hidden] {
  display: none;
}

.reader__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: max-content;
  margin: 18px auto 0;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(0, 0, 102, 0.08);
  backdrop-filter: blur(10px);
}

.control-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: var(--navy);
}

.page-status {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 160px;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.page-status strong {
  color: var(--ink);
}

.page-status__track {
  flex: 1;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(38, 27, 23, 0.1);
}

.page-status__track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 350ms ease;
}

.reader__hint {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.reader__hint span {
  margin-right: 6px;
  color: var(--navy);
}

.action:focus-visible,
.control-button:focus-visible,
.page-arrow:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 8px 0 0;
  padding: 18px max(20px, calc((100vw - 1480px) / 2));
  border-top: 4px solid var(--accent);
  color: rgba(255, 255, 255, 0.72);
  background: var(--navy);
  font-size: 0.72rem;
}

.footer__logo {
  width: 130px;
  height: 38px;
  object-fit: cover;
  object-position: center;
}

.reader:fullscreen {
  width: 100%;
  padding: 22px;
  background: var(--paper);
}

.reader:fullscreen .reader__intro,
.reader:fullscreen .reader__hint,
.reader:fullscreen + footer {
  display: none;
}

.reader:fullscreen .reader__stage {
  min-height: calc(100vh - 92px);
}

.reader:fullscreen .book-wrap {
  height: calc(100vh - 120px);
}

.reader:fullscreen .reader__controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 30;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 253, 249, 0.88);
  box-shadow: 0 10px 30px rgba(45, 28, 21, 0.13);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

@media (max-width: 780px) {
  .reader {
    width: min(100% - 24px, 1480px);
  }

  .topbar {
    width: 100%;
    padding: 11px 12px;
  }

  .brand__logo {
    width: 136px;
    height: 44px;
  }

  .edition-chip {
    display: none;
  }

  .action--download {
    width: 42px;
    padding: 0;
  }

  .action--download span,
  .reader__intro p {
    display: none;
  }

  .reader {
    padding-top: 30px;
  }

  .reader__stage {
    min-height: clamp(460px, 68vh, 720px);
    border-radius: 20px;
  }

  .book-wrap {
    width: calc(100% - 38px);
    height: clamp(430px, 64vh, 680px);
  }

  .page-arrow {
    display: none;
  }

  .stage-signature {
    display: none;
  }

  footer {
    width: 100%;
    padding: 16px 12px;
  }
}

@media (max-width: 450px) {
  h1 {
    font-size: 1.55rem;
  }

  .reader__stage {
    min-height: 62vh;
  }

  .book-wrap {
    height: 59vh;
  }
}

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