/* A notebook page on a desk by day, a blackboard by night. Cartoon outlines and hard shadows keep
   it playful; the parts a stressed parent needs (choices, the page box, the print button) stay big
   and obvious. */
:root {
  color-scheme: light;
  --desk: #f3ede1;
  --paper: #fffdf7;
  --rule: rgba(64, 120, 210, 0.11);
  --margin-line: rgba(226, 75, 75, 0.4);
  --ink: #1e2640;
  --ink-soft: #3a4463;
  --muted: #5d6680;
  --card: #ffffff;
  --outline: #1e2640;
  --shadow: #1e2640;
  --accent: #2c5bd6;
  --pencil: #ffcf3f;
  --pencil-ink: #231c00;
  --note: #fff3a3;
  --note-ink: #2b2a1f;
  --tape: rgba(255, 255, 255, 0.65);
  --book: #ff6b5b;
  --book-spine: #e2493a;
  --ok: #1d7f46;
  --danger: #c22f2f;
  --g1: #ff7a7a;
  --g2: #ffa94d;
  --g3: #ffd84d;
  --g4: #5fd68c;
  --g5: #5cb3ff;
  --g6: #b394ff;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Safari has a rounded system face with Greek; everywhere else this is the system font. Japanese
     rounded faces are left out on purpose: their Greek letters are full-width. */
  --font-fun: ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --desk: #16211c;
    --paper: #234235;
    --rule: transparent;
    --margin-line: transparent;
    --ink: #f4f1e6;
    --ink-soft: #e0dccd;
    --muted: #b9c6bb;
    --card: #2b4c3f;
    --outline: #ece8d8;
    --shadow: #0c1511;
    --accent: #a6d4ff;
    --pencil: #ffd75e;
    --tape: rgba(255, 255, 255, 0.4);
    --ok: #8fe6b4;
    --danger: #ffa094;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font: 17px/1.55 var(--font);
  color: var(--ink);
  background: var(--desk);
}

a {
  color: var(--accent);
}

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* The page: ruled notebook paper, or a blackboard in a wooden frame. */
.sheet {
  position: relative;
  max-width: 760px;
  margin: 10px auto 18px;
  padding: 6px 16px 28px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(30, 38, 64, 0.05), 0 22px 44px -28px rgba(30, 38, 64, 0.5);
}

@media (min-width: 720px) {
  .sheet {
    margin: 28px auto 24px;
    padding: 12px 40px 40px 86px;
    background-image:
      linear-gradient(to right, transparent 62px, var(--margin-line) 62px 64px, transparent 64px),
      repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  }

  /* Binder holes down the left edge. */
  .sheet::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 90px;
    bottom: 90px;
    width: 20px;
    background: radial-gradient(circle at 10px 10px, var(--desk) 0 8px, transparent 9px) 0 0 / 20px 140px repeat-y;
  }
}

@media (prefers-color-scheme: dark) {
  .sheet {
    border: 10px solid #7a5532;
    border-radius: 12px;
    background-image:
      radial-gradient(ellipse at 20% 15%, rgba(255, 255, 255, 0.06), transparent 45%),
      radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.04), transparent 50%);
    box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.35), 0 22px 44px -26px rgba(0, 0, 0, 0.8);
  }

  @media (min-width: 720px) {
    .sheet {
      padding-left: 48px;
    }

    .sheet::before {
      display: none;
    }
  }
}

/* Hero: the forgotten book and its complaint. */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "mascot text";
  align-items: center;
  gap: 4px 14px;
  padding: 14px 0 4px;
}

.mascot {
  grid-area: mascot;
  position: relative;
  width: 104px;
  margin: 18px 0 0;
}

.mascot-art {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* The mascot is also the way home. */
.home-link {
  display: block;
  border-radius: 14px;
}

.home-link:hover .m-body {
  animation-duration: 0.9s;
}

.bubble {
  position: absolute;
  top: -14px;
  left: 74px;
  z-index: 1;
  padding: 6px 12px;
  white-space: nowrap;
  font: 800 0.82rem/1.2 var(--font-fun);
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: 14px 14px 14px 4px;
  box-shadow: 2px 2px 0 var(--shadow);
  transform: rotate(-3deg);
  animation: pop 0.5s 0.3s both cubic-bezier(0.2, 1.4, 0.4, 1);
}

.hero-text {
  grid-area: text;
  padding-top: 22px;
}

.hero h1 {
  margin: 0;
  font: 800 clamp(1.9rem, 7.4vw, 3.1rem) / 1.05 var(--font-fun);
  letter-spacing: -0.01em;
}

.hero h1 a {
  color: inherit;
  text-decoration: none;
}

.marker {
  padding: 0 0.08em;
  border-radius: 4px;
  background: linear-gradient(transparent 55%, var(--pencil) 55% 92%, transparent 92%);
}

@media (prefers-color-scheme: dark) {
  .marker {
    background: linear-gradient(transparent 55%, rgba(255, 215, 94, 0.45) 55% 92%, transparent 92%);
  }
}

.lead {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 34em;
}

@media (max-width: 519px) {
  .hero {
    grid-template-areas: "mascot text" "lead lead";
  }

  .hero-text {
    display: contents;
  }

  .hero h1 {
    grid-area: text;
    padding-top: 26px;
  }

  .lead {
    grid-area: lead;
  }
}

@media (min-width: 720px) {
  .hero {
    grid-template-columns: 1fr auto;
    grid-template-areas: "text mascot";
    padding-top: 26px;
  }

  .hero-text {
    padding-top: 0;
  }

  .mascot {
    width: 150px;
    margin: 30px 26px 0 0;
  }

  .bubble {
    top: -42px;
    left: auto;
    right: -10px;
    font-size: 0.9rem;
    border-radius: 14px 14px 4px 14px;
  }
}

/* Once a book is open the hero shrinks to a header line. */
body[data-stage="pages"] .hero {
  grid-template-columns: auto 1fr;
  grid-template-areas: "mascot text";
  padding: 8px 0 0;
}

body[data-stage="pages"] .mascot {
  width: 52px;
  margin: 0;
}

body[data-stage="pages"] .bubble,
body[data-stage="pages"] .lead {
  display: none;
}

body[data-stage="pages"] .hero-text {
  display: block;
  padding: 0;
}

body[data-stage="pages"] .hero h1 {
  padding: 0;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
}

/* The mascot. */
.m-shadow {
  fill: var(--ink);
  opacity: 0.13;
}

.m-cover {
  fill: var(--book);
  stroke: var(--outline);
  stroke-width: 3;
}

.m-spine {
  fill: var(--book-spine);
}

.m-label {
  fill: #fff;
  stroke: var(--outline);
  stroke-width: 2.5;
}

.m-eye {
  fill: #fff;
  stroke: var(--outline);
  stroke-width: 2.5;
}

.m-pupil {
  fill: #1e2640;
}

.m-line {
  fill: none;
  stroke: var(--outline);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.m-line.thin {
  stroke-width: 2;
}

.m-hand {
  fill: var(--book);
  stroke: var(--outline);
  stroke-width: 2.5;
}

.m-drop {
  fill: #7cc8ff;
  stroke: var(--outline);
  stroke-width: 2;
}

.m-body,
.m-eyes,
.m-wave,
.m-drop {
  transform-box: view-box;
}

.m-body {
  transform-origin: 75px 135px;
  animation: bob 2.8s ease-in-out infinite;
}

.m-eyes {
  transform-origin: 82px 78px;
  animation: blink 5s infinite;
}

.m-wave {
  transform-origin: 120px 84px;
  animation: wave 0.9s ease-in-out infinite alternate;
}

.m-drop {
  transform-origin: 114px 48px;
  animation: drip 2.8s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  50% {
    transform: translateY(-4px) rotate(-2deg);
  }
}

@keyframes blink {
  0%,
  93%,
  100% {
    transform: scaleY(1);
  }
  96% {
    transform: scaleY(0.1);
  }
}

@keyframes wave {
  from {
    transform: rotate(-10deg);
  }
  to {
    transform: rotate(12deg);
  }
}

@keyframes drip {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 1;
  }
  80% {
    transform: translateY(4px);
    opacity: 0.6;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.6) rotate(-3deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(-3deg);
  }
}

/* Steps: where the parent is, and a way back to any earlier choice. */
.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 16px 0 4px;
  padding: 0;
  list-style: none;
}

.steps li > button,
.steps li > span {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 7px;
  width: 100%;
  min-height: 50px;
  padding: 6px 8px;
  text-align: left;
  color: var(--muted);
  background: none;
  border: 2px solid transparent;
  border-radius: 12px;
}

.steps .dot {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font: 800 0.82rem/1 var(--font-fun);
  border: 2px solid currentColor;
  border-radius: 50%;
}

.steps .name {
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
}

/* A step without a chosen value yet: its name sits level with the number. */
.steps .name:last-child {
  grid-row: span 2;
  font-size: 0.86rem;
}

.steps .value {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.steps .done > button {
  cursor: pointer;
  color: var(--ink);
  background: var(--card);
  border-color: var(--outline);
  box-shadow: 2px 2px 0 var(--shadow);
}

.steps .done > button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--shadow);
}

.steps .done > span {
  color: var(--ink);
}

.steps .done .dot {
  color: #fff;
  background: var(--ok);
  border-color: var(--outline);
}

.steps .current > span {
  color: var(--ink);
  border: 2px dashed var(--outline);
}

.steps .current .dot {
  color: var(--pencil-ink);
  background: var(--pencil);
  border-color: var(--outline);
}

.steps .name,
.steps .value {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Phones: the steps become small chips that wrap instead of squeezing into four columns. Finished
   steps show only the choice, steps still to come are left out, and once a book is open the page
   box itself says what comes next. */
@media (max-width: 559px) {
  .steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .steps li {
    min-width: 0;
    max-width: 100%;
  }

  .steps .todo,
  body[data-stage="pages"] .steps .current {
    display: none;
  }

  .steps li > button,
  .steps li > span {
    width: auto;
    min-height: 40px;
    padding: 4px 12px 4px 5px;
    column-gap: 6px;
  }

  .steps .dot {
    width: 24px;
    height: 24px;
  }

  .steps .done .name {
    display: none;
  }

  .steps .done .value {
    grid-row: span 2;
    max-width: 11em;
    font-size: 0.92rem;
  }
}

.step-title {
  margin: 20px 0 14px;
  font: 800 1.35rem/1.25 var(--font-fun);
}

/* Δημοτικό, Γυμνάσιο, Λύκειο: a label like a notebook's section tab. */
.level + .level {
  margin-top: 22px;
}

.level-title {
  display: inline-block;
  margin: 0 0 10px;
  padding: 2px 12px;
  font: 800 0.95rem/1.6 var(--font-fun);
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--shadow);
}

/* Choices: little notebooks, subject cards and book cards. */
.choices {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
}

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

@media (min-width: 560px) {
  .choices.grades {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.choices.books {
  grid-template-columns: 1fr;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 66px;
  padding: 12px 14px;
  text-align: left;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.choice:hover {
  transform: translate(-1px, -2px) rotate(-0.4deg);
  box-shadow: 5px 6px 0 var(--shadow);
}

.choice:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--shadow);
}

.choice .text {
  min-width: 0;
}

.choice strong {
  display: block;
  font-weight: 700;
  line-height: 1.25;
}

.choice small {
  display: block;
  margin-top: 2px;
  font-size: 0.84rem;
  color: var(--muted);
}

.choice .emoji {
  flex: none;
  width: 42px;
  font-size: 1.75rem;
  line-height: 1;
  text-align: center;
}

.choice.grade {
  border-left: 12px solid var(--tab);
  border-radius: 8px var(--radius) var(--radius) 8px;
  padding-left: 12px;
}

.choice.grade .badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font: 800 1.2rem/1 var(--font-fun);
  color: #1e2640;
  background: var(--tab);
  border: 2px solid var(--outline);
  border-radius: 50%;
}

@media (max-width: 459px) {
  .choice.grade {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .choice.grade .badge {
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
  }
}

.choice.book small {
  overflow-wrap: anywhere;
}

/* The open book: a cover in the grade's colour, then the sticky note for the pages. */
.book-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 6px;
}

.book-cover {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 68px;
  padding-left: 6px;
  font-size: 1.6rem;
  background: var(--tab, var(--book));
  border: 2px solid var(--outline);
  border-radius: 5px 10px 10px 5px;
  box-shadow: 3px 3px 0 var(--shadow);
}

.book-cover::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  border-left: 2px solid var(--outline);
}

.book-head h2 {
  margin: 0;
  font: 800 1.3rem/1.2 var(--font-fun);
}

.book-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.book-head .title {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.note {
  position: relative;
  margin: 26px 6px 10px;
  padding: 24px 18px 16px;
  color: var(--note-ink);
  background: var(--note);
  border-radius: 3px 3px 22px 3px;
  box-shadow: 0 12px 20px -14px rgba(0, 0, 0, 0.55), inset 0 -10px 18px -16px rgba(0, 0, 0, 0.35);
  transform: rotate(-0.8deg);
}

.note::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 50%;
  width: 116px;
  height: 27px;
  background: var(--tape);
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateX(-50%) rotate(2deg);
}

.note label {
  display: block;
  font: 800 1.18rem/1.3 var(--font-fun);
}

.note input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 4px 2px 6px;
  font: 800 2.1rem/1.15 var(--font-fun);
  color: #1b1a12;
  background: transparent;
  border: 0;
  border-bottom: 3px dashed rgba(43, 42, 31, 0.4);
  border-radius: 0;
}

.note input::placeholder {
  color: rgba(43, 42, 31, 0.35);
}

.note input:focus {
  outline: none;
  border-bottom: 3px solid var(--note-ink);
}

.note-help {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: rgba(43, 42, 31, 0.78);
}

.note-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.note .key {
  min-height: 40px;
  padding: 6px 14px;
  font: 800 1rem/1 var(--font-fun);
  color: var(--note-ink);
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(43, 42, 31, 0.55);
  border-radius: 10px;
  cursor: pointer;
}

.note .key:hover {
  background: rgba(255, 255, 255, 0.8);
}

.note .key:active {
  transform: translateY(1px);
}

.hint {
  margin: 10px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.hint[hidden],
.status[hidden],
.card[hidden],
.progress[hidden],
.print-bar[hidden],
.toast[hidden] {
  display: none;
}

.error {
  color: var(--danger);
  font-weight: 600;
}

.ok {
  color: var(--ok);
  font-weight: 600;
}

/* "Opening the book…" with a pencil that scribbles and a running joke. */
.status {
  margin: 14px 0 0;
  font-weight: 700;
}

.status.busy::before {
  content: "✏️";
  display: inline-block;
  margin-right: 8px;
  animation: scribble 0.5s ease-in-out infinite alternate;
}

.status.busy[data-joke]::after {
  content: attr(data-joke);
  display: block;
  margin-top: 2px;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

@keyframes scribble {
  from {
    transform: translateX(-2px) rotate(-14deg);
  }
  to {
    transform: translateX(4px) rotate(10deg);
  }
}

/* Cards: the download fallback and the "you have the file" note. */
.card {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--shadow);
}

.card p {
  margin: 0 0 8px;
}

.card ol {
  margin: 0;
  padding-left: 22px;
}

.card li {
  margin: 8px 0;
}

.card li .button {
  margin: 4px 0;
}

label.inline {
  display: inline;
  font-weight: inherit;
}

input[type="file"] {
  display: block;
  max-width: 100%;
  margin-top: 6px;
  font: inherit;
}

.progress {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.progress progress {
  display: block;
  width: 100%;
  height: 10px;
  margin-bottom: 4px;
  accent-color: var(--accent);
}

/* The relay's progress: a pencil-yellow bar that fills as the bytes of the pages arrive, striped
   while there is nothing to measure against. */
.meter {
  max-width: 420px;
  margin-top: 10px;
}

.meter[hidden] {
  display: none;
}

.meter-track {
  height: 14px;
  overflow: hidden;
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--shadow);
}

.meter-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pencil);
  transition: width 0.25s ease-out;
}

/* One stripe period across and down, so the tiles meet without a seam. */
.meter.unknown .meter-fill {
  width: 100%;
  background: repeating-linear-gradient(-45deg, var(--pencil) 0 8px, transparent 8px 16px) 0 0 / 22.63px 22.63px;
  animation: meter-stripes 0.9s linear infinite;
}

@keyframes meter-stripes {
  to {
    background-position: 22.63px 0;
  }
}

.meter-text {
  margin: 5px 0 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .meter-fill {
    transition: none;
  }

  .meter.unknown .meter-fill {
    animation: none;
  }
}

/* Buttons. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 20px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--shadow);
}

.button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--shadow);
}

.button.primary {
  font-size: 1.1rem;
  color: var(--pencil-ink);
  background: var(--pencil);
}

.button.small {
  min-height: 42px;
  padding: 7px 12px;
  font-size: 0.95rem;
  font-weight: 600;
}

.text-button {
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.actions .adjust {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* Print and save stay at the bottom of the screen while the pages scroll under them, and settle
   below the pages at the end. */
.print-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: var(--paper);
  box-shadow: 0 -14px 14px -14px rgba(30, 38, 64, 0.45);
}

.print-bar .button {
  flex: 0 0 auto;
}

@media (max-width: 519px) {
  .print-bar .button {
    flex: 1 1 auto;
  }

  .print-bar .wide-only {
    display: none;
  }
}

@media (prefers-color-scheme: dark) {
  .print-bar {
    box-shadow: 0 -14px 14px -14px rgba(0, 0, 0, 0.7);
  }
}

/* The preview: sheets of paper, clipped to the notebook. */
.preview {
  display: grid;
  gap: 26px;
  margin-top: 26px;
}

.preview:empty {
  display: none;
}

.preview figure {
  position: relative;
  margin: 0 4px;
  padding: 10px;
  background: #fff;
  border: 2px solid var(--outline);
  border-radius: 6px;
  box-shadow: 4px 5px 0 var(--shadow);
  transform: rotate(0.5deg);
}

.preview figure:nth-child(even) {
  transform: rotate(-0.5deg);
}

.preview figure::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 24px;
  width: 22px;
  height: 56px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 56'%3E%3Cpath d='M7 20V9a4 4 0 0 1 8 0v35a7 7 0 0 1-14 0V15' fill='none' stroke='%238a93a6' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat;
}

.preview img {
  display: block;
  width: 100%;
  height: auto;
}

.preview figcaption {
  margin-top: 8px;
  font: 700 0.92rem/1.3 var(--font-fun);
  color: #4a4f60;
  text-align: center;
}

/* A friendly word after printing. */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  font-weight: 700;
  color: var(--pencil-ink);
  background: var(--pencil);
  border: 2px solid var(--outline);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--shadow);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

footer {
  max-width: 760px;
  margin: 0 auto 32px;
  padding: 0 20px;
  font-size: 0.85rem;
  color: var(--muted);
}

footer p {
  margin: 0 0 8px;
}

footer .signature {
  font-family: var(--font-fun);
  font-weight: 700;
}

#print-root {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .choice:hover,
  .button:hover {
    transform: none;
  }
}

@media print {
  @page {
    margin: 8mm;
  }

  body {
    background: #fff;
  }

  body > :not(#print-root) {
    display: none !important;
  }

  #print-root {
    display: block;
  }

  /* 258mm fits the printable height of both A4 and Letter paper. */
  #print-root img {
    display: block;
    width: 100%;
    max-height: 258mm;
    object-fit: contain;
    object-position: top left;
  }

  #print-root img:not(:last-child) {
    break-after: page;
  }
}
