/* ==========================================================================
   Hora del Cuento — soft pastel picture-book styles
   ========================================================================== */

:root {
  --cream: #fff8f0;
  --paper: #fffdf9;
  --ink: #3b3355;
  --ink-soft: #6e6588;
  --line: #efe3d8;

  --peach: #ffd9cc;
  --peach-deep: #f4a58c;
  --sky: #d2e7f7;
  --sky-deep: #8bbde6;
  --mint: #cfefe3;
  --mint-deep: #78c9a8;
  --lavender: #e4dcf7;
  --lavender-deep: #a998de;
  --butter: #fff1bf;
  --butter-deep: #f5c84c;

  /* Per-book accent (overridden by .theme-*) */
  --accent: var(--lavender);
  --accent-deep: var(--lavender-deep);
  --highlight: #ffecb0;
  --vocab-ink: #6a4fb8;

  --font-display: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-read: 'Andika', Verdana, ui-sans-serif, sans-serif;

  --radius-lg: 28px;
  --radius: 20px;
  --shadow-soft: 0 1px 2px rgb(59 51 85 / 0.05), 0 10px 30px -14px rgb(59 51 85 / 0.22);
  --shadow-lift: 0 2px 4px rgb(59 51 85 / 0.06), 0 18px 36px -16px rgb(59 51 85 / 0.3);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: clamp(16px, 4vw, 40px);
}

.theme-peach { --accent: var(--peach); --accent-deep: var(--peach-deep); --highlight: #ffe2c4; --vocab-ink: #b84a2e; }
.theme-sky { --accent: var(--sky); --accent-deep: var(--sky-deep); --highlight: #ffecb0; --vocab-ink: #2a6aa8; }
.theme-mint { --accent: var(--mint); --accent-deep: var(--mint-deep); --highlight: #ffecb0; --vocab-ink: #23805b; }
.theme-lavender { --accent: var(--lavender); --accent-deep: var(--lavender-deep); --highlight: #ffe6c8; --vocab-ink: #6a4fb8; }

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-display);
  color: var(--ink);
  background:
    radial-gradient(60rem 30rem at -10% -12%, rgb(255 217 204 / 0.7), transparent 60%),
    radial-gradient(50rem 26rem at 110% -8%, rgb(210 231 247 / 0.8), transparent 60%),
    var(--cream);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .23 0 0 0 0 .2 0 0 0 0 .33 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; }

button { font: inherit; color: inherit; }

h1, h2, p { margin: 0; }

h1 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; text-wrap: balance; }
h1:focus { outline: none; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: 12px;
}

.icon { width: 24px; height: 24px; flex: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-weight: 500;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */

.site-header,
main {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem);
}
.brand-mark { width: 42px; height: 42px; }

.offline-status {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--line);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.offline-status.is-ready { background: var(--mint); box-shadow: none; color: var(--ink); }

.lang-switch {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--line);
}
.lang-switch button {
  min-width: 48px;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.lang-switch button[aria-pressed='true'] { background: var(--ink); color: var(--cream); }
.lang-switch button[aria-pressed='false']:hover { background: var(--lavender); }

main { flex: 1; padding-bottom: 48px; }
main:focus { outline: none; }
main > section { animation: fade-in 0.45s var(--ease-out) both; }

/* ---------- Shared bits ---------- */

.eyebrow {
  font-weight: 500;
  font-size: 0.98rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px 8px 10px;
  margin-bottom: clamp(16px, 3vw, 28px);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  font-weight: 500;
  max-width: 100%;
  transition: background-color 0.2s, transform 0.2s var(--ease-out);
}
.back-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-link:hover { background: var(--accent); transform: translateX(-2px); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-deep);
  color: var(--ink);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px -10px color-mix(in oklab, var(--accent-deep) 70%, var(--ink));
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s, background-color 0.2s;
}
.btn:hover { transform: translateY(-2px); background: color-mix(in oklab, var(--accent-deep) 88%, white); }
.btn:active { transform: translateY(1px); }
.btn-big { min-height: 62px; padding: 16px 30px; font-size: 1.2rem; }
.btn-big .icon { width: 28px; height: 28px; }
.btn-ghost {
  background: transparent;
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--ink) 18%, transparent);
}
.btn-ghost:hover { background: var(--paper); }

/* Book cover with a spine crease */
.cover {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: 6px 18px 18px 6px;
  background: var(--accent);
  box-shadow: var(--shadow-lift);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.cover::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg,
    rgb(59 51 85 / 0.22) 0,
    rgb(255 255 255 / 0.35) 2.5%,
    rgb(59 51 85 / 0.08) 5%,
    transparent 9%);
  box-shadow: inset 0 0 0 1px rgb(59 51 85 / 0.06);
}

/* ---------- Library ---------- */

.library-intro {
  max-width: 40rem;
  padding-block: clamp(12px, 3vw, 32px) clamp(28px, 5vw, 56px);
}
.library-intro h1 { font-size: clamp(2.1rem, 1.3rem + 3.4vw, 3.6rem); }
.lede {
  margin-top: 14px;
  font-family: var(--font-read);
  font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 34ch;
}

.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: clamp(40px, 6vw, 64px) clamp(20px, 4vw, 48px);
  max-width: 920px;
}

.shelf-item {
  animation: rise 0.7s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 90ms + 80ms);
}

.shelf-link {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  container-type: inline-size;
  border-radius: 18px;
}
/* The little wooden ledge each book stands on */
.shelf-link::before {
  content: '';
  position: absolute;
  top: calc(100cqw * 4 / 3 - 4px);
  left: -9%;
  right: -9%;
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(#ead7c4, #dcc3ab);
  box-shadow: 0 10px 18px -10px rgb(59 51 85 / 0.45);
}
.shelf-link:hover .cover,
.shelf-link:focus-visible .cover {
  transform: translateY(-8px) rotate(-1.5deg);
  box-shadow: 0 26px 40px -18px rgb(59 51 85 / 0.45);
}

.shelf-title {
  margin-top: 26px;
  font-weight: 600;
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
  line-height: 1.2;
}
.shelf-meta { font-size: 0.95rem; color: var(--ink-soft); }

.status {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--line);
}
.status-progress { background: var(--accent); box-shadow: none; }
.status-done { background: var(--butter); box-shadow: none; }

.dots { display: inline-flex; gap: 4px; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--accent-deep);
}
.dot.is-filled { background: var(--accent-deep); }
.status-progress .dot { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--accent-deep) 70%, var(--ink)); }
.status-progress .dot.is-filled { background: color-mix(in oklab, var(--accent-deep) 70%, var(--ink)); }

/* ---------- Book ---------- */

.book-layout {
  display: grid;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}
.cover-large { width: min(260px, 70%); margin-inline: auto; }

.book-info { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.book-info h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.2rem); }
.summary {
  font-family: var(--font-read);
  font-size: clamp(1.12rem, 1rem + 0.4vw, 1.3rem);
  line-height: 1.6;
  max-width: 44ch;
}
.book-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 8px 12px; }

.chapter-path {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Dotted trail connecting the chapter dots */
.chapter-path::before {
  content: '';
  position: absolute;
  left: 33px;
  top: 40px;
  bottom: 40px;
  border-left: 3px dotted var(--accent-deep);
}

.step-link {
  position: relative;
  display: grid;
  grid-template-columns: 44px clamp(72px, 18vw, 104px) 1fr auto;
  align-items: center;
  gap: clamp(10px, 2.4vw, 18px);
  padding: 10px 14px 10px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.25s var(--ease-out);
}
.step-link:hover { background: var(--paper); box-shadow: var(--shadow-soft); transform: translateX(3px); }

.step-dot {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 3px var(--accent-deep);
  font-weight: 600;
  font-size: 1.1rem;
}
.step.is-done .step-dot { background: var(--accent-deep); box-shadow: none; }
.step.is-current .step-dot {
  background: var(--butter);
  box-shadow: inset 0 0 0 3px var(--butter-deep), 0 0 0 6px rgb(245 200 76 / 0.25);
}

.step-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  background: var(--accent);
}
.step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.step-label { font-size: 0.88rem; font-weight: 500; color: var(--ink-soft); }
.step-title { font-weight: 600; font-size: clamp(1.02rem, 0.95rem + 0.3vw, 1.15rem); line-height: 1.25; }
.step-time { font-size: 0.92rem; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

@media (min-width: 820px) {
  .book-layout { grid-template-columns: minmax(240px, 340px) 1fr; }
  .cover-large { width: 100%; position: sticky; top: 24px; }
}

@media (max-width: 420px) {
  .step-link { grid-template-columns: 44px 64px 1fr; }
  .step-time { display: none; }
}

/* ---------- Chapter: an open picture book ---------- */

.spread {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  container-type: inline-size;
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
/* The fold down the middle of the book */
.spread::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 51.92%; /* 1.08 / 2.08 */
  width: 48px;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg,
    transparent,
    rgb(59 51 85 / 0.08) 42%,
    rgb(59 51 85 / 0.16) 50%,
    rgb(255 255 255 / 0.5) 54%,
    transparent);
}

.illustration {
  position: relative;
  margin: 0;
  background: var(--accent);
}
/* Two stacked layers: the next scene fades in over the current one,
   and the visible one drifts slowly so the picture never feels frozen. */
.illustration .scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s var(--ease-out);
}
.illustration .scene.is-visible {
  opacity: 1;
  animation: drift 16s ease-in-out infinite alternate;
}

.book-page {
  --story-size: 1.8rem;
  display: flex;
  flex-direction: column;
  /* Fixed height = the 4:3 illustration column, so the book never changes size.
     Long pages shrink their text instead (see fitText in views.js). */
  height: calc(100cqw * 0.3894);
  overflow: hidden;
  padding: clamp(24px, 2.8vw, 34px) clamp(28px, 3.6vw, 44px) clamp(16px, 2vw, 22px);
}
.book-page[data-text-size='s'] { --story-size: 1.45rem; }
.book-page[data-text-size='l'] { --story-size: 2.15rem; }
.book-page[data-text-size='xl'] { --story-size: 2.55rem; }

.chapter-heading { display: flex; flex-direction: column; gap: 4px; }
.chapter-heading .eyebrow { font-size: 0.92rem; }
.chapter-heading h1 { font-size: clamp(1.3rem, 1.05rem + 0.6vw, 1.55rem); }

.page-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding-block: 12px;
}
.page-text {
  font-family: var(--font-read);
  font-size: var(--story-size);
  line-height: 1.5;
  text-wrap: pretty;
}
.page-text.turn-next { animation: turn-next 0.45s var(--ease-out) both; }
.page-text.turn-prev { animation: turn-prev 0.45s var(--ease-out) both; }

.sentence {
  padding: 0.06em 0.14em;
  margin: 0 -0.14em;
  border-radius: 0.35em;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 0.3s var(--ease-out);
}
.sentence:hover { background: color-mix(in oklab, var(--accent) 55%, transparent); }
.sentence.is-current { background: var(--highlight); }

/* Vocabulary words: bold, in the book's ink color, with a wavy underline */
.vocab {
  background: none;
  color: var(--vocab-ink);
  font-weight: 700;
  text-decoration: underline wavy color-mix(in oklab, var(--vocab-ink) 55%, transparent);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.22em;
  text-decoration-skip-ink: none;
  cursor: help;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.page-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent-deep) 28%, var(--line));
  transition: background-color 0.3s;
}
.page-dot.is-past { background: color-mix(in oklab, var(--accent-deep) 60%, var(--paper)); }
.page-dot.is-active { width: 22px; background: var(--accent-deep); }

/* End of chapter, shown on the text page */
.end-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  margin-top: 14px;
  padding: 18px 24px;
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--butter) 75%, var(--paper));
  animation: pop-in 0.5s var(--ease-out) both;
}
.end-star .icon {
  width: 44px;
  height: 44px;
  color: var(--butter-deep);
  animation: twinkle 1.6s var(--ease-out) 0.2s both;
}
.end-title { font-weight: 600; font-size: 1.45rem; }
.end-body { font-family: var(--font-read); font-size: 1.15rem; color: var(--ink-soft); }
.end-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.end-actions .btn { min-height: 46px; padding: 10px 18px; font-size: 1rem; }

/* Player */
.player {
  position: relative;
  margin-top: 20px;
  padding: 14px clamp(16px, 2.4vw, 28px) 16px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

/* Seek row: 0:00 [=====o-----] 1:33 */
.seek {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.times { display: contents; }
.seek-bar { grid-column: 2; grid-row: 1; }
.t-now { grid-column: 1; grid-row: 1; min-width: 3.2ch; }

.range {
  --fill: 0%;
  --track: color-mix(in oklab, var(--accent) 55%, var(--line));
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.range::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent-deep) var(--fill), var(--track) var(--fill));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--paper);
  border: 5px solid var(--accent-deep);
  box-shadow: 0 2px 6px rgb(59 51 85 / 0.25);
  transition: transform 0.15s var(--ease-out);
}
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
.range::-moz-range-track { height: 10px; border-radius: 999px; background: var(--track); }
.range::-moz-range-progress { height: 10px; border-radius: 999px; background: var(--accent-deep); }
.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 5px solid var(--accent-deep);
  box-shadow: 0 2px 6px rgb(59 51 85 / 0.25);
}
.range:focus-visible { outline-offset: 2px; }

/* speed | transport | text size + volume */
.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}
.controls > .speed { justify-self: start; }
.controls-end { justify-self: end; display: flex; align-items: center; gap: 18px; }

.transport { display: flex; align-items: center; justify-content: center; gap: 12px; }

.icon-btn,
.play-btn {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s var(--ease-out);
}
.icon-btn { width: 52px; height: 52px; background: transparent; }
.icon-btn .icon { width: 30px; height: 30px; }
.icon-btn:hover:not(:disabled) { background: var(--accent); }
.icon-btn:active:not(:disabled) { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.page-turn { background: color-mix(in oklab, var(--accent) 45%, var(--paper)); }
.page-turn { width: 46px; height: 46px; }
.page-turn .icon { width: 24px; height: 24px; }

.play-btn {
  width: 78px;
  height: 78px;
  background: var(--accent-deep);
  box-shadow: 0 10px 22px -10px color-mix(in oklab, var(--accent-deep) 60%, var(--ink));
}
.play-btn .icon { width: 36px; height: 36px; }
.play-btn .icon-play { transform: translateX(2px); }
.play-btn .icon-pause,
.play-btn.is-playing .icon-play { display: none; }
.play-btn.is-playing .icon-pause { display: block; }
.play-btn:hover { transform: scale(1.04); }
.play-btn:active { transform: scale(0.95); }

.pill-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 50%, var(--paper));
}
.chip,
.size-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}
.size-btn { min-width: 42px; padding: 4px 8px; font-weight: 600; line-height: 1; }
.size-btn[data-font='s'] { font-size: 0.85rem; }
.size-btn[data-font='m'] { font-size: 1.05rem; }
.size-btn[data-font='l'] { font-size: 1.3rem; }
.size-btn[data-font='xl'] { font-size: 1.55rem; }
.chip[aria-pressed='true'],
.size-btn[aria-pressed='true'] { background: var(--paper); box-shadow: 0 2px 8px -2px rgb(59 51 85 / 0.25); font-weight: 600; }
.chip[aria-pressed='false']:hover,
.size-btn[aria-pressed='false']:hover { background: rgb(255 255 255 / 0.5); }

.volume { display: inline-flex; align-items: center; gap: 8px; width: 150px; color: var(--ink-soft); }

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  max-width: calc(100% - 16px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.3s, transform 0.3s var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Narrow screens: basic stacked fallback (the design targets desktop) */
@media (max-width: 899px) {
  .spread { grid-template-columns: 1fr; }
  .spread::after { display: none; }
  .illustration { aspect-ratio: 4 / 3; }
  .book-page { height: auto; }
  .controls { grid-template-columns: 1fr; justify-items: center; }
  .controls > .speed,
  .controls-end { justify-self: center; }
  .player { position: sticky; bottom: 8px; z-index: 2; }
}
@media (pointer: coarse) {
  .volume { display: none; }
}

/* ---------- Notices ---------- */

.notice {
  max-width: 36rem;
  margin: clamp(24px, 8vw, 80px) auto;
  padding: clamp(24px, 5vw, 40px);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}
.notice h1 { font-size: clamp(1.6rem, 1.3rem + 1.5vw, 2.2rem); }
.notice p { font-family: var(--font-read); font-size: 1.1rem; line-height: 1.6; }
.notice pre {
  width: 100%;
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: 14px;
  background: var(--lavender);
  font-size: 0.92rem;
  line-height: 1.7;
}

/* ---------- Motion ---------- */

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
@keyframes twinkle { from { transform: scale(0.4) rotate(-40deg); opacity: 0; } }
@keyframes turn-next { from { opacity: 0; transform: translateX(28px); } }
@keyframes turn-prev { from { opacity: 0; transform: translateX(-28px); } }
@keyframes drift {
  from { transform: scale(1.02); }
  to { transform: scale(1.08) translate(-1.5%, -1%); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
