/* ===== Tokens (only these colours) ===== */
:root {
  --paper: #F4ECDD;
  --white: #FAF6EE;
  --kraft: #E5D9C3;
  --ink: #1F1A17;
  --faded: #594F48;
  --tomato: #C8442F;
  --sage: #A7B59E;
  --washi: #E8CF98;
  --shadow: 0 4px 12px rgba(31, 26, 23, .15);
  --serif: "Literata", Georgia, serif;
  --hand: "Caveat", cursive;
  --script: "La Belle Aurore", "Caveat", cursive;   /* pen script, used only for the cover caption */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .12 0 0 0 0 .1 0 0 0 0 .09 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  /* one set of motion curves, so everything moves like the same paper */
  --ease-paper-drop: cubic-bezier(0.2, 0.8, 0.3, 1);     /* paper landing: quick, then a soft stop */
  --ease-paper-fold: cubic-bezier(0.4, 0, 0.2, 1);       /* heavy fold: the envelope flap */
  --ease-wax-press: cubic-bezier(0.2, 0, 0.38, 0.9);     /* firm thumb press, no spring */
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
input, textarea { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;                    /* the page never slides sideways */
  overscroll-behavior: none;             /* no rubber-band bounce or pull-to-refresh */
  touch-action: manipulation;            /* no double-tap zoom */
}
body {
  -webkit-user-select: none; user-select: none;            /* double-click / long-press does not select text */
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  margin: 0;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background-color: var(--paper);
  /* paper grain: tiny inline SVG noise, low opacity */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .12 0 0 0 0 .1 0 0 0 0 .09 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;      /* 16px minimum */
  line-height: 1.6;
}
main { max-width: 480px; margin: 0 auto; padding: 24px 20px 64px; overflow-x: hidden; overflow-x: clip; }   /* tilted notes must not widen the page */
section { margin: 0 0 56px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.hand { font-family: var(--hand); font-size: 1.375rem; line-height: 1.2; color: var(--faded); }
.muted { color: var(--faded); }

/* ===== Section heading with hand-drawn underline ===== */
.heading {
  display: inline-block;
  font-size: 1.75rem;
  padding-bottom: 14px;
  margin-bottom: 24px;
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C30 1 55 9 90 5 S150 2 198 6' fill='none' stroke='%23C8442F' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ===== Polaroid with washi tape ===== */
.polaroid {
  position: relative;
  width: min(78vw, 300px);
  margin: 28px auto;
  padding: 12px 12px 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  border-radius: 2px;
  transform: rotate(-2deg);
}
.polaroid.tilt-r { transform: rotate(2.5deg); }
.polaroid::before {            /* washi tape strip */
  content: "";
  position: absolute;
  top: -12px; left: 50%;
  width: 96px; height: 26px;
  margin-left: -48px;
  background: var(--washi);
  opacity: .9;
  transform: rotate(var(--tr, -4deg));
  clip-path: polygon(0 8%, 4% 0, 8% 10%, 12% 0, 92% 0, 96% 10%, 100% 0, 100% 92%, 96% 100%, 92% 90%, 88% 100%, 8% 100%, 4% 90%, 0 100%);
}
.polaroid img { display: block; }
.polaroid img, .polaroid .slot { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.polaroid figcaption {
  font-family: var(--hand);
  font-size: 1.5rem;
  line-height: 1.1;
  text-align: center;
  padding: 10px 4px 6px;
  min-height: 44px;
}

/* ===== Wax-stamp button ===== */
.stamp {
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
  width: 80px; height: 80px;              /* >= 44px tap target */
  border: 0; border-radius: 48% 52% 50% 50% / 52% 48% 52% 48%;
  background: var(--tomato);
  color: var(--white);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: .04em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow);
  transform: rotate(-4deg);
  transition: transform .12s var(--ease-wax-press);
}
.stamp::after {                          /* dashed inner ring */
  content: ""; position: absolute; inset: 7px;
  border: 2px dashed var(--white); border-radius: 50%;
  pointer-events: none;
}
.stamp:active { transform: rotate(-2.5deg) scale(.92); }
.stamp:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.field:focus, .field:focus-visible { outline: none; box-shadow: none; border-bottom: 2px solid var(--tomato); padding-bottom: 8px; }

/* ===== Ruled-line input ===== */
.field {
  display: block; width: 100%;
  min-height: 48px;
  padding: 8px 2px 8.5px;
  -webkit-appearance: none; appearance: none;   /* iOS adds its own look */
  border: 0; border-bottom: 1.5px solid var(--faded);   /* pencil line, not a black rule */
  border-radius: 0;
  background: transparent;
  box-shadow: none; outline: none;
  text-align: center;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;                     /* >= 16px so iOS doesn't zoom */
}
.field::placeholder { color: var(--faded); opacity: .7; }

/* ===== Postmark ring ===== */
.postmark {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 84px; height: 84px;
  position: relative;
  border: 2px solid currentColor;
  border-radius: 50%;
  color: var(--tomato);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  transform: rotate(-8deg);
  opacity: .85;
  mix-blend-mode: multiply;
}
.postmark::after { content: ""; position: absolute; inset: 4px; border: 1px solid currentColor; border-radius: 50%; }
.postmark.sage { color: var(--sage); }
.postmark.sage span, .postmark.sage small { color: var(--faded); }
.postmark small { font-size: 1rem; font-weight: 400; }

/* ===== Chat-fragment quote scrap (me = tomato, her = sage) ===== */
.scrap {
  position: relative;
  max-width: 85%;
  margin: 12px 0;
  padding: 10px 16px 10px 17px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
  filter: drop-shadow(0 3px 5px rgba(31, 26, 23, .15));   /* filter, because clip-path would cut a box-shadow */
}
.scrap::before {                         /* paper with ragged right edge */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--white);
  clip-path: polygon(0 0, 100% 0, 98.5% 22%, 100% 41%, 98% 63%, 100% 82%, 99% 100%, 0 100%);
}
.scrap::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--edge); }
.scrap .who {
  display: block; margin-bottom: 0;
  font-family: var(--hand); font-size: 1.25rem; line-height: 1.1;
  color: var(--faded);
}
.scrap.me  { margin-left: auto;  --edge: var(--tomato); transform: rotate(1deg); }
.scrap.her { margin-right: auto; --edge: var(--sage);   transform: rotate(-1.5deg); }
.scrap.friend { margin-right: auto; --edge: var(--faded); transform: rotate(1deg); }

/* ===== Empty placeholder slot ===== */
.slot {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px;
  padding: 12px;
  border: 2px dashed var(--faded);
  border-radius: 2px;
  background: var(--kraft);
  color: var(--faded);
  font-family: var(--hand);
  font-size: 1.25rem;
  text-align: center;
}

/* ===== Torn-edge note (letters, numbers, contents) ===== */
.note {
  position: relative;
  margin: 28px 0;
  transform: rotate(-.8deg);
  filter: drop-shadow(0 3px 5px rgba(31, 26, 23, .15));
}
.note-body {
  padding: 32px 20px;
  background-color: var(--white);
  /* faint ruled lines: 32px tile, 1px line at y=22 = text baseline (16px text, 32px line-height) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='32'%3E%3Crect y='22' width='8' height='1' fill='%23594F48' fill-opacity='.2'/%3E%3C/svg%3E");
  line-height: 32px;
  clip-path: polygon(0 4px, 5% 0, 10% 5px, 16% 1px, 22% 6px, 29% 2px, 35% 5px, 42% 0, 49% 5px, 56% 2px, 63% 6px, 70% 1px, 77% 5px, 84% 0, 91% 5px, 96% 2px, 100% 5px,
                       100% calc(100% - 5px), 95% calc(100% - 1px), 89% calc(100% - 6px), 82% calc(100% - 2px), 75% calc(100% - 5px), 67% 100%, 60% calc(100% - 4px), 52% calc(100% - 1px), 45% calc(100% - 6px), 37% calc(100% - 2px), 30% 100%, 23% calc(100% - 5px), 15% calc(100% - 1px), 8% calc(100% - 5px), 0 calc(100% - 2px));
}
.note-body p { margin: 0; }

/* ===== Kraft envelope (letters, password page) ===== */
.envelope {
  position: relative;
  width: min(86vw, 340px);
  aspect-ratio: 3 / 2;
  margin: 28px auto;
  background-color: var(--kraft);
  /* top flap only: a V from the top corners down to the seal (50%, 56%) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0 0 L50 56 L100 0' fill='none' stroke='%23594F48' stroke-opacity='.5' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  box-shadow: var(--shadow);
  border-radius: 2px;
  transform: rotate(1.5deg);
}
.envelope .seal {
  position: absolute; left: 50%; top: 56%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50% 48% 52% 50% / 48% 52% 48% 52%;
  background: var(--tomato);
  box-shadow: var(--shadow);
  transform: rotate(-6deg);
}
.envelope .seal::after { content: ""; position: absolute; inset: 5px; border: 1.5px dashed var(--white); border-radius: 50%; }
.envelope .env-label { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-family: var(--hand); font-size: 1.375rem; line-height: 1.1; }

/* ===== Test-section helpers (removed later) ===== */
.test-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.test-label { font-family: var(--hand); font-size: 1.25rem; color: var(--tomato); margin: 28px 0 4px; }

/* ===== Gate ===== */
.gate {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 20px calc(env(safe-area-inset-bottom) + 16px);
  overflow-y: auto;
}
.gate.gone { opacity: 0; pointer-events: none; transition: opacity .4s ease; }
.gate-env {
  aspect-ratio: auto;
  width: min(92vw, 360px);
  margin: 0;
  padding: 156px 24px 22px;             /* seal bottom (132px) + 24px gap */
  background-image: none;               /* the flap is its own element here */
  transform: rotate(-1.5deg);
}
.gate-env .flap {
  position: absolute; left: 0; right: 0; top: 0; height: 110px;
  transform-origin: top;
  background-color: var(--kraft);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transition: transform .6s ease;
}
.gate-env .flap::after {                 /* V outline, 1px faded ink at 50% */
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0 0 L50 100 L100 0' fill='none' stroke='%23594F48' stroke-opacity='.5' stroke-width='2' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.gate-env .seal { top: 110px; z-index: 2; transition: opacity .25s ease; }
.gate.open .flap { transform: perspective(600px) rotateX(180deg); }
.gate.open .seal { opacity: 0; }
.gate-form { display: flex; flex-direction: column; align-items: stretch; }
.gate-q { display: block; margin-bottom: 8px; text-align: center; font-size: 1.125rem; font-weight: 700; line-height: 1.35; }
.gate .field { text-align: center; }
.gate-msg { min-height: 1.3em; margin: 8px 0 2px; text-align: center; color: var(--tomato); }
.gate-msg.wobble { animation: wobble .5s ease; }
.gate .gate-open { display: block; min-width: 132px; margin: 10px auto 0; }
.gate .gate-open:disabled { opacity: .7; }
.gate-test { margin: 24px 0 0; font-size: 1.125rem; }
@keyframes wobble {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px) rotate(-1.5deg); }
  40% { transform: translateX(6px) rotate(1.5deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(3px) rotate(.5deg); }
}

/* ===== Page shell, progress bar ===== */
#app { opacity: 0; transition: opacity .5s ease; }
#app.in { opacity: 1; }
.progress {
  position: fixed; left: 0; right: 0; top: env(safe-area-inset-top, 0px); z-index: 20;
  height: 3px; background: var(--tomato);
  transform: scaleX(0); transform-origin: left; pointer-events: none;
}

/* ===== Opening ===== */
.opening { display: flex; flex-direction: column; }
.opening .polaroid { width: min(68vw, 270px); margin: 20px auto; }
/* the key line on the cover: a paper note with washi tape and a hand-drawn tomato underline */
.opening-line {
  position: relative; margin: 22px 6px 0; padding: 20px 16px 26px;
  background: var(--white); box-shadow: var(--shadow); border-radius: 2px;
  text-align: center; color: var(--ink); font-size: 1.875rem; line-height: 1.15;
  transform: rotate(-1.5deg);
}
.opening-line::before {                                  /* washi tape strip */
  content: ""; position: absolute; top: -11px; left: 50%; width: 88px; height: 24px; margin-left: -44px;
  background: var(--washi); opacity: .9; transform: rotate(3deg);
  clip-path: polygon(0 8%, 4% 0, 8% 10%, 12% 0, 92% 0, 96% 10%, 100% 0, 100% 92%, 96% 100%, 92% 90%, 88% 100%, 8% 100%, 4% 90%, 0 100%);
}
.opening-line::after {                                   /* hand-drawn underline */
  content: ""; position: absolute; left: 14%; right: 14%; bottom: 9px; height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C30 1 55 9 90 5 S150 2 198 6' fill='none' stroke='%23C8442F' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.opening > .slot { margin-top: 8px; min-height: 44px; padding: 4px 12px; }
.counters { display: grid; gap: 28px; margin-top: 36px; }
.counter { display: flex; align-items: center; gap: 16px; }
.counter:nth-child(even) { flex-direction: row-reverse; text-align: right; }
.counter .postmark { flex: none; }
.counter-line { display: flex; align-items: baseline; gap: .25em; }
.counter:nth-child(even) .counter-line { justify-content: flex-end; }
.counter .num { font-weight: 700; font-size: 2.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter .unit { font-size: 1.25rem; color: var(--faded); }

/* ===== Good moments: native swipe cards ===== */
.deck {
  display: flex; gap: 14px; align-items: flex-start;     /* each card is as tall as its own content */
  margin: 0 -20px; padding: 24px 20px 28px;       /* room for tilt + shadow, bleeds to screen edges */
  overflow-x: auto;
  scroll-snap-type: x mandatory; scroll-padding: 0 20px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }
.deck:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.card {
  position: relative;
  flex: 0 0 85%;
  scroll-snap-align: start; scroll-snap-stop: always;
  padding: 14px 14px 10px;
  background: var(--white);
  box-shadow: var(--shadow);
  border-radius: 2px;
  transform: rotate(-1deg);
}
.card:nth-child(even) { transform: rotate(1deg); }
.card-photo { display: flex; width: 100%; aspect-ratio: 4 / 3; min-height: 0; object-fit: cover; }
.stamp-group { position: absolute; top: -18px; right: 10px; display: flex; align-items: center; gap: 6px; }
.card .postmark { background: var(--white); mix-blend-mode: normal; }   /* multiply made it vanish on dark photos */
.card-time { padding: 0 6px; background: var(--white); color: var(--tomato); font-size: 1.25rem; transform: rotate(-4deg); }
.card-title { margin: 16px 0 6px; font-size: 1.375rem; }
.card .scrap { max-width: 92%; }
.card-note { margin: 10px 0; line-height: 1.25; }
.card-note.small { font-size: 1.25rem; }
.slot-line { min-height: 44px; padding: 4px 12px; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faded); opacity: .35; }
.dot.on { background: var(--tomato); opacity: 1; transform: scale(1.4); }

/* ===== Contents list, ribbon bookmark (back to contents) ===== */
section { scroll-margin-top: 16px; }
.toc { margin: 0; padding: 0; list-style: none; }
.toc a {
  display: flex; align-items: baseline;
  min-height: 48px; padding: 10px 0;                  /* >= 44px tap target */
  color: var(--ink); text-decoration: none;
  font-family: var(--hand); font-size: 1.5rem;
  -webkit-tap-highlight-color: transparent;
}
.toc a:active { color: var(--tomato); }
.toc a:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.toc .leader { display: none; }
.toc .pg { min-width: 1.5em; margin-left: auto; text-align: right; font-family: var(--hand); font-size: 1.375rem; color: var(--tomato); }

.ribbon {
  position: fixed; z-index: 25;
  top: calc(env(safe-area-inset-top, 0px) + 3px);     /* just below the progress bar */
  right: max(12px, env(safe-area-inset-right));
  width: 44px; height: 64px; padding: 0;              /* 44px tap area */
  border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 3px 4px rgba(31, 26, 23, .15));
  opacity: 0; transition: opacity .5s ease;
}
.ribbon { pointer-events: none; }                  /* hidden on the home page and the gate */
.ribbon.in { opacity: 1; pointer-events: auto; }
.ribbon::before {
  content: ""; position: absolute; top: 0; left: 8px; right: 8px; bottom: 6px;
  background: var(--tomato);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}
.ribbon:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

.ribbon-hint {
  position: fixed; z-index: 24; pointer-events: none;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(max(12px, env(safe-area-inset-right)) + 48px);   /* just left of the ribbon */
  display: flex; align-items: center; gap: 4px;
  color: var(--faded); font-family: var(--hand); font-size: 1.25rem; line-height: 1.1; white-space: nowrap;
  opacity: 0; transition: opacity .6s ease;
}
.ribbon-hint.in { opacity: 1; }
.ribbon-hint svg { flex: none; width: 34px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }


/* ===== Places ===== */
.place { margin: 0 0 44px; }
.place-label {
  display: inline-block; margin: 0 0 12px; padding: 6px 18px;
  background: var(--washi); color: var(--ink); opacity: .95;
  font-weight: 600; font-size: 1.0625rem; letter-spacing: .03em;
  clip-path: polygon(0 8%, 3% 0, 6% 10%, 9% 0, 94% 0, 97% 10%, 100% 0, 100% 92%, 97% 100%, 94% 90%, 91% 100%, 6% 100%, 3% 90%, 0 100%);   /* torn tape ends */
}
.place-photos { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; padding: 6px 0 4px; }
.polaroid.mini { width: 46%; margin: 0 -2% 12px; padding: 8px 8px 22px; }
.polaroid.mini:nth-child(even) { margin-top: 22px; }
.polaroid.mini:nth-child(n+3) { margin-top: -6px; }
.polaroid.mini:nth-child(n+4):nth-child(even) { margin-top: 12px; }
.polaroid.mini::before { width: 56px; height: 20px; margin-left: -28px; top: -10px; }
.polaroid.mini .slot { min-height: 0; padding: 4px; font-size: 1.0625rem; }
.polaroid.mini figcaption { min-height: 0; margin-top: -14px; padding: 0; font-size: 1.25rem; }

/* ===== Our numbers ===== */
.numbers-range { margin: -10px 0 18px; font-size: 1.5rem; }
.total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 36px; }
.total-num { font-weight: 700; font-size: 3.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.total .hand { font-size: 1.75rem; }
.pair { margin: 0 0 34px; }
.pair-label { margin: 0 0 6px; font-size: 1.125rem; }
.pair-emoji { margin: 0 0 4px; font-size: 3.25rem; line-height: 1.1; }
.side { margin: 0 0 10px; }
.side-num { display: block; font-weight: 700; font-size: 2rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 16px; min-width: 6px; }
.side-name { display: inline-block; margin: 0 0 2px; padding-bottom: 1px; font-size: 1.375rem; line-height: 1.1; color: var(--ink); border-bottom: 3px solid var(--tomato); }
.side-name.her { border-bottom-color: var(--sage); }
.bar-ink {                                              /* hand-inked stroke: ragged ends, grows from the left */
  position: absolute; inset: 0; transform: scaleX(0); transform-origin: left;
  clip-path: polygon(0 12%, 1.5% 0, 97% 6%, 100% 32%, 98% 58%, 100% 94%, 3% 100%, 0 84%);
}
.bar.me .bar-ink { background: var(--tomato); }
.bar.her .bar-ink { background: var(--sage); }
.go .bar-ink { transform: none; transition: transform .9s cubic-bezier(.2, .7, .2, 1); }
.pair-note { margin: 6px 0 0 14px; color: var(--tomato); font-size: 1.5rem; transform: rotate(-1.5deg); }
.facts { display: grid; gap: 22px; margin: 44px 0; }
.fact { display: flex; align-items: center; gap: 14px; }
.fact:nth-child(even) { flex-direction: row-reverse; text-align: right; }
.fact-num { flex: none; font-weight: 700; font-size: 2.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fact-text { font-size: 1.5rem; line-height: 1.15; }
.fact-detail { display: block; font-size: 1.25rem; }
.nick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 0 0 44px; }
.nick-title { margin: 0 0 6px; color: var(--tomato); font-size: 1.5rem; font-weight: 400; line-height: 1.15; }
.nick-list { margin: 0; padding: 0; list-style: none; font-family: var(--hand); font-size: 1.5rem; line-height: 1.3; }
.nick-list li { display: flex; align-items: baseline; gap: 6px; }
.nick-list .rank { flex: none; width: 1em; color: var(--faded); }
.nick-list .nm { flex: 1; min-width: 0; }
.nick-list .ct { font-family: var(--serif); font-size: 1rem; color: var(--faded); }
.emoji-top { display: grid; gap: 18px; margin-top: 8px; }
.em-who { display: inline-block; margin: 0 0 6px; padding-bottom: 1px; font-size: 1.5rem; line-height: 1.1; border-bottom: 3px solid var(--tomato); }
.em-who.her { border-bottom-color: var(--sage); }
.em-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 4px; text-align: center; }
.em-cell { min-width: 0; }
.em-char { font-size: 1.875rem; line-height: 1.2; }
.em-count { display: block; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }

/* ===== Numbers: sub-parts on torn notes and kraft scraps ===== */
.part-body { background-image: none; line-height: 1.3; padding: 28px 18px 26px; }
.part-body.kraft { background-color: var(--kraft); }
.note.tilt-b { transform: rotate(.7deg); }
.part-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 16px; font-size: 1.375rem; }
.part-tag { color: var(--tomato); font-size: 1.375rem; font-weight: 400; }
.part-body .facts { margin: 6px 0 0; }
.part-body .nick-grid { margin: 0; }
.part-body .pair:last-child { margin-bottom: 0; }
.rbar-row { display: grid; grid-template-columns: 3.2em 1fr 3.6em; align-items: center; gap: 10px; min-height: 36px; }
.rbar-label { font-size: 1.375rem; line-height: 1.1; }
.rbar { position: relative; height: 22px; min-width: 6px; }
.rbar .bar-ink { background: var(--ink); }
.rbar.accent .bar-ink { background: var(--tomato); }
.rbar-num { text-align: right; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.rbar-note { margin: -2px 0 6px 3.2em; color: var(--tomato); font-size: 1.25rem; line-height: 1.15; transform: rotate(-1deg); transform-origin: left; }

/* ===== Our pictures: staggered prints ===== */
.pics-grid { display: flex; gap: 14px; align-items: flex-start; }
.pics-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 26px; }
.pics-col:nth-child(2) { margin-top: 40px; }            /* second column sits lower */
.print { position: relative; margin: 0; padding: 6px; background: var(--white); box-shadow: var(--shadow); border-radius: 2px; }
.print-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.print-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.print-frame { display: block; position: relative; width: 100%; aspect-ratio: 4 / 5; min-height: 0; overflow: hidden; background: var(--kraft); }
.print .slot.print-frame { display: flex; padding: 6px; }
.print-img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.print-cap { margin: 8px 2px 2px; text-align: center; line-height: 1.15; }
.print.tape-l::before, .print.tape-r::after {            /* washi strip on a corner */
  content: ""; position: absolute; z-index: 2; top: -8px; width: 52px; height: 18px;
  background: var(--washi); opacity: .9; pointer-events: none;
  clip-path: polygon(0 8%, 6% 0, 12% 10%, 18% 0, 82% 0, 88% 10%, 94% 0, 100% 8%, 100% 92%, 94% 100%, 88% 90%, 82% 100%, 18% 100%, 12% 90%, 6% 100%, 0 92%);
}
.print.tape-l::before { left: var(--tx, -12px); transform: rotate(var(--tr, -38deg)); }
.print.tape-r::after { right: var(--tx, -12px); transform: rotate(var(--tr, 36deg)); }

/* ===== Full-screen photo viewer ===== */
.viewer { position: fixed; inset: 0; z-index: 40; background-color: var(--paper); background-image: var(--grain); }
.viewer-scroll {
  position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior: contain; touch-action: pan-x;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.viewer-scroll::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%; height: 100dvh; display: flex; flex-direction: column;
  scroll-snap-align: start; scroll-snap-stop: always;
  padding: calc(env(safe-area-inset-top, 0px) + 64px) env(safe-area-inset-right, 0px) calc(env(safe-area-inset-bottom, 0px) + 12px) env(safe-area-inset-left, 0px);
}
.slide-box { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.slide-box img { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100dvh - 190px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); padding: 10px; background: var(--white); box-shadow: var(--shadow); border-radius: 2px; transform: rotate(-.6deg); }
.slide-cap { flex: none; min-height: 2.4em; margin: 0; padding: 8px 16px 0; text-align: center; color: var(--ink); font-size: 1.5rem; }
.viewer-close { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top, 0px) + 10px); left: max(12px, env(safe-area-inset-left)); }
.viewer-open { overflow: hidden; }
.viewer-open .ribbon, .viewer-open .ribbon-hint { visibility: hidden; }
.paper-label {
  pointer-events: auto; min-width: 44px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 2px; background: var(--white); color: var(--ink);
  font-family: var(--hand); font-size: 1.5rem; box-shadow: var(--shadow); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.paper-label:first-child { transform: rotate(-2deg); }
.paper-label:last-child { transform: rotate(1.5deg); }
.paper-label:focus-visible { outline: 2px solid var(--tomato); outline-offset: 2px; }

/* ===== Pages: one view visible at a time ===== */
.view { display: none; }
.view:focus { outline: none; }
.view.on { display: block; animation: page-turn .3s ease both; }
@keyframes page-turn {                                  /* opacity + a small slide and turn only */
  from { opacity: 0; transform: translateX(14px) rotate(.6deg); }
  to   { opacity: 1; transform: none; }
}
/* end of every chapter: the next-page card, then a small link back */
.chapter-nav { padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
.end-card { display: block; margin: 8px 0 6px; color: var(--ink); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.end-card:active { transform: rotate(-.8deg) translateY(1px); }
.end-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.end-body { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 96px; background-image: none; line-height: 1.2; padding: 26px 22px; }
.end-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.end-label { font-size: 1rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faded); }
.end-title { font-weight: 700; font-size: 1.5rem; line-height: 1.15; }
.end-arrow { flex: none; width: 44px; height: 32px; fill: none; stroke: var(--tomato); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.back-link {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 4px;
  color: var(--faded); text-decoration: none; font-size: 1.375rem;
  -webkit-tap-highlight-color: transparent;
}
.back-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== Home: compact cover + contents ===== */
.opening.compact { margin: 0 0 18px; }
.opening.compact .polaroid { width: min(45vw, 200px); margin: 14px auto 8px; }
.opening.compact .polaroid.wide { width: min(88vw, 340px); }   /* a wide photo gets a wider print */
.opening.compact .opening-line { margin: 22px 4px 0; font-size: 1.75rem; }
.opening.compact > .slot { margin-top: 4px; }
.opening.compact .counters { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.counter.compact, .counter.compact:nth-child(even) { flex-direction: column; align-items: center; gap: 0; text-align: center; }
.counter.compact .counter-line, .counter.compact:nth-child(even) .counter-line { justify-content: center; }
.counter.compact .num { font-size: 2.25rem; }
.counter.compact .unit { font-size: 1.125rem; }
.counter.compact .hand { font-size: 1.25rem; line-height: 1.1; }
.toc-body { background-image: none; line-height: 1.2; padding: 20px 20px 12px; }   /* rows are 48px, so no ruled lines */
.toc-body .heading { margin-bottom: 4px; padding-bottom: 10px; font-size: 1.375rem; }

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

/* ===== Quiz ===== */
.qdots { gap: 6px; margin: 0 0 22px; }
.qdots .dot { width: 10px; height: 10px; }
.qdots .dot.done { background: var(--tomato); opacity: .55; }
.quiz-q { margin: 0 0 20px; font-size: 1.375rem; line-height: 1.3; }
.quiz-q:focus { outline: none; }
.answers { display: grid; gap: 12px; }
.ans {
  position: relative; width: 100%; min-height: 56px; padding: 12px 52px 12px 16px;
  border: 0; border-radius: 2px; background: var(--white); color: var(--ink);
  box-shadow: var(--shadow); text-align: left; cursor: pointer;
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.3;
  transform: rotate(var(--r, 0deg));
  -webkit-tap-highlight-color: transparent;
  transition: opacity .2s ease;
}
.ans:active { transform: rotate(var(--r, 0deg)) scale(.98); }
.ans:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ans.miss { opacity: .65; }
.ans.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: rotate(var(--r, 0deg)); }
  25% { transform: rotate(var(--r, 0deg)) translateX(-6px); }
  50% { transform: rotate(var(--r, 0deg)) translateX(6px); }
  75% { transform: rotate(var(--r, 0deg)) translateX(-3px); }
}
.tick {
  position: absolute; right: 14px; top: 50%; width: 28px; height: 24px; margin-top: -12px;
  fill: none; stroke: var(--tomato); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  animation: tick-pop .35s ease both;
}
@keyframes tick-pop { from { opacity: 0; transform: scale(.4) rotate(-12deg); } to { opacity: 1; transform: none; } }
.after { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 20px; }
.explain { margin: 0; align-self: stretch; color: var(--faded); }
.quiz-next { margin-top: 4px; }
.quiz-result { display: flex; flex-direction: column; align-items: center; text-align: center; }
.quiz-result:focus { outline: none; }
.quiz-score { margin: 0 0 4px; }
.quiz-score-num { font-weight: 700; font-size: 3.25rem; line-height: 1.1; color: var(--tomato); }
.quiz-score-of { font-size: 1.25rem; color: var(--faded); }
.quiz-remark { margin: 4px 0 0; font-size: 1.75rem; line-height: 1.2; color: var(--ink); }
.letter-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 8px;
  color: var(--tomato); text-decoration: none; font-size: 1.625rem;
  -webkit-tap-highlight-color: transparent;
}
.letter-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.quiz-again.paper-label { min-height: 48px; margin: 4px 0 0; background: none; box-shadow: none; color: var(--faded); font-size: 1.375rem; text-decoration: underline; text-underline-offset: 4px; transform: none; }

/* ===== Letter lock, padlock in contents ===== */
.letter-locked { text-align: center; }
.letter-locked[hidden], .letter-open[hidden], .lock[hidden] { display: none; }
.letter-sign { margin: 8px 0 0; text-align: right; font-size: 1.75rem; }
.lock { position: relative; display: inline-block; align-self: center; width: 20px; height: 20px; margin-left: 12px; border-radius: 50% 48% 52% 50% / 48% 52% 48% 52%; background: var(--tomato); transform: rotate(-6deg); box-shadow: 0 1px 3px rgba(31, 26, 23, .2); }
.lock::after { content: ""; position: absolute; inset: 3px; border: 1.5px dashed var(--white); border-radius: 50%; }

/* ===== Lined notebook page (letters) ===== */
.poem-body { position: relative; padding: 32px 20px 32px 44px; }
.poem-body::before { content: ""; position: absolute; left: 30px; top: 0; bottom: 0; width: 1px; background: var(--tomato); opacity: .45; }
.poem-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 32px; }
.poem-body .slot { min-height: 64px; }

/* ===== Envelopes that open (letters page, "For you") ===== */
.lenv { background-image: none; width: min(86vw, 340px); }
.lenv .peek {                                           /* edge of the paper, shows once the flap is up */
  position: absolute; left: 7%; right: 7%; top: 8px; height: 34px; background: var(--white);
  box-shadow: inset 0 -1px 0 rgba(89, 79, 72, .25); opacity: 0; transition: opacity .3s ease;
}
.lenv .flap {
  position: absolute; left: 0; right: 0; top: 0; height: 56%; z-index: 1;
  background-color: var(--kraft); clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .6s var(--ease-paper-fold), opacity .5s ease .1s;
}
.lenv .flap::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0 0 L50 100 L100 0' fill='none' stroke='%23594F48' stroke-opacity='.5' stroke-width='2' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.lenv .seal { z-index: 2; transition: opacity .25s ease; }
.lenv .env-label { z-index: 2; }
.lenv.open .flap { transform: perspective(600px) rotateX(180deg); opacity: 0; }
.lenv.open .seal { opacity: 0; }
.lenv.open .peek { opacity: 1; }

.letter-card { margin: 0 0 36px; }
.env-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.env-btn .lenv { margin: 12px auto; }
.env-btn:active .lenv { opacity: .9; }
.env-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.letter-paper:not([hidden]) { animation: paper-up .5s var(--ease-paper-drop) both; }
@keyframes paper-up { from { opacity: 0; transform: translateY(36px); } to { opacity: 1; transform: none; } }
.letter-photo { display: block; width: 100%; height: auto; }
.letter-photo + .letter-photo { margin-top: 12px; }
.poem-body.photos { padding: 20px 14px; }
.poem-body.photos::before { content: none; }
.letter-slot { min-height: 160px; }
.fold-row { text-align: center; margin: 4px 0 8px; }
.fold-row .paper-label { min-height: 48px; }
.letter-open .lenv { margin: 12px auto 4px; }

/* ===== Signature + hidden line ===== */
.sign { margin-top: 32px; }
.sign-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sign-hint { font-size: 1.25rem; opacity: .6; transition: opacity .3s ease; }
.sign-hint.gone { opacity: 0; pointer-events: none; }
.sign-btn {
  min-width: 44px; min-height: 48px; margin-left: auto; padding: 0 4px; border: 0; background: none; cursor: pointer;
  font-size: 2rem; line-height: 1.2; color: var(--ink); text-align: right; -webkit-tap-highlight-color: transparent;
}
.sign-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sign-hidden { margin: 4px 0 0; text-align: right; font-size: 1.75rem; line-height: 1.2; color: var(--tomato); opacity: 0; transition: opacity .8s ease; }
.sign-hidden.slot { font-size: 1.25rem; }
.sign-hidden.on { opacity: 1; }

/* ===== Intro line under a page heading ===== */
.page-intro { margin: -8px 0 22px; color: var(--tomato); font-size: 1.5rem; line-height: 1.2; transform: rotate(-.8deg); }

/* ===== "click here to close the letter" hint, shown under an open envelope ===== */
.close-hint {
  display: block; width: 100%; min-height: 48px; margin: 0 0 6px; padding: 0 8px;
  border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  color: var(--tomato); font-size: 1.5rem; line-height: 1.2; text-align: center;
}
.close-hint[hidden] { display: none; }
.close-hint:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== Places: a polaroid is a button that opens the full-screen viewer ===== */
.polaroid.mini .place-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.polaroid.mini .place-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== Motion: paper lands and tape is pressed down by a thumb ===== */
.will-reveal { opacity: 0; }
.will-reveal.landed { animation: paper-land .45s var(--ease-paper-drop) both; }
.print.will-reveal.landed::before, .print.will-reveal.landed::after, .polaroid.mini.will-reveal.landed::before { animation: tape-slap .3s var(--ease-wax-press) .25s both; }
@keyframes paper-land { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
@keyframes tape-slap { 0% { opacity: 0; scale: 1.3; } 70% { opacity: 1; scale: .96; } 100% { opacity: .9; scale: 1; } }

/* ===== Quiz polish ===== */
.quiz-count { margin: 0 0 14px; text-align: center; color: var(--tomato); font-size: 1.5rem; line-height: 1.1; transform: rotate(-1deg); }
.end-card[hidden] { display: none; }

/* =====================================================================
   BOLDER SCRAPBOOK: layered paper, tape on every note, pencil doodles
   (all hand-drawn lines use only the site colours)
   ===================================================================== */
:root {
  --doodle-sparkle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23C8442F' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M14 3v8M4 9l6 4M24 7l-6 5'/%3E%3C/svg%3E");
  --doodle-circle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 60' preserveAspectRatio='none' fill='none' stroke='%23C8442F' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath vector-effect='non-scaling-stroke' d='M62 4C100 2 118 18 114 34 110 52 76 58 50 56 18 54 4 40 8 24 12 10 36 6 68 8'/%3E%3C/svg%3E");
  --doodle-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40' fill='none' stroke='%23594F48' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8C20 2 44 8 48 30M40 24l8 7 5-10'/%3E%3C/svg%3E");
  --doodle-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath fill='%23C8442F' d='M12 20C2 12 2 4 8 3c3-.5 4 2 4 3 0-1 1-3.500 4-3 6 1 6 9-4 17z'/%3E%3C/svg%3E");
  --doodle-underline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C30 1 55 9 90 5 S150 2 198 6' fill='none' stroke='%23C8442F' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  --tape-clip: polygon(0 8%, 4% 0, 8% 10%, 12% 0, 92% 0, 96% 10%, 100% 0, 100% 92%, 96% 100%, 92% 90%, 88% 100%, 8% 100%, 4% 90%, 0 100%);
}

/* every page heading gets a little pencil sparkle */
.heading { position: relative; }
.heading::after { content: ""; position: absolute; right: -32px; top: -10px; width: 26px; height: 26px; background: var(--doodle-sparkle) 0 0 / 100% 100% no-repeat; opacity: .85; }

/* washi tape on every torn note (contents, letters, numbers, "next page") */
.note::before {
  content: ""; position: absolute; z-index: 2; top: -12px; left: 16%; width: 88px; height: 24px;
  background: var(--washi); opacity: .92; transform: rotate(var(--tape-rot, -4deg)); clip-path: var(--tape-clip); pointer-events: none;
}
.note.tilt-b::before { left: auto; right: 14%; --tape-rot: 5deg; }
.end-card::before { left: auto; right: 22%; --tape-rot: 3deg; }

/* stacked paper: a kraft sheet (and a sage one) peeking out from behind */
.opening.compact .polaroid { box-shadow: 7px 8px 0 -3px var(--kraft), 13px 15px 0 -6px var(--sage), var(--shadow); }
.card { box-shadow: 6px 8px 0 -4px var(--kraft), var(--shadow); }
.card::before {                                       /* tape holding each memory card */
  content: ""; position: absolute; z-index: 3; top: -11px; left: 22px; width: 78px; height: 22px;
  background: var(--washi); opacity: .92; transform: rotate(-7deg); clip-path: var(--tape-clip); pointer-events: none;
}
.card:nth-child(even)::before { left: 38px; transform: rotate(5deg); }
.card:nth-child(3n)::before { left: 30px; width: 90px; transform: rotate(-2deg); }

/* cover: the day counters are circled in pencil */
.counter-line { position: relative; }
.counter-line::after { content: ""; position: absolute; left: -14px; right: -14px; top: -8px; bottom: -10px; background: var(--doodle-circle) 0 0 / 100% 100% no-repeat; opacity: .75; pointer-events: none; }

/* places: an arrow from each tape label down to its photos */
.place-arrow { display: inline-block; width: 58px; height: 38px; margin: 0 0 8px 8px; vertical-align: middle; background: var(--doodle-arrow) 0 0 / 100% 100% no-repeat; opacity: .8; }

/* our numbers: the big total is underlined in red pencil */
.total-num { position: relative; display: inline-block; }
.total-num::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 10px; background: var(--doodle-underline) 0 0 / 100% 100% no-repeat; }

/* quiz result: little sparkles beside the score */
.quiz-score { position: relative; display: inline-block; }
.quiz-score::before, .quiz-score::after { content: ""; position: absolute; top: -2px; width: 28px; height: 28px; background: var(--doodle-sparkle) 0 0 / 100% 100% no-repeat; }
.quiz-score::before { left: -36px; }
.quiz-score::after { right: -34px; transform: scaleX(-1); }

/* letters: every envelope carries a postage stamp and a postmark */
.lenv::before {
  content: ""; position: absolute; z-index: 2; top: 12px; right: 14px; width: 40px; height: 50px;
  background: var(--white) var(--doodle-heart) center / 52% no-repeat; outline: 3px dotted var(--white); outline-offset: 1px; transform: rotate(3deg);
}
.lenv::after {
  content: ""; position: absolute; z-index: 2; top: 30px; right: 44px; width: 58px; height: 58px; border: 2px solid var(--tomato); border-radius: 50%; opacity: .5; transform: rotate(-12deg);
  box-shadow: inset 0 0 0 4px var(--kraft), inset 0 0 0 5px var(--tomato);
}

/* ===== Cover caption: a pen script, like writing on the white strip of a polaroid ===== */
.opening .polaroid figcaption { font-family: var(--script); font-size: clamp(1.25rem, 6.4vw, 1.625rem); line-height: 1.3; white-space: nowrap; color: var(--ink); padding-top: 12px; }   /* one line, scales with the screen */

/* ===== Music label (only when content.js has a song) ===== */
.music-btn { position: fixed; z-index: 24; left: max(12px, env(safe-area-inset-left)); bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); min-height: 44px; padding: 0 14px; font-size: 1.25rem; opacity: .92; }
.music-btn[hidden] { display: none; }
.viewer-open .music-btn { visibility: hidden; }
/* ===== Small line under the quiz result picture ===== */
.quiz-result .polaroid figcaption.quiz-caption { min-height: 0; padding: 8px 4px 6px; font-size: 1.25rem; line-height: 1.2; color: var(--faded); text-wrap: balance; }

/* ===== Our edits: the same prints, with a play mark; videos in the full-screen viewer ===== */
.play-mark { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--white); box-shadow: var(--shadow); pointer-events: none; }
.play-mark::before { content: ""; position: absolute; left: 17px; top: 12px; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent var(--tomato); }
.slide-box { position: relative; }
.slide-box video { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100dvh - 190px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); padding: 10px; background: var(--white); box-shadow: var(--shadow); border-radius: 2px; transform: rotate(-.6deg); cursor: pointer; }
.slide-mark { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: var(--white); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.slide-mark::before { content: ""; position: absolute; left: 21px; top: 15px; border-style: solid; border-width: 13px 0 13px 21px; border-color: transparent transparent transparent var(--tomato); }
.slide-mark.paused { opacity: .95; }
.slide-mark.loading { opacity: .95; }
.slide-mark.loading::before { content: none; }
.slide-mark.loading::after { content: "loading…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--hand); font-size: 1.125rem; color: var(--faded); }
.viewer-sound { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top, 0px) + 10px); right: max(12px, env(safe-area-inset-right)); }
.viewer-sound[hidden] { display: none; }
