/* Spec 020: storybooks — the shelf, the maker, the progress card and the reader.
   Colours are tokens only (tokens.css). */

.crayon-blue {
  background: var(--crayon-blue);
  color: var(--on-crayon);
  text-decoration: none;
}

.books-body,
.maker {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Spec 271 amendment 1 (the owner on TestFlight, 2026-11-03): while no book is left, the one-more-story card is the whole maker:
   the steps, Your book and the bar of Back, "More below" and Next are not drawn under it (js/views/books.js `maker-spent`). */
.maker.maker-spent > :not(.story-offer-host) {
  display: none;
}

.books-make {
  min-height: calc(var(--touch-kid) * 1.75);
}

.books-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.book-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-raised);
}

.book-open {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: var(--touch-kid);
}

.book-open img {
  width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--crayon-blue);
}

.book-open strong {
  font-size: var(--font-lg);
  overflow-wrap: anywhere;
}

/* Spec 111 (the owner, build 21: "favorite as a star icon you can toggle ... and a delete icon also to the right, rather
   than buttons below"): the card is its open button, then a row of compact icons on the right under the words. */
.book-item .card-icons {
  justify-content: flex-end;
  /* Spec 151: a row's cards are one height; the icons sit at each card's foot. */
  margin-top: auto;
}

.book-marks {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: flex;
  gap: 6px;
}

/* Spec 151 (the owner on build 34: "the 'My favourites' button is confusing ... This page itself is confusing and hard to
   navigate"): sections under headings in place of the filter. Favourites and Story series are strips of small cards; All
   my books is one grid whose rows are one height (spec 148's rule), so a long library scans evenly. */
.books-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.books-section[hidden] {
  display: none;
}

.books-section h2,
.books-all-title {
  margin: var(--space-2) 0 0;
}

.books-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: calc(-1 * var(--space-2)) 0 0;
}

.books-hint[hidden] {
  display: none;
}

.books-hint .icon {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--crayon-yellow);
}

.books-grid {
  grid-auto-rows: 1fr;
}

/* A favourite's small card: the series card's look, the cover with a star in its corner; a strip's cards are one height. */
.books-favourites .worlds-strip > li {
  display: flex;
}

.book-favourite {
  width: 168px;
  flex: 1;
  justify-content: flex-start;
}

.book-favourite .book-cover img {
  width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--crayon-blue);
}

.book-favourite .favourite-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--crayon-yellow);
}

.book-favourite .favourite-mark .icon {
  width: 20px;
  height: 20px;
}

/* Spec 151 (the owner on build 34: "What is that play button for?"): a book's video says what it is, as Xocana Books'
   "Video" (spec 141, the same corner and size): "Video" with a clapperboard once it is made, "Making video…" with the
   hopping dragon while it is made. The cover is the card's width at 5:3 (its padding aside), so the corner is found from
   the card's own width (a container query unit). */
.book-item {
  position: relative;
  container-type: inline-size;
}

.book-item .book-video {
  position: absolute;
  top: calc(var(--space-2) + 60cqw - 48px - 8px);
  left: calc(var(--space-2) + 8px);
  max-width: calc(100% - 2 * var(--space-2) - 16px);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  background: var(--crayon-teal);
  color: var(--on-crayon);
  font-weight: 800;
  font-size: var(--font-xs);
  line-height: 1.1;
  text-decoration: none;
  box-shadow: var(--elevation-raised);
}

.book-item .book-video[hidden] {
  display: none;
}

.book-item .book-video .book-video-art {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.book-item .book-video .icon {
  width: 20px;
  height: 20px;
}

.book-item .book-video[data-state="making"] {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--hairline);
}

/* Spec 147: a video being made is a tiny hopping dragon, never a spinner. */
.book-item .book-video[data-state="making"] .book-video-art {
  background: url("/img/friend-dragon.svg") center / contain no-repeat;
  animation: busy-friend-hop 1.1s ease-in-out infinite;
  transform-origin: 50% 90%;
}

.book-item .book-video[data-state="making"] .icon {
  visibility: hidden;
}

.book-item .book-video:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .book-item .book-video[data-state="making"] .book-video-art {
    animation: none;
  }
}

/* The maker: one big question at a time, crayon chips. */
.maker-title {
  font-size: var(--font-2xl);
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.chip {
  min-height: var(--touch-kid);
  padding: var(--space-2) var(--space-4);
  border: 3px solid var(--surface-muted);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-lg);
  font-weight: 600;
  cursor: pointer;
}

/* Spec 052: "More ideas" deals six other presets; it reads as a chip, not as an idea. */
.chip-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-start;
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  font-weight: 700;
}

.chip-more .icon {
  width: 1.2em;
  height: 1.2em;
}

.chip[aria-pressed="true"] {
  background: var(--crayon-yellow);
  color: var(--on-crayon);
  border-color: var(--crayon-yellow);
}

.chip img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.maker input {
  min-height: var(--touch-kid);
  font-size: var(--font-lg);
}

.maker-nav {
  justify-content: space-between;
}

.maker-nav .button {
  min-height: var(--touch-kid);
}

/* While a book is made. Spec 049: the screen is full: the friend whose turn it is speaks above a
   big ring that fills as the pages are made, the three friends below it (the one speaking hops), and
   a dot a page. */
.making-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  min-height: min(78vh, 900px);
  padding: var(--space-5) var(--space-4);
  text-align: center;
}

/* Spec 179: a new path of a choice is a new book in its series: a small pill above the friends' line. */
.making-new-path {
  margin: 0;
  max-width: 34ch;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--font-md);
  font-weight: 700;
}

.making-new-path[hidden] {
  display: none;
}

.making-line {
  margin: 0;
  max-width: 34ch;
  padding: var(--space-3) var(--space-5);
  background: var(--surface);
  color: var(--text);
  border: 3px solid var(--tile-edge);
  border-radius: var(--radius-xl);
  font-size: var(--font-xl);
  font-weight: 700;
}

.making-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: min(80vw, 52vh, 440px);
  aspect-ratio: 1;
}

.making-ring-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.making-ring-track,
.making-ring-fill {
  fill: none;
  stroke-width: 9;
}

.making-ring-track {
  stroke: var(--surface-muted);
}

.making-ring-fill {
  stroke: var(--crayon-yellow);
  stroke-linecap: round;
  transition: stroke-dashoffset 600ms ease-out;
}

.making-ring-words {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  max-width: 62%;
}

.making-icon {
  width: 56px;
  height: 56px;
  color: var(--crayon-yellow);
}

.making-stage {
  margin: 0;
  font-size: var(--font-2xl);
}

.making-friends {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
}

.making-friend {
  width: clamp(84px, 22vw, 140px);
  height: auto;
  opacity: 0.7;
  /* Every friend bobs all the time, out of step, so a change of turn never restarts (or snaps) an animation; the
     turn only brightens and grows the friend whose turn it is (the owner, 2026-10-13: "they shake oddly"). */
  animation: making-friend-bob 2.4s ease-in-out infinite;
  transform-origin: 50% 90%;
  will-change: transform;
  transition: opacity 400ms ease-out, scale 400ms ease-out;
}

.making-friend:nth-child(2) {
  animation-delay: -0.8s;
}

.making-friend:nth-child(3) {
  animation-delay: -1.6s;
}

.making-friend.turn {
  opacity: 1;
  scale: 1.08;
}

@keyframes making-friend-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  25% {
    transform: translateY(-6px) rotate(-2deg);
  }

  50% {
    transform: translateY(-10px) rotate(0deg);
  }

  75% {
    transform: translateY(-6px) rotate(2deg);
  }
}

.making-dots {
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.making-dots li {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-muted);
  border: 2px solid var(--tile-edge);
}

.making-dots li.done {
  background: var(--crayon-yellow);
}

.making-dots li.now {
  background: var(--crayon-pink);
  transform: scale(1.25);
}

@media (prefers-reduced-motion: reduce) {
  .making-friend.turn {
    animation: none;
  }

  .making-ring-fill,
  .making-friend {
    transition: none;
    animation: none;
  }
}

/* Sideways on a phone: the ring beside the friends. */
@media (orientation: landscape) and (max-height: 560px) {
  .making-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "ring line"
      "ring friends"
      "ring dots";
    align-items: center;
    min-height: auto;
  }

  .making-ring {
    grid-area: ring;
    width: min(44vw, 78vh);
  }

  .making-line {
    grid-area: line;
  }

  .making-friends {
    grid-area: friends;
  }

  .making-dots {
    grid-area: dots;
    justify-content: center;
  }
}

/* Spec 162: one calm line for the grown-up just above the way out, in the secondary ink (checked in light, dark and
   bedtime), as small as the page's quiet notes; it is there from the first paint, so nothing moves. */
.making-leave {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.making-leave-line {
  margin: 0;
  max-width: 44ch;
  color: var(--text-secondary);
  font-size: var(--font-md);
  line-height: 1.4;
}

.making-sorry {
  padding: var(--space-5);
  background: var(--crayon-orange);
  color: var(--on-crayon);
  border-radius: var(--radius-lg);
  font-size: var(--font-lg);
  font-weight: 700;
  text-align: center;
}

/* The reader: a landscape page. Wide screens put the picture beside the words.
   Spec 060: the reader fills the screen like an open book (over the site's bar and footer, as the
   phone's reader has no bar): its title row, the book, and its buttons. */
.reader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: max(var(--space-2), env(safe-area-inset-top)) max(var(--space-3), env(safe-area-inset-right))
    max(var(--space-2), env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left));
  overflow: hidden;
  /* Spec 178 (the owner, on a desktop: the choice page "cut off at the left edge"): a hidden overflow can still be scrolled
     by a focus or a script, which slides the whole book sideways and leaves it there; clipped, the reader never scrolls. */
  overflow: clip;
  background-color: var(--page);
  background-image: var(--gradient-sky);
}

.reader-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Spec 060, revision 2026-10-11: the close ✕ beside the bar, round on the surface like the walkthrough's
   Skip; it is outside .reader-top, so the calm reader never fades it. */
.reader-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.reader-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--elevation-raised);
  text-decoration: none;
}

.reader-close .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.reader-close:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

/* Spec 135 (the owner on build 31: the bar "cluttered and overlapping"): the way back, the page count in digits with a
   little bar in the middle, then Print and the flag, 48 px each; no title (the cover and the running head show it whole). */
.reader-top {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.reader-back {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.35em;
  min-height: 44px;
  font-weight: 700;
}

.reader-back .icon {
  flex: none;
  width: 1.3em;
  height: 1.3em;
}

.reader-progress {
  display: grid;
  flex: none;
  justify-items: center;
  gap: 3px;
  margin: 0 auto;
  padding: 5px 14px 6px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--elevation-raised);
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.reader-progress progress {
  width: 56px;
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--accent);
  appearance: none;
}

.reader-progress progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-muted);
}

.reader-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.reader-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

.reader-tools {
  display: flex;
  flex: none;
  gap: var(--space-2);
  margin-inline-start: auto;
}

.reader-tools .round {
  width: 48px;
  height: 48px;
}

.reader-tools .round .icon {
  width: 26px;
  height: 26px;
}

/* Spec 226 amendment 2026-10-26: the top bar's Languages button, a round 48 px button that grows to hold "EN · ES" beside its
   globe (the globe alone on a narrow phone, where Print also gives way when Share and Languages are both there: Print keeps
   the cover's link and The End's card). */
.reader-tools .round.reader-languages {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 48px;
  gap: 4px;
  padding: 0 12px;
  border-radius: 999px;
}

.reader-languages-codes {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .reader-languages-codes {
    display: none;
  }

  .reader-tools .round.reader-languages {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .reader-tools:has(> [data-ref="languagesOpen"]:not([hidden])):has(> [data-ref="shareBook"]:not([hidden])) > [data-ref="printBook"] {
    display: none;
  }
}

/* On the cover (no page count) a phone of 360 px and more has room for the codes again. */
@media (min-width: 360px) and (max-width: 420px) {
  .reader-top:has(> .reader-progress[hidden]) .reader-languages-codes {
    display: inline;
  }

  .reader-top:has(> .reader-progress[hidden]) .reader-tools .round.reader-languages {
    width: auto;
    padding: 0 10px;
  }
}

.end-actions .end-share {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.end-actions .end-share .icon {
  width: 1.25em;
  height: 1.25em;
}

/* The Languages sheet: a panel at the foot of the screen (centred on a wide one), its two segmented controls. */
.languages-sheet {
  width: min(560px, calc(100vw - 16px));
  max-width: none;
  margin: auto auto 8px;
  padding: var(--space-4) var(--space-5) var(--space-5);
  border: var(--ui-stroke-panel) solid var(--panel-edge);
  border-radius: var(--ui-radius-panel);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--elevation-raised);
}

@media (min-width: 700px) {
  .languages-sheet {
    margin: auto;
  }
}

.languages-sheet::backdrop {
  background: var(--page-shade);
}

.languages-sheet[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.languages-sheet-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.languages-sheet-head > .icon {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  color: var(--crayon-blue);
}

.languages-sheet-head h2 {
  flex: 1;
  margin: 0;
  font-size: 1.4rem;
}

.languages-sheet > .muted {
  margin: 0;
}

.languages-pair {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.languages-pair[hidden] {
  display: none;
}

.languages-pair .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.end-actions .end-home {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.end-actions .end-home .icon {
  width: 1.25em;
  height: 1.25em;
}

.reader-stage {
  perspective: 1600px;
  /* Spec 060: the book takes the room the title and the buttons leave; its pages are sized to it. */
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 10px 16px 16px 10px;
  container-type: size;
}

/* Spec 049: the sheet is paper, with the edges of the pages beneath it and a shade along the spine
   (a single page's left edge, a spread's middle). */
.sheet {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 1500px;
  background: var(--paper);
  /* Spec 060: warm paper with a faint grain (drawn once by the browser, never per frame). */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.42 0 0 0 0 0.3 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  color: var(--on-paper);
  border-radius: 8px 18px 18px 8px;
  /* The page edges stacked beneath, and the cover's board round them. */
  box-shadow:
    3px 3px 0 -1px var(--paper),
    3px 3px 0 0 var(--paper-edge),
    6px 6px 0 -1px var(--paper),
    6px 6px 0 0 var(--paper-edge),
    9px 9px 0 -1px var(--paper),
    9px 9px 0 0 var(--paper-edge),
    0 0 0 8px var(--cover-cloth-deep),
    var(--elevation-float);
  touch-action: pan-y;
  user-select: none;
  transform-origin: left center;
  backface-visibility: hidden;
  perspective: 2000px;
}

.sheet::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 28px;
  background: linear-gradient(90deg, var(--page-shade), transparent);
  pointer-events: none;
}

.sheet.spread {
  border-radius: 18px;
  box-shadow:
    -3px 3px 0 -1px var(--paper),
    -3px 3px 0 0 var(--paper-edge),
    3px 3px 0 -1px var(--paper),
    3px 3px 0 0 var(--paper-edge),
    -6px 6px 0 -1px var(--paper),
    -6px 6px 0 0 var(--paper-edge),
    6px 6px 0 -1px var(--paper),
    6px 6px 0 0 var(--paper-edge),
    0 0 0 8px var(--cover-cloth-deep),
    var(--elevation-float);
}

.sheet.spread::before {
  inset: 0 auto 0 calc(50% - 32px);
  width: 64px;
  background: linear-gradient(90deg, transparent, var(--page-shade) 48%, var(--page-shade) 52%, transparent);
}

.sheet:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 4px;
}

/* Spec 060: the picture is as large as the page is wide, at most 62% of the page; when the
   words need the room it gives way down to 28%. It is printed on the paper in a rounded frame with a mat, an inner
   line and a soft shadow. Spec 135: the frame grows to 4:3 when the page has room (the picture is cropped a little at its
   sides), and the room the words leave goes round them (they are centred under it), not above the picture. */
.sheet-picture {
  flex: 0 1 auto;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: max(28%, 96px);
  max-height: 62%;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  container-type: size;
}

.sheet-picture img {
  display: block;
  box-sizing: border-box;
  width: min(100cqw, 150cqh);
  height: min(100cqh, 75cqw);
  object-fit: cover;
  padding: 4px;
  border-radius: 16px;
  background: var(--paper-edge);
  outline: 1px solid var(--page-shade);
  outline-offset: -5px;
  box-shadow: 0 4px 10px var(--page-shade);
}

/* The words, in the story's face (story-fonts.css) at the page fit's step (data-step), roomy for
   early readers; only at the smallest step do they scroll. */
.sheet-words {
  position: relative;
  flex: 1 0 auto;
  min-height: 0;
  /* The picture gives way first; the words scroll only past its smallest (page-fit.js's room). */
  max-height: calc(100% - max(28%, 96px) - clamp(10px, 2.5cqmin, 20px) - var(--head-space, 0px));
  overflow-y: auto;
  /* Spec 178: the words scroll down, never sideways (the choice's pictures stay whole and in place). */
  overflow-x: hidden;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 clamp(4px, 3%, 14px);
  font-family: var(--story-family, var(--font-family));
  font-size: calc(var(--step, 22px) * var(--story-scale, 1));
  line-height: 1.45;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

.sheet-words p {
  margin: 0;
}

/* Spec 135: the words and their ornaments are centred in the room under the picture; the spacers give way first, so a
   column that scrolls still starts at its top. */
.sheet-words::before,
.sheet-words::after {
  content: "";
  flex: 1 1 0;
}

.sheet-words .family-words,
.sheet-words .sheet-tail {
  margin-top: var(--space-3);
}

/* Spec 135: the running head: the book's title, small and whole, between two rules in the paper's edge colour, at the
   head of every page of a book that has room for it (page-fit.js chooseBookStep). */
.running-head {
  display: none;
  flex: none;
  align-items: center;
  gap: 10px;
  min-height: clamp(20px, 3.5cqh, 28px);
  margin: 0 0 calc(clamp(10px, 2.5cqmin, 20px) / -2);
  color: var(--on-paper);
  font-family: var(--story-family, var(--font-family));
  font-size: clamp(12px, 1.9cqh, 15px);
  line-height: 1.1;
  text-align: center;
  opacity: 0.78;
}

.sheet.has-head {
  --head-space: calc(clamp(20px, 3.5cqh, 28px) - clamp(10px, 2.5cqmin, 20px) / 2);
}

.sheet.has-head .running-head {
  display: flex;
}

.running-head::before,
.running-head::after {
  content: "";
  flex: 1 1 0;
  min-width: 12px;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--cover-foil) 0 4px, transparent 4px 7px, var(--paper-edge) 7px calc(100% - 7px), transparent calc(100% - 7px) calc(100% - 4px), var(--cover-foil) calc(100% - 4px));
}

.running-title {
  flex: 0 1 auto;
  max-width: 78%;
  overflow-wrap: break-word;
}

/* Spec 135: a small flourish over the words, and a vignette under them (three sparkles over a cloud), each where it fits
   (page-fit.js placeWords). */
.page-divider,
.page-vignette {
  display: none;
  flex: none;
  align-self: center;
  background: var(--cover-foil);
}

.page-divider {
  width: min(180px, 70%);
  height: clamp(16px, 0.8em, 28px);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 28'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M78 14C60 8 46 22 28 14c-6-3-4-9 1-7'/%3E%3Cpath d='M102 14c18-6 32 8 50 0 6-3 4-9-1-7'/%3E%3C/g%3E%3Ccircle cx='20' cy='14' r='2'/%3E%3Ccircle cx='160' cy='14' r='2'/%3E%3Cpath d='M90 5q1.6 7.4 9 9-7.4 1.6-9 9-1.6-7.4-9-9 7.4-1.6 9-9z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 28'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M78 14C60 8 46 22 28 14c-6-3-4-9 1-7'/%3E%3Cpath d='M102 14c18-6 32 8 50 0 6-3 4-9-1-7'/%3E%3C/g%3E%3Ccircle cx='20' cy='14' r='2'/%3E%3Ccircle cx='160' cy='14' r='2'/%3E%3Cpath d='M90 5q1.6 7.4 9 9-7.4 1.6-9 9-1.6-7.4-9-9 7.4-1.6 9-9z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.page-vignette {
  width: 144px;
  height: 48px;
  margin-top: clamp(10px, 2.5cqmin, 20px);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 144 48'%3E%3Cpath d='M50 44c-8 0-9-9-2-11 0-8 10-11 15-5 4-8 18-7 19 2 8-2 13 6 8 11z' fill='black' fill-opacity='.35' stroke='black' stroke-width='1.6' stroke-linejoin='round'/%3E%3Cpath d='M44 6q1.2 5.6 6.6 6.8-5.4 1.2-6.6 6.8-1.2-5.6-6.6-6.8 5.4-1.2 6.6-6.8zM72 0q1.6 7.4 9 9-7.4 1.6-9 9-1.6-7.4-9-9 7.4-1.6 9-9zM100 6q1.2 5.6 6.6 6.8-5.4 1.2-6.6 6.8-1.2-5.6-6.6-6.8 5.4-1.2 6.6-6.8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 144 48'%3E%3Cpath d='M50 44c-8 0-9-9-2-11 0-8 10-11 15-5 4-8 18-7 19 2 8-2 13 6 8 11z' fill='black' fill-opacity='.35' stroke='black' stroke-width='1.6' stroke-linejoin='round'/%3E%3Cpath d='M44 6q1.2 5.6 6.6 6.8-5.4 1.2-6.6 6.8-1.2-5.6-6.6-6.8 5.4-1.2 6.6-6.8zM72 0q1.6 7.4 9 9-7.4 1.6-9 9-1.6-7.4-9-9 7.4-1.6 9-9zM100 6q1.2 5.6 6.6 6.8-5.4 1.2-6.6 6.8-1.2-5.6-6.6-6.8 5.4-1.2 6.6-6.8z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.sheet-page.has-divider .page-divider,
.sheet-page.has-vignette .page-vignette {
  display: block;
}

.sheet-page {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(10px, 2.5cqmin, 20px);
  min-width: 0;
  min-height: 0;
  padding: clamp(12px, 5cqmin, 28px) clamp(12px, 5cqmin, 28px) calc(clamp(12px, 5cqmin, 28px) + 24px);
}

@media (min-width: 760px) and (min-aspect-ratio: 1 / 1) {
  .sheet-page {
    display: grid;
    grid-template-columns: 3fr 2fr;
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: clamp(10px, 2.5cqmin, 20px);
    row-gap: 0;
    align-items: stretch;
  }

  /* Spec 135: the running head over the words' column; the picture the page's whole height beside them. */
  .sheet-page > .running-head {
    grid-column: 2;
    grid-row: 1;
    margin: 0 0 clamp(6px, 1.2cqmin, 10px);
  }

  .sheet-picture {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 100%;
    aspect-ratio: auto;
    max-height: none;
    min-height: 0;
  }

  .sheet-words {
    grid-column: 2;
    grid-row: 2;
    max-height: 100%;
  }

  /* Spec 135: the page number's medallion at the foot of the words' column. */
  .sheet-page > .folio {
    left: 80%;
  }

  .sheet.spread .sheet-page > .folio {
    left: 50%;
  }

  /* The cue sits under the words' column, not over the picture beside them. */
  .sheet-page > .words-more {
    grid-column: 2;
    grid-row: 1;
    inset: auto 0 0;
  }
}

/* Spec 033: two facing pages on a large landscape screen, each its picture above its words, with
   the book's fold between them. */
.sheet.spread {
  grid-template-columns: 1fr 1fr;
}

.sheet.spread .sheet-page {
  display: flex;
  flex-direction: column;
}

.sheet.spread .sheet-page > .running-head {
  margin: 0 0 calc(clamp(10px, 2.5cqmin, 20px) / -2);
}

.sheet.spread .sheet-words {
  max-height: calc(100% - max(28%, 96px) - clamp(10px, 2.5cqmin, 20px) - var(--head-space, 0px));
}

.sheet.spread .sheet-page > .words-more {
  grid-column: auto;
  grid-row: auto;
  inset: auto clamp(12px, 5cqmin, 28px) calc(clamp(12px, 5cqmin, 28px) + 14px);
}

.sheet.spread .sheet-picture {
  height: auto;
  aspect-ratio: 4 / 3;
  min-height: max(28%, 96px);
  max-height: 62%;
}

.sheet.spread .sheet-page-right {
  border-inline-start: 1px solid var(--paper-edge);
}

/* Spec 049: the leaf that turns. It sits over the sheet, swings about the spine with its back face
   (the new facing page in a spread) and a shade across it; the old facing page waits beneath it. */
.leaf {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  transform-style: preserve-3d;
  pointer-events: none;
}

.leaf-left {
  inset: 0 50% 0 0;
}

.leaf-right {
  inset: 0 0 0 50%;
}

.leaf-from-left {
  transform-origin: left center;
}

.leaf-from-right {
  transform-origin: right center;
}

.leaf-under {
  z-index: 2;
  background: var(--paper);
}

.leaf-face {
  position: absolute;
  inset: 0;
  display: grid;
  background: var(--paper);
  backface-visibility: hidden;
  box-shadow: 0 0 24px var(--page-shade);
  overflow: hidden;
}

.leaf-back {
  transform: rotateY(180deg);
}

.leaf-face > .sheet-page {
  min-height: 100%;
}

.leaf-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--page-shade), transparent 60%);
  opacity: 0;
  pointer-events: none;
}

.leaf-from-right .leaf-shade {
  background: linear-gradient(270deg, var(--page-shade), transparent 60%);
}

/* The turn: the new page swings in from the spine. */
.sheet.turn-next {
  animation: book-turn-next 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.sheet.turn-back {
  transform-origin: right center;
  animation: book-turn-back 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes book-turn-next {
  from {
    transform: rotateY(-80deg);
    opacity: 0.3;
  }

  to {
    transform: rotateY(0);
    opacity: 1;
  }
}

@keyframes book-turn-back {
  from {
    transform: rotateY(80deg);
    opacity: 0.3;
  }

  to {
    transform: rotateY(0);
    opacity: 1;
  }
}

@keyframes book-fade {
  from {
    opacity: 0.2;
  }

  to {
    opacity: 1;
  }
}

/* Less motion: the page fades in instead of turning. */
@media (prefers-reduced-motion: reduce) {
  .sheet.turn-next,
  .sheet.turn-back {
    animation: book-fade 200ms ease-out;
    transform: none;
  }
}

/* Spec 049: the buttons calm down after a moment; they keep their place, so the book never moves. Spec 247: all but the
   pill at the row's end (.reader-peek), which shows only while they are calm. */
.reader-top,
.reader-controls > *,
.reader-hint {
  transition: opacity 320ms ease-out;
}

.reader.calm .reader-top,
.reader.calm .reader-controls > :not(.reader-peek),
.reader.calm .reader-hint {
  opacity: 0;
  pointer-events: none;
}

/* Spec 247 (the owner, 2026-10-31: "When reading the book I didn't see controls to mute narrator or things like that, it
   looks great but a non invasive way to show the controls should be present"): while the buttons are calm, a small
   see-through pill in the → button's own place (so it covers nothing the buttons did not): the speaker, which mutes at once
   without bringing the buttons back, and "⋯", which brings them all back. Hidden (and out of the tab order) otherwise. */
.reader-peek {
  grid-row: 1;
  grid-column: 2 / 4;
  justify-self: end;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
  border: var(--ui-stroke-panel) solid var(--panel-edge);
  border-radius: 999px;
  background: var(--chrome-veil);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 320ms ease-out, visibility 0s linear 320ms;
}

.reader.calm .reader-peek {
  opacity: 0.86;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 320ms ease-out;
}

.reader.calm .reader-peek:hover,
.reader.calm .reader-peek:focus-within {
  opacity: 1;
}

.reader-peek .round {
  width: var(--reader-switch);
  height: var(--reader-switch);
}

@media (prefers-reduced-motion: reduce) {
  .reader-top,
  .reader-controls > *,
  .reader-hint,
  .reader-peek,
  .reader.calm .reader-peek {
    transition: none;
  }
}

/* Spec 184 (the owner, 2026-10-16, on a phone at bedtime: "Play and next page button honestly look horrid make them better and
   center it properly"): the app's bottom row (BookReaderPage's BottomChrome). Three columns: ‹ at the start, → at the end
   (both turns one size), and between them, centred on the page whichever turn shows, the dock: a veil pill with the panels'
   edge holding ▶ (the yellow crayon, the biggest) and the two switches. Flat like the app (spec 181): edges, no shadows.
   Every icon is one size; the sprite draws each glyph centred in its box, and ▶ steps right by its own lean. */
.reader-controls {
  --reader-turn: var(--touch-kid);
  --reader-play: 56px;
  --reader-switch: 48px;
  --reader-icon: 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: var(--space-3);
}

.reader-controls > [data-ref="previous"] {
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
}

.reader-controls > [data-ref="next"] {
  grid-row: 1;
  grid-column: 3;
  justify-self: end;
}

.reader-controls > .reader-dock {
  grid-row: 1;
  grid-column: 2;
}

.reader-dock {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
  border: var(--ui-stroke-panel) solid var(--panel-edge);
  border-radius: 999px;
  background: var(--chrome-veil);
}

.round {
  display: inline-grid;
  place-items: center;
  width: var(--touch-kid);
  height: var(--touch-kid);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--elevation-raised);
  cursor: pointer;
}

.round.sun {
  background: var(--crayon-yellow);
  color: var(--on-crayon);
}

.round[aria-pressed="false"] {
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.round:disabled {
  opacity: 0.4;
  cursor: default;
}

.round .icon {
  width: 32px;
  height: 32px;
}

/* The turns: ‹ is the app's SecondaryButton (the soft accent with the words' ink), → the KidButton's yellow. */
.reader-controls .round {
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.reader-turn {
  width: var(--reader-turn);
  height: var(--reader-turn);
  background: var(--accent-soft);
  color: var(--text);
}

.reader-turn.sun {
  background: var(--crayon-yellow);
  color: var(--on-crayon);
}

.reader-controls .icon {
  width: var(--reader-icon);
  height: var(--reader-icon);
}

/* The switches sit in the dock: on, a soft accent circle; off, only the crossed-out glyph in the quieter ink. Spec 247: ↻
   (read the page again) and the pill's "⋯" are the switches' size in the soft accent. */
.reader-switch,
.reader-replay {
  width: var(--reader-switch);
  height: var(--reader-switch);
}

.reader-replay,
.reader-peek-more {
  background: var(--accent-soft);
  color: var(--text);
}

.reader-switch[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
}

.reader-switch[aria-pressed="false"] {
  background: transparent;
  color: var(--text-secondary);
}

/* Pressed (and a mouse's hover): the yellow darkens like the KidButton's, the others take the press tint. */
.reader-turn.sun:active:not(:disabled) {
  background: color-mix(in srgb, var(--crayon-yellow) 86%, var(--text));
}

.reader-turn:not(.sun):active:not(:disabled),
.reader-switch:active:not(:disabled),
.reader-replay:active:not(:disabled),
.reader-peek-more:active:not(:disabled) {
  background: color-mix(in srgb, var(--accent-soft) 82%, var(--accent));
}

@media (hover: hover) {
  .reader-turn.sun:hover:not(:disabled) {
    background: color-mix(in srgb, var(--crayon-yellow) 86%, var(--text));
  }

  .reader-turn:not(.sun):hover:not(:disabled),
  .reader-switch:hover:not(:disabled),
  .reader-replay:hover:not(:disabled),
  .reader-peek-more:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent-soft) 82%, var(--accent));
  }
}

/* ▶ with its words on a wide screen: a yellow pill of the dock's height, the icon as big as the others. */
.reader-controls .reader-read {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--reader-play);
  height: var(--reader-play);
  padding: 0 26px 0 18px;
  border: 0;
  border-radius: 999px;
}

.reader-read .icon {
  flex: none;
}

/* ▶ and ⏸ sit small in their boxes (a triangle 12 by 15 px in 28): drawn a fifth larger they weigh what the arrows do.
   Material's ▶ is heavier on its left: it steps right by 3% of its box, so its middle (not its box) is centred; ⏸ is even. */
.reader-controls .reader-read .icon {
  width: calc(var(--reader-icon) * 1.2);
  height: calc(var(--reader-icon) * 1.2);
}

.reader-read[data-state="play"] .icon {
  translate: 3% 0;
}

@media (max-width: 420px) {

  .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Spec 025: read-along. The word being said lights up; a word with a time can be tapped. */
.sheet-words .word {
  border-radius: 6px;
  padding: 0 2px;
  transition: background-color 80ms linear;
}

/* Spec 247: a Chinese or Japanese run is boxes that wrap between any two characters; no padding inside the run. */
.sheet-words .word.joins-next,
.fit-measure .word.joins-next {
  padding-right: 0;
}

.sheet-words .word.joined,
.fit-measure .word.joined {
  padding-left: 0;
}

.sheet-words .word.hearable {
  cursor: pointer;
}

.sheet-words .word.now {
  background: var(--paper-highlight);
  color: var(--on-paper);
}

@media (prefers-reduced-motion: reduce) {
  .sheet-words .word {
    transition: none;
  }
}

/* Spec 027: the kid's worlds, a world's head, the maker's chapter line and the grown-up's theme. */
.worlds-strip {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding: 0 0 var(--space-2);
  margin: 0;
  list-style: none;
}

.world-open {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 200px;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--elevation-raised);
  min-height: var(--touch-kid);
}

.world-open img {
  width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--crayon-purple);
}

.world-head .row {
  flex-wrap: wrap;
  gap: var(--space-2);
}

.maker-theme {
  display: grid;
  /* Spec 082: one column as wide as the maker, never wider (an auto column took the theme box's input's own width and
     ran the box 35 px past a 320 px screen). */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}

/* Spec 028: the choice at the end of a book, the sleep screen, and bedtime's buttons. */
.sheet-choice {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  margin-top: var(--space-3);
}

.sheet-choice-question {
  font-size: var(--font-xl);
  font-weight: 700;
  margin: 0;
}

/* Spec 118: the hint is ink on the page's paper, as the phone's (the app's muted grey went pale on paper in dark).
   Spec 178 (the owner: "It was hard to understand we had to choose"): the story's size, bold, with a sparkle before it. */
.sheet-choice-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--on-paper);
  font-weight: 800;
  line-height: 1.25;
}

.sheet-choice-hint .icon {
  flex: none;
  width: 1.5em;
  height: 1.5em;
  color: var(--secondary);
}

.sheet-choice-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.choice-option {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-height: var(--touch-kid);
}

.choice-option img {
  width: 100%;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--crayon-yellow);
}

.choice-option[aria-pressed="true"] {
  border-color: var(--accent);
}

/* Spec 118, amended 2026-10-14: the other path uses one of the family's books. A small note for the grown-up sits on the
   picture (no room is added under the page's words, CHOICE_HEIGHT), ink on the page's paper, gentle when none is left. */
.choice-picture {
  position: relative;
  display: block;
}

.choice-picture img {
  display: block;
}

.choice-note {
  position: absolute;
  left: var(--space-1);
  bottom: var(--space-1);
  max-width: calc(100% - 2 * var(--space-1));
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--on-paper);
  font-size: var(--font-xs);
  font-weight: 600;
  line-height: 1.3;
  text-align: start;
}

/* Spec 179: which card is which. A badge on the picture's top corner, in words: "Keep reading" (the book's own path, on the
   page's paper), "New book" (the new path, a new book in the series, in the accent) and "Read your new path" once made. */
.choice-path {
  position: absolute;
  inset-inline-start: var(--space-1);
  top: var(--space-1);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 2 * var(--space-1));
  padding: 2px var(--space-2);
  border-radius: 999px;
  background: var(--paper);
  color: var(--on-paper);
  font-size: var(--font-xs);
  font-weight: 700;
  line-height: 1.3;
  text-align: start;
}

.choice-path .icon {
  flex: none;
  width: 1.1em;
  height: 1.1em;
}

.choice-path[data-path="new"],
.choice-path[data-path="open"] {
  background: var(--accent);
  color: var(--on-accent);
}

.sheet-choice-explain {
  font-size: var(--font-sm);
}

.choice-option:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Spec 178: while no picture is picked the two invite a tap. Always: a sun ring round each (the static highlight, all that
   shows with less motion). With motion: they hop in one after the other when the page shows (.arrive), then every few
   seconds each glows and swells a little in turn; a press on → (or a swipe on) shakes them (.nudge). It all stops the moment
   one is picked (data-invite goes): the picked one wears the accent ring, the other steps back. */
.sheet-choice[data-invite="true"] .choice-option:not([aria-pressed="true"]) {
  border-color: var(--secondary);
}

.sheet-choice.nudge .choice-option {
  box-shadow: 0 0 0 4px var(--secondary);
}

.choice-option.chosen {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent);
}

.sheet-choice.picking .choice-option:not(.chosen) {
  opacity: 0.5;
}

@media (prefers-reduced-motion: no-preference) {
  .sheet-choice[data-invite="true"] .choice-option {
    animation: choice-glow 5s ease-in-out 1.5s infinite;
  }

  .sheet-choice[data-invite="true"] .choice-option:nth-child(2) {
    animation-delay: 4s;
  }

  /* The hop waits for the page's turn (spec 049's leaf, 560 to 760 ms) to uncover the pictures. */
  .sheet-choice[data-invite="true"].arrive .choice-option {
    animation: choice-arrive 650ms cubic-bezier(0.3, 1.4, 0.5, 1) 500ms both, choice-glow 5s ease-in-out 2s infinite;
  }

  .sheet-choice[data-invite="true"].arrive .choice-option:nth-child(2) {
    animation-delay: 700ms, 4.5s;
  }

  .sheet-choice[data-invite="true"].nudge .choice-option {
    animation: choice-shake 480ms ease-in-out;
  }
}

@keyframes choice-arrive {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
  }

  60% {
    opacity: 1;
    transform: translateY(-6px) scale(1.03);
  }

  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes choice-glow {
  0%,
  60%,
  100% {
    box-shadow: 0 0 0 0 transparent;
    transform: none;
  }

  75% {
    box-shadow: 0 0 0 6px var(--secondary);
    transform: scale(1.035);
  }

  90% {
    box-shadow: 0 0 0 0 transparent;
    transform: none;
  }
}

@keyframes choice-shake {
  0%,
  100% {
    transform: none;
  }

  20% {
    transform: translateX(-7px) rotate(-1.5deg);
  }

  40% {
    transform: translateX(6px) rotate(1.5deg);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(3px);
  }
}

/* Spec 178: → waits on the choice page but still answers (aria-disabled, not disabled): it looks as faded as a disabled
   button and nudges the pictures. */
.round[aria-disabled="true"] {
  opacity: 0.4;
}

.reader-sleep {
  display: grid;
  place-items: center;
  min-height: 50vh;
  font-size: var(--font-2xl);
  text-align: center;
}

/* The shelf's Bedtime is Home's night pill (.bedtime-bar, .bedtime-pill, .bedtime-line in app.css). */

/* Spec 032: the reader's report panel and the reviewers' queue. */
.reader-report {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.report-reasons {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.review-list,
.review-pages {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-list button {
  display: grid;
  gap: var(--space-1);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--surface-muted);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.review-pages li {
  display: grid;
  gap: var(--space-2);
}

.review-pages img {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  border-radius: var(--radius-lg);
}

/* Spec 060: the reader as a picture book. The page fit's steps (page-fit.js STEPS): the sheet takes
   the book's step and the hidden measure takes each step it tries. */
.sheet[data-step="40"],
.fit-measure[data-step="40"] {
  --step: 40px;
}

.sheet[data-step="36"],
.fit-measure[data-step="36"] {
  --step: 36px;
}

.sheet[data-step="33"],
.fit-measure[data-step="33"] {
  --step: 33px;
}

.sheet[data-step="30"],
.fit-measure[data-step="30"] {
  --step: 30px;
}

.sheet[data-step="28"],
.fit-measure[data-step="28"] {
  --step: 28px;
}

.sheet[data-step="26"],
.fit-measure[data-step="26"] {
  --step: 26px;
}

.sheet[data-step="24"],
.fit-measure[data-step="24"] {
  --step: 24px;
}

.sheet[data-step="22"],
.fit-measure[data-step="22"] {
  --step: 22px;
}

.sheet[data-step="21"],
.fit-measure[data-step="21"] {
  --step: 21px;
}

.sheet[data-step="20"],
.fit-measure[data-step="20"] {
  --step: 20px;
}

.sheet[data-step="19"],
.fit-measure[data-step="19"] {
  --step: 19px;
}

.sheet[data-step="18"],
.fit-measure[data-step="18"] {
  --step: 18px;
}

.sheet[data-step="17"],
.fit-measure[data-step="17"] {
  --step: 17px;
}

/* The measure: a copy of the words column, laid out the same, never seen. */
.fit-measure {
  position: absolute;
  inset: 0 clamp(4px, 3%, 14px) auto;
  margin: 0;
  visibility: hidden;
  pointer-events: none;
  font-size: calc(var(--step, 22px) * var(--story-scale, 1));
}

.fit-measure .word {
  padding: 0 2px;
}

/* More words below (the words scroll): the paper fades over them and a small arrow points down. */
.words-more {
  position: absolute;
  inset: auto clamp(12px, 5cqmin, 28px) calc(clamp(12px, 5cqmin, 28px) + 14px);
  height: 2.6rem;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--paper) 72%);
}

.words-more::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  background: var(--on-paper);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The page number at the foot of each page. Spec 135: in a medallion, a paper disc in a foil ring with a leafy wing on
   each side. */
.folio {
  position: absolute;
  left: 50%;
  bottom: clamp(6px, 1.6cqmin, 12px);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  border: 1.5px solid var(--cover-foil);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 2.8px color-mix(in srgb, var(--cover-foil) 60%, transparent);
  color: var(--on-paper);
  font-family: var(--story-family, var(--font-family));
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.folio:empty {
  display: none;
}

.folio::before,
.folio::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 36px;
  height: 14px;
  margin-top: -7px;
  background: var(--cover-foil);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 14'%3E%3Cpath d='M2 7h34' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='2.5' cy='7' r='2'/%3E%3Cpath d='M14 7q4-6 9-5-3 3-9 5zM24 7q4 6 9 5-3-3-9-5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 14'%3E%3Cpath d='M2 7h34' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='2.5' cy='7' r='2'/%3E%3Cpath d='M14 7q4-6 9-5-3 3-9 5zM24 7q4 6 9 5-3-3-9-5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.folio::before {
  right: calc(100% + 2px);
}

.folio::after {
  left: calc(100% + 2px);
  transform: scaleX(-1);
}

/* Printer's corner marks on the paper's outer corners (both pages' in a spread). Spec 135 (the owner: "corner decorations
   in the book's style"): an L with a curl turning in along each arm, a dot at each end and a sparkle in the corner, in a
   warm mix of the foil and the paper's edge, so they read on the day, night and bedtime papers alike. */
.sheet::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 1;
  pointer-events: none;
  background: color-mix(in srgb, var(--cover-foil) 45%, var(--paper-edge));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform=''%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") top right / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(0 40) scale(1 -1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") bottom right / 40px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform=''%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") top right / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(0 40) scale(1 -1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") bottom right / 40px no-repeat;
}

.sheet.spread::after {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform=''%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") top right / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(0 40) scale(1 -1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") bottom right / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(40 0) scale(-1 1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") top left / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(40 40) scale(-1 -1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") bottom left / 40px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform=''%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") top right / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(0 40) scale(1 -1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") bottom right / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(40 0) scale(-1 1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") top left / 40px no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(40 40) scale(-1 -1)'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 2h22q10 0 10 10v22'/%3E%3Cpath d='M18 2c-1 5-6 7-8 4'/%3E%3Cpath d='M38 22c-5 1-7 6-4 8'/%3E%3C/g%3E%3Ccircle cx='5' cy='2' r='1.6'/%3E%3Ccircle cx='38' cy='35' r='1.6'/%3E%3Cpath d='M27 8q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5z'/%3E%3C/g%3E%3C/svg%3E") bottom left / 40px no-repeat;
}

.sheet.at-cover::after,
.sheet.at-cover::before {
  display: none;
}

/* The cover: cloth over board, a spine band, a foil frame; the title in the story's bold face and the
   cover picture in a rounded foil frame. Sideways, the inside of the cover (stars) on the left. */
.sheet-cover {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
  border-radius: inherit;
  overflow: hidden;
}

.sheet.at-cover,
.sheet.at-end {
  grid-template-columns: 1fr;
}

.cover-endpaper {
  display: none;
  background-color: var(--paper);
  background-image: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--paper-edge) 80%, transparent) 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 75%, color-mix(in srgb, var(--paper-edge) 55%, transparent) 0 1.4px, transparent 1.8px);
  background-size: 52px 52px, 37px 37px;
}

@container (min-aspect-ratio: 1 / 1) {
  .sheet-cover {
    grid-template-columns: 1fr 1fr;
  }

  .cover-endpaper {
    display: block;
  }
}

.cover-board {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(12px, 3cqmin, 24px);
  min-height: 0;
  padding: clamp(20px, 6cqmin, 44px) clamp(20px, 5cqmin, 36px) clamp(20px, 6cqmin, 44px) clamp(34px, 8cqmin, 56px);
  color: var(--on-cover);
  background-color: var(--cover-cloth);
  background-image:
    linear-gradient(90deg, color-mix(in srgb, var(--cover-cloth-deep) 70%, transparent) 0 clamp(14px, 4cqmin, 28px), var(--cover-cloth-deep) 0 calc(clamp(14px, 4cqmin, 28px) + 2px), transparent 0),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--cover-cloth-deep) 28%, transparent) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--cover-foil) 6%, transparent) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 55% 45%, transparent 55%, color-mix(in srgb, var(--cover-cloth-deep) 60%, transparent));
}

.cover-board::before {
  content: "";
  position: absolute;
  inset: clamp(10px, 3cqmin, 18px) clamp(10px, 3cqmin, 18px) clamp(10px, 3cqmin, 18px) clamp(26px, 6.5cqmin, 46px);
  border: 2px solid var(--cover-foil);
  border-radius: 12px;
  box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 5px color-mix(in srgb, var(--cover-foil) 55%, transparent);
  pointer-events: none;
}

/* Spec 135 (the owner: "the cover is very boring and should have subtle Xocana logo branding"): the book's picture printed
   on the board inside its foil frame and beside the spine; the title on a panel across its top, in the printed cover's
   face (spec 127, Luckiest Guy, with the book's face for letters it lacks); at its foot, the printed cover's tab, "A
   Xocana story" with the wordmark. A book with no picture keeps the cloth, with the panel at its top (spec 157). */
.cover-picture {
  position: absolute;
  inset: calc(clamp(10px, 3cqmin, 18px) + 7px) calc(clamp(10px, 3cqmin, 18px) + 7px) calc(clamp(10px, 3cqmin, 18px) + 7px) calc(clamp(26px, 6.5cqmin, 46px) + 7px);
  box-sizing: border-box;
  margin: 0;
  overflow: hidden;
  isolation: isolate;
  border: 2px solid var(--cover-foil);
  border-radius: 12px;
  background: var(--paper);
}

/* Spec 200: the picture is held at its top, and across where the API says (data-cover-focus in eighths, ReaderCoverFit.Drawn). */
.cover-picture img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
}

.sheet[data-cover-focus="0"] .cover-art { object-position: 0% 0; }
.sheet[data-cover-focus="1"] .cover-art { object-position: 12.5% 0; }
.sheet[data-cover-focus="2"] .cover-art { object-position: 25% 0; }
.sheet[data-cover-focus="3"] .cover-art { object-position: 37.5% 0; }
.sheet[data-cover-focus="5"] .cover-art { object-position: 62.5% 0; }
.sheet[data-cover-focus="6"] .cover-art { object-position: 75% 0; }
.sheet[data-cover-focus="7"] .cover-art { object-position: 87.5% 0; }
.sheet[data-cover-focus="8"] .cover-art { object-position: 100% 0; }

.cover-picture .cover-wash {
  display: none;
}

/* Spec 200 (spec 199 T012, the owner: "yes apply the same rule cover inside the reader"): unless the API says the picture's
   top is calm (cover-over), the title is in the band: its panel on the cloth above the picture, the picture under it (filling
   its frame since spec 222; whole beside the title) on a soft wash of itself behind a paper veil, as the phone draws it. */
.sheet.cover-band .cover-picture {
  position: relative;
  inset: auto;
  flex: 1 1 0;
  align-self: stretch;
  min-height: 0;
  margin: calc(10px - clamp(12px, 3cqmin, 24px)) calc(clamp(10px, 3cqmin, 18px) + 7px - clamp(20px, 5cqmin, 36px)) calc(clamp(10px, 3cqmin, 18px) + 7px - clamp(20px, 6cqmin, 44px)) calc(clamp(26px, 6.5cqmin, 46px) + 7px - clamp(34px, 8cqmin, 56px));
}

.sheet.cover-band .cover-picture .cover-wash {
  position: absolute;
  inset: 0;
  display: block;
  object-position: 50% 50%;
  filter: blur(14px);
  transform: scale(1.15);
}

.sheet.cover-band .cover-picture::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--paper);
  opacity: 0.6;
}

/* Spec 222 (the coordinator, 2026-10-23: the band's frame showed a pale wash above and below the picture): under the panel the
   picture fills its frame, held at its top (the ground gives way, never the head) and centred across; nothing covers it.
   Beside the title (below) it stays whole on its wash. */
.sheet.cover-band .cover-picture .cover-art {
  z-index: 2;
  object-fit: cover;
  object-position: 50% 0;
}

/* Spec 200: the band's panel is the cover's first row, its own height, the picture under it. */
.sheet.cover-band .cover-panel {
  flex: none;
  order: -1;
}

/* Spec 200: over the picture, the panel ends within the picture's calm top (reader.js measures the room, the title shrinks). */
.sheet.cover-over .cover-panel {
  max-height: var(--cover-panel-room, none);
}

.cover-panel {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  margin-top: 14px;
  padding: clamp(8px, 2.4cqmin, 14px) clamp(10px, 3cqmin, 18px);
  border: 2px solid var(--cover-foil);
  border-radius: 18px;
  background: var(--paper);
  color: var(--on-paper);
  box-shadow: 0 6px 16px var(--page-shade);
}

/* Spec 157: a cover without a picture keeps its title at the top, a little lower than over a picture (it sat in the
   middle, where the cover's Read to me now is). */
.sheet.cover-plain .cover-board {
  padding-top: clamp(28px, 10cqmin, 72px);
}

.cover-title {
  position: relative;
  margin: 0;
  max-width: 100%;
  font-family: var(--story-family, var(--font-family));
  font-weight: 700;
  font-size: var(--cover-title-size, clamp(1.4rem, 7cqmin, 3.1rem));
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.cover-story {
  position: absolute;
  bottom: calc(clamp(10px, 3cqmin, 18px) + 7px + 14px);
  left: clamp(14px, 4cqmin, 28px);
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  width: max-content;
  max-width: calc(100% - clamp(14px, 4cqmin, 28px) - 48px);
  margin: 0 auto;
  padding: 4px 14px;
  border: 1.5px solid var(--cover-foil);
  border-radius: 999px;
  background: var(--paper);
  color: var(--on-paper);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.cover-story .wordmark {
  font-size: 1.15rem;
  line-height: 1;
}

.cover-story span:empty {
  display: none;
}

/* Spec 209 (the owner, 2026-10-18: "In phone landscape, the reader cover picture is a thin strip and the 'A Xocana story'
   badge sits on the hero"): a short sideways book (a phone on its side: the open book at least 12 wide for 5 high) sets the
   cover's title and tab beside the picture, not above and over it. The picture fills the board's right part, whole on its
   wash (spec 200's band: reader.js takes the band when the title's panel is beside the picture, so nothing covers a
   head); the panel and "A Xocana story" sit on the cloth at its left, centred. */
@container (min-aspect-ratio: 12 / 5) {
  .sheet.cover-band .cover-board,
  .sheet.cover-over .cover-board {
    justify-content: center;
    padding-right: calc(44% + clamp(10px, 3cqmin, 18px) + 7px + 10px);
  }

  .sheet.cover-band .cover-picture,
  .sheet.cover-over .cover-picture {
    position: absolute;
    inset: calc(clamp(10px, 3cqmin, 18px) + 7px) calc(clamp(10px, 3cqmin, 18px) + 7px) calc(clamp(10px, 3cqmin, 18px) + 7px) auto;
    width: 44%;
    flex: none;
    margin: 0;
  }

  .sheet.cover-band .cover-picture .cover-art {
    object-fit: contain;
  }

  .sheet.cover-band .cover-panel,
  .sheet.cover-over .cover-panel {
    margin-top: 0;
    max-height: none;
    padding: 6px 8px;
  }

  .sheet.cover-band .cover-title,
  .sheet.cover-over .cover-title {
    font-size: var(--cover-title-size, clamp(0.95rem, 7.5cqmin, 1.35rem));
  }

  .sheet.cover-band .cover-story,
  .sheet.cover-over .cover-story {
    position: relative;
    inset: auto;
    flex: none;
    flex-wrap: wrap;
    row-gap: 0;
    max-width: 100%;
    margin: 0 auto;
    padding: 3px 10px;
    font-size: 0.8rem;
    white-space: normal;
    text-align: center;
  }
}

/* Spec 157 (the owner on build 34: "letting the user tap to start the book reading"): the cover waits for the child.
   Spec 178 (the owner: "Play button not aligned properly"): one centred group of two pills of one size: "Read to me" (accent,
   its ▶ inside) on top, "Read it myself" (paper, foil edge) under it. One grid column as wide as the wider pill, never wider
   than the page; the same height, padding, radius, border and icon size for both. Upright they sit over the picture's foot,
   right of the spine and above the tab; sideways on the inside of the cover, beside the board. The ▶ hops now and then, never
   with less motion (as the phone's Ambient "Bob"). */
.sheet-cover > .cover-endpaper {
  grid-row: 1;
  grid-column: 1;
}

.sheet-cover > .cover-board {
  grid-row: 1;
  grid-column: -2 / -1;
}

.cover-start {
  position: relative;
  z-index: 1;
  grid-row: 1;
  grid-column: 1;
  align-self: end;
  justify-self: center;
  display: grid;
  grid-template-columns: minmax(0, max-content);
  justify-items: stretch;
  gap: var(--space-3);
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 8px calc(clamp(10px, 3cqmin, 18px) + 7px + 14px + 34px + 16px) calc(clamp(14px, 4cqmin, 28px) + 8px);
}

@container (min-aspect-ratio: 1 / 1) {
  .cover-start {
    align-self: center;
    padding: 16px;
  }
}

.sheet.cover-opening .cover-start {
  visibility: hidden;
}

.cover-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  min-height: var(--touch-kid);
  box-sizing: border-box;
  margin: 0;
  padding: 10px 26px 10px 20px;
  border: 3px solid;
  border-radius: 999px;
  box-shadow: var(--elevation-raised);
  font: inherit;
  font-size: var(--font-lg);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.cover-choice .icon {
  flex: none;
  width: 28px;
  height: 28px;
}

/* The ▶ glyph sits small in its box: drawn larger in the same 28 px of room, it looks as big as the book. */
.cover-choice .cover-start-play {
  width: 36px;
  height: 36px;
  margin: -4px;
}

.cover-read-to-me {
  border-color: var(--surface);
  background: var(--accent);
  color: var(--on-accent);
}

.cover-read-to-me:hover {
  background: var(--accent-strong);
}

.cover-read-myself {
  border-color: var(--cover-foil);
  background: var(--surface);
  color: var(--text);
}

.cover-read-myself:hover {
  background: var(--surface-muted);
}

/* Spec 223: the printed book, quiet under the two pills: small words on a soft paper pill, no shadow, the foil's thin edge. */
.cover-print {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 6px;
  min-height: 44px;
  margin: 0;
  padding: 4px 14px;
  border: 1px solid var(--cover-foil);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.cover-print .icon {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.cover-print:hover {
  background: var(--surface);
}

@media (prefers-reduced-motion: no-preference) {
  .cover-start-play {
    animation: cover-start-hop 7s ease-in-out 2s infinite;
  }
}

@keyframes cover-start-hop {
  0%, 82%, 100% {
    transform: translateY(0);
  }

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

  90% {
    transform: translateY(0);
  }

  94% {
    transform: translateY(-3px);
  }
}

/* The End: the title in the story's bold face, a foil flourish with sparkles, the child's picture
   beside the hero with an arrow between, the caption and what next. Sideways: words left, pictures right. */
.sheet-end-page {
  grid-column: 1 / -1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(14px, 5cqmin, 32px);
}

.end-inner {
  display: grid;
  gap: clamp(10px, 3cqmin, 22px);
  min-height: 100%;
  align-content: center;
  justify-items: center;
  text-align: center;
}

@container (min-aspect-ratio: 5 / 4) {
  .end-inner {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }

  .end-pictures {
    grid-column: 2;
    grid-row: 1;
  }
}

/* Spec 222: the pictures' side of The End is only a box with two pages side by side (.end-spread, below). */
.end-side {
  display: contents;
}

/* Upright: the title, the flourish, the two pictures, the caption, the buttons. */
.end-words {
  display: contents;
}

.end-title {
  order: 1;
}

.end-flourish {
  order: 2;
}

.end-pictures {
  order: 3;
}

.end-caption {
  order: 4;
}

.end-actions {
  order: 5;
}

/* Spec 135 (the owner: "The End page also doesn't have any Xocana branding"): Xocana's dragon beside the wordmark, small,
   under the buttons. */
.end-mark {
  order: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.end-mark img {
  width: 34px;
  height: auto;
}

.end-mark .wordmark {
  font-size: 1.5rem;
  line-height: 1;
}

@container (min-aspect-ratio: 5 / 4) {
  .end-words {
    display: grid;
    gap: clamp(8px, 2.4cqmin, 16px);
    justify-items: center;
  }
}

.end-title {
  margin: 0;
  font-family: var(--story-family, var(--font-family));
  font-weight: 700;
  font-size: clamp(2.2rem, 11cqmin, 4.5rem);
  line-height: 1.05;
  color: var(--on-paper);
}

.end-flourish {
  display: block;
  width: min(280px, 70%);
  height: 34px;
  background: var(--cover-foil);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 280 34'%3E%3Cg fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M126 18C95 8 70 30 40 18c-9-4-6-12 2-9'/%3E%3Cpath d='M154 18c31-10 56 12 86 0 9-4 6-12-2-9'/%3E%3C/g%3E%3Cpath d='M140 6q2 10 12 12-10 2-12 12-2-10-12-12 10-2 12-12z'/%3E%3Cpath d='M60 4q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5zM222 26q1 3 4 4-3 1-4 4-1-3-4-4 3-1 4-4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 280 34'%3E%3Cg fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M126 18C95 8 70 30 40 18c-9-4-6-12 2-9'/%3E%3Cpath d='M154 18c31-10 56 12 86 0 9-4 6-12-2-9'/%3E%3C/g%3E%3Cpath d='M140 6q2 10 12 12-10 2-12 12-2-10-12-12 10-2 12-12z'/%3E%3Cpath d='M60 4q1 4 5 5-4 1-5 5-1-4-5-5 4-1 5-5zM222 26q1 3 4 4-3 1-4 4-1-3-4-4 3-1 4-4z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.end-pictures {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2cqmin, 16px);
  margin: 0;
}

.end-frame {
  margin: 0;
  width: clamp(84px, 30cqmin, 240px);
  aspect-ratio: 1;
  transform: rotate(-3deg);
}

.end-frame.end-hero {
  transform: rotate(3deg);
}

.end-frame img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 5px;
  border-radius: 18px;
  background: var(--paper-edge);
  outline: 1px solid var(--page-shade);
  outline-offset: -6px;
  box-shadow: 0 5px 12px var(--page-shade);
}

.end-frame.end-hero img {
  background: var(--cover-foil);
}

.end-arrow {
  flex: none;
  width: 30px;
  height: 30px;
  color: var(--cover-foil);
}

.end-caption {
  margin: 0;
  max-width: 34ch;
  font-family: var(--story-family, var(--font-family));
  font-size: clamp(1.05rem, 3.4cqmin, 1.35rem);
  line-height: 1.35;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

.end-actions .button {
  min-height: 52px;
  padding: 10px 18px;
  font-size: 1.05rem;
}

/* On paper the outlined button is ink on paper, by day and by night. */
.end-actions .button.ghost {
  color: var(--on-paper);
  border-color: var(--on-paper);
  background: transparent;
}

@media (hover: hover) {
  .end-actions .button.ghost:hover:not(:disabled) {
    background: transparent;
  }
}

/* Spec 222 (the owner on the unfolded Duo's The End: "the right page looks empty and odd next to a crowded left page"):
   with two pages side by side, The End is an open book too: the left page the ending and the printed book's card (its
   cover larger), the right page the child's drawing over the hero, what next and Xocana's mark under a soft foil line; each
   page centred on its own. */
.sheet.end-spread {
  box-shadow:
    -3px 3px 0 -1px var(--paper),
    -3px 3px 0 0 var(--paper-edge),
    3px 3px 0 -1px var(--paper),
    3px 3px 0 0 var(--paper-edge),
    -6px 6px 0 -1px var(--paper),
    -6px 6px 0 0 var(--paper-edge),
    6px 6px 0 -1px var(--paper),
    6px 6px 0 0 var(--paper-edge),
    0 0 0 8px var(--cover-cloth-deep),
    var(--elevation-float);
}

.sheet.end-spread::before {
  inset: 0 auto 0 calc(50% - 32px);
  width: 64px;
  background: linear-gradient(90deg, transparent, var(--page-shade) 48%, var(--page-shade) 52%, transparent);
}

.sheet.end-spread .end-inner {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 72px;
  align-items: center;
}

.sheet.end-spread .end-words,
.sheet.end-spread .end-side {
  display: grid;
  grid-row: 1;
  gap: clamp(10px, 2.4cqmin, 18px);
  justify-items: center;
  align-content: center;
}

.sheet.end-spread .end-words {
  grid-column: 1;
}

.sheet.end-spread .end-side {
  grid-column: 2;
}

.sheet.end-spread .end-pictures {
  grid-column: auto;
  grid-row: auto;
  flex-direction: column;
  gap: 10px;
}

/* What next two by two (the coordinator: none left alone on its line); a label too long for half the page takes the row. */
.sheet.end-spread .end-actions {
  width: min(100%, 28rem);
}

.sheet.end-spread .end-actions > * {
  flex: 1 1 40%;
  justify-content: center;
}

.sheet.end-spread .end-frame {
  width: clamp(120px, 26cqh, 300px);
}

.sheet.end-spread .end-arrow {
  transform: rotate(90deg);
}

.sheet.end-spread .end-mark {
  padding: 12px 28px 0;
  border-top: 1px solid color-mix(in srgb, var(--cover-foil) 55%, transparent);
}

.sheet.end-spread .end-print {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  text-align: center;
}

.sheet.end-spread .end-print .print-offer-art {
  width: clamp(96px, 20cqh, 180px);
  height: auto;
  aspect-ratio: 1;
}

.sheet.end-spread .end-print .print-offer-actions {
  justify-content: center;
}

/* The report panel sits over the book while a grown-up writes. */
.reader-report {
  position: absolute;
  inset: auto var(--space-3) var(--space-3);
  z-index: 4;
  max-height: calc(100% - 2 * var(--space-3));
  overflow-y: auto;
  box-shadow: var(--elevation-float);
}

/* A phone keeps its height for the book: no key hint, and the buttons a little smaller. */
@media (max-width: 640px), (max-height: 520px) {
  .reader-hint {
    display: none;
  }

  /* Spec 135: on a phone the way back is a round arrow and Read to me a round play button (their words stay for a screen
     reader), so the bar and the controls each keep to one row at 320 px in every language (spec 140: the speed is gone). */
  .reader-back {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 50%;
  }

  .reader-back {
    background: var(--surface);
    box-shadow: var(--elevation-raised);
  }

  .reader-back span,
  .reader-read span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .reader-top {
    gap: var(--space-2);
  }

  /* The way back and the tools as the ✕ (44 px), the count a little narrower: the bar fits 320 px with room to spare. */
  .reader-back,
  .reader-tools .round {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .reader-tools {
    gap: 6px;
  }

  .reader-progress {
    padding: 4px 11px 5px;
  }

  .reader-progress progress {
    width: 44px;
  }

  /* Spec 184: the turns 56 px and every icon 28 px; ▶ a 56 px circle with no inside padding (the yellow button's 14 by 24
     pushed its icon 6 px down). Spec 247: with ↻ in the dock the row is 56 + 6 + (4 + 56 + 4 + 48 + 4 + 48 + 4 + 48 + 4 +
     2 * 2) + 6 + 56 = 348, which fits from a 375 px phone; narrower phones take the steps below. */
  .reader-controls {
    --reader-turn: 56px;
    --reader-icon: 28px;
    column-gap: 6px;
  }

  .reader-controls .reader-read {
    display: inline-grid;
    place-items: center;
    width: var(--reader-play);
    padding: 0;
    border-radius: 50%;
  }
}

/* Spec 247: a phone under 375 px: the turns and ▶ 50, the switches and ↻ 46, the dock's gaps 2 px: 50 + 4 + (4 + 50 + 2 + 46
   + 2 + 46 + 2 + 46 + 4 + 2 * 2) + 4 + 50 = 314 (a 360 px phone has 336). */
@media (max-width: 374px) {
  .reader-controls {
    --reader-turn: 50px;
    --reader-play: 50px;
    --reader-switch: 46px;
    column-gap: 4px;
  }

  .reader-dock {
    gap: 2px;
  }
}

/* Spec 247: 320 px: every control 44 px (the smallest target any platform allows), the dock's padding 2 px: 44 + 4 + (2 + 44
   + 2 + 44 + 2 + 44 + 2 + 44 + 2 + 2 * 2) + 4 + 44 = 286 (a 320 px phone has 296). */
@media (max-width: 340px) {
  .reader-controls {
    --reader-turn: 44px;
    --reader-play: 44px;
    --reader-switch: 44px;
    --reader-icon: 26px;
  }

  .reader-dock {
    padding: 2px;
  }
}

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

/* Spec 062: Big moments. The themes are tiles with their little picture (catalog shapes, content colours),
   the questions are plain fields with an example each, the outline is a numbered plan of the pages. Tokens
   only; the photo a grown-up added is framed on its page like a snapshot taped to the paper. */
.books-moments {
  min-height: calc(var(--touch-kid) * 1.25);
}

.maker-moments {
  align-self: flex-start;
  font-weight: 700;
  color: var(--text);
}

.moments-lead {
  margin: 0;
  max-width: 60ch;
  font-size: var(--font-lg);
}

/* Spec 183 (the owner, 2026-10-16, on "Who's in the story?" by night: "build a hero button or container overlaps a
   little there"): each step is its own column with the maker's gap, as the book maker's steps are, so a card grid never
   meets the field, the banner or the next grid edge to edge (it was block flow with no gap: 0 px). */
.moments-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* The gap is the step's only spacing: a paragraph's own margins would add 32 px to it. */
.moments-step > p {
  margin-block: 0;
}

/* Spec 064: the themes are the maker's picture cards (choices.js); a theme card also says what it is for. */
.moment-themes .choice-about {
  font-size: var(--font-xs);
}

.moment-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.moment-head-art .moment-art {
  display: block;
  width: 64px;
  height: 77px;
}

.moment-fields {
  display: grid;
  gap: var(--space-3);
}

.moment-fields .field {
  display: grid;
  gap: var(--space-2);
}

.moment-fields textarea {
  min-height: calc(var(--touch-kid) * 1.5);
  font: inherit;
  font-size: var(--font-lg);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 2px solid var(--tile-edge);
  background: var(--surface);
  color: var(--text);
}

.moment-slots {
  display: grid;
  gap: var(--space-4);
}

/* Spec 109: room between a slot's pictures and its Add a photo button (8 px read as touching). */
.moment-slot {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.moment-outline {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
  counter-reset: moment-step;
}

.moment-outline li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 2px solid var(--tile-edge);
}

.moment-pages {
  padding: 2px var(--space-2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.moment-note {
  flex-basis: 100%;
  font-size: 0.95rem;
}

/* The reader: the grown-up's picture as a framed snapshot on the page's picture, the family's own words
   under the page's words, and the grown-ups' page after The End. */
.sheet-picture {
  position: relative;
}

.sheet-picture img.sheet-photo {
  position: absolute;
  inset-inline-end: 3%;
  inset-block-end: 4%;
  width: min(36cqw, 48cqh);
  height: auto;
  aspect-ratio: 4 / 3;
  padding: 6px 6px 14px;
  border-radius: 6px;
  background: var(--paper);
  outline: 1px solid var(--page-shade);
  outline-offset: 0;
  box-shadow: var(--elevation-raised);
  transform: rotate(3deg);
}

.family-words {
  margin: var(--space-2) 0 0;
  padding-inline-start: var(--space-3);
  border-inline-start: 4px solid var(--crayon-pink);
  font-style: italic;
}

.sheet.at-end .sheet-tips-page {
  grid-column: 1 / -1;
}

.sheet-tips-page {
  grid-column: 1 / -1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(14px, 5cqmin, 32px);
}

.tips-inner {
  display: grid;
  gap: var(--space-3);
  max-width: 60ch;
  margin: 0 auto;
}

.tips-title {
  margin: 0;
  font-size: clamp(1.3rem, 5cqmin, 2rem);
}

/* The page is paper in both themes: its lead is the paper's ink, a little softer. */
.tips-lead {
  margin: 0;
  color: var(--on-paper);
  opacity: 0.78;
  font-size: clamp(1rem, 3cqmin, 1.15rem);
}

.tips-list {
  margin: 0;
  padding-inline-start: 1.2em;
  display: grid;
  gap: var(--space-2);
  font-size: clamp(1rem, 3.2cqmin, 1.2rem);
  line-height: 1.45;
}

/* Spec 064: the maker's picture cards, as in "How Xocana works" (walkthrough/show.css, .wt-card): a big card
   with a hairline edge, the picture on a paper well (paper by night too, so every picture reads), a bold word
   under it. Chosen: the Accent edge, the light accent fill and a green check badge. Two across on a phone,
   three on a tablet, four on a wide window. A press sinks the card a little (still with reduced motion). The
   step reads "Step N of 7" over the big purple question; Back and Next are big pills with arrows. Tokens only. */
.maker-count {
  margin: 0;
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-secondary);
}

.maker .maker-title {
  margin-top: calc(var(--space-3) * -1);
  font-size: clamp(30px, 7vw, var(--font-2xl));
  line-height: 1.1;
  color: var(--ink-purple);
}

/* Spec 150 amendment 2026-10-26: "Step N of 7" and the question on the left, the round ✕ on the right (48 px, on the surface,
   as the reader's ✕ and the star's pencil); the question wraps beside it. */
.maker-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
}

.maker-head-words {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.maker .maker-head .maker-title {
  margin: 0;
}

.maker-close {
  display: grid;
  place-items: center;
  width: var(--touch-standard);
  height: var(--touch-standard);
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 2px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.maker-close .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.maker-close:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

.choice-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
  }
}

@media (min-width: 900px) {
  .choice-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.choice-grid > li {
  display: flex;
}

.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  width: 100%;
  min-height: 176px;
  padding: var(--space-2) var(--space-2) var(--space-3);
  border: var(--ui-stroke-choice) solid var(--hairline);
  border-radius: var(--ui-radius-choice-card);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.choice-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-well {
  position: relative;
  display: grid;
  place-items: center;
  height: 112px;
  padding: 6px;
  border-radius: var(--ui-radius-choice-well);
  background: var(--paper);
  overflow: hidden;
}

.choice-well > * {
  grid-area: 1 / 1;
}

.choice-art,
.choice-well .hero-art,
.choice-well .moment-art {
  width: 100%;
  height: 100%;
  max-height: 100px;
  object-fit: contain;
}

/* Spec 211 amendment 2: a drawing or photo fills the well (inside its padding) exactly, so where it sits (object-position,
   js/picture-crop.js) keeps its pet's or toy's head in view; a tall photo used to stand taller than the well. */
.choice-well > .choice-picture {
  /* Out of the well's grid (whose area would be its containing block), over the art, inside the well's padding. */
  grid-area: auto;
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.choice-label {
  font-size: var(--ui-font-choice-card);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.choice-about {
  margin-top: calc(var(--space-1) * -1);
  color: var(--text-secondary);
  font-size: var(--font-xs);
  line-height: 1.3;
}

.choice-check {
  position: absolute;
  top: -6px;
  right: -6px;
  display: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--success);
  color: var(--on-accent);
}

.choice-check .icon {
  width: 22px;
  height: 22px;
}

[aria-pressed="true"] > .choice-check {
  display: grid;
  animation: choice-pop 0.22s ease-out;
}

@keyframes choice-pop {
  from {
    transform: scale(0.4);
  }
}

/* The kid's pictures for a Big moment's place: picture-only cards. */
.picture-grid .choice-card {
  min-height: 0;
  padding: var(--space-2);
}

.picture-grid .choice-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Words a child picks (a name, a grown-up's theme, a choice question's answer): pills of the same family. */
.choice-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.choice-pill,
.choice-more {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  /* Spec 170: the app's ChoicePill: 60 high, 30 round, a 3 px Hairline edge, 19 bold. */
  min-height: var(--ui-height-choice-pill);
  padding: var(--space-2) var(--space-5);
  border: var(--ui-stroke-choice) solid var(--hairline);
  border-radius: var(--ui-radius-choice-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--ui-font-choice-pill);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.choice-pill[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-pill .choice-check {
  top: -9px;
  right: -9px;
  width: 30px;
  height: 30px;
}

.choice-pill .choice-check .icon {
  width: 18px;
  height: 18px;
}

/* Spec 193: "Ways to pick a hero", under the question: one small pill a way, as wide as its words, wrapping; a down arrow
   says the part is further down the page. Quieter than an idea (2 px edge, 16 px words) and never pressed. */
.maker-jumps {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.maker-jumps p {
  margin: 0;
}

.maker-jump-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.maker-jump {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 48px;
  padding: var(--space-1) var(--space-4) var(--space-1) var(--space-3);
  border: 2px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-md);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.maker-jump .icon {
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
}

/* A part brought into view stops below the sticky header. */
.maker [data-ref="makerHeroesLabel"],
.maker [data-ref="makerWaysLabel"],
.maker [data-ref="makerSparksLabel"],
.maker [data-ref="makerFriendsLabel"],
.maker [data-ref="makerField"] {
  scroll-margin-top: var(--space-8);
}

/* "More ideas": a pill of the same family that reads as an action, not as an idea. */
.choice-more {
  align-self: flex-start;
  min-height: 56px;
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

.choice-more .icon {
  width: 1.2em;
  height: 1.2em;
}

/* Back and Next: big pills with arrows, Next in the sun's yellow; the bar stays in reach on a phone. */
.maker-nav .button {
  min-height: var(--touch-kid);
  padding: var(--space-2) var(--space-5);
  font-size: var(--font-md);
}

.maker-nav .button .icon {
  width: 26px;
  height: 26px;
}

/* Next fills what is left of its row (a whole row when the words need it), up to a comfortable width. */
.maker-nav .maker-next {
  flex: 1 0 auto;
  max-width: 22rem;
  margin-left: auto;
  padding-right: var(--space-4);
  font-size: var(--font-lg);
}

/* Spec 193 (US4): "Xocana picks the rest", a quiet pill of the "More ideas" family (the soft accent, a sparkle) beside the
   yellow one, which stays the child's own next step: just before Next on a wide screen; on a phone it has the top row and
   Back and Next stay below it where they always are, as on the app's StepBar (StepBarPart.Aside). */
.maker-nav .maker-picks {
  align-self: center;
}

.maker-nav.has-picks .maker-picks {
  margin-left: auto;
}

.maker-nav.has-picks .maker-next {
  margin-left: 0;
}

/* The step's own parts sit in the maker's column as before; the summary hides them. */
.maker-body {
  display: contents;
}

/* Spec 193 (US4): the summary of Xocana's picks, a row a step it took the place of. */
.maker-picked {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.maker-picked > p {
  margin: 0;
  font-size: var(--font-md);
}

.maker-pick-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.maker-pick {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 56px;
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.maker-pick-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.maker-pick-question {
  color: var(--text-secondary);
  font-size: var(--font-sm);
}

.maker-pick-words {
  font-size: var(--font-lg);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.maker-pick .icon {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

@media (max-width: 640px) {
  .maker-nav.has-picks .maker-picks {
    order: -1;
    flex: 1 0 100%;
    justify-content: center;
    margin-left: 0;
  }

  .maker-nav.has-picks .maker-next {
    margin-left: auto;
  }

  /* Spec 211 amendment: a part brought into view stops above the sticky bar of Back and Next. */
  .maker .maker-pronoun,
  .maker .maker-cast-picks,
  .maker .maker-need {
    scroll-margin-bottom: 11rem;
  }

  .maker-nav {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0 calc(var(--space-5) * -1);
    padding: var(--space-3) var(--space-5) var(--space-4);
    border-top: 2px solid var(--hairline);
    background: var(--chrome-veil);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  [aria-pressed="true"] > .choice-check {
    animation: none;
  }
}

/* Spec 066: a holiday book wears its holiday. Its printed colours (content, like the hero art; the title's contrast
   on its cloth is checked by HolidayCatalogTests) come in as custom properties set from design/holidays.json, and
   take the book's own cover tokens inside the sheet: the cloth, its deep edge (the board round the pages) and the
   foil; the title and The End take the holiday's face. Every page gets a frame in its margin, over the paper and
   under the words, with a motif in each corner and a row of the border motif at its head and foot; the paper,
   the words and the page fit are unchanged. */
.sheet.holiday {
  --cover-cloth: var(--holiday-cloth);
  --cover-cloth-deep: var(--holiday-cloth-deep);
  --cover-foil: var(--holiday-foil);
  --on-cover: var(--holiday-on-cloth);
}

/* Spec 096: the book's title face (story-fonts.css, one weight) on the cover and The End. */
.sheet.has-title-face .cover-title,
.sheet.has-title-face .end-title {
  font-family: var(--story-title, var(--story-family, var(--font-family)));
  font-weight: 400;
  font-synthesis: none;
}

/* Spec 135: the cover's title in the printed cover's face (spec 127), the book's title face for letters it lacks. */
.sheet .cover-panel .cover-title {
  font-family: "Xocana Print Cover", var(--story-title, var(--story-family, var(--font-family)));
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Spec 066: a holiday's panel is its cloth, with the title in its colour (contrast checked on that cloth). */
.sheet.holiday .cover-panel {
  background: var(--holiday-cloth);
  color: var(--holiday-on-cloth);
}

/* Spec 096: page 1 begins with a big letter in the title face; the word keeps its highlight and its tap. */
.has-initial > .word:first-child {
  display: inline-block;
}

.has-initial > .word:first-child::first-letter {
  font-family: var(--story-title, var(--story-family, var(--font-family)));
  font-size: calc(2em * var(--story-title-scale, 1));
  font-weight: 400;
  line-height: 1;
}

.sheet.holiday .cover-title,
.sheet.holiday .end-title,
.sheet.holiday .end-greeting {
  font-family: var(--holiday-title-family, var(--story-family, var(--font-family)));
  font-weight: 700;
}

.sheet.holiday .has-initial > .word:first-child::first-letter {
  font-family: var(--holiday-title-family, var(--story-title, var(--story-family, var(--font-family))));
}

.holiday-corners {
  position: absolute;
  inset: clamp(18px, 5cqmin, 30px) clamp(18px, 5cqmin, 30px) clamp(18px, 5cqmin, 30px) clamp(34px, 8.5cqmin, 58px);
  pointer-events: none;
}

.holiday-corners .holiday-motif {
  position: absolute;
  width: clamp(30px, 13cqmin, 76px);
  height: auto;
  aspect-ratio: 1;
}

.holiday-corners .corner-0 { top: 0; left: 0; transform: rotate(-8deg); }
.holiday-corners .corner-1 { top: 0; right: 0; transform: rotate(8deg); }
.holiday-corners .corner-2 { bottom: 0; left: 0; transform: rotate(6deg); }
.holiday-corners .corner-3 { bottom: 0; right: 0; transform: rotate(-6deg); }

.holiday-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  pointer-events: none;
}

.sheet.spread .holiday-frame {
  grid-template-columns: 1fr 1fr;
}

.sheet.at-cover .holiday-frame,
.sheet:not(.spread) .holiday-page + .holiday-page {
  display: none;
}

.holiday-page {
  --frame-margin: clamp(12px, 5cqmin, 28px);
  position: relative;
  margin: calc(var(--frame-margin) * 0.42);
  border: 2px solid color-mix(in srgb, var(--holiday-frame) 85%, transparent);
  border-radius: calc(var(--frame-margin) * 0.5);
}

.holiday-corner {
  position: absolute;
  width: calc(var(--frame-margin) * 1.05);
  height: calc(var(--frame-margin) * 1.05);
}

.holiday-corner.top-left { top: 0; left: 0; transform: translate(-30%, -30%); }
.holiday-corner.top-right { top: 0; right: 0; transform: translate(30%, -30%); }
.holiday-corner.bottom-left { bottom: 0; left: 0; transform: translate(-30%, 30%); }
.holiday-corner.bottom-right { bottom: 0; right: 0; transform: translate(30%, 30%); }

/* In a spread the corners at the fold stay plain. */
.sheet.spread .holiday-page:first-child .holiday-corner.top-right,
.sheet.spread .holiday-page:first-child .holiday-corner.bottom-right,
.sheet.spread .holiday-page + .holiday-page .holiday-corner.top-left,
.sheet.spread .holiday-page + .holiday-page .holiday-corner.bottom-left {
  display: none;
}

.holiday-row {
  position: absolute;
  left: calc(var(--frame-margin) * 1.2);
  right: calc(var(--frame-margin) * 1.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(var(--frame-margin) * 0.6);
}

.holiday-row.head { top: 0; transform: translateY(-50%); }
.holiday-row.foot { bottom: 0; transform: translateY(50%); }

.holiday-row .holiday-motif {
  width: calc(var(--frame-margin) * 0.6);
  height: calc(var(--frame-margin) * 0.6);
}

.end-motifs {
  order: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(6px, 2cqmin, 14px);
}

.end-motifs .holiday-motif:first-child { transform: rotate(-10deg); }
.end-motifs .holiday-motif:last-child { transform: rotate(10deg); }

.end-greeting {
  order: 2;
  margin: 0;
  font-weight: 700;
  font-size: clamp(1.15rem, 4.6cqmin, 1.8rem);
  color: var(--on-paper);
}

/* Spec 104: "Make a new hero": the maker's ways to a hero are picture cards like the ideas, a link or a button, each the
   whole target; the friends' cards show the friend's own drawing. */
a.choice-card.hero-way {
  text-decoration: none;
}

/* Spec 172 (the owner, 2026-10-15: the ways "in the bedtime theme, or maybe the dark theme, are not visible"): the well is
   paper in every palette (spec 064), so its icon is drawn in the paper's own ink, as the pictures on the other wells are.
   The lavender page ink (--ink-purple, a lavender by night) on the paper was 1.5:1 in dark and 1.0:1 in Moon; the paper's ink
   is 7:1 and more on it in light, dark and Moon (tokens.json's onPaper/paper pair). The phone's cards do the same. */
.hero-way .way-icon {
  width: 64px;
  height: 64px;
  color: var(--on-paper);
}

.maker-pronoun {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  /* Spec 211 amendment: the ring's room is always there, so the question does not move when Next rings it. */
  margin: 0 calc(var(--space-3) * -1);
  padding: var(--space-2) var(--space-3);
  border: 3px solid transparent;
  border-radius: var(--radius-lg);
}

/* Spec 211 amendment (the owner on build 42): the part Next waits for is ringed in the crayon orange (as the people notice
   after a refusal) and says why in a line with an info sign, right under it. It stops clear of the sticky header and of the
   bar of Back and Next on a phone when it is brought into view. */
.maker-pronoun.is-needed {
  border-color: var(--crayon-orange);
  background: var(--surface);
}

.maker-need {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-weight: 700;
  color: var(--text);
}

.maker-need[hidden] {
  display: none;
}

.maker-need .icon {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.maker-pronoun,
.maker-cast-picks,
.maker-need {
  scroll-margin-top: var(--space-8);
  scroll-margin-bottom: var(--space-5);
}

.maker .field.is-needed input,
.cast-chip input.is-needed {
  border-color: var(--crayon-orange);
  box-shadow: 0 0 0 1px var(--crayon-orange);
}

.maker-cast-picks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Spec 211 amendment (the owner on build 42, on Free): the Family plan's room, a small note under the counter, its link a
   quiet one; once the Free book's one place is taken it is a soft panel. Information, not a pop-up. */
.maker-cast-family {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--text-secondary);
}

.maker-cast-family[hidden] {
  display: none;
}

.maker-cast-family .icon {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-top: 2px;
}

.maker-cast-family p {
  margin: 0;
}

.maker-cast-family a {
  font-weight: 700;
  white-space: nowrap;
}

.maker-cast-family.is-full {
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
}

/* Spec 201: "Who reads the story?", a quiet row of pills above the bar (the last step, the summary), the storyteller beside
   its question. */
.maker-narrator {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.maker-narrator-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-weight: 600;
}

.maker-narrator-title .icon {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
}

.maker-narrator > .muted {
  margin: 0;
}

/* Spec 226 amendment 2026-10-26 (the owner on build 49: the languages "very hidden ... not very accessible and confusing"):
   the maker's Language card, a panel like the app's: its heading, the story language as a pill (its code chip, the name and a
   down chevron over a native select), the "Two-language book" switch row (a Family badge on Free) and, once on, the second
   language's pill over a little page of the book. */
.maker-language {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: var(--ui-stroke-panel) solid var(--panel-edge);
  border-radius: var(--ui-radius-panel);
  background: var(--surface);
}

.maker-language-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.maker-language-title .icon {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--crayon-blue);
}

.language-pill {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
}

.language-pill-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.language-pill-box {
  position: relative;
  display: block;
}

/* The select is the pill (so a keyboard's focus is the field's own accent edge); the code chip sits inside its start. */
.language-pill-box select {
  width: 100%;
  min-height: 56px;
  padding-inline-start: 64px;
  border-width: 2px;
  border-radius: var(--ui-radius-choice-pill);
  background-color: var(--surface);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.language-code {
  position: absolute;
  top: 50%;
  inset-inline-start: 12px;
  translate: 0 -50%;
  padding: 2px 9px;
  border-radius: var(--ui-radius-badge);
  pointer-events: none;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.language-two {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: var(--space-3) 0 0;
  border: 0;
  border-top: 1px solid var(--hairline);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.language-two-words {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.language-two-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 1.1rem;
  font-weight: 700;
}

.language-two-line {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.family-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--ui-radius-badge);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.family-badge[hidden] {
  display: none;
}

.family-badge .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.language-second {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.language-second[hidden] {
  display: none;
}

.language-preview {
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.language-preview p {
  margin: 0;
}

.language-preview-main {
  color: var(--on-paper);
  font-size: 1.1rem;
  font-weight: 600;
}

.language-preview-second {
  color: var(--on-paper-muted);
  font-size: 1rem;
}

/* Spec 111 (the owner, build 21: "display the make a hero button in a non invasive way"): the last card of "My heroes",
   a hero card's size so the grid stays tidy, but light: a dashed outline on the page, no fill, no shadow, a small "+". */
a.choice-card.build-hero-card {
  border: 2px dashed var(--text-secondary);
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  text-decoration: none;
}

/* Spec 172: no paper well here, as on the phone (its "+" sits on the page): the page's quiet ink on the paper was 1.3:1 by
   night, and on the page it reads in every palette (textSecondary/page, 4.5:1). */
.build-hero-card .choice-well {
  background: transparent;
  color: var(--text-secondary);
}

.build-hero-card .way-icon {
  width: 36px;
  height: 36px;
}

.build-hero-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Spec 121: the Starter Library's shelf reuses My library's cards; a locked book's cover is dimmed under its lock, and the
   small marks (lock, new, you choose) sit in the cover's corner like a book's video mark. */
.library-locked img {
  opacity: 0.55;
}

.library-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--elevation-raised);
}

.library-mark .icon {
  width: 20px;
  height: 20px;
}

.library-mark-lock {
  color: var(--crayon-purple);
}

.library-mark-new {
  color: var(--crayon-orange);
}

.library-mark-choice {
  color: var(--crayon-teal);
}

/* Spec 120: a Free book's last page is the hero's portrait on Xocana's art background (a rainbow, a star and a cloud on
   the sky); a page with no picture shows the background alone. */
.sheet-picture[data-art] {
  background:
    url("/img/art/rainbow.svg") no-repeat left 6% top 8% / 22% auto,
    url("/img/art/star.svg") no-repeat right 8% top 10% / 9% auto,
    url("/img/art/cloud.svg") no-repeat right 6% bottom 8% / 20% auto,
    linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
}

.sheet-picture[data-art="hero"] img:not(.sheet-photo) {
  object-fit: contain;
  padding: 8%;
  background: transparent;
}


/* Spec 126 (the owner on TestFlight build 28): Xocana Books names itself small, as the phone's bar does, over a warm
   heading ("Stories to read together"), never the same words twice. */
.page-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page-head .page-name {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--font-sm);
  font-weight: 700;
}

.page-head h1 {
  margin: 0;
}

/* Spec 126: every card on the shelf is one height, a one-line title's ("keep the smaller one for all"). The title keeps a
   box and js/title-fit.js draws it at the largest size that fits (22px down to 13px). Spec 127 (the owner: "for German
   books or long text make sure it doesn't cut"): no clamp and no ellipsis; the box holds three lines at 13px, a title
   still too long shrinks on to 11px, and past that the box grows (the row's cards with it) rather than hide a word.
   "Free" or "Family" is the card's last row, 48px tall, with the palette at its right end, so both sit at the same place
   on every card. */
.library-item .library-title {
  --title-size: var(--font-lg);
  display: block;
  min-height: var(--library-title-room, 50px);
  font-size: var(--title-size);
  line-height: 1.25;
  overflow-wrap: break-word;
}

/* While a size is tried the box is exactly its room, so a size whose lines do not fit shows as overflow. */
.library-item .library-title.title-fitting {
  height: var(--library-title-room, 50px);
  overflow: hidden;
}

.library-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 48px;
  margin-top: calc(-1 * var(--space-1));
}

.library-foot .card-icon {
  margin-inline-start: auto;
}

/* Spec 141 (the owner on build 32: "a small labelled menu ... rather than unexplained icons"): spec 132's order button and
   spec 136's unlabelled play button are gone from the cover. The cover keeps one labelled "Video" (a clapperboard and the
   word) in its bottom-left corner, and the card's last row ends with "⋯" (the book's actions in Xocana's own sheet). The
   cover is the card's width at 5:3 (its padding aside), so the corner is found from the card's own width (a container
   query unit). */
.library-item {
  position: relative;
  container-type: inline-size;
}

.library-item .library-video {
  position: absolute;
  top: calc(var(--space-2) + 60cqw - 48px - 8px);
  left: calc(var(--space-2) + 8px);
  max-width: calc(100% - 2 * var(--space-2) - 16px);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  background: var(--crayon-teal);
  color: var(--on-crayon);
  font-weight: 800;
  font-size: var(--font-xs);
  line-height: 1.1;
  text-decoration: none;
  box-shadow: var(--elevation-raised);
}

.library-item .library-video .icon {
  flex: none;
  width: 20px;
  height: 20px;
}

.library-item .library-video.is-sample {
  background: var(--crayon-pink);
}

.library-item .library-video:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Spec 141: the shelf's one quiet line for a Free family (it plays the sample; no price). */
.library-video-note {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) var(--space-4);
  border: var(--ui-stroke-panel) solid var(--panel-edge);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.library-video-note[hidden] {
  display: none;
}

.library-video-note .icon {
  flex: none;
  width: 26px;
  height: 26px;
  color: var(--crayon-pink);
}

.library-video-note .library-video-note-go {
  margin-inline-start: auto;
  color: var(--text-secondary);
}

.library-video-note:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Spec 166: every theme card is as tall as the tallest (css/app.css, .card-grid); on a phone the picture's well and the
   lines step in a little, so equal rows stay snug at 320 px and in German. */
@media (max-width: 420px) {
  .moment-themes .moment-theme {
    padding-inline: var(--space-1);
  }

  .moment-themes .choice-well {
    height: 88px;
  }

  .moment-themes .choice-about {
    line-height: 1.25;
  }
}

/* Spec 211: the hero step's help line, and "The star" on the steps after it (its picture, its name, a pencil back). */
.maker-hero-help {
  margin: 0;
  max-width: 60ch;
}

.maker-star {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 28rem;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-2);
  border: 2px solid var(--accent-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
}

.maker-star[hidden] {
  display: none;
}

.maker-star-picture {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--paper);
}

.maker-star-picture > img,
.maker-star-picture > svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Spec 211 amendment 2: a picture fills the frame exactly (its height was the picture's own, so a tall photo stood taller
   than the frame), so where it sits (object-position, js/picture-crop.js) keeps a pet's head in view. */
.maker-star-picture,
.cast-thumb {
  position: relative;
}

.maker-star-picture > img,
.cast-thumb > img {
  position: absolute;
  inset: 0;
}

.maker-star-words {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.maker-star-label {
  color: var(--text-secondary);
  font-size: var(--font-sm);
}

.maker-star-name {
  font-size: var(--font-lg);
  overflow-wrap: anywhere;
}

.maker-star-change {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: var(--touch-standard);
  height: var(--touch-standard);
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 2px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.maker-star-change:focus-visible,
.cast-tab:focus-visible,
.cast-chip-remove:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

/* On the name step the star's picture is beside the question, large, so the name is clearly the picture's. */
.maker-star.maker-star-big .maker-star-picture {
  width: 120px;
  height: 120px;
}

/* Spec 211: "Who else is in the story?": the counter, the picks as chips, the four tabs and the box for the family's words. */
.maker-cast-count {
  margin: 0;
  font-weight: 700;
}

.cast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cast-chips[hidden] {
  display: none;
}

.cast-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  min-height: 56px;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-1);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--text);
}

.cast-thumb {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--paper);
}

.cast-thumb > img,
.cast-thumb > svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cast-chip-name {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cast-chip input {
  width: 9rem;
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--space-2);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.cast-chip-remove {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.cast-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--space-2);
  max-width: 44rem;
}

.cast-tab {
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.cast-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cast-ideas {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cast-ideas[hidden] {
  display: none;
}

.cast-typed {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
}

.cast-typed .field {
  flex: 1 1 14rem;
  margin: 0;
}

.maker-cast {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.maker-cast[hidden] {
  display: none;
}

.maker-cast > p {
  margin: 0;
}

/* Spec 226: complete second text on the same page, with its own script shaping. */
.sheet-words .second-language-words { font-size: .9em; opacity: .8; margin-block-start: .65em; }
.bilingual-selection { min-height: 48px; white-space: normal; }
.cover-title, .end-title { white-space: pre-line; }

.bilingual-heading-second { display: block; font-size: 90%; opacity: .8; }

/* Spec 226: language controls wrap below the playback dock, keeping both turns reachable. */
.reader-language-controls { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); min-width: 0; }
.reader-language-controls:empty { display: none; }
.reader-language-controls .bilingual-selection { flex: 1 1 140px; min-width: 0; }

/* Spec 246 (the owner, 2026-10-31: make the story maker clearly better; "it's hard to see there are more options below").
   The step's dots under "Step N of M": one a step, the ones done in the accent, the one on show long and yellow. */
.maker-progress {
  display: flex;
  gap: 6px;
  margin: 2px 0 var(--space-2);
}

.maker-progress > span {
  flex: 0 0 auto;
  width: 12px;
  height: 8px;
  border-radius: 999px;
  background: var(--hairline);
}

.maker-progress > span.done {
  background: var(--accent);
}

.maker-progress > span.now {
  width: 32px;
  background: var(--crayon-yellow);
}

/* "More for your book": everything a grown-up may add where the yellow pill makes the book, under its own heading. */
.maker-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 2px dashed var(--hairline);
}

.maker-options-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  scroll-margin-top: var(--space-4);
}

.maker-options-title .icon {
  width: 1.2em;
  height: 1.2em;
}

.maker-end {
  display: block;
  height: 1px;
  margin-top: calc(var(--space-4) * -1);
}

/* The bar of Back and Next sticks to the window's foot at every width (it did on a phone only, so on a desktop "Make my
   book!" and every option were under the fold). While the step goes on below, a soft fade on its top edge says so. */
.maker-nav {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--chrome-veil);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.maker-nav::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--chrome-veil));
  opacity: 0;
  pointer-events: none;
}

.maker-nav.more-below::before {
  opacity: 0.9;
}

@media (prefers-reduced-motion: no-preference) {
  .maker-nav::before {
    transition: opacity 0.2s ease;
  }
}

@media (max-width: 640px) {
  .maker-nav {
    margin: 0 calc(var(--space-5) * -1);
    padding: var(--space-3) var(--space-5) var(--space-4);
    border-width: 2px 0 0;
    border-radius: 0;
  }
}

/* Spec 279 (the owner, 2026-11-02: "things should be a bit smaller so the user is able to see all the different options on
   each step"): the maker drawn small enough that a step's choices show at once. Research R1 measured 2 of 7 ideas above the
   bar on a 390 px phone; six now fit in two rows of three (one row of six on a desktop), each card still the whole target
   and 48 px and more (spec 063), its words wrapped and hyphenated, never cut (spec 082). Scoped to the maker: Big moments,
   the heroes and My art keep their cards. */
.books.is-making > [data-ref="booksBack"] {
  display: none;
}

/* The page's heading stays for a screen reader; the step's question is the heading a child sees. */
.books.is-making > [data-ref="booksTitle"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.maker {
  gap: var(--space-3);
}

.maker .maker-title,
.maker .maker-head .maker-title {
  font-size: clamp(24px, 6.4vw, 30px);
  line-height: 1.15;
}

.maker-progress {
  margin: 0;
}

/* At least 6.25 rem (100 px at the default size, more with larger text, so the columns drop by themselves) and at most six
   to a row: three on a phone, six on a desktop. */
.maker .choice-grid {
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fill, minmax(max(6.25rem, calc((100% - 5 * var(--space-2)) / 6)), 1fr));
}

.maker .choice-card {
  min-height: 0;
  gap: 6px;
  padding: 6px 6px var(--space-2);
  border-width: 2px;
}

.maker .choice-well {
  height: 72px;
  padding: 4px;
}

.maker .choice-art,
.maker .choice-well .hero-art,
.maker .choice-well .moment-art {
  max-height: 64px;
}

.maker .choice-well > .choice-picture {
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
}

/* Only a long word breaks (German, Czech), at a hyphenation point. */
.maker .choice-label {
  font-size: 15px;
  line-height: 1.2;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 12 5 5;
}

.maker .choice-check {
  top: -5px;
  right: -5px;
  width: 28px;
  height: 28px;
  border-width: 2px;
}

.maker .choice-check .icon {
  width: 18px;
  height: 18px;
}

.maker .choice-pills {
  gap: var(--space-2);
}

.maker .choice-pill {
  min-height: 52px;
  padding: var(--space-1) var(--space-4);
  font-size: var(--font-md);
}

.maker .choice-more {
  min-height: 48px;
  padding: var(--space-1) var(--space-4);
  font-size: var(--font-md);
}

.maker .maker-jump {
  font-size: 15px;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
}

/* The star in one slim row: its picture, its name, the pencil (48 px). */
.maker-star {
  padding: 4px var(--space-2) 4px 4px;
  gap: var(--space-2);
}

.maker-star-picture {
  width: 44px;
  height: 44px;
}

.maker-star.maker-star-big .maker-star-picture {
  width: 88px;
  height: 88px;
}

.maker-star-label {
  font-size: var(--font-xs);
}

.maker-star-name {
  font-size: var(--font-md);
}

/* Back and Next a little lower (still a kid's 56 px). */
.maker-nav .button {
  min-height: 56px;
}

/* "More below": in the bar, just before the yellow pill (it covered the page's words as a pill over them): a round arrow,
   with its words where the bar has room (the first step, no Back). */
.maker-nav .maker-more-below {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 48px;
  min-height: 48px;
  margin-left: auto;
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-sm);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.maker-nav .maker-more-below[hidden] {
  display: none;
}

.maker-nav .maker-more-below .icon {
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
}

.maker-nav .maker-more-below-words {
  display: none;
  white-space: nowrap;
}

.maker-nav.no-back .maker-more-below {
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
}

.maker-nav.no-back .maker-more-below-words {
  display: inline;
}

.maker-nav .maker-more-below:not([hidden]) ~ .maker-next {
  margin-left: 0;
}

.maker-nav .maker-more-below:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

/* Your book: the answers as tiles, two or more to a row, each the whole target (spec 193's rows, widened to every step). */
.maker-picked {
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: none;
}

.maker-pick-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(6.5rem, 100%), 1fr));
  gap: var(--space-2);
}

.maker-pick-rows > li {
  display: flex;
}

.maker-pick {
  position: relative;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 56px;
  padding: var(--space-2);
}

.maker-pick .icon {
  position: absolute;
  top: 6px;
  right: 6px;
}

.maker-pick-question {
  font-size: var(--font-xs);
  line-height: 1.25;
}

.maker-pick-words {
  font-size: 15px;
  line-height: 1.2;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 12 5 5;
}

.maker-pick .icon {
  width: 20px;
  height: 20px;
}

.maker-options {
  gap: var(--space-3);
  padding-top: var(--space-3);
}


/* Spec 282 (A3): the star's tile spans its row (beside a 40 px picture a two-column tile broke "Sparklehoof" mid-word). */
.maker-pick-rows > li.maker-pick-star-row {
  grid-column: 1 / -1;
}

.maker-pick-star .maker-pick-words {
  -webkit-hyphens: manual;
  hyphens: manual;
}

/* Your book's star tile: its picture beside the words. */
.maker-pick-picture {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--paper);
}

.maker-pick-picture > img,
.maker-pick-picture > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Back and the yellow pill share one row on a phone in every language: the yellow pill shrinks and its words wrap inside it
   ("Mein Buch machen!" took a second row of its own). */
.maker-nav .maker-next {
  flex: 1 1 0;
  min-width: 0;
  white-space: normal;
}

/* Japanese breaks between phrases, not inside a word, where the browser can (a narrow card's "おはなしの教え"). */
.maker .choice-label:lang(ja),
.maker-pick-text:lang(ja) {
  word-break: auto-phrase;
}

.maker-nav .maker-back {
  flex: 0 0 auto;
  padding-left: var(--space-3);
  padding-right: var(--space-4);
}

/* A section's heading on the hero step sits right over its cards (a paragraph's own margins left 40 px around it). */
.maker p.maker-sub {
  margin: var(--space-2) 0 calc(var(--space-1) * -1);
}

/* Spec 279, CI's small-phone pictures (the iPhone Duo's outer screen: no option card above the bar on the first step): the
   ways to a hero are one row that scrolls sideways (they wrapped to three rows), the help line is short, and on a short or
   narrow window the question is smaller and the bar lower. */
.maker-jump-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

/* On a phone the row runs to the screen's edges, so a cut chip at the edge says it goes on. */
@media (max-width: 640px) {
  .maker-jump-row {
    margin: 0 calc(var(--space-5) * -1);
    padding: 2px var(--space-5);
  }
}

.maker-jump-row::-webkit-scrollbar {
  display: none;
}

.maker .maker-jump {
  flex: 0 0 auto;
  white-space: nowrap;
}

.maker .maker-hero-help {
  line-height: 1.35;
}

@media (max-width: 420px), (max-height: 720px) {
  .maker .maker-title,
  .maker .maker-head .maker-title {
    font-size: 24px;
  }

  .maker {
    gap: var(--space-2);
  }
}

@media (max-height: 500px) {
  .maker-nav {
    padding-top: var(--space-1);
    padding-bottom: var(--space-1);
  }

  .maker-nav .button {
    min-height: 48px;
    padding-top: var(--space-1);
    padding-bottom: var(--space-1);
    font-size: var(--font-md);
  }

  .maker-nav .maker-next {
    font-size: var(--font-md);
  }
}


/* A paragraph's own margins (16 px above and below) left gaps on every step ("Up to you…", the cast's line); the column's gap
   spaces them. */
.maker p:not(.maker-sub) {
  margin: 0;
}

@media (max-height: 500px) {
  .maker-star-picture {
    width: 40px;
    height: 40px;
  }

  .maker-star-label {
    display: none;
  }
}
