:root {
  color-scheme: light;
  --ink: #314156;
  --muted: #6c7890;
  --paper: #fff9ee;
  --leaf: #79a978;
  --rose: #dd7d86;
  --gold: #f0b64d;
  --blue: #75b9d7;
  --line: rgba(49, 65, 86, 0.18);
  --shadow: 0 24px 70px rgba(68, 86, 108, 0.24);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: #eef8ee;
  background-image:
    radial-gradient(circle at 16% 82%, rgba(255, 207, 111, 0.4) 0 0.45rem, transparent 0.5rem),
    radial-gradient(circle at 88% 26%, rgba(255, 147, 162, 0.34) 0 0.4rem, transparent 0.46rem),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.72), transparent 18rem),
    linear-gradient(135deg, #e7f7e6 0%, #dff6fb 46%, #fff0dc 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  pointer-events: none;
  content: "";
}

body::before {
  inset: 0;
  opacity: 0.72;
  background-repeat: repeat;
  background-size: 150px 120px;
  background-image:
    radial-gradient(ellipse at 24px 92px, rgba(115, 167, 110, 0.26) 0 16px, transparent 17px),
    radial-gradient(ellipse at 44px 88px, rgba(125, 183, 114, 0.24) 0 19px, transparent 20px),
    radial-gradient(circle at 112px 34px, rgba(240, 182, 77, 0.42) 0 5px, transparent 6px),
    radial-gradient(circle at 120px 42px, rgba(221, 125, 134, 0.3) 0 4px, transparent 5px);
}

body::after {
  right: -80px;
  bottom: -70px;
  width: 360px;
  height: 280px;
  border-radius: 50% 50% 0 0;
  background:
    radial-gradient(circle at 28% 44%, rgba(255, 255, 255, 0.78) 0 42px, transparent 44px),
    radial-gradient(circle at 48% 34%, rgba(255, 255, 255, 0.75) 0 58px, transparent 60px),
    radial-gradient(circle at 70% 48%, rgba(255, 255, 255, 0.72) 0 44px, transparent 46px);
}

body[data-theme="starry"] {
  background-color: #e9eefb;
  background-image:
    radial-gradient(circle at 18% 24%, rgba(255, 229, 143, 0.75) 0 0.22rem, transparent 0.28rem),
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.92) 0 0.18rem, transparent 0.24rem),
    radial-gradient(circle at 86% 72%, rgba(255, 229, 143, 0.72) 0 0.25rem, transparent 0.31rem),
    linear-gradient(135deg, #f7f0ff 0%, #dfeeff 48%, #fff4d8 100%);
}

body[data-theme="starry"]::before {
  background-size: 180px 150px;
  background-image:
    radial-gradient(circle at 30px 35px, rgba(247, 191, 83, 0.54) 0 4px, transparent 5px),
    radial-gradient(circle at 86px 92px, rgba(255, 255, 255, 0.76) 0 5px, transparent 6px),
    radial-gradient(circle at 140px 44px, rgba(221, 125, 134, 0.28) 0 7px, transparent 8px);
}

body[data-theme="clouds"] {
  background-color: #e4f8ff;
  background-image:
    linear-gradient(90deg, rgba(240, 182, 77, 0.38) 0 2px, transparent 2px 24px),
    linear-gradient(135deg, #dbf6ff 0%, #eefaf3 55%, #fff3e5 100%);
}

body[data-theme="clouds"]::before {
  background-size: 210px 150px;
  background-image:
    radial-gradient(circle at 42px 70px, rgba(255, 255, 255, 0.82) 0 24px, transparent 25px),
    radial-gradient(circle at 70px 58px, rgba(255, 255, 255, 0.8) 0 32px, transparent 33px),
    radial-gradient(circle at 102px 72px, rgba(255, 255, 255, 0.78) 0 24px, transparent 25px),
    linear-gradient(135deg, transparent 0 65px, rgba(221, 125, 134, 0.34) 66px 78px, transparent 79px 100%);
}

body[data-theme="paper"] {
  background-color: #f8f1e6;
  background-image:
    linear-gradient(90deg, rgba(111, 89, 62, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(111, 89, 62, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 18% 18%, rgba(240, 182, 77, 0.22), transparent 18rem),
    radial-gradient(circle at 88% 70%, rgba(117, 185, 215, 0.2), transparent 20rem),
    #f8f1e6;
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

body[data-theme="paper"]::before {
  background-size: 140px 140px;
  background-image:
    radial-gradient(circle at 38px 38px, rgba(121, 169, 120, 0.22) 0 7px, transparent 8px),
    radial-gradient(circle at 98px 86px, rgba(221, 125, 134, 0.22) 0 6px, transparent 7px),
    linear-gradient(30deg, transparent 0 65px, rgba(49, 65, 86, 0.06) 66px 68px, transparent 69px);
}

button,
select {
  font: inherit;
}

.story-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  padding: 18px clamp(12px, 2vw, 28px) 20px;
  gap: 14px;
}

.reader-topbar,
.progress-row {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #7a4d07;
  background: var(--gold);
  font-size: 17px;
  box-shadow: 0 8px 22px rgba(122, 77, 7, 0.2);
}

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

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(49, 65, 86, 0.16);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(68, 86, 108, 0.13);
  font-size: 13px;
  font-weight: 800;
}

.theme-picker select {
  max-width: 112px;
  border: 0;
  color: var(--ink);
  background: transparent;
  outline: 0;
  font-weight: 800;
}

.icon-button,
.nav-button {
  border: 1px solid rgba(49, 65, 86, 0.16);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 24px rgba(68, 86, 108, 0.13);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, opacity 180ms ease;
}

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

.icon-button:disabled,
.nav-button:disabled {
  cursor: default;
  opacity: 0.35;
  transform: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 21px;
  font-weight: 800;
}

.book-stage {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  width: min(1260px, 100%);
  min-height: 0;
  margin: 0 auto;
  gap: 12px;
}

.book-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  perspective: 2400px;
}

.book {
  filter: drop-shadow(var(--shadow));
  transition: transform 220ms ease;
}

.book.is-cover-centered {
  transform: translateX(-25%);
}

.book.is-ending-centered {
  transform: translateX(25%);
}

.nav-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 72px;
  border-radius: 999px;
  font-size: 42px;
  line-height: 1;
}

.page {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(139, 108, 73, 0.18);
  background: var(--paper);
}

.page-inner {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  padding: clamp(10px, 1.5vw, 16px);
  gap: 12px;
}

.cover-page .page-inner,
.ending-page .page-inner,
.blessing-page .page-inner {
  grid-template-rows: 1fr;
}

.cover-image-inner,
.ending-image-inner {
  place-items: center;
  padding: clamp(14px, 2vw, 22px);
}

.cover-image,
.ending-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(139, 108, 73, 0.14);
}

.art-frame {
  display: grid;
  min-height: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #ffffff;
}

.art-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.reading-panel {
  display: grid;
  gap: 7px;
  padding: 13px 14px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.page-number {
  color: var(--rose);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.page-caption {
  margin: 0;
  color: #38526c;
  font-size: clamp(15px, 1.45vw, 18px);
  font-weight: 800;
  line-height: 1.45;
}

.page-text {
  margin: 0;
  color: #526175;
  font-size: clamp(13px, 1.2vw, 15px);
  line-height: 1.7;
}

.blessing-card {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  height: 100%;
  gap: 18px;
  padding: clamp(28px, 4vw, 54px);
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 50% 26%, rgba(240, 182, 77, 0.28), transparent 11rem),
    radial-gradient(circle at 20% 74%, rgba(117, 185, 215, 0.18), transparent 10rem),
    linear-gradient(150deg, rgba(255, 255, 255, 0.6), rgba(255, 245, 229, 0.94));
}

.blessing-title {
  max-width: 10em;
  margin: 0;
  color: #38526c;
  font-size: clamp(31px, 4.6vw, 50px);
  line-height: 1.2;
  animation: blessingGlow 2.8s ease-in-out infinite;
}

.blessing-copy {
  max-width: 22em;
  margin: 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.78;
  animation: blessingFloat 4.2s ease-in-out infinite;
}

.blessing-stars {
  color: var(--gold);
  font-size: 30px;
  letter-spacing: 0.28em;
  animation: twinkle 1.8s ease-in-out infinite alternate;
}

.blessing-sparkles span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 20px rgba(240, 182, 77, 0.62);
  animation: sparkleDrift 5s ease-in-out infinite;
}

.blessing-sparkles span:nth-child(1) { top: 18%; left: 18%; }
.blessing-sparkles span:nth-child(2) { top: 26%; right: 20%; animation-delay: 0.7s; }
.blessing-sparkles span:nth-child(3) { bottom: 24%; left: 22%; animation-delay: 1.3s; }
.blessing-sparkles span:nth-child(4) { right: 18%; bottom: 20%; animation-delay: 2s; }
.blessing-sparkles span:nth-child(5) { top: 48%; left: 50%; animation-delay: 2.7s; }

.progress-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), var(--gold), var(--rose));
  transition: width 220ms ease;
}

.load-error {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 32px;
  border-radius: 12px;
  color: #94414a;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

@keyframes blessingGlow {
  0%, 100% {
    text-shadow: 0 0 0 rgba(240, 182, 77, 0);
    transform: scale(1);
  }

  50% {
    text-shadow: 0 0 24px rgba(240, 182, 77, 0.38);
    transform: scale(1.018);
  }
}

@keyframes blessingFloat {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

@keyframes twinkle {
  from {
    opacity: 0.52;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes sparkleDrift {
  0%, 100% {
    opacity: 0.28;
    transform: translateY(0) scale(0.75);
  }

  50% {
    opacity: 0.95;
    transform: translateY(-14px) scale(1.15);
  }
}

@media (max-width: 760px) {
  .story-shell {
    padding: 12px 10px 14px;
    gap: 10px;
  }

  .reader-topbar {
    min-height: 38px;
  }

  .brand {
    gap: 8px;
    font-size: 17px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
    font-size: 14px;
  }

  .reader-actions {
    gap: 6px;
  }

.theme-picker {
    width: 36px;
    justify-content: center;
    padding: 0;
  }

  .theme-picker span {
    display: none;
  }

  .theme-picker select {
    width: 20px;
    color: transparent;
  }

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

  .book-stage {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 6px;
  }

  .nav-button {
    width: 36px;
    height: 56px;
    font-size: 32px;
  }

  .page-inner {
    padding: 9px;
    gap: 8px;
  }

  .reading-panel {
    padding: 10px 11px 11px;
  }

  .blessing-card {
    padding: 24px;
  }

  .progress-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }
}
