/* Curio (docs/DESIGN.md → Tokens is the source of truth for every value
   here and in ios/Curio/Assets.xcassets/Colors). Light is the default; dark
   applies with the system setting unless the page chose Light, or whenever
   the page chose Dark. theme.ts sets data-theme before the first paint. */
@font-face { font-family: "Fredoka"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("/fonts/fredoka-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Fredoka"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("/fonts/fredoka-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 600 800; font-display: swap; src: url("/fonts/nunito-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 600 800; font-display: swap; src: url("/fonts/nunito-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --ground: #FFF9F0;
  --surface: #FFFFFF;
  --border: #EDE6DA;
  --ink: #211E3B;
  --muted: #5B5775;
  --label: #6B6785;
  --placeholder: #7A7690;
  --accent-fill: #4F46C9;
  --on-accent: #FFFFFF;
  --accent-text: #4F46C9;
  --accent-heading: #4F46C9;
  --accent-tint: #E6E1FF;
  --connector: #CFC8FF;
  --upcoming-connector: #E4DFD3;
  --upcoming: #9A95B5;
  --locked: #D6CFC2;
  --success: #1F7A45;
  --heart: #E0554A;
  --icon-disc: #FFFFFF;
  --sun: #FFCF6E;
  --sparkle: #FFFFFF;
  --field-dim: #EFE8F3; --field-mid: #E2D9F6; --field-lit: #C3B8F4; --field-crest: #8F85EA;
  --danger: #B3261E;
  --danger-tint: #FDECEA;
  --scrim: rgba(33, 30, 59, 0.4);
  --halo-opacity: 0.5;
  --weather-fill: #DCEBFB; --weather-ink: #1D5FA8;
  --animals-fill: #DBF3E3; --animals-ink: #1F7A45;
  --space-fill: #E6E1FF; --space-ink: #4F46C9;
  --sound-fill: #FFE3D6; --sound-ink: #B8452E;
  --light-fill: #FCEBC4; --light-ink: #8A5A00;
  --body-fill: #FADCE8; --body-ink: #A8336B;
  --earth-fill: #F1E7D6; --earth-ink: #7A5424;
  --electricity-fill: #D9F2F1; --electricity-ink: #116B69;
  --forces-fill: #E3E8EF; --forces-ink: #3E5A7A;
  --matter-fill: #EEE2F7; --matter-ink: #77389F;
  --plants-fill: #E6F2D2; --plants-ink: #4A6E12;
  --font-display: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif;
  --font-body: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --border-width: 1.5px;
  --radius-card: 20px;
  --radius-chip: 14px;
  --radius-bar: 24px;
  --toolbar-h: 64px;
  --column: 680px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #17152A;
  --surface: #221F3A;
  --border: #332F52;
  --ink: #F3F0FF;
  --muted: #A9A4C6;
  --label: #8E89AE;
  --placeholder: #8E89AE;
  --accent-fill: #6A61E8;
  --on-accent: #FFFFFF;
  --accent-text: #A9A2FF;
  --accent-heading: #B1AAFF;
  --accent-tint: #2A2652;
  --connector: #3E3870;
  --upcoming-connector: #332F52;
  --upcoming: #8E89AE;
  --locked: #3E3870;
  --success: #6FCF97;
  --heart: #FF7A6E;
  --icon-disc: #17152A;
  --sun: #FFCF6E;
  --sparkle: #F3F0FF;
  --field-dim: #221F3B; --field-mid: #2D2952; --field-lit: #474093; --field-crest: #8A82F5;
  --danger: #FF9A93;
  --danger-tint: #3A1F24;
  --scrim: rgba(0, 0, 0, 0.55);
  --halo-opacity: 0.12;
  --weather-fill: #1C2E48; --weather-ink: #8FC3FF;
  --animals-fill: #1B3326; --animals-ink: #7ED9A1;
  --space-fill: #2A2652; --space-ink: #B1AAFF;
  --sound-fill: #3D2420; --sound-ink: #FFA48D;
  --light-fill: #3A2E12; --light-ink: #FFD37A;
  --body-fill: #3B1F2D; --body-ink: #FF9CC4;
  --earth-fill: #33291B; --earth-ink: #E0B98A;
  --electricity-fill: #163332; --electricity-ink: #7AD6D2;
  --forces-fill: #1F2733; --forces-ink: #A9C1DD;
  --matter-fill: #2F2140; --matter-ink: #D3A6F0;
  --plants-fill: #25321A; --plants-ink: #B5D986;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --ground: #17152A;
    --surface: #221F3A;
    --border: #332F52;
    --ink: #F3F0FF;
    --muted: #A9A4C6;
    --label: #8E89AE;
    --placeholder: #8E89AE;
    --accent-fill: #6A61E8;
    --on-accent: #FFFFFF;
    --accent-text: #A9A2FF;
    --accent-heading: #B1AAFF;
    --accent-tint: #2A2652;
    --connector: #3E3870;
    --upcoming-connector: #332F52;
    --upcoming: #8E89AE;
    --locked: #3E3870;
    --success: #6FCF97;
    --heart: #FF7A6E;
    --icon-disc: #17152A;
    --sun: #FFCF6E;
    --sparkle: #F3F0FF;
    --field-dim: #221F3B; --field-mid: #2D2952; --field-lit: #474093; --field-crest: #8A82F5;
    --danger: #FF9A93;
    --danger-tint: #3A1F24;
    --scrim: rgba(0, 0, 0, 0.55);
    --halo-opacity: 0.12;
    --weather-fill: #1C2E48; --weather-ink: #8FC3FF;
    --animals-fill: #1B3326; --animals-ink: #7ED9A1;
    --space-fill: #2A2652; --space-ink: #B1AAFF;
    --sound-fill: #3D2420; --sound-ink: #FFA48D;
    --light-fill: #3A2E12; --light-ink: #FFD37A;
    --body-fill: #3B1F2D; --body-ink: #FF9CC4;
    --earth-fill: #33291B; --earth-ink: #E0B98A;
    --electricity-fill: #163332; --electricity-ink: #7AD6D2;
    --forces-fill: #1F2733; --forces-ink: #A9C1DD;
    --matter-fill: #2F2140; --matter-ink: #D3A6F0;
    --plants-fill: #25321A; --plants-ink: #B5D986;
  }
}

/* Base */
* { box-sizing: border-box; }
html { background: var(--ground); }
body { margin: 0; background: var(--ground); color: var(--ink); min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, textarea, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:where(button, textarea, select, input, a):focus-visible { outline: 3px solid var(--accent-text); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.icon { display: inline-flex; flex-shrink: 0; }
.icon svg, .icon-button svg, .send svg { width: 100%; height: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; transform: translateY(-200%); z-index: 20; padding: 12px; background: var(--surface); border: 2px solid var(--accent-text); border-radius: 8px; color: var(--ink); }
.skip-link:focus { transform: none; }

/* Category colours: spark cards, illustrations, stamps. */
.cat-weather { --cat-fill: var(--weather-fill); --cat-ink: var(--weather-ink); }
.cat-animals { --cat-fill: var(--animals-fill); --cat-ink: var(--animals-ink); }
.cat-space { --cat-fill: var(--space-fill); --cat-ink: var(--space-ink); }
.cat-sound { --cat-fill: var(--sound-fill); --cat-ink: var(--sound-ink); }
.cat-light { --cat-fill: var(--light-fill); --cat-ink: var(--light-ink); }
.cat-body { --cat-fill: var(--body-fill); --cat-ink: var(--body-ink); }
.cat-earth { --cat-fill: var(--earth-fill); --cat-ink: var(--earth-ink); }
.cat-electricity { --cat-fill: var(--electricity-fill); --cat-ink: var(--electricity-ink); }
.cat-forces { --cat-fill: var(--forces-fill); --cat-ink: var(--forces-ink); }
.cat-matter { --cat-fill: var(--matter-fill); --cat-ink: var(--matter-ink); }
.cat-plants { --cat-fill: var(--plants-fill); --cat-ink: var(--plants-ink); }

/* Shared controls */
.icon-button {
  flex-shrink: 0; width: 44px; height: 44px; padding: 11px; border-radius: 50%;
  background: var(--surface); border: var(--border-width) solid var(--border); color: var(--muted);
  display: grid; place-items: center;
}
.icon-button.accent { color: var(--accent-text); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 18px;
  background: var(--surface); border: var(--border-width) solid var(--border);
  color: var(--accent-text); font-size: 14px; font-weight: 800;
}
.pill .icon { width: 16px; height: 16px; }
.pill:disabled { opacity: .6; }
.primary, .secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px;
  border-radius: 26px; font-size: 17px; font-weight: 800;
}
.primary { border: 0; background: var(--accent-fill); color: var(--on-accent); }
.secondary { background: var(--surface); border: var(--border-width) solid var(--border); color: var(--accent-text); font-size: 16px; }
.primary .icon, .secondary .icon { width: 18px; height: 18px; }
/* Pointer devices: the border turns accent on hover; no shadows. */
@media (hover: hover) {
  .icon-button:hover, .pill:not(:disabled):hover, .secondary:hover, .chip:not(:disabled):hover, .spark-card:not(:disabled):hover, .rail-step:hover, .earlier-trail:not(:disabled):hover { border-color: var(--accent-text); }
  .resume-card:not(:disabled):hover, .primary:hover { filter: brightness(1.06); }
}

/* Pixel field: a science scene in the bottom half of Home and Trail
   (field-worker.ts), fixed behind the content and reaching the bottom edge
   behind the see-through bar. It never takes pointer events. */
.pixel-field { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 50vh; z-index: 0; pointer-events: none; }
body[data-view="stamps"] .pixel-field { display: none; }
/* Trail complete: the whole screen, for the stamp celebration burst. */
body[data-view="complete"] .pixel-field { top: 0; height: 100vh; }
/* The page scrolls inside <main>, not the window, so the content can fade
   out just above the bar (a mask, sized by the bar's height, which app.ts
   keeps in --dock-h) while the pixels behind stay visible to the bottom. */
main { position: fixed; inset: 0; z-index: 1; overflow-y: auto; overscroll-behavior: contain; }
body[data-dock="true"] main {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--dock-h, 90px) - 20px), transparent calc(100% - var(--dock-h, 90px) + 6px));
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--dock-h, 90px) - 20px), transparent calc(100% - var(--dock-h, 90px) + 6px));
}

/* Screens: one column (phone); wider layouts in the breakpoints below. */
.screen { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 20px 136px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: .01em; }
.brand-mark { width: 36px; height: 36px; padding: 8px; border-radius: 11px; background: var(--accent-fill); color: var(--on-accent); display: grid; place-items: center; }
.brand-mark svg { width: 100%; height: 100%; }

/* Home */
.greeting { margin-top: 18px; font-family: var(--font-display); font-size: 27px; line-height: 32px; font-weight: 700; }
.resume-card {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; width: 100%; margin-top: 18px; padding: 16px 18px;
  border: 0; border-radius: var(--radius-card); background: var(--accent-fill); color: var(--on-accent); text-align: left;
}
.resume-label, .resume-question { grid-column: 1 / -1; }
.resume-label { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.resume-question { font-family: var(--font-display); font-size: 18px; line-height: 22px; font-weight: 600; }
.resume-row { display: flex; align-items: center; gap: 12px; min-width: 0; margin-top: 2px; }
.dots { display: flex; gap: 5px; flex-shrink: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--on-accent); opacity: .6; }
.dot.done { background: var(--on-accent); opacity: 1; }
.resume-step { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-go { display: flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 800; }
.resume-go .icon { width: 18px; height: 18px; }
/* Earlier unfinished trails, under the resume card. */
.earlier-trails { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.earlier-trails:empty { display: none; }
.earlier-trail {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 14px;
  border-radius: var(--radius-chip); background: var(--surface); border: var(--border-width) solid var(--border);
  color: var(--ink); text-align: left;
}
.earlier-trail:disabled { opacity: .6; }
.earlier-disc { flex-shrink: 0; width: 36px; height: 36px; padding: 9px; border-radius: 50%; background: var(--cat-fill); color: var(--cat-ink); display: grid; place-items: center; }
.earlier-disc svg { width: 100%; height: 100%; }
.earlier-words { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.earlier-question { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.earlier-step { font-size: 12px; font-weight: 700; color: var(--label); }
.earlier-trail > .icon { width: 16px; height: 16px; color: var(--accent-text); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.section-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.sparks-error { margin-top: 10px; color: var(--danger); }
.spark-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.spark-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 148px; padding: 14px;
  border: var(--border-width) solid transparent; border-radius: var(--radius-card);
  background: var(--cat-fill); color: var(--ink); text-align: left;
}
.spark-card:disabled { opacity: .7; }
.spark-card { position: relative; }
.new-stamp {
  position: absolute; top: 12px; right: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-fill); color: var(--on-accent); font-size: 11px; font-weight: 800; letter-spacing: .02em;
}
/* Six sparks load on wide layouts; if the window narrows, show four. */
.spark-grid .spark-card:nth-child(n+5) { display: none; }
.icon-disc { width: 40px; height: 40px; padding: 9px; border-radius: 50%; background: var(--icon-disc); color: var(--cat-ink); display: grid; place-items: center; }
.icon-disc svg { width: 100%; height: 100%; }
.spark-words { display: flex; flex-direction: column; gap: 3px; }
.spark-topic { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--cat-ink); }
.spark-question { font-size: 15px; line-height: 19px; font-weight: 700; }
.made-with-love { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 12px; font-weight: 700; color: var(--label); }
.made-with-love .icon { width: 13px; height: 13px; }
.heart { fill: var(--heart); }

/* Bottom bar: see-through, over the pixel field; the content fades out
   above it instead (main's mask). */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
}
.dock > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.compose { display: flex; align-items: flex-end; gap: 10px; }
.compose textarea {
  flex: 1; resize: none; min-height: 48px; max-height: 160px; padding: 12px 18px; border-radius: var(--radius-bar);
  background: var(--surface); border: 2px solid var(--connector); color: var(--ink);
  font-size: 16px; font-weight: 600; line-height: 1.4;
}
.compose textarea::placeholder { color: var(--placeholder); opacity: 1; }
.send {
  flex-shrink: 0; width: 48px; height: 48px; padding: 13px; border-radius: 50%; border: 0;
  background: var(--accent-fill); color: var(--on-accent); display: grid; place-items: center;
}
/* Accent only when there is something to send. */
.send:disabled { background: var(--border); color: var(--placeholder); }
#cancel { padding: 14px; }
.disclaimer { text-align: center; font-size: 11px; font-weight: 700; color: var(--label); margin-top: 6px; }
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .dock { background: var(--ground); }
}

/* Trail */
.trail-title { min-width: 0; text-align: center; display: flex; flex-direction: column; gap: 1px; }
.trail-title h1 { font-family: var(--font-display); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trail-title p, .caption { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--label); }
.trail { display: flex; flex-direction: column; margin-top: 14px; }
.rail-step {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 0 12px 0 0;
  border: var(--border-width) solid transparent; border-radius: 12px; background: transparent; color: var(--muted); text-align: left;
}
.rail-step .icon { width: 16px; height: 16px; }
.rail-question { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-step[aria-expanded="true"] .rail-question { white-space: normal; }
.rail-answer { display: flex; align-items: flex-start; gap: 12px; padding: 4px 0 8px 38px; }
.rail-answer .answer { margin: 0; font-size: 16px; line-height: 24px; flex: 1; }
.step-disc {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent-text); font-size: 13px; font-weight: 800;
}
.step-disc.current { background: var(--accent-fill); color: var(--on-accent); margin-top: 3px; }
.connector { width: 2px; height: 10px; margin-left: 12px; border-radius: 1px; background: var(--connector); }
.current-head { display: flex; align-items: flex-start; gap: 12px; margin-top: 2px; }
.current-question { flex: 1; min-width: 0; font-family: var(--font-display); font-size: 24px; line-height: 29px; font-weight: 600; color: var(--accent-heading); }
.current-head .speak { margin-top: -6px; }
.speak[aria-pressed="true"] { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.illustration { margin-top: 14px; aspect-ratio: 350 / 124; border-radius: 18px; background: var(--cat-fill); overflow: hidden; }
.illustration > svg { display: block; width: 100%; height: 100%; }
.illustration .sparkle { fill: var(--sparkle); opacity: .9; }
.illustration .halo { fill: var(--sparkle); opacity: var(--halo-opacity); }
.illustration .disc { fill: var(--icon-disc); }
.illustration .glyph { color: var(--cat-ink); }
.answer { margin-top: 14px; font-size: 17px; line-height: 26px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.dive-label { margin-top: 14px; font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--label); }
.dive-chips { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.chip {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: var(--radius-chip); background: var(--surface); border: var(--border-width) solid var(--border);
  color: var(--accent-text); font-size: 15px; line-height: 19px; font-weight: 700; text-align: left;
}
.chip-text { flex: 1; }
.chip .icon { width: 18px; height: 18px; }
.chip:disabled { opacity: .6; }
/* Phones show two choices; wider layouts show all three. */
.dive-chips .chip:nth-child(n+3) { display: none; }
.finish { margin-top: 20px; }
.loading { display: flex; align-items: center; gap: 16px; color: var(--muted); padding: 16px 0; }
/* A 3×3 pixel "thinking" animation (compositor-only: opacity and transform). */
.thinking { flex-shrink: 0; display: grid; grid-template-columns: repeat(3, 8px); gap: 3px; }
.thinking-pixel { width: 8px; height: 8px; border-radius: 2px; background: var(--field-crest); animation: think 1.2s ease-in-out infinite; }
.thinking-pixel:nth-child(2), .thinking-pixel:nth-child(4) { animation-delay: .15s; }
.thinking-pixel:nth-child(3), .thinking-pixel:nth-child(5), .thinking-pixel:nth-child(7) { animation-delay: .3s; }
.thinking-pixel:nth-child(6), .thinking-pixel:nth-child(8) { animation-delay: .45s; }
.thinking-pixel:nth-child(9) { animation-delay: .6s; }
@keyframes think { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: none; } }
.loading-words { display: flex; flex-direction: column; gap: 4px; }
.loading-title { font-weight: 700; }
.fact-line { font-size: 15px; line-height: 21px; color: var(--ink); }
.error { margin-top: 14px; padding: 16px; border-radius: var(--radius-card); background: var(--danger-tint); color: var(--danger); display: flex; flex-direction: column; align-items: flex-start; gap: 12px; line-height: 1.5; }

/* Trail complete */
.complete { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.header-spacer { width: 44px; height: 44px; }
.stamp-hero {
  width: 156px; height: 156px; margin: 26px auto 0; padding: 30px; border-radius: 50%;
  background: var(--cat-fill); border: 5px solid var(--accent-fill); color: var(--cat-ink);
}
.stamp-hero svg { width: 100%; height: 100%; stroke-width: 1.6; }
/* The new stamp lands (once per trail; off with Reduce Motion). */
.stamp-hero.landing { animation: stamp-land .75s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes stamp-land { from { transform: scale(.2) rotate(-18deg); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
.complete h1 { margin-top: 20px; text-align: center; font-family: var(--font-display); font-size: 30px; line-height: 34px; font-weight: 700; }
.complete-sub { margin: 8px auto 0; max-width: 300px; text-align: center; font-size: 16px; line-height: 23px; color: var(--muted); }
.recap { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; padding: 16px; border-radius: 18px; background: var(--surface); border: var(--border-width) solid var(--border); }
.fact { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 21px; font-weight: 700; }
.fact .icon { width: 20px; height: 20px; margin-top: 1px; color: var(--success); }
.fact .icon svg { stroke-width: 2.6; }
.stamps-head { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.stamps-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.stamps-count { font-size: 13px; font-weight: 800; color: var(--label); }
.stamps { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.stamp { width: 56px; height: 56px; padding: 15px; border-radius: 50%; background: var(--cat-fill); color: var(--cat-ink); display: grid; place-items: center; }
.stamp svg { width: 100%; height: 100%; }
.stamp.new { background: var(--accent-fill); color: var(--on-accent); }
.stamp.locked { background: transparent; border: 2px dashed var(--locked); }
.complete-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 24px; }

/* First-launch welcome */
.screen.welcome { max-width: 480px; display: flex; flex-direction: column; align-items: stretch; padding-top: 48px; padding-bottom: 48px; }
.brand-mark.welcome-mark { width: 72px; height: 72px; padding: 16px; border-radius: 20px; align-self: center; }
.welcome-heading { margin-top: 20px; text-align: center; font-family: var(--font-display); font-size: 32px; line-height: 38px; font-weight: 700; }
.welcome-sub { margin-top: 8px; text-align: center; font-size: 17px; line-height: 24px; color: var(--muted); }
.welcome-label { margin-top: 28px; font-size: 15px; font-weight: 800; }
.welcome-input { margin-top: 8px; min-height: 52px; padding: 0 18px; border-radius: var(--radius-bar); border: var(--border-width) solid var(--border); background: var(--surface); color: var(--ink); font-size: 17px; font-weight: 600; }
.welcome-input::placeholder { color: var(--placeholder); }
.welcome-help { margin-top: 6px; font-size: 13px; color: var(--label); }
.welcome-steps { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.welcome-steps li { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-chip); background: var(--surface); border: var(--border-width) solid var(--border); }
.welcome-steps .icon { grid-row: 1 / span 2; grid-column: 1; width: 40px; height: 40px; padding: 10px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-text); order: -1; }
.welcome-steps strong { grid-column: 2; font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.welcome-steps span:not(.icon) { grid-column: 2; font-size: 14px; color: var(--muted); }
.welcome .primary { margin-top: 28px; }

/* Stamps */
.stamps-empty { margin-top: 24px; text-align: center; font-size: 16px; color: var(--muted); }
.stamp-kinds { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; }
.stamp-kind { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.stamp-kind-disc { width: 72px; height: 72px; padding: 20px; border-radius: 50%; background: var(--cat-fill); color: var(--cat-ink); display: grid; place-items: center; }
.stamp-kind-disc svg { width: 100%; height: 100%; }
.stamp-kind.missing .stamp-kind-disc { background: transparent; border: 2px dashed var(--locked); color: var(--upcoming); }
.stamp-kind-name { font-size: 13px; font-weight: 800; line-height: 16px; color: var(--ink); }
.stamp-kind-count { font-size: 12px; font-weight: 700; color: var(--label); }
.stamp-kind:not(.missing) .stamp-kind-count { color: var(--cat-ink); }
.stamps-subhead { margin-top: 28px; font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.stamp-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stamp-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: var(--radius-chip); background: var(--surface); border: var(--border-width) solid var(--border); }
.stamp-row-disc { flex-shrink: 0; width: 34px; height: 34px; padding: 8px; border-radius: 50%; background: var(--cat-fill); color: var(--cat-ink); display: grid; place-items: center; }
.stamp-row-disc svg { width: 100%; height: 100%; }
.stamp-row-name { flex: 1; font-size: 15px; font-weight: 700; }
.stamp-row-date { font-size: 13px; font-weight: 700; color: var(--label); }
.screen.stamps-screen { max-width: 720px; }
@media (min-width: 700px) { .stamp-kinds { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .stamp-kinds { grid-template-columns: repeat(6, minmax(0, 1fr)); } .screen.stamps-screen { max-width: 960px; } }

/* Settings */
.settings { width: min(92vw, 420px); padding: 20px; border-radius: var(--radius-card); border: var(--border-width) solid var(--border); background: var(--surface); color: var(--ink); }
.settings::backdrop { background: var(--scrim); }
.settings-form { display: flex; flex-direction: column; gap: 8px; }
.settings h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.settings label { font-size: 14px; font-weight: 800; color: var(--muted); margin-top: 6px; }
.settings input, .settings select { min-height: 48px; padding: 0 14px; border-radius: var(--radius-chip); border: var(--border-width) solid var(--border); background: var(--ground); color: var(--ink); font-size: 16px; }
.settings-help { font-size: 13px; color: var(--label); }
.settings .primary { margin-top: 14px; }

/* Wide-layout pieces: hidden on phones. */
.side-rail, .finished-card { display: none; }
.stamps-pill:not([hidden]) { display: inline-flex; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.stamps-pill { min-height: 44px; padding: 0 14px; border-radius: 22px; color: var(--ink); font-size: 14px; gap: 8px; }
.pill-disc { width: 22px; height: 22px; padding: 5px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-text); display: grid; place-items: center; }
.pill-disc svg { width: 100%; height: 100%; stroke-width: 2.5; }
.finished-card { flex-direction: column; gap: 10px; margin-top: 20px; padding: 18px 20px; border-radius: var(--radius-card); background: var(--surface); border: var(--border-width) solid var(--border); }
.finished-head { display: flex; align-items: center; justify-content: space-between; }
.finished-head h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.finished-count { font-size: 13px; font-weight: 800; color: var(--label); }
.finished-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--muted); }
.finished-disc { flex-shrink: 0; width: 32px; height: 32px; padding: 8px; border-radius: 50%; background: var(--cat-fill); color: var(--cat-ink); display: grid; place-items: center; }
.finished-disc svg, .identity-disc svg { width: 100%; height: 100%; }

/* 700–1100 px: the phone layout with wider gutters. */
@media (min-width: 700px) {
  .screen { padding-left: 32px; padding-right: 32px; }
  .dock { padding-left: 32px; padding-right: 32px; }
}

/* ≥1100 px (iPad landscape, TabletHome/TabletTrail.dc.html): two columns. */
@media (min-width: 1100px) {
  /* Wide windows: the layout stops growing at --page and stays centred
     (the iPad landscape layout, a little wider); --inset is the margin on
     each side, used to keep the fixed question bar under its column. The
     pixel field still spans the whole window. */
  :root { --page: 1240px; --inset: max(0px, calc((100vw - var(--page)) / 2)); }
  .screen { max-width: none; }
  .home, .trail-screen { max-width: var(--page); }
  .finished-card { display: flex; }
  .stamps-pill { padding: 0 16px; font-size: 15px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand { font-size: 24px; gap: 12px; }

  /* Home: a 380 px column (greeting, resume, finished) beside Sparks. */
  .home { display: grid; grid-template-columns: 380px minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 32px; padding: 24px 40px 110px; }
  .home > .app-header { grid-column: 1 / -1; min-height: 48px; }
  .home-side { grid-column: 1; }
  .home .sparks { grid-column: 2; grid-row: 2; }
  .home .made-with-love { grid-column: 1; justify-content: flex-start; }
  .greeting { margin-top: 24px; font-size: 34px; line-height: 40px; }
  .resume-card { grid-template-columns: 1fr; gap: 12px; margin-top: 20px; padding: 22px 24px; border-radius: 24px; }
  .resume-question { font-size: 22px; line-height: 27px; }
  .dot { width: 10px; height: 10px; }
  .resume-step { font-size: 14px; }
  .resume-go { justify-content: center; min-height: 46px; margin-top: 4px; border-radius: 23px; background: var(--on-accent); color: var(--accent-fill); font-size: 16px; }
  .home .section-head { margin-top: 24px; }
  .home .section-head h2 { font-size: 22px; }
  .home .section-head .pill { min-height: 40px; padding: 0 16px; border-radius: 20px; font-size: 15px; }
  .spark-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 14px; }
  .spark-grid .spark-card:nth-child(n+5) { display: flex; }
  .spark-card { min-height: 186px; padding: 18px; border-radius: 22px; }
  .icon-disc { width: 48px; height: 48px; padding: 11px; }
  .spark-topic { font-size: 12px; }
  .spark-question { font-size: 17px; line-height: 22px; }
  body[data-view="home"] .dock { left: calc(var(--inset) + 40px + 380px + 32px); right: calc(var(--inset) + 40px); padding-left: 0; padding-right: 0; }
  .dock > * { max-width: none; }

  /* Trail: the whole trail in a 340 px side rail; the step beside it. */
  .trail-screen { display: grid; grid-template-columns: 340px minmax(0, 1fr); padding: 0; min-height: 100dvh; }
  .trail-screen > .trail-header { display: none; }
  .side-rail {
    display: flex; flex-direction: column; gap: 18px; grid-row: 1 / span 2;
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 24px 24px 24px 32px; background: var(--surface); border-right: var(--border-width) solid var(--border);
  }
  .trail { grid-column: 2; margin: 0; padding: 24px 40px 120px; }
  .trail .rail-item:not(.open), .trail .connector { display: none; }
  .trail .rail-item.open { margin-bottom: 16px; }
  .current-head > .step-disc { display: none; }
  .current-question { font-size: 34px; line-height: 40px; }
  .current-head .speak { width: 48px; height: 48px; margin-top: 0; }
  /* The picture as a full-width banner, the answer below it. */
  .step-body { display: flex; flex-direction: column; gap: 22px; margin-top: 22px; }
  .step-body .illustration { width: 100%; height: 200px; aspect-ratio: auto; margin: 0; border-radius: 22px; }
  .step-body .answer { margin: 0; max-width: 72ch; font-size: 18px; line-height: 29px; }
  .dive-label { margin-top: 26px; font-size: 17px; }
  .dive-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
  .dive-chips .chip:nth-child(n+3) { display: flex; }
  .chip { min-height: 64px; padding: 12px 16px; border-radius: 16px; line-height: 20px; }
  .finish { max-width: 360px; }
  body[data-view="trail"] .dock { left: calc(var(--inset) + 340px + 40px); right: calc(var(--inset) + 40px); padding-left: 0; padding-right: 0; }
  /* Only the step column fades above the bar; the rail stays whole. */
  body[data-view="trail"][data-dock="true"] main {
    -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(to bottom, #000 calc(100% - var(--dock-h, 90px) - 20px), transparent calc(100% - var(--dock-h, 90px) + 6px));
    mask-image: linear-gradient(#000, #000), linear-gradient(to bottom, #000 calc(100% - var(--dock-h, 90px) - 20px), transparent calc(100% - var(--dock-h, 90px) + 6px));
    -webkit-mask-size: calc(var(--inset) + 340px) 100%, 100% 100%; mask-size: calc(var(--inset) + 340px) 100%, 100% 100%;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  }
  .compose textarea { min-height: 52px; padding: 14px 20px; border-radius: 26px; font-size: 17px; }
  .send { width: 52px; height: 52px; padding: 14px; }

  .rail-back { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 15px; font-weight: 800; align-self: flex-start; }
  .rail-back .icon { width: 20px; height: 20px; }
  .rail-identity { display: flex; align-items: center; gap: 12px; }
  .identity-disc { flex-shrink: 0; width: 48px; height: 48px; padding: 11px; border-radius: 50%; background: var(--cat-fill); color: var(--cat-ink); }
  .identity-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .identity-name { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
  .rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
  .rail-entry { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 8px 0; border: 0; background: transparent; color: var(--muted); text-align: left; font-size: 15px; line-height: 20px; font-weight: 700; }
  .rail-entry .step-disc { width: 28px; height: 28px; margin: 0; }
  .rail-entry-text { padding-top: 4px; }
  .rail-entry.current { margin-left: -12px; padding: 10px 12px; border-radius: 14px; background: var(--accent-tint); color: var(--ink); font-weight: 800; }
  .rail-entry.upcoming { align-items: center; color: var(--upcoming); }
  .rail-entry.upcoming .rail-entry-text { padding-top: 0; }
  .upcoming-disc { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: 2px dashed var(--locked); }
  .rail-line { width: 2px; height: 14px; margin-left: 13px; border-radius: 1px; background: var(--connector); }
  .rail-line.ahead { background: var(--upcoming-connector); }
  .so-far { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding: 14px 16px; border-radius: 16px; background: var(--ground); border: var(--border-width) solid var(--border); }
  .so-far .fact { font-size: 14px; line-height: 19px; gap: 8px; }
  .so-far .fact .icon { width: 18px; height: 18px; margin: 0; }
}

/* With room around the centred layout, the Trail rail becomes a card
   instead of a panel against the window edge. */
@media (min-width: 1320px) {
  .side-rail { top: 24px; height: calc(100dvh - 48px); margin-top: 24px; border: var(--border-width) solid var(--border); border-radius: 24px; }
}
/* ≥1400 px (web): the iPad layouts, as wide web matches iPad. */
@media (min-width: 1400px) {
  .complete { max-width: 560px; }
}

/* Screen changes: View Transitions where supported. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .25s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
