:root {
  --bg: #fff7ec;
  --bg-soft: #f5f0fe;
  --card: rgba(255, 255, 255, 0.92);
  --paper: #fffdf8;
  --text: #2f241d;
  --muted: #7b6878;
  --accent: #8b5cf6;
  --accent-dark: #6d3be8;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --warm: #ffb86b;
  --warm-soft: rgba(255, 184, 107, 0.24);
  --line: rgba(80, 50, 120, 0.12);
  --shadow: 0 22px 70px rgba(54, 35, 84, 0.16);
  --shadow-soft: 0 12px 32px rgba(54, 35, 84, 0.10);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: TildaSans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 184, 107, 0.36), transparent 34rem),
    radial-gradient(circle at 90% 10%, rgba(139, 92, 246, 0.28), transparent 34rem),
    linear-gradient(180deg, #fff7ec 0%, #f5f0fe 58%, #fffaf5 100%);
  line-height: 1.6;
}

button {
  font: inherit;
}

.storybook-app {
  position: relative;
  width: min(1160px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 16px 28px;
  overflow: hidden;
}

.magic-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.star {
  position: absolute;
  color: rgba(139, 92, 246, 0.34);
  font-size: 28px;
  animation: floatStar 7s ease-in-out infinite;
}

.star_1 {
  top: 9%;
  left: 8%;
}

.star_2 {
  top: 18%;
  right: 9%;
  animation-delay: -2s;
}

.star_3 {
  bottom: 18%;
  left: 10%;
  animation-delay: -4s;
}

.star_4 {
  bottom: 12%;
  right: 14%;
  animation-delay: -1s;
}

@keyframes floatStar {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    opacity: .45;
  }
  50% {
    transform: translateY(-14px) rotate(10deg);
    opacity: .9;
  }
}

.cover-screen,
.reader-screen,
.finish-screen {
  position: relative;
  z-index: 1;
  display: none;
}

.cover-screen.is-active,
.reader-screen.is-active,
.finish-screen.is-active {
  display: block;
}

.cover-card {
  display: grid;
  gap: 22px;
  align-items: center;
  min-height: calc(100vh - 120px);
  padding: 16px 0;
}

.cover-art,
.cover-info,
.finish-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.cover-art {
  position: relative;
  padding: 12px;
}

.cover-art::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 28px;
  background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.14));
  pointer-events: none;
}

.cover-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 26px;
  box-shadow: 0 18px 46px rgba(49, 31, 69, 0.18);
}

.cover-placeholder {
  min-height: 420px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  background: linear-gradient(145deg, #f5f0fe, #fff7ec);
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
}

.cover-info {
  padding: clamp(26px, 5vw, 52px);
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
}

.brand-pill::before {
  content: "✦";
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--warm);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 14px;
  color: #271a35;
  font-size: clamp(34px, 7vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.subtitle {
  margin: 0 0 18px;
  color: var(--accent-dark);
  font-size: clamp(19px, 3vw, 26px);
  font-weight: 700;
}

.cover-note {
  max-width: 560px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: clamp(17px, 2.4vw, 21px);
}

.primary-button,
.nav-button,
.ghost-button,
.new-story-button,
.gift-button {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
}

.primary-button {
  min-height: 58px;
  padding: 17px 30px;
  color: #ffffff !important;
  background: var(--accent) !important;
  font-size: 20px;
  font-weight: 850;
  box-shadow: 0 14px 30px rgba(139, 92, 246, 0.28);
}

.primary-button:hover {
  color: #ffffff !important;
  background: var(--accent-dark) !important;
  transform: translateY(-2px);
}

.ghost-button {
  min-height: 44px;
  padding: 11px 17px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 750;
}

.ghost-button:hover {
  color: var(--accent-dark);
  transform: translateY(-1px);
  background: #ffffff;
}

.new-story-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 17px 30px;
  color: var(--accent-dark) !important;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  text-decoration: none !important;
  font-size: 20px;
  font-weight: 850;
  box-shadow: var(--shadow-soft);
}

.new-story-button:hover {
  color: var(--accent-dark) !important;
  background: #ffffff;
  transform: translateY(-2px);
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 14px;
  backdrop-filter: blur(12px);
}

.reader-progress,
.mobile-progress {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.book-stage {
  position: relative;
  min-height: 540px;
  perspective: 1400px;
}

.reader-page {
  display: none;
  animation: pageIn .34s ease both;
}

.reader-page.is-active {
  display: block;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateX(18px) rotateY(-3deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
  }
}

.paper-sheet {
  position: relative;
  margin: 0 auto;
  background:
    linear-gradient(90deg, rgba(139, 92, 246, 0.08), transparent 7%, transparent 93%, rgba(139, 92, 246, 0.08)),
    var(--paper);
  border: 1px solid rgba(91, 68, 120, 0.14);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.paper-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 184, 107, 0.15), transparent 18rem),
    linear-gradient(90deg, rgba(0, 0, 0, 0.035), transparent 14%, transparent 86%, rgba(0, 0, 0, 0.035));
}

.page-content {
  position: relative;
  display: grid;
  min-height: min(740px, calc(100vh - 170px));
}

.page-content_with-image {
  grid-template-rows: auto 1fr;
}

.page-content_text-only {
  min-height: min(720px, calc(100vh - 170px));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 4vw, 42px);
}

.page-illustration {
  margin: 0;
  background: #f8efe7;
}

.story-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 56vh;
  object-fit: contain;
  background: #f8efe7;
}

.page-text-block {
  padding: clamp(22px, 5vw, 54px);
}

.page-content_text-only .page-text-block {
  width: min(760px, 100%);
  padding: clamp(30px, 6vw, 70px);
  border-radius: 28px;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 184, 107, 0.16), transparent 16rem),
    radial-gradient(circle at 92% 12%, rgba(139, 92, 246, 0.12), transparent 16rem),
    rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(139, 92, 246, 0.10);
}

.page-content_text-only .page-text-block::before {
  content: "✦";
  display: block;
  margin-bottom: 18px;
  color: rgba(139, 92, 246, 0.45);
  font-size: 34px;
  line-height: 1;
}

.page-content_text-only .story-text {
  font-size: clamp(22px, 3.1vw, 32px);
  line-height: 1.78;
}

.page-kicker {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.page-title {
  margin: 0 0 14px;
  color: #2b1d3f;
  font-size: clamp(25px, 5vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.story-text {
  color: #33273f;
  font-size: clamp(19px, 4.8vw, 25px);
  line-height: 1.72;
}

.story-text p {
  margin: 0 0 16px;
}

.story-text p.dialogue-line {
  margin-top: 18px;
  padding-left: 18px;
  text-indent: -18px;
}

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

.empty-text {
  color: #9a6819;
  font-style: italic;
}

.reader-controls {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 16px 0 4px;
  backdrop-filter: blur(12px);
}

.nav-button {
  min-height: 54px;
  padding: 15px 20px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  font-size: 17px;
  font-weight: 850;
}

.nav-button.nav-button_primary {
  color: #ffffff !important;
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 14px 30px rgba(139, 92, 246, 0.28);
}

.nav-button.nav-button_primary:hover {
  color: #ffffff !important;
  background: var(--accent-dark) !important;
  border-color: var(--accent-dark) !important;
  transform: translateY(-2px);
}

.nav-button:hover {
  transform: translateY(-1px);
}

.nav-button:disabled {
  cursor: not-allowed;
  opacity: .42;
  transform: none;
  box-shadow: none;
}

.finish-screen {
  min-height: calc(100vh - 100px);
  place-items: center;
}

.finish-screen.is-active {
  display: grid;
}

.finish-card {
  width: min(720px, 100%);
  padding: clamp(30px, 6vw, 56px);
  text-align: center;
}

.finish-icon {
  margin-bottom: 14px;
  font-size: 54px;
}

.finish-card h2 {
  margin: 0 0 12px;
  color: #271a35;
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.08;
}

.finish-card p {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 19px;
}

.gift-box {
  margin: 28px 0 26px;
  padding: 22px 20px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 184, 107, 0.22), transparent 14rem),
    radial-gradient(circle at 92% 10%, rgba(139, 92, 246, 0.14), transparent 14rem),
    rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(139, 92, 246, 0.12);
}

.gift-icon {
  margin-bottom: 8px;
  font-size: 34px;
}

.gift-box h3 {
  margin: 0 0 8px;
  color: #271a35;
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.16;
}

.gift-box p {
  max-width: 560px;
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.gift-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 14px 22px;
  color: #ffffff !important;
  background: var(--warm) !important;
  text-decoration: none !important;
  font-size: 17px;
  font-weight: 850;
  box-shadow: 0 12px 26px rgba(255, 184, 107, 0.28);
}

.gift-button:hover {
  color: #ffffff !important;
  background: #f59e3d !important;
  transform: translateY(-2px);
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.footer {
  position: relative;
  z-index: 1;
  padding: 22px 0 0;
  color: rgba(47, 36, 29, 0.56);
  text-align: center;
  font-size: 14px;
  font-weight: 650;
}

@media (min-width: 860px) {
  .storybook-app {
    padding: 34px 28px 34px;
  }

  .cover-card {
    grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.1fr);
    gap: 34px;
  }

  .reader-topbar {
    padding-top: 0;
  }

  .page-content_with-image {
    grid-template-columns: minmax(340px, 0.95fr) minmax(420px, 1.05fr);
    grid-template-rows: auto;
    align-items: stretch;
  }

  .page-illustration {
    display: grid;
    place-items: center;
    min-height: 620px;
    border-right: 1px solid rgba(91, 68, 120, 0.10);
  }

  .story-image {
    max-height: 720px;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .page-text-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .story-text {
    font-size: clamp(21px, 2vw, 26px);
  }
}

@media (max-width: 640px) {
  .storybook-app {
    padding: 12px 12px 18px;
  }

  .cover-card {
    min-height: calc(100vh - 70px);
    padding: 8px 0;
  }

  .cover-art {
    padding: 8px;
    border-radius: 26px;
  }

  .cover-image {
    max-height: 56vh;
    border-radius: 20px;
  }

  .cover-info {
    border-radius: 26px;
  }

  .brand-pill {
    margin-bottom: 14px;
  }

  .primary-button,
  .new-story-button,
  .gift-button {
    width: 100%;
  }

  .reader-topbar {
    padding: 8px 0 10px;
  }

  .book-stage {
    min-height: 520px;
  }

  .paper-sheet {
    border-radius: 26px;
  }

  .page-content {
    min-height: auto;
  }

  .page-content_text-only {
    min-height: calc(100vh - 155px);
    padding: 12px;
  }

  .page-content_text-only .page-text-block {
    padding: 26px 20px 30px;
  }

  .page-content_text-only .story-text {
    font-size: clamp(20px, 5.4vw, 24px);
    line-height: 1.68;
  }

  .story-image {
    max-height: 48vh;
  }

  .page-text-block {
    padding: 22px 20px 26px;
  }

  .story-text {
    line-height: 1.66;
  }

  .reader-controls {
    gap: 8px;
    padding-top: 12px;
  }

  .nav-button {
    min-height: 50px;
    padding: 13px 16px;
    font-size: 16px;
  }

  .mobile-progress {
    min-width: 48px;
    text-align: center;
  }

  .finish-actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .star,
  .reader-page {
    animation: none;
  }

  .primary-button,
  .nav-button,
  .ghost-button,
  .new-story-button,
  .gift-button {
    transition: none;
  }
}