* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #1f2c2c;
  color: #fffaf4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.vault-shell,
.reader {
  width: 100vw;
  height: 100vh;
}

.reader {
  position: relative;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(72px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow: hidden;
}

.reader-stage {
  position: relative;
  width: min(100%, calc((100vh - 116px) * .7727));
  max-width: 760px;
  aspect-ratio: 8.5 / 11;
  touch-action: pan-y;
}

.reader-page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fffaf4;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .35);
  opacity: 0;
  transform: translateX(34px) scale(.985);
  transition: opacity .24s ease, transform .28s ease;
}

.print-stack {
  display: none;
}

.reader-page.is-active {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.reader-page.is-exiting-left {
  opacity: 0;
  transform: translateX(-34px) scale(.985);
}

.reader-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 250, 244, .28);
  border-radius: 50%;
  background: rgba(255, 250, 244, .12);
  color: #fffaf4;
  font-size: 44px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(18px);
}

.reader-nav-prev {
  left: clamp(10px, 3vw, 34px);
}

.reader-nav-next {
  right: clamp(10px, 3vw, 34px);
}

.reader-nav:disabled {
  opacity: .28;
  cursor: default;
}

.reader-bottom {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 8px 10px 8px 16px;
  border: 1px solid rgba(255, 250, 244, .18);
  border-radius: 999px;
  background: rgba(16, 22, 22, .72);
  backdrop-filter: blur(18px);
}

.reader-bottom span {
  font-size: 13px;
  font-weight: 900;
}

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

.reader-actions a,
.reader-actions button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  background: #fffaf4;
  color: #1f2c2c;
  text-decoration: none;
  font: inherit;
  font-size: 12px;
  font-weight: 950;
  cursor: pointer;
}

.reader-actions .reader-shop-link {
  background: #c7a05d;
}

.final-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(31, 44, 44, .94);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
}

.final-card.is-active {
  opacity: 1;
  pointer-events: auto;
}

.final-card h1 {
  margin: 0;
  max-width: 520px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 7vw, 78px);
  font-weight: 500;
  line-height: .94;
}

.final-card p {
  max-width: 460px;
  color: rgba(255, 250, 244, .76);
  line-height: 1.6;
}

.final-card a {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 22px;
  background: #fffaf4;
  color: #1f2c2c;
  text-decoration: none;
  font-weight: 950;
}

@media (max-width: 740px) {
  .reader-nav {
    top: auto;
    bottom: 82px;
    width: 46px;
    height: 46px;
    font-size: 34px;
  }

  .reader-bottom {
    align-items: flex-start;
    flex-direction: column;
    border-radius: 18px;
  }

  .reader-actions {
    width: 100%;
    overflow-x: auto;
  }
}

@media print {
  body {
    overflow: visible;
    background: white;
  }

  .reader {
    display: block;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .reader-stage {
    display: none;
  }

  .print-stack {
    display: block;
  }

  .print-page {
    display: block;
    width: 8.5in;
    height: 11in;
    margin: 0 auto;
    object-fit: contain;
    background: white;
    page-break-after: always;
  }

  .reader-page {
    display: none;
  }

  .reader-nav,
  .reader-bottom,
  .final-card {
    display: none;
  }
}
