/* Story reader v5 — focused, child-friendly reader overrides */

.storybody {
  font-family: ui-rounded, "Avenir Next Rounded", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,.72) 0 7%, transparent 8%),
    radial-gradient(circle at 88% 18%, rgba(255,255,255,.58) 0 5%, transparent 6%),
    linear-gradient(155deg, #dff4ff 0%, #fff4c8 52%, #ffe5f1 100%);
  background-attachment: scroll;
}

.loading {
  width: min(92vw, 520px);
  margin: auto;
  padding: 34px 24px;
  border-radius: 32px;
  background: rgba(255,255,255,.84);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-weight: 800;
}

.loading p { color: var(--ink); }

.start-gate {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
}

.start-card,
.error-card {
  width: min(100%, 620px);
  padding: clamp(28px, 7vw, 46px) clamp(20px, 6vw, 40px);
  text-align: center;
  border: 5px solid rgba(255,255,255,.86);
  border-radius: 34px;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.start-emoji {
  font-size: clamp(3.6rem, 16vw, 6rem);
  line-height: 1;
  filter: drop-shadow(0 8px 10px rgba(53,49,94,.14));
  animation: welcome-bob 2.6s ease-in-out infinite;
}

@keyframes welcome-bob {
  50% { transform: translateY(-8px) rotate(2deg); }
}

.start-eyebrow {
  margin-top: 18px;
  color: var(--accent);
  font-size: .84rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.start-card h1,
.error-card h1 {
  margin-top: 8px;
  font-size: clamp(1.75rem, 7vw, 2.65rem);
  line-height: 1.08;
  color: var(--ink);
}

.start-note,
.error-card p {
  max-width: 46ch;
  margin: 14px auto 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 4vw, 1.18rem);
  line-height: 1.55;
}

.start-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.choice-btn {
  min-height: 116px;
  padding: 18px 14px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 28px rgba(53,49,94,.2);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}

.choice-btn--quiet {
  color: var(--ink);
  background: #fff;
  border: 3px solid color-mix(in srgb, var(--accent) 28%, white);
}

.choice-btn .choice-icon { font-size: 2.25rem; line-height: 1; }
.choice-btn strong { font-size: clamp(1rem, 4vw, 1.2rem); }
.choice-btn small { font-size: .82rem; opacity: .86; }
.choice-btn:active { transform: scale(.97); }

.book {
  max-width: 900px;
}

.book-header {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: calc(8px + var(--safe-top)) 12px 9px;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid rgba(255,255,255,.8);
}

.home-link,
.reader-settings > summary {
  width: 50px;
  height: 50px;
  min-width: 50px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 1.4rem;
}

.story-title {
  font-size: clamp(1.08rem, 4.7vw, 1.55rem);
  line-height: 1.12;
}

.reader-settings {
  position: relative;
}

.reader-settings > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.reader-settings > summary::-webkit-details-marker { display: none; }
.reader-settings[open] > summary { outline: 3px solid color-mix(in srgb, var(--accent) 32%, white); }

.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 40;
  width: min(82vw, 290px);
  padding: 16px;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.setting-row {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 900;
}
.setting-row + .setting-row { margin-top: 16px; }
.setting-row select {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 2px solid #e9e2f7;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.speed-line { display: flex; align-items: center; gap: 9px; }
.speed-line input { flex: 1; accent-color: var(--accent); }

.read-progress {
  height: 9px;
  margin-top: 2px;
}

.book-stage {
  padding: 14px 12px 20px;
}

.page-card {
  gap: 14px;
  padding: clamp(14px, 4vw, 28px);
  border-width: 4px;
  border-radius: 30px;
  background: rgba(255,254,248,.98);
}

.illustration-wrap {
  position: relative;
  border-radius: 22px;
  border: 4px solid #fff;
  box-shadow: inset 0 0 0 1px rgba(53,49,94,.04);
}

.img-loading,
.image-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
  color: var(--ink-soft);
  background:
    linear-gradient(110deg, transparent 20%, rgba(255,255,255,.75) 42%, transparent 64%) 0 0 / 220% 100%,
    linear-gradient(145deg, #eee8ff, #ffeaf4);
  animation: paint-shimmer 1.8s linear infinite;
}

.img-loading span,
.image-fallback span { font-size: clamp(2.4rem, 12vw, 4.2rem); }
.img-loading strong,
.image-fallback strong { font-size: clamp(.9rem, 3.5vw, 1.08rem); }
.image-fallback { animation: none; background: linear-gradient(145deg, #eef8ff, #fff3cf); }

@keyframes paint-shimmer {
  to { background-position: -220% 0, 0 0; }
}

.page-image {
  animation: picture-arrive .42s var(--ease);
}

@keyframes picture-arrive {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: scale(1); }
}

.page-kicker {
  align-self: center;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, white);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .04em;
}

.page-text {
  max-width: 64ch;
  font-size: clamp(1.14rem, 4.7vw, 1.48rem);
  line-height: 1.72;
}

body.theme-bella .page-text {
  max-width: 42ch;
  font-size: clamp(1.3rem, 5.6vw, 1.7rem);
  line-height: 1.85;
}

.word {
  padding: 1px 2px;
  border-radius: 7px;
  transition: background .16s linear, color .16s linear, box-shadow .16s linear;
}

.word.highlight {
  background: #ffe17b;
  color: #3f3200;
  box-shadow: 0 0 0 3px #ffe17b;
}

.book-dock {
  gap: 7px;
  padding: 9px 12px calc(9px + var(--safe-bottom));
  background: rgba(255,255,255,.9);
}

.dock-main { gap: clamp(8px, 3vw, 16px); }

.dock-action {
  min-width: 66px;
  min-height: 68px;
  padding: 7px 10px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}

.dock-action .action-icon { font-size: 1.75rem; line-height: 1; }
.dock-action small { color: var(--ink-soft); font-size: .72rem; font-weight: 900; }
.dock-action:active { transform: scale(.94); }
.dock-action:disabled { opacity: .36; }

.dock-action--primary {
  min-width: 92px;
  min-height: 82px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--accent) 35%, transparent);
}
.dock-action--primary small { color: #fff; font-size: .82rem; }
.dock-action--primary .action-icon { font-size: 2rem; }

.dock-action--stop {
  min-width: 58px;
  background: #fff5f7;
}

.playing-indicator {
  width: 28px;
  margin-left: -6px;
}

.dock-sub {
  min-height: 44px;
  gap: 10px 16px;
}

.page-indicator {
  padding: 7px 12px;
  border-radius: 999px;
  background: #f3effb;
  color: var(--ink);
}

@media (max-width: 560px) {
  .start-actions { grid-template-columns: 1fr; }
  .choice-btn { min-height: 92px; }
  .dock-main { justify-content: space-between; }
  .dock-action { min-width: 58px; min-height: 64px; padding-inline: 7px; }
  .dock-action--primary { min-width: 84px; min-height: 78px; }
  .dock-action--stop { min-width: 52px; }
  .playing-indicator { display: none; }
}

@media (max-width: 360px) {
  .dock-action { min-width: 52px; }
  .dock-action--primary { min-width: 76px; }
  .dock-action small { font-size: .66rem; }
  .page-card { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .start-emoji,
  .img-loading { animation: none !important; }
}
