:root {
  --cream: #fff8f0;
  --coral: #ef795a;
  --coral-dark: #c9553d;
  --sage: #7aab7b;
  --sage-light: #dce9d6;
  --navy: #2c3e5d;
  --parchment: #f5ecd7;
  --ink: #3a2e2a;
  --sky: #a9ccda;
  --butter: #f4d78a;
  --rose: #d9a6b4;
  --wood: #9a694a;
  --wood-dark: #69432f;
  --line: rgba(58, 46, 42, 0.14);
  --shadow: rgba(58, 46, 42, 0.18);
  --font-rounded: "Nunito", "Trebuchet MS", sans-serif;
  --font-reading: "Nunito", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: var(--font-reading);
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    repeating-linear-gradient(7deg, transparent 0 8px, rgba(58, 46, 42, 0.025) 8px 9px),
    repeating-linear-gradient(97deg, transparent 0 13px, rgba(255, 255, 255, 0.34) 13px 14px);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  padding: 0;
  color: inherit;
  background: none;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  overflow: clip;
}

.shelf-view {
  min-height: 100vh;
  padding: 28px clamp(20px, 5vw, 72px) 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 30px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 32%),
    var(--cream);
}

.shelf-view::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 22vh;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(92deg, rgba(105, 67, 47, 0.09) 0 2px, transparent 2px 76px),
    linear-gradient(180deg, transparent, rgba(154, 105, 74, 0.13));
}

.library-header,
.shelf-area,
.library-footer {
  width: min(1240px, 100%);
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

.library-header {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(340px, 1.3fr);
  gap: clamp(30px, 7vw, 110px);
  align-items: start;
}

.brand-mark {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  font-family: var(--font-rounded);
  font-size: 1.04rem;
  font-weight: 800;
  text-decoration: none;
}

.brand-flower {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--coral);
  box-shadow: 3px 4px 0 rgba(44, 62, 93, 0.12);
}

.library-heading {
  display: grid;
  gap: 12px;
}

.eyebrow,
.reader-kicker,
.chapter-label,
.art-label {
  margin: 0;
  color: var(--coral-dark);
  font-family: var(--font-rounded);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--navy);
  font-family: var(--font-rounded);
  font-size: 5.2rem;
  line-height: 0.94;
  letter-spacing: 0;
}

.welcome-copy {
  max-width: 520px;
  margin: 2px 0 0;
  color: rgba(58, 46, 42, 0.72);
  font-size: 1.03rem;
  line-height: 1.55;
}

.shelf-area {
  align-self: center;
  padding-block: 18px 4px;
}

.shelf-wrap {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: clamp(14px, 2.3vw, 30px);
  align-items: end;
  padding: 0 clamp(12px, 2vw, 26px) 35px;
  position: relative;
}

.shelf-wrap::before,
.shelf-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.shelf-wrap::before {
  bottom: 8px;
  height: 28px;
  border-radius: 5px 5px 2px 2px;
  background:
    repeating-linear-gradient(92deg, transparent 0 58px, rgba(255, 255, 255, 0.08) 58px 60px),
    linear-gradient(180deg, #ad7958, var(--wood));
  box-shadow: 0 13px 0 var(--wood-dark), 0 26px 30px rgba(58, 46, 42, 0.16);
}

.shelf-wrap::after {
  bottom: 30px;
  height: 5px;
  background: rgba(105, 67, 47, 0.22);
}

.shelf-book {
  min-width: 0;
  display: grid;
  gap: 11px;
  text-align: left;
  transform-origin: center bottom;
  transition: transform 260ms cubic-bezier(.2, .8, .2, 1), filter 260ms ease;
}

.shelf-book:hover,
.shelf-book:focus-visible,
.shelf-book.is-selected {
  z-index: 2;
  transform: translateY(-14px) rotate(-1deg);
  filter: saturate(1.04);
}

.shelf-book--2,
.shelf-book--5 {
  transform: rotate(1.1deg);
}

.shelf-book--3 {
  transform: rotate(-0.8deg);
}

.shelf-book--2:hover,
.shelf-book--2:focus-visible,
.shelf-book--2.is-selected,
.shelf-book--3:hover,
.shelf-book--3:focus-visible,
.shelf-book--3.is-selected,
.shelf-book--5:hover,
.shelf-book--5:focus-visible,
.shelf-book--5.is-selected {
  transform: translateY(-14px) rotate(0deg);
}

.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4.25;
  padding: 16px 14px;
  border: 1px solid rgba(58, 46, 42, 0.11);
  border-radius: 5px 8px 8px 5px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 9px;
  overflow: hidden;
  position: relative;
  color: var(--navy);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.55), transparent 36%),
    linear-gradient(180deg, var(--cover-b), var(--cover-a));
  box-shadow:
    inset 7px 0 0 rgba(44, 62, 93, 0.08),
    0 15px 24px rgba(58, 46, 42, 0.2);
}

.cover-texture,
.art-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(12deg, transparent 0 5px, rgba(44, 62, 93, 0.035) 5px 6px),
    repeating-linear-gradient(102deg, transparent 0 9px, rgba(255, 255, 255, 0.15) 9px 10px);
}

.cover-series,
.cover-ribbon {
  position: relative;
  z-index: 1;
  font-family: var(--font-rounded);
  font-size: 0.61rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.cover-series {
  color: rgba(44, 62, 93, 0.7);
}

.book-cover > strong {
  min-width: 0;
  position: relative;
  z-index: 1;
  font-family: var(--font-rounded);
  font-size: 1.14rem;
  line-height: 1.05;
}

.cover-placeholder {
  min-height: 0;
  margin-block: 2px;
  padding: 10px;
  border: 1px dashed rgba(44, 62, 93, 0.25);
  border-radius: 4px;
  display: grid;
  place-content: center;
  gap: 5px;
  position: relative;
  z-index: 1;
  color: rgba(44, 62, 93, 0.6);
  background: rgba(255, 248, 240, 0.36);
  font-family: var(--font-rounded);
  font-size: 0.62rem;
  text-align: center;
  text-transform: uppercase;
}

.cover-art {
  min-height: 0;
  border: 1px solid rgba(44, 62, 93, 0.16);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: var(--parchment);
  box-shadow: 3px 4px 0 rgba(44, 62, 93, 0.08);
}

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

.cover-placeholder span:first-child {
  color: var(--coral-dark);
  font-size: 1rem;
}

.cover-ribbon {
  width: max-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 3px;
  color: #24422f;
  background: color-mix(in srgb, var(--cover-c) 72%, white);
}

.shelf-book-meta {
  min-width: 0;
  min-height: 54px;
  padding-inline: 4px;
  display: grid;
  align-content: start;
  gap: 3px;
}

.shelf-book-meta strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--navy);
  font-family: var(--font-rounded);
  font-size: 0.9rem;
  line-height: 1.18;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.shelf-book-meta span {
  color: rgba(58, 46, 42, 0.62);
  font-size: 0.76rem;
}

.library-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  color: rgba(58, 46, 42, 0.54);
  font-size: 0.78rem;
}

.library-footer span:nth-child(2) {
  color: var(--coral);
}

.preview-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: clamp(18px, 5vw, 64px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.preview-layer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  cursor: default;
  background: rgba(44, 62, 93, 0.46);
  backdrop-filter: blur(5px);
}

.story-preview {
  width: min(920px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid rgba(58, 46, 42, 0.12);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(300px, 1.25fr);
  gap: clamp(28px, 6vw, 76px);
  align-items: center;
  overflow-y: auto;
  position: relative;
  transform: translateY(18px) scale(0.98);
  background:
    repeating-linear-gradient(9deg, transparent 0 10px, rgba(58, 46, 42, 0.018) 10px 11px),
    var(--cream);
  box-shadow: 0 34px 90px rgba(44, 62, 93, 0.32);
  transition: transform 280ms cubic-bezier(.2, .8, .2, 1);
}

.preview-layer.is-open .story-preview {
  transform: translateY(0) scale(1);
}

.round-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(44, 62, 93, 0.12);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 7px 18px rgba(58, 46, 42, 0.12);
  transition: transform 160ms ease, background 160ms ease;
}

.round-button:hover {
  transform: translateY(-2px);
  background: white;
}

.preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  font-size: 1.8rem;
  line-height: 1;
}

.preview-cover-button {
  width: 100%;
  transform: rotate(-1.5deg);
  transition: transform 190ms ease;
}

.preview-cover-button:hover {
  transform: translateY(-5px) rotate(0deg);
}

.book-cover--preview {
  max-width: 300px;
  margin-inline: auto;
  padding: 24px 22px;
  box-shadow: inset 9px 0 0 rgba(44, 62, 93, 0.08), 0 24px 40px rgba(58, 46, 42, 0.24);
}

.book-cover--preview > strong {
  font-size: 1.8rem;
}

.book-cover--preview .cover-placeholder {
  font-size: 0.72rem;
}

.preview-copy {
  display: grid;
  gap: 16px;
}

.preview-copy h2 {
  max-width: 18ch;
  margin: 0;
  color: var(--navy);
  font-family: var(--font-rounded);
  font-size: 3.4rem;
  line-height: 0.98;
  letter-spacing: 0;
}

.story-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-facts span {
  padding: 7px 10px;
  border: 1px solid rgba(44, 62, 93, 0.1);
  border-radius: 999px;
  color: var(--navy);
  background: white;
  font-family: var(--font-rounded);
  font-size: 0.75rem;
  font-weight: 700;
}

.synopsis {
  max-width: 52ch;
  margin: 0;
  color: rgba(58, 46, 42, 0.8);
  font-size: 1.02rem;
  line-height: 1.65;
}

.start-button,
.secondary-button,
.page-button {
  min-height: 50px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-family: var(--font-rounded);
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.start-button {
  width: max-content;
  min-width: 190px;
  padding: 0 20px;
  color: white;
  background: var(--coral-dark);
  box-shadow: 5px 6px 0 rgba(44, 62, 93, 0.14);
}

.start-button:hover,
.secondary-button:hover,
.page-button:not(:disabled):hover {
  transform: translateY(-2px);
}

.start-button:hover {
  background: #b94a35;
  box-shadow: 5px 8px 0 rgba(44, 62, 93, 0.13);
}

.reader-view {
  height: 100svh;
  min-height: 0;
  padding: 0;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 66px;
  gap: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(8deg, transparent 0 10px, rgba(58, 46, 42, 0.02) 10px 11px),
    linear-gradient(180deg, #f9f2e6, #e8efdf);
}

body.reading {
  overflow: hidden;
}

body.reading .app-shell {
  height: 100svh;
  overflow: hidden;
}

.reader-bar,
.reader-controls {
  width: 100%;
}

.reader-bar {
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 42px);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  position: relative;
  z-index: 4;
  background: rgba(255, 248, 240, 0.92);
  box-shadow: 0 1px 0 rgba(58, 46, 42, 0.1);
  backdrop-filter: blur(12px);
}

.reader-heading {
  min-width: 0;
}

.reader-heading h2 {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--navy);
  font-family: var(--font-rounded);
  font-size: 1.35rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-count {
  min-width: 80px;
  padding: 8px 11px;
  border: 1px solid rgba(44, 62, 93, 0.09);
  border-radius: 999px;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.64);
  font-family: var(--font-rounded);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.book-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  perspective: 1400px;
}

.book-page {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  position: relative;
}

.story-page,
.ending-page {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--parchment);
  box-shadow: none;
}

.story-page {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.page-enter-next {
  animation: page-in-next 420ms cubic-bezier(.2, .75, .2, 1) both;
}

.page-enter-prev {
  animation: page-in-prev 420ms cubic-bezier(.2, .75, .2, 1) both;
}

@keyframes page-in-next {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes page-in-prev {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}

.page-art {
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: clamp(10px, 1.5vw, 22px);
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    repeating-linear-gradient(8deg, transparent 0 11px, rgba(44, 62, 93, 0.025) 11px 12px),
    linear-gradient(145deg, #dbe9e4, #f2dfc3);
}

.page-illustration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
  display: block;
  background: transparent;
  box-shadow: none;
  user-select: none;
}

.page-copy {
  width: auto;
  min-height: 0;
  padding: clamp(28px, 4vw, 64px);
  display: grid;
  align-content: center;
  gap: 12px;
  overflow: hidden;
  position: relative;
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(58, 46, 42, 0.025) 27px 28px),
    var(--cream);
}

.story-page.copy-left .page-art {
  grid-column: 2;
}

.story-page.copy-left .page-copy {
  grid-column: 1;
  grid-row: 1;
}

.story-page.copy-right .page-art {
  grid-column: 1;
}

.story-page.copy-right .page-copy {
  grid-column: 2;
  grid-row: 1;
}

.page-text {
  display: grid;
  gap: 7px;
}

.page-text p {
  max-width: 88ch;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.42;
}

.page-copy.text-compact .page-text p {
  font-size: 0.91rem;
  line-height: 1.35;
}

.page-copy.text-dense .page-text {
  gap: 5px;
}

.page-copy.text-dense .page-text p {
  font-size: 0.83rem;
  line-height: 1.28;
}

.page-number {
  position: absolute;
  right: 20px;
  bottom: 14px;
  color: rgba(58, 46, 42, 0.42);
  font-family: var(--font-rounded);
  font-size: 0.72rem;
}

.reader-controls {
  min-height: 66px;
  padding: 10px clamp(16px, 3vw, 42px) 12px;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 132px;
  gap: 16px;
  align-items: center;
  background: rgba(255, 248, 240, 0.94);
  box-shadow: 0 -1px 0 rgba(58, 46, 42, 0.08);
}

.page-button {
  width: 100%;
  min-height: 46px;
  padding-inline: 14px;
  border: 1px solid rgba(44, 62, 93, 0.12);
  color: var(--navy);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 3px 4px 0 rgba(44, 62, 93, 0.1);
}

.next-button {
  color: white;
  background: var(--navy);
}

.page-button:disabled {
  opacity: 0.34;
  cursor: default;
  box-shadow: none;
}

.dots {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(44, 62, 93, 0.22);
  transition: width 180ms ease, border-radius 180ms ease, background 180ms ease;
}

.dot.is-active {
  width: 26px;
  border-radius: 999px;
  background: var(--coral-dark);
}

.ending-page {
  padding: clamp(30px, 7vw, 76px);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  background:
    repeating-linear-gradient(12deg, transparent 0 10px, rgba(58, 46, 42, 0.02) 10px 11px),
    linear-gradient(145deg, var(--cream), var(--sage-light));
}

.ending-mark {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--coral);
  font-size: 2rem;
  box-shadow: 5px 6px 0 rgba(44, 62, 93, 0.12);
}

.ending-page h3 {
  max-width: 15ch;
  margin: 4px 0 0;
  color: var(--navy);
  font-family: var(--font-rounded);
  font-size: 3.5rem;
  line-height: 1;
}

.ending-page > p:not(.eyebrow) {
  max-width: 50ch;
  margin: 0;
  line-height: 1.6;
}

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

.secondary-button {
  min-width: 140px;
  padding-inline: 18px;
  border: 1px solid rgba(44, 62, 93, 0.16);
  color: var(--navy);
  background: white;
}

@media (max-width: 900px) {
  h1 {
    font-size: 4.2rem;
  }

  .library-header {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .library-heading {
    max-width: 620px;
  }

  .shelf-wrap {
    grid-template-columns: repeat(5, minmax(145px, 1fr));
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .shelf-book {
    scroll-snap-align: start;
  }

  .story-preview {
    grid-template-columns: minmax(180px, 0.65fr) minmax(280px, 1.35fr);
    gap: 28px;
  }

  .preview-copy h2 {
    font-size: 2.7rem;
  }

  .page-copy {
    padding: 26px 30px;
  }
}

@media (max-width: 680px) {
  .shelf-view {
    min-height: 100svh;
    padding: 18px 16px 22px;
    grid-template-rows: auto auto auto;
    align-content: start;
    gap: 24px;
  }

  .shelf-view::after {
    display: none;
  }

  .library-header {
    gap: 18px;
  }

  .library-heading {
    gap: 8px;
  }

  .brand-mark {
    font-size: 0.94rem;
  }

  .brand-flower {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: 2.65rem;
    line-height: 0.98;
  }

  .welcome-copy {
    max-width: 34rem;
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .shelf-area {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: start;
    overflow: visible;
    padding: 0;
  }

  .shelf-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 14px;
    align-items: start;
    overflow: visible;
    padding: 0;
  }

  .shelf-wrap::before,
  .shelf-wrap::after {
    display: none;
  }

  .shelf-book,
  .shelf-book--2,
  .shelf-book--3,
  .shelf-book--5 {
    gap: 8px;
    transform: none;
  }

  .shelf-book:hover,
  .shelf-book:focus-visible,
  .shelf-book.is-selected,
  .shelf-book--2:hover,
  .shelf-book--2:focus-visible,
  .shelf-book--2.is-selected,
  .shelf-book--3:hover,
  .shelf-book--3:focus-visible,
  .shelf-book--3.is-selected,
  .shelf-book--5:hover,
  .shelf-book--5:focus-visible,
  .shelf-book--5.is-selected {
    transform: translateY(-4px);
  }

  .book-cover {
    padding: 11px 10px;
    gap: 7px;
  }

  .book-cover > strong {
    font-size: 0.86rem;
  }

  .cover-series,
  .cover-ribbon {
    font-size: 0.52rem;
  }

  .cover-ribbon {
    padding: 4px 6px;
  }

  .shelf-book-meta {
    min-height: 48px;
    padding-inline: 2px;
  }

  .shelf-book-meta strong {
    font-size: 0.82rem;
  }

  .library-footer {
    padding-top: 4px;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px 10px;
    overflow: visible;
    font-size: 0.72rem;
    text-align: center;
    white-space: normal;
  }

  .preview-layer {
    padding: 0;
    place-items: end center;
  }

  .story-preview {
    width: 100%;
    max-height: 92svh;
    padding: 30px 22px calc(24px + env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    transform: translateY(100%);
  }

  .preview-layer.is-open .story-preview {
    transform: translateY(0);
  }

  .preview-close {
    top: 12px;
    right: 12px;
  }

  .book-cover--preview {
    padding: 13px 11px;
  }

  .book-cover--preview > strong {
    font-size: 0.92rem;
  }

  .book-cover--preview .cover-placeholder {
    padding: 5px;
    font-size: 0.48rem;
  }

  .preview-copy {
    padding-top: 12px;
    gap: 11px;
  }

  .preview-copy h2 {
    padding-right: 34px;
    font-size: 1.72rem;
  }

  .synopsis {
    grid-column: 1 / -1;
    font-size: 0.93rem;
    line-height: 1.5;
  }

  .story-facts span {
    padding: 5px 8px;
    font-size: 0.68rem;
  }

  .start-button {
    width: 100%;
  }

  .reader-view {
    height: 100dvh;
    padding: 0;
    grid-template-rows: 60px minmax(0, 1fr) 58px;
    gap: 0;
  }

  .reader-bar {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 9px;
    min-height: 60px;
    padding: 8px 10px;
  }

  .reader-kicker {
    display: none;
  }

  .reader-heading h2 {
    font-size: 0.92rem;
  }

  .page-count {
    min-width: 62px;
    padding: 7px 8px;
    font-size: 0.66rem;
  }

  .book-page {
    width: 100vw;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }

  .story-page {
    min-height: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 58%) minmax(0, 42%);
  }

  .page-art {
    padding: 8px;
  }

  .page-illustration {
    object-position: center;
    background: transparent;
  }

  .page-copy {
    padding: 14px 18px 18px;
    gap: 6px;
  }

  .story-page.copy-left .page-art,
  .story-page.copy-right .page-art {
    grid-column: 1;
    grid-row: 1;
  }

  .story-page.copy-left .page-copy,
  .story-page.copy-right .page-copy {
    grid-column: 1;
    grid-row: 2;
  }

  .chapter-label {
    font-size: 0.64rem;
  }

  .page-text {
    gap: 6px;
  }

  .page-text p {
    font-size: 0.81rem;
    line-height: 1.3;
  }

  .page-copy.text-compact .page-text p {
    font-size: 0.76rem;
    line-height: 1.26;
  }

  .page-copy.text-dense .page-text p {
    font-size: 0.7rem;
    line-height: 1.2;
  }

  .page-number {
    right: 13px;
    bottom: 9px;
  }

  .reader-controls {
    min-height: 58px;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    gap: 8px;
  }

  .page-button {
    min-height: 44px;
    padding: 0;
    gap: 0;
    font-size: 1.1rem;
  }

  .page-button span:not([aria-hidden="true"]) {
    display: none;
  }

  .dot {
    width: 6px;
    height: 6px;
  }

  .dot.is-active {
    width: 18px;
  }

  .ending-page {
    padding: 28px 20px;
  }

  .ending-actions {
    width: 100%;
  }

  .ending-actions .secondary-button,
  .ending-actions .start-button {
    width: 100%;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 680px) {
    .reader-view {
      padding-top: max(env(safe-area-inset-top), 84px);
      grid-template-rows: 60px minmax(0, 1fr) 58px;
      background: var(--cream);
    }

    body.reading .app-shell {
      height: 100dvh;
    }

    .story-page {
      grid-template-rows: minmax(0, 54%) minmax(0, 46%);
    }
  }
}

@media (min-width: 520px) and (max-width: 680px) {
  .shelf-wrap {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .story-page {
    grid-template-rows: minmax(0, 52%) minmax(0, 48%);
  }

  .page-copy {
    padding: 10px 14px 14px;
  }

  .story-preview {
    grid-template-columns: 98px minmax(0, 1fr);
    gap: 15px;
  }

  .preview-copy h2 {
    font-size: 1.48rem;
  }

  .story-facts span:nth-child(3) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
