:root {
  color-scheme: light;
  --bg: #f7f6f4;
  --surface: #ffffff;
  --surface-soft: #f0ece8;
  --ink: #171316;
  --muted: #756a70;
  --line: rgba(39, 31, 34, 0.14);
  --wine: #7a2140;
  --wine-deep: #2d101e;
  --gold: #d7ad64;
  --shadow: 0 18px 60px rgba(38, 24, 30, 0.18);
  --page-width: min(94vw, 900px);
  font-family: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(215, 173, 100, 0.18), transparent 30rem),
    linear-gradient(180deg, #faf9f7 0%, var(--bg) 36%, #efedf0 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(23, 19, 22, 0.035) 1px, transparent 1px);
  background-size: 100% 5px;
  opacity: 0.4;
  z-index: -1;
}

a {
  color: inherit;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px clamp(14px, 3vw, 36px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.reader-title {
  min-width: 0;
  overflow: hidden;
  color: var(--wine-deep);
  font-size: clamp(0.88rem, 1.4vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  white-space: nowrap;
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
}

.reader-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(122, 33, 64, 0.2);
  border-radius: 999px;
  background: #fff;
  color: var(--wine);
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.icon-button span {
  display: block;
  transform: translateY(-1px);
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.42;
  transform: none;
}

.icon-button.is-disabled,
.turn-link.is-disabled,
.jump-nav-link.is-disabled {
  pointer-events: none;
  cursor: default;
  opacity: 0.42;
  transform: none;
}

.book-shell {
  display: grid;
  gap: clamp(22px, 4vw, 42px);
  justify-items: center;
  padding: clamp(18px, 4vw, 42px) 0 64px;
}

.page-shell {
  gap: clamp(18px, 3vw, 28px);
}

.cover-page {
  position: relative;
  isolation: isolate;
  width: min(92vw, calc((100svh - 142px) * 0.6667), 690px);
  min-width: min(92vw, 320px);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: var(--wine-deep);
  box-shadow: var(--shadow);
}

.cover-page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 42%, rgba(0, 0, 0, 0.16) 62%, rgba(0, 0, 0, 0.76) 100%),
    radial-gradient(circle at 50% 8%, transparent 45%, rgba(20, 7, 14, 0.18) 100%);
  z-index: 1;
}

.cover-callout {
  position: absolute;
  right: clamp(16px, 5vw, 42px);
  bottom: clamp(18px, 5vw, 44px);
  left: clamp(16px, 5vw, 42px);
  z-index: 2;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.free-label {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--wine);
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(0.88rem, 2.3vw, 1.04rem);
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
}

.free-label-link {
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.free-label-link:hover,
.free-label-link:focus-visible {
  background: var(--wine);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.start-reading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #f3d79b);
  color: #2a141c;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.reader-progress {
  position: sticky;
  top: 64px;
  z-index: 15;
  width: 100%;
  height: 3px;
  margin-top: -42px;
  background: transparent;
}

.reader-progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  transition: width 180ms ease;
}

.page-shell .reader-progress {
  margin-top: -28px;
}

.book-heading {
  width: min(94vw, 900px);
  padding: 2px clamp(14px, 3vw, 28px) 0;
  text-align: center;
}

.book-heading h1 {
  margin: 0;
  color: var(--wine-deep);
  font-size: clamp(1.55rem, 4.2vw, 2.8rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: 0;
}

#av_top_wrapper,
#av_content_1_wrapper {
  width: min(94vw, 900px) !important;
  border: 1px solid rgba(122, 33, 64, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 42px rgba(46, 34, 38, 0.08);
}

#av_top_wrapper {
  display: none !important;
}

#av_top_wrapper p,
#av_content_1_wrapper p {
  margin: 10px 0 0;
  color: rgba(117, 106, 112, 0.76);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

.zoom-toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 7px 10px;
  border: 1px solid rgba(122, 33, 64, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(46, 34, 38, 0.08);
}

.zoom-button {
  width: 38px;
  height: 38px;
  font-size: 1rem;
}

.zoom-level {
  min-width: 54px;
  color: var(--wine-deep);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.page-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(94vw, 900px);
  padding: 10px;
  border: 1px solid rgba(122, 33, 64, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(46, 34, 38, 0.08);
  font-family: Arial, Helvetica, sans-serif;
}

.page-jump label {
  color: var(--wine-deep);
  font-size: 0.88rem;
  font-weight: 800;
}

.page-jump-field {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: min(100%, 330px);
}

.page-jump input {
  width: 96px;
  height: 42px;
  border: 1px solid rgba(122, 33, 64, 0.22);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: 700 0.95rem Arial, Helvetica, sans-serif;
  text-align: center;
}

.page-jump input:focus-visible {
  border-color: var(--wine);
  outline: 2px solid rgba(122, 33, 64, 0.18);
  outline-offset: 2px;
}

.page-jump-button {
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid rgba(215, 173, 100, 0.72);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #f3d79b);
  color: #2a141c;
  cursor: pointer;
  font: 800 0.88rem Arial, Helvetica, sans-serif;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.page-jump-button:hover,
.page-jump-button:focus-visible {
  border-color: var(--wine);
  outline: none;
  transform: translateY(-1px);
}

.page-jump-button:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none;
}

.page-jump-status {
  min-height: 1.1em;
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.jump-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: 120px;
  padding: 10px 16px;
  border: 1px solid rgba(122, 33, 64, 0.22);
  border-radius: 999px;
  background: #fff;
  color: var(--wine);
  font: 800 0.84rem Arial, Helvetica, sans-serif;
  text-align: center;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.jump-nav-link:hover,
.jump-nav-link:focus-visible {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.jump-nav-link-primary {
  background: linear-gradient(135deg, var(--gold), #f3d79b);
  border-color: rgba(215, 173, 100, 0.72);
  color: #2a141c;
}

.pages {
  display: grid;
  justify-items: center;
  width: 100%;
  gap: clamp(22px, 4vw, 38px);
  padding: 0 clamp(10px, 3vw, 24px);
}

.single-page-reader {
  padding-top: 0;
}

.pdf-page {
  width: var(--page-width);
  scroll-margin-top: 92px;
}

.page-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 46px rgba(46, 34, 38, 0.13);
}

.page-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(39, 31, 34, 0.08);
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.76rem;
}

.text-wrap {
  min-height: 420px;
  background: #fff;
}

.text-page {
  display: none;
  width: 100%;
  max-width: 66ch;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 62px) clamp(18px, 5vw, 56px);
  color: #221b1f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(1.06rem * var(--reader-font-scale, 1));
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.text-page.is-ready {
  display: block;
}

.text-page p {
  margin: 0 0 1.05em;
}

.text-page p:last-child {
  margin-bottom: 0;
}

.text-page .text-page-empty {
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: center;
}

.page-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 420px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.88rem;
}

.reader-note {
  width: min(94vw, 900px);
  padding: clamp(16px, 4vw, 24px) clamp(18px, 5vw, 34px);
  border: 1px solid rgba(122, 33, 64, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: #3a3035;
  box-shadow: 0 12px 34px rgba(46, 34, 38, 0.07);
  text-align: center;
}

.reader-note p {
  margin: 0 auto 0.65em;
  max-width: 72ch;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  line-height: 1.55;
}

.reader-note p:last-child {
  margin-bottom: 0;
}

.reader-note-small {
  padding-top: 14px;
  padding-bottom: 14px;
}

.reader-note-small p {
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.86rem;
  line-height: 1.45;
}

.loading-card,
.fallback-card,
.ad-shell {
  width: min(94vw, 900px);
  border: 1px solid rgba(122, 33, 64, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 42px rgba(46, 34, 38, 0.08);
}

.loading-card,
.fallback-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 118px;
  padding: 20px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
}

.fallback-card {
  flex-direction: column;
  text-align: center;
}

.fallback-card a {
  color: var(--wine);
  font-weight: 700;
}

.loader {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(122, 33, 64, 0.18);
  border-top-color: var(--wine);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.ad-shell {
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 10px;
  color: rgba(117, 106, 112, 0.72);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ad-shell ins {
  width: 100%;
}

.page-turner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: min(94vw, 900px);
}

.turn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  min-width: min(44vw, 190px);
  padding: 12px 18px;
  border: 1px solid rgba(122, 33, 64, 0.22);
  border-radius: 999px;
  background: #fff;
  color: var(--wine);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.turn-link:hover,
.turn-link:focus-visible {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.turn-link-primary {
  background: linear-gradient(135deg, var(--gold), #f3d79b);
  border-color: rgba(215, 173, 100, 0.72);
  color: #2a141c;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .reader-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 58px;
  }

  .reader-title {
    font-size: 0.86rem;
  }

  .reader-status {
    grid-column: 1 / -1;
    order: 3;
    justify-content: center;
    width: 100%;
    padding-top: 2px;
    font-size: 0.76rem;
  }

  .reader-actions {
    gap: 6px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .page-jump {
    gap: 8px;
  }

  .book-heading {
    padding-top: 0;
  }

  .book-heading h1 {
    font-size: 1.62rem;
    line-height: 1.18;
  }

  #av_top_wrapper,
  #av_content_1_wrapper {
    min-height: 320px !important;
  }

  .page-jump-field {
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-jump-field label {
    flex-basis: 100%;
    text-align: center;
  }

  .page-jump input {
    width: min(42vw, 120px);
  }

  .jump-nav-link {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .book-shell {
    padding-top: 14px;
  }

  .cover-page {
    width: min(92vw, calc((100svh - 132px) * 0.6667), 520px);
  }

  .reader-progress {
    top: 78px;
    margin-top: -26px;
  }

  .page-shell .reader-progress {
    margin-top: -22px;
  }

  .page-meta {
    min-height: 34px;
    font-size: 0.7rem;
  }

  .text-wrap,
  .page-placeholder {
    min-height: 300px;
  }

  .text-page {
    max-width: none;
    padding: 22px 18px 30px;
    font-size: calc(1rem * var(--reader-font-scale, 1));
    line-height: 1.68;
  }

  .turn-link {
    min-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
