:root {
  color-scheme: light;
  --paper: #f7f0e6;
  --paper-warm: #efe1ce;
  --ink: #3f3328;
  --muted: #796c60;
  --soft: #fffaf2;
  --gold: #d4a24f;
  --rose: #d39285;
  --sage: #899f89;
  --blue: #90b0c4;
  --night: #47536b;
  --shadow: rgba(63, 51, 40, 0.18);
}

/* Stable reading layout for all story pages. Keep this block at the end. */
.app-shell:not(.cover-mode) {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  padding: 10px;
}

.app-shell:not(.cover-mode) .book {
  width: min(100%, 520px);
  height: calc(100vh - 92px);
  min-height: 0;
}

.app-shell:not(.cover-mode) .page {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 38%) minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.app-shell:not(.cover-mode) .page::after {
  display: none;
}

.app-shell:not(.cover-mode) .art {
  align-self: center;
  overflow: hidden;
}

.app-shell:not(.cover-mode) .art-frame {
  width: min(46vw, 230px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 3 / 4;
  border-width: 6px;
}

.app-shell:not(.cover-mode) .copy {
  display: flex;
  min-height: 0;
  height: 100%;
  max-height: none;
  max-width: none;
  flex-direction: column;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin-bottom: 10px;
  font-size: clamp(1.55rem, 8vw, 2.75rem);
  line-height: 0.98;
}

.app-shell:not(.cover-mode) h2 {
  font-size: clamp(1.4rem, 7vw, 2.35rem);
  line-height: 1.08;
}

.app-shell:not(.cover-mode) .meta {
  gap: 6px;
  margin-top: 12px;
}

.app-shell:not(.cover-mode) .meta span {
  padding: 4px 8px;
  font-size: 0.76rem;
}

.app-shell:not(.cover-mode) .main-text {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin-top: 14px;
  padding: 0 8px 42px 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.92rem;
  line-height: 1.68;
}

@media (max-width: 560px) {
  .app-shell:not(.cover-mode) .book {
    width: min(100%, 430px);
    height: calc(100svh - 82px);
  }

  .app-shell:not(.cover-mode) .art-frame {
    width: min(54vw, 210px);
  }
}

/* Absolute final override: story pages must stay as a 9:16 phone page everywhere. */
html,
body {
  width: 100% !important;
  height: 100% !important;
}

.app-shell:not(.cover-mode) {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  justify-items: center !important;
  align-items: center !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  padding: 10px !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .book {
  box-sizing: border-box !important;
  width: min(calc((100vh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
  height: min(calc(100vh - 106px), calc((100vw - 24px) * 16 / 9), 764px) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: 9 / 16 !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .page {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: minmax(0, 38%) minmax(0, 1fr) !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 14px !important;
  gap: 12px !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .page::before,
.app-shell:not(.cover-mode) .page::after {
  display: none !important;
}

.app-shell:not(.cover-mode) .art {
  display: grid !important;
  place-items: center !important;
  min-width: 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: visible !important;
}

.app-shell:not(.cover-mode) .art-frame {
  position: relative !important;
  width: min(62%, 220px) !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: 3 / 4 !important;
  margin: 0 auto !important;
  border-width: 6px !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .art-frame img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
}

.app-shell:not(.cover-mode) .copy {
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin: 0 0 6px !important;
  font-size: clamp(2.35rem, 13vw, 3.9rem) !important;
  line-height: 0.95 !important;
}

.app-shell:not(.cover-mode) h2 {
  margin: 0 !important;
  font-size: clamp(1.75rem, 9vw, 3rem) !important;
  line-height: 1.05 !important;
}

.app-shell:not(.cover-mode) .meta {
  flex-wrap: wrap !important;
  gap: 6px !important;
  margin: 10px 0 0 !important;
}

.app-shell:not(.cover-mode) .meta span {
  padding: 4px 8px !important;
  font-size: 0.78rem !important;
}

.app-shell:not(.cover-mode) .main-text {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin-top: 12px !important;
  padding: 0 8px 42px 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  font-size: 0.94rem !important;
  line-height: 1.68 !important;
}

.app-shell:not(.cover-mode) .controls {
  width: min(calc((100vh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
  margin-top: 8px !important;
}

@supports (height: 100svh) {
  .app-shell:not(.cover-mode) {
    height: 100svh !important;
    min-height: 100svh !important;
  }

  .app-shell:not(.cover-mode) .book {
    width: min(calc((100svh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
    height: min(calc(100svh - 106px), calc((100vw - 24px) * 16 / 9), 764px) !important;
  }

  .app-shell:not(.cover-mode) .controls {
    width: min(calc((100svh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
  }
}

/* Final cover fix: phone-first full cover, no top crop, no floating blank page. */
html,
body {
  margin: 0 !important;
  min-height: 100% !important;
  overflow: hidden !important;
}

.app-shell.cover-mode {
  box-sizing: border-box !important;
  display: grid !important;
  place-items: center !important;
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #efe1ce !important;
}

.cover-mode .book {
  width: min(100vw, calc(100dvh * 9 / 16)) !important;
  height: min(100dvh, calc(100vw * 16 / 9)) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: 9 / 16 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

.cover-mode .cover-page {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: transparent !important;
}

.cover-mode .cover-page::before,
.cover-mode .cover-page::after {
  display: none !important;
}

.cover-mode .cover-button {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  transform: none !important;
}

.cover-mode .cover-image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: none !important;
}

.cover-mode .cover-copy {
  position: absolute !important;
  inset: auto 0 6.5% 0 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  padding: 0 18px !important;
  pointer-events: none !important;
}

.cover-mode .cover-cta {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  max-width: calc(100% - 36px) !important;
  padding: 10px 22px !important;
  border-radius: 999px !important;
  background: rgba(63, 51, 40, 0.58) !important;
  color: #fffaf2 !important;
  font-size: 1rem !important;
  line-height: 1.2 !important;
  box-shadow: 0 12px 30px rgba(63, 51, 40, 0.18) !important;
}

.cover-mode .controls {
  display: none !important;
}

@supports not (height: 100dvh) {
  .app-shell.cover-mode {
    height: 100svh !important;
    min-height: 100svh !important;
  }

  .cover-mode .book {
    width: min(100vw, calc(100svh * 9 / 16)) !important;
    height: min(100svh, calc(100vw * 16 / 9)) !important;
  }
}

/* Hide hotspot hints while keeping the secret click areas active. */
.hotspot {
  background: transparent !important;
  outline: none !important;
}

.hotspot-mark,
.hotspot::after {
  display: none !important;
}

/* Final-final reading tune: reduce title size and reserve a real scroll area. */
.app-shell:not(.cover-mode) .page {
  grid-template-rows: minmax(0, 30%) minmax(0, 1fr) !important;
  padding: 16px 16px 12px !important;
  gap: 10px !important;
}

.app-shell:not(.cover-mode) .art-frame {
  width: min(52%, 180px) !important;
  border-width: 5px !important;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin: 0 0 4px !important;
  font-size: clamp(1.65rem, 7.6vw, 2.55rem) !important;
  line-height: 1 !important;
}

.app-shell:not(.cover-mode) h2 {
  margin: 0 !important;
  font-size: clamp(1.18rem, 5.6vw, 1.8rem) !important;
  line-height: 1.12 !important;
}

.app-shell:not(.cover-mode) .meta {
  margin-top: 7px !important;
  gap: 5px !important;
}

.app-shell:not(.cover-mode) .meta span {
  padding: 3px 7px !important;
  font-size: 0.72rem !important;
}

.app-shell:not(.cover-mode) .main-text {
  display: block !important;
  flex: 1 1 auto !important;
  min-height: 120px !important;
  margin-top: 9px !important;
  padding: 0 8px 64px 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  font-size: 0.88rem !important;
  line-height: 1.6 !important;
}

/* Final reading tune: keep titles elegant, leave room for scrollable text. */
.app-shell:not(.cover-mode) .page {
  grid-template-rows: minmax(0, 32%) minmax(0, 1fr) !important;
  padding: 16px 16px 12px !important;
  gap: 10px !important;
}

.app-shell:not(.cover-mode) .art-frame {
  width: min(54%, 190px) !important;
  border-width: 5px !important;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin-bottom: 4px !important;
  font-size: clamp(1.9rem, 9.5vw, 3rem) !important;
  line-height: 0.98 !important;
  white-space: pre-line !important;
}

.app-shell:not(.cover-mode) h2 {
  font-size: clamp(1.35rem, 6.6vw, 2.15rem) !important;
  line-height: 1.1 !important;
}

.app-shell:not(.cover-mode) .meta {
  margin-top: 8px !important;
}

.app-shell:not(.cover-mode) .main-text {
  display: block !important;
  min-height: 90px !important;
  margin-top: 10px !important;
  padding: 0 8px 56px 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  font-size: 0.9rem !important;
  line-height: 1.62 !important;
}

/* Hard lock story pages to a 9:16 mobile canvas on every device. */
.app-shell:not(.cover-mode) {
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  padding: 8px;
}

.app-shell:not(.cover-mode) .book {
  width: min(calc((100vh - 92px) * 9 / 16), calc(100vw - 20px), 460px);
  height: auto;
  min-height: 0;
  aspect-ratio: 9 / 16;
}

.app-shell:not(.cover-mode) .page {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 38%) minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.app-shell:not(.cover-mode) .art {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: visible;
}

.app-shell:not(.cover-mode) .art-frame {
  width: min(62%, 230px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 3 / 4;
  border-width: 6px;
}

.app-shell:not(.cover-mode) .art-frame img {
  object-fit: contain;
  background: #f6ead9;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin-bottom: 8px;
  font-size: clamp(1.45rem, 7vw, 2.65rem);
}

.app-shell:not(.cover-mode) h2 {
  font-size: clamp(1.32rem, 6.4vw, 2.25rem);
}

.app-shell:not(.cover-mode) .main-text {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.app-shell:not(.cover-mode) .controls {
  width: min(calc((100vh - 92px) * 9 / 16), calc(100vw - 20px), 460px);
  margin-top: 8px;
}

@media (max-width: 560px) {
  .app-shell:not(.cover-mode) {
    height: 100svh;
    min-height: 100svh;
    padding: 8px;
  }

  .app-shell:not(.cover-mode) .book {
    width: min(calc((100svh - 86px) * 9 / 16), calc(100vw - 16px));
  }

  .app-shell:not(.cover-mode) .controls {
    width: min(calc((100svh - 86px) * 9 / 16), calc(100vw - 16px));
  }

  .app-shell:not(.cover-mode) .art-frame {
    width: min(62%, 220px);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(212, 162, 79, 0.22), transparent 25rem),
    radial-gradient(circle at 88% 78%, rgba(137, 159, 137, 0.2), transparent 24rem),
    linear-gradient(135deg, #f8f2ea 0%, #eadbcc 100%);
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", SimSun, Georgia, serif;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  padding: clamp(16px, 3.6vw, 42px);
}

.app-shell.cover-mode {
  display: block;
  min-height: 100vh;
  padding: 0;
}

.book {
  position: relative;
  width: min(1120px, 100%);
  height: min(720px, calc(100vh - 126px));
  min-height: 560px;
  margin: auto;
  perspective: 1800px;
}

.app-shell:not(.cover-mode) .book {
  width: min(1120px, 100%);
  height: min(720px, calc(100vh - 126px));
  min-height: 560px;
}

.cover-mode .book {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  min-height: 0;
  margin: 0;
  padding: 0;
  perspective: none;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(320px, 1.02fr);
  gap: clamp(26px, 4.5vw, 62px);
  align-items: center;
  padding: clamp(24px, 4.6vw, 58px);
  overflow: hidden;
  border: 1px solid rgba(63, 51, 40, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 18%),
    var(--paper);
  box-shadow: 0 24px 70px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: rotateY(-15deg) translateX(34px) scale(0.98);
  transform-origin: left center;
  transition: opacity 560ms ease, transform 760ms cubic-bezier(0.2, 0.82, 0.2, 1);
}

.page::before {
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(63, 51, 40, 0.08);
  border-radius: 6px;
  content: "";
  pointer-events: none;
}

.page::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: linear-gradient(transparent, rgba(63, 51, 40, 0.14), transparent);
  content: "";
  opacity: 0.5;
}

.page.active {
  z-index: 2;
  opacity: 1;
  pointer-events: auto;
  transform: rotateY(0deg) translateX(0) scale(1);
}

.page.previous {
  opacity: 0;
  transform: rotateY(18deg) translateX(-28px) scale(0.98);
  transform-origin: right center;
}

.cover-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 246, 220, 0.58), transparent 25rem),
    radial-gradient(circle at 82% 78%, rgba(144, 176, 196, 0.26), transparent 24rem),
    linear-gradient(135deg, #f6ecde, #e5d2bd);
  box-shadow: none;
}

.cover-mode .cover-page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
}

.cover-page::before {
  display: none;
}

.cover-page::after {
  display: none;
}

.cover-button {
  position: relative;
  display: block;
  width: auto;
  height: 100vh;
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  cursor: pointer;
  box-shadow: 0 24px 54px rgba(63, 51, 40, 0.18);
  text-align: center;
  transition: transform 420ms cubic-bezier(0.2, 0.82, 0.2, 1), box-shadow 420ms ease;
}

.cover-button:hover,
.cover-button:focus-visible {
  transform: scale(1.01);
  box-shadow: 0 34px 78px rgba(63, 51, 40, 0.25);
  outline: none;
}

.cover-image {
  display: block;
  width: auto;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: #f2e4cf;
}

.cover-copy {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  display: flex;
  width: 100%;
  min-height: auto;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 0 18px 20px;
  color: #fff8ec;
  text-shadow: 0 2px 18px rgba(46, 37, 30, 0.34);
  pointer-events: none;
}

.cover-cta {
  align-self: flex-start;
  align-self: center;
  margin-top: 0;
  border: 1px solid rgba(255, 248, 236, 0.42);
  border-radius: 999px;
  padding: 9px 16px;
  background: rgba(52, 42, 34, 0.32);
  color: #fff8ec;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
}

.art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}

.art-frame {
  position: relative;
  width: min(100%, 440px);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 10px solid rgba(255, 249, 239, 0.9);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(212, 162, 79, 0.18), rgba(144, 176, 196, 0.24));
  box-shadow: 0 18px 36px rgba(63, 51, 40, 0.14);
}

.placeholder-art,
.placeholder-art svg,
.art-frame img {
  width: 100%;
  height: 100%;
  display: block;
}

.art-frame img {
  position: relative;
  z-index: 1;
  object-fit: cover;
}

.placeholder-art {
  position: absolute;
  inset: 0;
}

.hotspot {
  position: absolute;
  z-index: 3;
  width: clamp(42px, 6vw, 72px);
  height: clamp(42px, 6vw, 72px);
  border: 0;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 250, 242, 0.28), rgba(255, 250, 242, 0) 64%);
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.hotspot-mark {
  position: absolute;
  inset: 35%;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.74);
  box-shadow: 0 0 18px rgba(255, 244, 208, 0.9);
  opacity: 0.62;
  transform: scale(0.8);
  animation: pulseHint 2.8s ease-in-out infinite;
}

.hotspot::after {
  position: absolute;
  inset: 14%;
  border-radius: inherit;
  border: 1px solid rgba(255, 250, 242, 0.42);
  content: "";
  opacity: 0.5;
  transition: opacity 220ms ease, transform 220ms ease;
}

.hotspot:hover::after,
.hotspot:focus-visible::after {
  opacity: 1;
  transform: scale(1.35);
}

@keyframes pulseHint {
  0%,
  100% {
    opacity: 0.34;
    transform: scale(0.76);
  }

  50% {
    opacity: 0.88;
    transform: scale(1);
  }
}

.copy {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 0;
  height: 100%;
  max-height: calc(100% - 8px);
  max-width: 460px;
  flex-direction: column;
}

.eyebrow {
  margin: 0 0 14px;
  color: rgba(63, 51, 40, 0.9);
  font-size: clamp(2rem, 4.8vw, 4.35rem);
  line-height: 0.96;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: 0;
}

h1 {
  max-width: 8ch;
  font-size: clamp(3.8rem, 10vw, 8rem);
}

h2 {
  font-size: clamp(2.05rem, 4.5vw, 4rem);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
}

.meta span {
  border: 1px solid rgba(63, 51, 40, 0.12);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 250, 242, 0.52);
  color: var(--muted);
  font-size: 0.82rem;
}

.main-text {
  flex: 1;
  min-height: 0;
  max-height: min(460px, 58vh);
  margin: 22px 0 0;
  padding: 0 10px 28px 0;
  overflow-y: auto;
  overflow-x: hidden;
  color: var(--ink);
  font-size: clamp(0.98rem, 1.35vw, 1.1rem);
  line-height: 1.76;
  white-space: pre-line;
  overscroll-behavior: contain;
}

.main-text::-webkit-scrollbar {
  width: 6px;
}

.main-text::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(63, 51, 40, 0.18);
}

.hidden-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: clamp(28px, 6vw, 76px);
  background: rgba(44, 35, 28, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

.page.revealed .hidden-layer {
  opacity: 1;
  pointer-events: auto;
}

.hidden-letter {
  width: min(620px, 100%);
  max-height: min(78vh, 620px);
  overflow: auto;
  border: 1px solid rgba(63, 51, 40, 0.12);
  border-radius: 8px;
  padding: clamp(24px, 4vw, 42px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 36%),
    #fff8ec;
  color: #3d3025;
  box-shadow: 0 24px 70px rgba(33, 26, 20, 0.3);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 800ms ease, transform 800ms ease;
  white-space: pre-line;
}

.page.revealed .hidden-letter {
  opacity: 1;
  transform: translateY(0);
}

.hidden-kicker {
  margin: 0 0 16px;
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hidden-text {
  margin: 0;
  font-family: "KaiTi", "STKaiti", "Noto Serif SC", serif;
  font-size: clamp(1.05rem, 2vw, 1.34rem);
  line-height: 1.9;
}

.close-layer {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(63, 51, 40, 0.12);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.84);
  color: var(--ink);
  cursor: pointer;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(520px, 100%);
  margin: 18px auto 0;
  transition: opacity 260ms ease, transform 260ms ease;
}

.cover-mode .controls {
  display: none;
}

.nav-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(63, 51, 40, 0.18);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.76);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(63, 51, 40, 0.1);
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.nav-button span {
  translate: 0 -2px;
  font-size: 2rem;
  line-height: 1;
}

.nav-button:hover:not(:disabled) {
  background: rgba(255, 252, 247, 0.96);
  transform: translateY(-1px);
}

.nav-button.primary {
  background: var(--ink);
  color: var(--soft);
}

.nav-button:disabled {
  cursor: default;
  opacity: 0.34;
}

.progress {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
  min-width: min(320px, calc(100vw - 160px));
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  height: 32px;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}

.market-line {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.market-line path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.market-line-base {
  stroke: rgba(63, 51, 40, 0.16);
  stroke-width: 3;
}

.market-line-fill {
  stroke: url("#marketGradient");
  stroke-width: 3.4;
  stroke-dasharray: 0;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 2px 5px rgba(194, 135, 82, 0.18));
  transition: stroke-dashoffset 520ms ease;
}

.market-arrow {
  fill: var(--sage);
  opacity: 0;
  filter: drop-shadow(0 2px 5px rgba(63, 51, 40, 0.2));
  transition: transform 520ms ease, opacity 220ms ease;
}

@media (max-width: 980px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100svh;
    padding: 10px;
  }

  .app-shell.cover-mode {
    min-height: 100svh;
    padding: 0;
  }

  .book {
    width: min(100%, 430px);
    height: calc(100svh - 82px);
    min-height: 0;
  }

  .app-shell:not(.cover-mode) .book {
    width: min(100%, 520px);
    height: calc(100svh - 82px);
    min-height: 0;
  }

  .cover-mode .book {
    width: 100vw;
    height: 100svh;
    padding: 0;
    overflow: hidden;
  }

  .page {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 43%) minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .app-shell:not(.cover-mode) .page {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 38%) minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .app-shell:not(.cover-mode) .art {
    align-self: center;
    overflow: hidden;
  }

  .cover-page {
    min-height: calc(100svh - 88px);
    padding: 0;
  }

  .cover-button {
    width: auto;
    height: 100svh;
    max-height: none;
  }

  .cover-image {
    width: auto;
    height: 100%;
  }

  .cover-copy {
    width: 100%;
    padding: 0 14px 16px;
    justify-content: flex-end;
  }

  .cover-cta {
    font-size: 0.9rem;
  }

  .page::after {
    display: none;
  }

  .copy {
    min-height: 0;
    max-height: none;
    max-width: none;
  }

  .app-shell:not(.cover-mode) .copy {
    display: flex;
    min-height: 0;
    max-height: none;
    max-width: none;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(3.4rem, 20vw, 6rem);
  }

  .eyebrow {
    margin-bottom: 10px;
    font-size: clamp(1.55rem, 8vw, 2.75rem);
    line-height: 0.98;
  }

  h2 {
    font-size: clamp(1.4rem, 7vw, 2.35rem);
    line-height: 1.08;
  }

  .meta {
    gap: 6px;
    margin-top: 12px;
  }

  .meta span {
    padding: 4px 8px;
    font-size: 0.76rem;
  }

  .main-text {
    max-height: none;
    margin-top: 14px;
    padding: 0 8px 42px 0;
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.68;
  }

  .app-shell:not(.cover-mode) .main-text {
    max-height: none;
    margin-top: 14px;
    padding: 0 8px 42px 0;
    flex: 1;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.68;
  }

  .controls {
    margin-top: 8px;
  }

  .art-frame {
    width: min(54vw, 210px);
    max-height: 100%;
    border-width: 6px;
  }

  .app-shell:not(.cover-mode) .art-frame {
    width: min(48vw, 230px);
    max-height: 100%;
    aspect-ratio: 3 / 4;
    border-width: 6px;
  }

  .hotspot {
    width: 52px;
    height: 52px;
  }

  .hidden-layer {
    padding: 18px;
  }

  .hidden-letter {
    max-height: 72svh;
    padding: 24px;
  }

  .hidden-text {
    font-size: 1rem;
    line-height: 1.78;
  }
}

/* Final stable reading layout override for all non-cover story pages. */
.app-shell:not(.cover-mode) {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  padding: 10px;
}

.app-shell:not(.cover-mode) .book {
  width: min(100%, 520px);
  height: calc(100vh - 92px);
  min-height: 0;
}

.app-shell:not(.cover-mode) .page {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 38%) minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.app-shell:not(.cover-mode) .page::after {
  display: none;
}

.app-shell:not(.cover-mode) .art {
  align-self: center;
  overflow: hidden;
}

.app-shell:not(.cover-mode) .art-frame {
  width: min(46vw, 230px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 3 / 4;
  border-width: 6px;
}

.app-shell:not(.cover-mode) .copy {
  display: flex;
  min-height: 0;
  height: 100%;
  max-height: none;
  max-width: none;
  flex-direction: column;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin-bottom: 10px;
  font-size: clamp(1.55rem, 8vw, 2.75rem);
  line-height: 0.98;
}

.app-shell:not(.cover-mode) h2 {
  font-size: clamp(1.4rem, 7vw, 2.35rem);
  line-height: 1.08;
}

.app-shell:not(.cover-mode) .meta {
  gap: 6px;
  margin-top: 12px;
}

.app-shell:not(.cover-mode) .meta span {
  padding: 4px 8px;
  font-size: 0.76rem;
}

.app-shell:not(.cover-mode) .main-text {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin-top: 14px;
  padding: 0 8px 42px 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.92rem;
  line-height: 1.68;
}

@media (max-width: 560px) {
  .app-shell:not(.cover-mode) .book {
    width: min(100%, 430px);
    height: calc(100svh - 82px);
  }

  .app-shell:not(.cover-mode) .art-frame {
    width: min(54vw, 210px);
  }
}

/* Absolute end override: story pages are always one 9:16 phone canvas. */
.app-shell:not(.cover-mode) {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  justify-items: center !important;
  align-items: center !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  padding: 10px !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .book {
  box-sizing: border-box !important;
  width: min(calc((100vh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
  height: min(calc(100vh - 106px), calc((100vw - 24px) * 16 / 9), 764px) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  aspect-ratio: 9 / 16 !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .page {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: minmax(0, 42%) minmax(0, 1fr) !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 16px 16px 12px !important;
  gap: 10px !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .page::before,
.app-shell:not(.cover-mode) .page::after {
  display: none !important;
}

.app-shell:not(.cover-mode) .art {
  display: grid !important;
  place-items: center !important;
  min-width: 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: visible !important;
}

.app-shell:not(.cover-mode) .art-frame {
  position: relative !important;
  width: min(64%, 250px) !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: 3 / 4 !important;
  margin: 0 auto !important;
  border-width: 5px !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .art-frame img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
}

.app-shell:not(.cover-mode) .copy {
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  overflow: hidden !important;
}

.app-shell:not(.cover-mode) .eyebrow {
  margin: 0 0 4px !important;
  font-size: clamp(1.65rem, 7.6vw, 2.55rem) !important;
  line-height: 1 !important;
}

.app-shell:not(.cover-mode) h2 {
  margin: 0 !important;
  font-size: clamp(1.18rem, 5.6vw, 1.8rem) !important;
  line-height: 1.12 !important;
}

.app-shell:not(.cover-mode) .meta {
  flex-wrap: wrap !important;
  gap: 5px !important;
  margin: 7px 0 0 !important;
}

.app-shell:not(.cover-mode) .meta span {
  padding: 3px 7px !important;
  font-size: 0.72rem !important;
}

.app-shell:not(.cover-mode) .main-text {
  flex: 1 1 auto !important;
  min-height: 120px !important;
  max-height: none !important;
  margin-top: 9px !important;
  padding: 0 8px 64px 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  font-size: 0.88rem !important;
  line-height: 1.6 !important;
}

.app-shell:not(.cover-mode) .controls {
  width: min(calc((100vh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
  margin-top: 8px !important;
}

@supports (height: 100svh) {
  .app-shell:not(.cover-mode) {
    height: 100svh !important;
    min-height: 100svh !important;
  }

  .app-shell:not(.cover-mode) .book {
    width: min(calc((100svh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
    height: min(calc(100svh - 106px), calc((100vw - 24px) * 16 / 9), 764px) !important;
  }

  .app-shell:not(.cover-mode) .controls {
    width: min(calc((100svh - 106px) * 9 / 16), calc(100vw - 24px), 430px) !important;
  }
}
