@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --night: #06152a;
  --night-soft: #0b2140;
  --ink: #f3f7ff;
  --muted: #9db0c8;
  --aqua: #55d6d0;
  --aqua-deep: #2faaa8;
  --gold: #f4d56f;
  --panel: rgba(12, 34, 61, 0.76);
  --line: rgba(154, 201, 219, 0.2);
  --shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  overflow-x: hidden;
}
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
}
body::before {
  background:
    radial-gradient(circle at 8% 12%, rgba(88, 196, 220, .2) 0 1px, transparent 2px),
    radial-gradient(circle at 90% 24%, rgba(242, 203, 109, .3) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 8%, rgba(127, 203, 224, .24) 0 1px, transparent 2px),
    radial-gradient(circle at 24% 66%, rgba(114, 193, 220, .16) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 80%, rgba(252, 220, 132, .22) 0 1px, transparent 2px),
    linear-gradient(155deg, #07172d 0%, #071c36 48%, #0a2440 100%);
  background-size: 220px 240px, 320px 330px, 270px 310px, 190px 220px, 260px 280px, 100% 100%;
}
body::after {
  background: radial-gradient(ellipse at 50% 42%, transparent 0 32%, rgba(2, 11, 25, .32) 88%);
}
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100svh; display: flex; flex-direction: column; }
.reader-header {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 22px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  color: var(--muted);
}
.home-link { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.home-mark { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(132, 220, 226, .48); border-radius: 50%; color: var(--aqua); font-size: 18px; }
.header-title { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.header-title .eyebrow { color: var(--aqua); font-size: 10px; text-transform: uppercase; letter-spacing: .2em; }
.header-title strong { color: #dce8f4; font-size: 13px; }
.icon-button, .control-button { border: 1px solid var(--line); color: var(--muted); background: rgba(8, 28, 52, .54); transition: border-color .2s ease, color .2s ease, background .2s ease, transform .2s ease; }
.icon-button { justify-self: end; border-radius: 50%; width: 34px; height: 34px; font-size: 20px; }
.icon-button:hover, .control-button:hover { color: var(--ink); border-color: rgba(85, 214, 208, .8); background: rgba(17, 57, 83, .72); transform: translateY(-1px); }

.story-stage { position: relative; width: min(100%, 1120px); margin: 0 auto; padding: 12px 22px 26px; display: flex; flex-direction: column; align-items: center; flex: 1; }
.stage-glow { position: absolute; width: min(80vw, 720px); height: 68vh; top: 13%; background: radial-gradient(ellipse, rgba(75, 181, 200, .13), transparent 68%); filter: blur(18px); pointer-events: none; }
.progress-line { width: min(100%, 700px); height: 3px; background: rgba(163, 204, 222, .18); border-radius: 999px; overflow: hidden; position: relative; z-index: 1; }
.progress-line span { display: block; height: 100%; width: 2.94%; background: linear-gradient(90deg, var(--aqua), #a2f3d8); border-radius: inherit; transition: width .35s ease; }
.slide-meta { width: min(100%, 700px); padding: 9px 4px 10px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; position: relative; z-index: 1; }
#slideLabel { color: #c7dbed; font-weight: 700; }
.slide-frame { position: relative; width: min(100%, 700px); aspect-ratio: 419.556 / 595.304; max-height: calc(100svh - 218px); display: grid; place-items: center; border: 1px solid rgba(153, 205, 220, .18); border-radius: 18px; overflow: hidden; background: #f7f5ef; box-shadow: 0 24px 70px var(--shadow), 0 0 0 8px rgba(10, 31, 55, .3); touch-action: pan-y; z-index: 1; }
.slide-frame::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 46px rgba(6, 20, 36, .18); pointer-events: none; }
#slideImage { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .16s ease, transform .16s ease; }
.slide-nav { position: absolute; top: 50%; translate: 0 -50%; width: 46px; height: 46px; border: 1px solid rgba(255, 255, 255, .34); border-radius: 50%; color: white; background: rgba(6, 24, 44, .58); backdrop-filter: blur(7px); font-size: 38px; line-height: 1; z-index: 3; opacity: .84; display: grid; place-items: center; transition: opacity .2s ease, background .2s ease, transform .2s ease; }
.slide-nav:hover { opacity: 1; background: rgba(11, 68, 78, .82); }
.slide-nav:active { transform: scale(.94); }
.slide-nav.previous { left: 14px; }
.slide-nav.next { right: 14px; }
.slide-nav:disabled { opacity: .22; cursor: not-allowed; }
.cover-action { position: absolute; left: 0; right: 0; bottom: 28px; display: flex; justify-content: center; z-index: 4; }
.primary-button { padding: 13px 21px; border: 0; border-radius: 999px; color: #062437; background: linear-gradient(135deg, #8be2d0, #f5dc7e); box-shadow: 0 10px 30px rgba(4, 25, 42, .5); font-weight: 800; font-size: 14px; transition: transform .2s ease, filter .2s ease; }
.primary-button:hover { filter: brightness(1.06); transform: translateY(-2px); }
.primary-button:active { transform: translateY(0); }

.reader-controls { margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 10px; position: relative; z-index: 2; }
.control-button { min-height: 36px; padding: 7px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; }
.control-button[aria-pressed='true'] { color: var(--aqua); border-color: rgba(85, 214, 208, .7); background: rgba(24, 91, 95, .38); }
.volume-control { height: 36px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; display: flex; align-items: center; gap: 8px; color: var(--muted); background: rgba(8, 28, 52, .54); }
.volume-control input { width: 92px; accent-color: var(--aqua); }
.swipe-hint { min-height: 18px; margin: 10px 0 0; color: rgba(177, 198, 217, .7); font-size: 11px; text-align: center; }
.completion-note { margin-top: 12px; max-width: 700px; padding: 12px 18px; border: 1px solid rgba(85, 214, 208, .3); border-radius: 14px; background: rgba(6, 30, 47, .7); text-align: center; color: #d8edf1; font-size: 12px; }
.completion-note strong { display: block; color: var(--gold); margin-bottom: 3px; }
.reader-footer { width: min(100%, 1120px); margin: auto auto 0; padding: 17px 22px max(17px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; gap: 12px; color: rgba(168, 188, 207, .7); font-size: 11px; }

[hidden] { display: none !important; }
@media (max-width: 640px) {
  .reader-header { grid-template-columns: 1fr auto; gap: 10px; padding-inline: 16px; }
  .header-title { grid-column: 1 / -1; grid-row: 2; order: 3; }
  .home-link { font-size: 12px; }
  .story-stage { padding: 8px 12px 16px; }
  .slide-frame { width: min(100%, 520px); border-radius: 14px; max-height: calc(100svh - 230px); box-shadow: 0 18px 40px var(--shadow), 0 0 0 5px rgba(10, 31, 55, .3); }
  .slide-nav { width: 40px; height: 40px; font-size: 32px; }
  .slide-nav.previous { left: 8px; }
  .slide-nav.next { right: 8px; }
  .cover-action { bottom: 18px; }
  .primary-button { font-size: 13px; padding: 12px 16px; }
  .reader-controls { gap: 6px; flex-wrap: wrap; }
  .control-button { padding-inline: 10px; }
  .control-button span:last-child { display: none; }
  .volume-control input { width: 78px; }
  .reader-footer { flex-direction: column; align-items: center; text-align: center; padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
