/* The CaricatureMe web app: the iOS app (mobile/), screen for screen. Its
   theme (mobile/src/theme.ts): cream, hot pink, turquoise, gold, purple,
   green; thick dark outlines with a heavier bottom-right edge (the "pop");
   rounded type; springy presses. Each screen has the iOS app's nav row
   (ScreenShell.tsx) and a body under it; the numbers below are the iOS
   app's points, named after the component they come from.

   One phone at every size (opslog: web): the app is a .device box. On a
   phone it fills the screen (100svh: the page never scrolls, so Safari's
   toolbar never folds and the height never changes); on a wide screen it
   is an iPhone's 393 x 852 points with its status bar and home indicator
   areas, scaled to fit and centred (app.js sets --scale). The page never
   scrolls; a screen's body scrolls inside the phone. What is inside the
   phone is laid out with flex, never from vh, svh or dvh.

   iOS Safari (global rule): nothing takes env(safe-area-inset-bottom) (the
   home indicator's room is a constant, --home-h); no fixed or sticky
   element gets a promoted layer at rest (screens and the viewer animate
   their transform or opacity only while they come and go); nothing is
   written per scroll frame. */
/* The iOS app's fonts (mobile/: @expo-google-fonts), SIL Open Font
   License (fonts/*-OFL.txt). */
@font-face { font-family: "Fredoka"; font-weight: 700; font-display: swap; src: url("fonts/Fredoka-Bold.ttf") format("truetype"); }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url("fonts/Nunito-Regular.ttf") format("truetype"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap; src: url("fonts/Nunito-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("fonts/Nunito-Bold.ttf") format("truetype"); }
:root {
  --pink: #FF5E78;
  --gold: #FFD700;
  --turquoise: #4ECDC4;
  --purple: #B388FF;
  --green: #95E77D;
  --bg: #FFF8F0;
  --white: #FFFFFF;
  --text: #333333;
  /* The iOS app's textMuted is #888888; text here is a shade darker to
     stay legible on cream (4.5:1). Icons and the grey button keep #888. */
  --muted: #6F6F6F;
  --muted-icon: #888888;
  --outline: #2D2D2D;
  --danger: #C62D47;
  --dark: #333333;
  /* theme.ts cartoon.darken(colour, 40): a button's bottom-right edge. */
  --pink-edge: #D73650;
  --turquoise-edge: #26A59C;
  --gold-edge: #D7AF00;
  --purple-edge: #8B60D7;
  --white-edge: #D7D7D7;
  /* theme.ts fontFamily: Fredoka Bold for titles, Nunito for the rest
     (400 body, 600 subtitles, 700 buttons), served from fonts/. */
  --title-font: "Fredoka", "Nunito", ui-rounded, -apple-system, system-ui, "Segoe UI", sans-serif;
  /* theme.ts animation.springConfig (damping 12, stiffness 150, mass 0.8)
     settles in about 850ms with a 13% overshoot: linear() below traces it;
     browsers without linear() get a cubic overshoot. */
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --spring-ms: 600ms;
  --out: cubic-bezier(.2, .8, .2, 1);
  /* ScreenShell's nav row (4 + 40 + 4) and the room kept under a screen
     for the home indicator: none in Safari, 34 when it is drawn. */
  --nav-h: 48px;
  --home-h: 0px;
  /* The phone's height and its status bar area: the screen's on a phone. */
  --app-h: 100svh;
  --status-h: 0px;
  color-scheme: light;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.096, 0.313, 0.563, 0.787, 0.957, 1.065, 1.117, 1.127, 1.111, 1.081, 1.049, 1.022, 1.002, 0.99, 0.984, 0.984, 0.987, 0.99, 0.994, 0.998, 1, 1.002, 1.002, 1);
    --spring-ms: 850ms;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; height: 100svh; overflow: hidden; background: var(--bg); color: var(--text);
  font: 17px/1.35 "Nunito", ui-rounded, -apple-system, system-ui, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; font: inherit; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
a, button, label { touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 3px; }
.screen:focus, .screen:focus-visible { outline: none; }
.noscript { padding: 24px; text-align: center; }
/* An icon (icons.js): a 24-point glyph in the current colour. */
.icon { display: block; width: 24px; height: 24px; flex: none; fill: currentColor; }
.c-gold { color: var(--gold); }
.c-pink { color: var(--pink); }
.c-purple { color: var(--purple); }
.c-turquoise { color: var(--turquoise); }
.c-green { color: var(--green); }

/* ── The phone ──────────────────────────────────────────────────────── */
/* Everything that floats (toasts, the viewer, confetti) is placed in it,
   absolutely, so it lands in the phone at any scale. */
.device { position: relative; width: 100%; height: var(--app-h); overflow: hidden; background: var(--bg); }
/* A wide screen (a laptop, a tablet, a phone on its side): an iPhone 16,
   393 x 852 points, its status bar (59) and home indicator (34) areas
   kept, scaled to the window and centred, with the app's pop outline.
   Hidden until the script has set its scale, so it never shows at the
   wrong size first. */
@media (min-width: 501px) {
  :root { --app-h: 852px; --status-h: 59px; --home-h: 34px; }
  html, body { background: #EFE4D6; }
  /* Fixed, so its unscaled box (taller than a short window) never gives
     the page anything to scroll. */
  .device {
    position: fixed; left: 50%; top: 50%; width: 393px; border-radius: 48px;
    transform: translate(-50%, -50%) scale(var(--scale, 1));
    box-shadow: 0 0 0 3px var(--outline), 8px 8px 0 3px var(--outline);
  }
  html:not([data-scaled]) .device { visibility: hidden; }
  .device::after {
    content: ""; position: absolute; z-index: 50; left: 50%; bottom: 8px; width: 134px; height: 5px; margin-left: -67px;
    border-radius: 3px; background: var(--outline); pointer-events: none;
  }
}
/* Opened from the Home Screen: no Safari toolbar, and the home indicator
   covers the bottom 34 points: a constant, never the safe-area inset.
   iOS starts the page under its status bar but blurs the page's top
   ~36 points (measured on the user's iPhone: a button's top edge blurred,
   its bottom 38 points lower crisp), so screens start below that band;
   only cream shows through the blur. */
@media (display-mode: standalone) and (max-width: 500px) {
  :root { --home-h: 34px; --status-h: 40px; }
}

/* ── Screens and their nav row (ScreenShell.tsx) ────────────────────── */
.screen { position: absolute; top: var(--status-h); left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; background: var(--bg); }
.nav { flex: none; display: flex; align-items: center; min-height: var(--nav-h); padding: 4px 16px; }
/* Its side slots are 52 wide at least: a 40 button and its gap. */
.nav > .round-btn { margin-right: 12px; }
.nav > .credit-badge { margin-left: 12px; }
.nav-slot { width: 52px; flex: none; }
.nav-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center;
  font-family: var(--title-font); font-size: 22px; font-weight: 700; color: var(--pink); text-shadow: 1px 1px 0 var(--outline);
}
/* The round white nav buttons (home, help, close): 40, outlined, the pop on the bottom-right. */
.round-btn {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border-radius: 999px;
  border: 2px solid var(--outline); border-right-width: 3.5px; border-bottom-width: 3.5px; background: var(--white); color: var(--text);
  cursor: pointer; transition: transform var(--spring-ms) var(--spring);
}
.round-btn .icon { width: 22px; height: 22px; }
.round-btn:active { transform: scale(.92); transition-duration: .15s; }
/* CreditBadge.tsx: white, outlined, a gold star and the count in pink. */
.credit-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 20px; flex: none;
  border: 2px solid var(--outline); border-right-width: 3.5px; border-bottom-width: 3.5px; background: var(--white);
  color: var(--pink); font-weight: 700; font-size: 16px; line-height: 20px; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: transform var(--spring-ms) var(--spring);
}
.credit-badge .icon { width: 20px; height: 20px; }
.credit-badge:active { transform: scale(.92); transition-duration: .15s; }
/* The body: what scrolls, over the home indicator's room. */
.body {
  position: relative; flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 0 calc(var(--home-h) + 4px);
}
.center-body { display: flex; align-items: center; justify-content: center; }
.pad-body { padding: 16px 16px calc(var(--home-h) + 20px); }

/* Pushed screens slide in from the right over the one before, which
   drifts left; going back reverses it. Get Credits slides up as a modal.
   Only while they move: at rest a screen has no transform. */
.screen.in-push, .screen.out-pop, .screen.in-modal, .screen.out-modal { z-index: 2; box-shadow: -6px 0 18px rgba(45, 45, 45, .12); }
.screen.in-push { animation: in-push .35s var(--out) both; }
.screen.out-push { animation: out-push .35s var(--out) both; }
.screen.out-pop { animation: out-pop .3s var(--out) both; }
.screen.in-pop { animation: in-pop .3s var(--out) both; }
.screen.in-modal { animation: in-modal .4s var(--out) both; box-shadow: 0 -6px 18px rgba(45, 45, 45, .12); }
.screen.out-modal { animation: out-modal .3s ease-in both; box-shadow: 0 -6px 18px rgba(45, 45, 45, .12); }
@keyframes in-push { from { transform: translateX(100%); } }
@keyframes out-push { to { transform: translateX(-30%); } }
@keyframes out-pop { to { transform: translateX(100%); } }
@keyframes in-pop { from { transform: translateX(-30%); } }
@keyframes in-modal { from { transform: translateY(100%); } }
@keyframes out-modal { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Buttons ────────────────────────────────────────────────────────── */
/* BigButton.tsx: a pill, outlined, its bottom-right edge a darker shade of
   its colour; white label with a soft shadow; shrinks to .92 on a press
   and springs back. 56 tall unless sized. */
.big-btn {
  --fill: var(--pink); --edge: var(--pink-edge);
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; max-width: 400px; min-height: 56px;
  margin: 0 auto; padding: 14px 32px; border-radius: 30px; border: 3px solid var(--outline); border-right: 5px solid var(--edge); border-bottom: 5px solid var(--edge);
  background: var(--fill); color: var(--white); font-weight: 700; font-size: 22px; line-height: 1.2; text-align: center;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, .25); text-decoration: none; cursor: pointer; -webkit-user-select: none; user-select: none;
  transition: transform var(--spring-ms) var(--spring);
}
.big-btn:active { transform: scale(.92); transition-duration: .15s; }
.big-btn .icon { width: 36px; height: 36px; }
.big-btn.tall { min-height: 70px; }
.big-btn.mid { min-height: 64px; }
.big-btn.turquoise { --fill: var(--turquoise); --edge: var(--turquoise-edge); }
.big-btn.gold { --fill: var(--gold); --edge: var(--gold-edge); }
.big-btn.purple { --fill: var(--purple); --edge: var(--purple-edge); }
.big-btn.white { --fill: var(--white); --edge: var(--white-edge); color: var(--text); text-shadow: none; font-size: 20px; }
.big-btn .g-mark { width: 26px; height: 26px; flex: none; }
/* ActionButton.tsx: a rounded square, icon over a small label; .9 on a press. */
.action-btn {
  --fill: var(--pink);
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 14px 4px; border-radius: 20px; border: 2.5px solid var(--outline); border-right-width: 4px; border-bottom-width: 4px;
  background: var(--fill); color: var(--white); font-weight: 700; font-size: 14px; line-height: 1.3; text-decoration: none;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, .2); cursor: pointer; -webkit-user-select: none; user-select: none;
  transition: transform var(--spring-ms) var(--spring), opacity .2s, background-color .2s;
}
.action-btn:active:not(:disabled) { transform: scale(.9); transition-duration: .15s, .2s, .2s; }
.action-btn:disabled { opacity: .4; cursor: default; }
.action-btn.turquoise { --fill: var(--turquoise); }
.action-btn.green { --fill: var(--green); }
.action-btn.green.saved { --fill: #7BBF6A; }
.action-btn.grey { --fill: var(--muted-icon); }
.action-btn.danger { --fill: var(--danger); }
.text-link { padding: 12px; color: var(--muted); font-weight: 700; font-size: 15px; text-align: center; }

/* ── Home (index.tsx) and the signed-out screens ────────────────────── */
.hero-body {
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding-left: 16px; padding-right: 16px;
  container-type: inline-size;
}
.floating { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
/* 16 icons, each fading in after i x 200ms and bobbing 12 up and 12 down,
   1.5s + i x 200ms each way. */
.floating .icon {
  position: absolute; width: 36px; height: 36px;
  animation: fade-in .4s ease-out var(--d) both, bob-in var(--t) ease-in-out var(--d) both, bob var(--t) ease-in-out calc(var(--d) + var(--t)) infinite alternate;
}
@keyframes bob-in { to { transform: translateY(-12px); } }
@keyframes bob { from { transform: translateY(-12px); } to { transform: translateY(12px); } }
.hero-circle {
  position: relative; z-index: 1; display: grid; place-items: center; width: 140px; height: 140px; flex: none; margin-bottom: 32px;
  border-radius: 999px; background: var(--pink); color: var(--white);
  border: 4px solid var(--outline); border-right-width: 9px; border-bottom-width: 9px;
}
.hero-circle .icon { width: 80px; height: 80px; }
.hero-titles { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; max-width: 100%; margin-bottom: 24px; }
.hero-title {
  padding: 0 4px 3px; white-space: nowrap; text-align: center;
  font-family: var(--title-font); font-size: 42px; font-size: clamp(28px, 11.5cqi, 42px); font-weight: 700; line-height: 1.2;
  color: var(--pink); text-shadow: 2px 2px 0 var(--outline);
}
.hero-sub {
  margin-top: 8px; white-space: nowrap; text-align: center; font-size: 22px; font-size: clamp(16px, 6cqi, 22px); font-weight: 600;
  color: var(--text); text-shadow: 1px 1px 0 rgba(0, 0, 0, .08);
}
.hero-buttons { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 24px; width: 100%; }
/* The first time home shows: the circle springs up from half its size,
   the titles drop in after 200ms, the buttons rise after 300ms. */
.entering .hero-circle { animation: grow-in var(--spring-ms) var(--spring) backwards, fade-in .5s ease backwards; }
.entering .hero-titles { animation: drop-in var(--spring-ms) var(--spring) .2s backwards, fade-in .5s ease .2s backwards; }
.entering .hero-buttons > * { animation: rise-in var(--spring-ms) var(--spring) .3s backwards, fade-in .5s ease .3s backwards; }
@keyframes grow-in { from { transform: scale(.5); } }
@keyframes drop-in { from { transform: translateY(-40px); } }
@keyframes rise-in { from { transform: translateY(100px); } }
.fine { position: relative; z-index: 1; display: flex; align-items: center; gap: 4px; margin-top: 12px; color: var(--muted); font-size: 14px; }
.fine a { padding: 12px 6px; color: var(--muted); font-weight: 700; text-decoration: none; }

/* ── Pick a Style (style.tsx) ───────────────────────────────────────── */
/* A section's divider: faint lines either side of its name, in capitals. */
.divider { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; border-radius: 1px; background: var(--outline); opacity: .15; }
.divider span { color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; }
.style-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
/* A tile springs up from nothing, 100ms after the one before. */
.style-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 0; border: 0; background: none;
  color: var(--text); cursor: pointer; -webkit-user-select: none; user-select: none;
  animation: grow-from-0 var(--spring-ms) var(--spring) var(--d, 0s) backwards; transition: transform var(--spring-ms) var(--spring);
}
.style-tile:active { transform: scale(.93); transition-duration: .15s; }
@keyframes grow-from-0 { from { transform: scale(0); } }
.style-pic { display: block; width: 100%; aspect-ratio: 1; overflow: hidden; border: 3px solid var(--outline); border-radius: 18%; background: var(--white); }
.style-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.style-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; padding: 0 4px;
  font-size: 14px; font-weight: 600; line-height: 1.25; text-align: center;
}
/* A style without a preview: its colour, its icon and its name in white. */
.style-plain {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; aspect-ratio: 1;
  border-radius: 18%; background: var(--fill, var(--pink)); color: var(--white);
}
.style-plain .icon { width: 35%; height: auto; aspect-ratio: 1; }
.style-plain .style-name { color: var(--white); font-size: 15px; font-weight: 700; text-shadow: 1px 1px 1px rgba(0, 0, 0, .25); }
.muted-center { padding: 48px 16px; color: var(--muted); font-size: 16px; font-weight: 600; text-align: center; }

/* ── Create (create.tsx) ────────────────────────────────────────────── */
/* No scroll here: the frame takes what the buttons leave. */
.create-body { display: flex; flex-direction: column; overflow: hidden; }
.image-wrap { flex: 1; min-height: 0; display: flex; padding: 8px 16px 0; }
.image-box { position: relative; flex: 1; min-width: 0; overflow: hidden; border: 4px solid var(--outline); border-radius: 20px; background: var(--dark); }
.pick {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  padding: 0 24px; background: var(--white); color: var(--muted-icon); cursor: pointer;
}
.pick:active { background: #FBF6F0; }
/* With a photo in, the picker stays over it, unseen: a tap on the photo
   picks another (the web's; the iOS app goes back to the styles for that). */
.image-box[data-phase="ready"] .pick, .image-box[data-phase="ready"] .pick:active { z-index: 1; background: transparent; }
.image-box[data-phase="ready"] .pick > span { display: none; }
.pick input, .tool-btn input, .add-thumb input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.pick-icon .icon { width: 64px; height: 64px; }
.pick-text { padding: 0 32px; color: var(--muted); font-size: 18px; font-weight: 600; text-align: center; }
.fill-img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
/* JigsawPuzzle.tsx: 4 x 5 pieces inset 1.5 (3 apart), radius 3, each
   showing its part of the photo, which covers the frame; the script moves
   them with the Web Animations API (transforms only). */
.puzzle, .assembled { position: absolute; inset: 0; }
.puzzle { transition: opacity .8s ease; }
.piece { position: absolute; overflow: hidden; border-radius: 3px; }
.piece > span, .assembled { background-position: center; background-repeat: no-repeat; background-size: cover; }
.piece > span { position: absolute; display: block; }
/* The smooth photo over the pieces while it is whole: in over .3s, out over .2s. */
.assembled { opacity: 0; transition: opacity .2s ease; }
.assembled.on { opacity: 1; transition-duration: .3s; }
/* ProcessingAnimation.tsx: the palette turns once in 2s, six icons orbit
   at 90 once in 3s and stay upright. */
.orbit { position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; margin: -110px 0 0 -110px; display: grid; place-items: center; transition: opacity .8s ease; }
.orbit-core { color: var(--pink); animation: spin 2s linear infinite; }
.orbit-core .icon { width: 52px; height: 52px; }
.orbit-ring { position: absolute; inset: 0; }
.orbit-ring i { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; animation: orbit 3s linear infinite; }
.orbit-ring .icon { width: 22px; height: 22px; }
/* Icon i starts i x 60 degrees round, clockwise from the right. */
.orbit-ring i:nth-child(2) { animation-delay: -.5s; }
.orbit-ring i:nth-child(3) { animation-delay: -1s; }
.orbit-ring i:nth-child(4) { animation-delay: -1.5s; }
.orbit-ring i:nth-child(5) { animation-delay: -2s; }
.orbit-ring i:nth-child(6) { animation-delay: -2.5s; }
@keyframes orbit {
  from { transform: rotate(0deg) translateX(90px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(90px) rotate(-360deg); }
}
/* The line while it draws, white on a dark band across the bottom; the
   slow note under it after a minute. */
.gen-overlay { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 16px 0; background: rgba(0, 0, 0, .4); text-align: center; transition: opacity .3s ease; }
.gen-message {
  padding: 0 24px; color: var(--white); font-family: var(--title-font); font-size: 20px; font-weight: 700; line-height: 1.25;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, .5);
}
.gen-slow { margin-top: 8px; padding: 0 16px; color: var(--white); font-size: 15px; line-height: 1.3; text-shadow: 1px 1px 2px rgba(0, 0, 0, .5); }
.quip-spin { display: none; }
/* The caricature crossfades in over .8s as the puzzle and the line fade. */
.image-box .result { z-index: 1; opacity: 0; transition: opacity .8s ease; }
.image-box.revealing .result { opacity: 1; }
.image-box.revealing .puzzle, .image-box.revealing .assembled, .image-box.revealing .orbit { opacity: 0; }
.image-box.revealing .gen-overlay { opacity: 0; }
/* The toolbar over the result: save, share | a new photo, from the camera or the library. */
.toolbar { position: absolute; z-index: 3; left: 8px; right: 8px; bottom: 8px; animation: fade-in .25s ease-out; }
.toolbar-inner {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px;
  border: 3px solid var(--outline); border-radius: 20px; background: rgba(255, 248, 240, .85);
}
.tool-btn {
  --fill: var(--pink);
  position: relative; display: grid; place-items: center; width: 42px; height: 42px; flex: none; padding: 0; border-radius: 999px;
  border: 2px solid var(--outline); border-right-width: 3px; border-bottom-width: 3px; background: var(--fill); color: var(--white);
  cursor: pointer; transition: transform var(--spring-ms) var(--spring), background-color .2s;
}
.tool-btn:active { transform: scale(.9); transition-duration: .15s, .2s; }
.tool-btn .icon { width: 22px; height: 22px; }
.tool-btn.green { --fill: var(--green); }
.tool-btn.green.saved { --fill: #7BBF6A; }
.tool-btn.turquoise { --fill: var(--turquoise); }
.tool-btn.purple { --fill: var(--purple); }
.tool-sep { width: 2px; height: 24px; border-radius: 1px; background: var(--outline); opacity: .2; }
/* Web only: the extra photos a style takes, as small thumbnails. */
.refs { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 16px 0; }
.refs-label { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.25; }
.thumbs { display: flex; gap: 10px; }
.thumbs-items { display: contents; }
.thumb { position: relative; width: 52px; height: 52px; flex: none; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border: 2px solid var(--outline); border-radius: 12px; }
.thumb-remove {
  position: absolute; top: -8px; right: -8px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 2px solid var(--outline); border-radius: 999px; background: var(--pink); color: var(--white); cursor: pointer;
}
.thumb-remove::after { content: ""; position: absolute; inset: -8px; }
.thumb-remove .icon { width: 14px; height: 14px; }
.add-thumb {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px; flex: none;
  border: 2px dashed var(--muted-icon); border-radius: 12px; background: var(--white); color: var(--pink); cursor: pointer;
}
.add-thumb:active { background: #FBF6F0; }
.add-thumb .icon { width: 26px; height: 26px; }
/* The two buttons under the frame. */
.bottom-bar { flex: none; display: flex; gap: 8px; min-height: 88px; padding: 8px 16px 0; }
/* create.tsx's error view, in place of the frame and its buttons. */
.error-body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; padding: 8px 32px calc(var(--home-h) + 96px); text-align: center; }
.error-icon .icon { width: 64px; height: 64px; }
.error-title { font-family: var(--title-font); font-size: 22px; font-weight: 700; color: var(--text); }
.error-detail { margin-top: -16px; padding: 0 16px; color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.4; }
.error-quota { color: var(--pink); font-size: 16px; font-weight: 600; }
.error-buttons { display: flex; flex-direction: column; gap: 16px; width: 100%; }
/* ConfettiAnimation.tsx: icons falling over the create screen for a few
   seconds once the result is in, then removed. */
.confetti { position: absolute; top: var(--nav-h); left: 0; right: 0; bottom: 0; z-index: 15; overflow: hidden; pointer-events: none; }
.confetti > span { position: absolute; top: 0; }
.confetti > span > span { display: block; }
.confetti .icon { animation: wobble .4s ease-in-out -.2s infinite alternate; }
@keyframes wobble { from { transform: rotate(-30deg); } to { transform: rotate(30deg); } }
.spinner {
  width: 48px; height: 48px; border: 6px solid var(--white); border-top-color: var(--pink); border-right-color: var(--turquoise);
  border-radius: 999px; outline: 3px solid var(--outline); animation: spin .9s linear infinite;
}

/* ── My Creations (gallery.tsx) ─────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
/* A picture, its outline in the next of the five colours. */
.tile {
  display: block; aspect-ratio: 1; padding: 0; overflow: hidden; border: 3px solid var(--accent, var(--outline)); border-radius: 20px;
  background: var(--dark); cursor: pointer; transition: transform var(--spring-ms) var(--spring);
}
.tile:active { transform: scale(.95); transition-duration: .15s; }
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* The add tile: a pink plus, two sparkles pulsing in its corners. */
.add-tile {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 0; border: 3px solid var(--outline); border-radius: 20px;
  background: var(--white); color: var(--pink); cursor: pointer; transition: transform var(--spring-ms) var(--spring);
}
.add-tile:active { transform: scale(.95); transition-duration: .15s; }
.add-tile > .icon { width: 30%; height: auto; aspect-ratio: 1; }
.add-tile .sparkle { position: absolute; width: 22%; height: auto; aspect-ratio: 1; animation: sparkle 1.2s ease-in-out infinite alternate; }
.add-tile .sparkle.tl { top: 12%; left: 12%; color: var(--gold); }
.add-tile .sparkle.br { right: 12%; bottom: 12%; color: var(--turquoise); }
@keyframes sparkle { from { opacity: .4; transform: rotate(0deg); } to { opacity: 1; transform: rotate(30deg); } }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; min-height: 100%; padding: 0 16px 48px; text-align: center; }
.empty-icons { position: relative; display: grid; place-items: center; width: 100px; height: 100px; margin-bottom: 8px; animation: fade-in .4s ease-out; }
.empty-circle { display: grid; place-items: center; width: 72px; height: 72px; border: 3px solid var(--outline); border-radius: 999px; background: var(--pink); color: var(--white); }
.empty-circle .icon { width: 32px; height: 32px; }
.empty-small { position: absolute; display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--outline); border-radius: 999px; color: var(--white); }
.empty-small .icon { width: 16px; height: 16px; }
.empty-small.turquoise { top: 0; right: 0; background: var(--turquoise); }
.empty-small.gold { bottom: 0; left: 0; background: var(--gold); }
.empty-text { font-family: var(--title-font); font-size: 22px; font-weight: 700; }
.empty-sub { margin-top: -12px; color: var(--muted); font-size: 15px; font-weight: 600; }
.empty-add { width: min(115px, 40%); }
.empty-add .add-tile { width: 100%; }
.web-note { padding: 20px 8px 0; color: var(--muted); font-size: 13px; text-align: center; }
#gallery-empty:not([hidden]) ~ .web-note { display: none; }

/* ── Get Credits (paywall.tsx) ──────────────────────────────────────── */
.paywall-body { padding-bottom: calc(var(--home-h) + 16px); }
.pay-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 16px; text-align: center; }
.pay-star { color: var(--gold); }
.pay-star .icon { width: 64px; height: 64px; }
.pay-title { font-family: var(--title-font); font-size: 24px; font-weight: 700; color: var(--pink); }
.pay-sub { color: var(--muted); font-size: 16px; font-weight: 600; }
.packs { display: flex; flex-direction: column; gap: 16px; padding: 0 16px; }
.pack {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 24px; border-radius: 20px; background: var(--white);
  border: 3px solid var(--outline); border-right-width: 5px; border-bottom-width: 5px;
}
.pack.best { border-color: var(--gold); background: #FFFDF0; }
.pack-star { color: var(--gold); }
.pack-star.pink { color: var(--pink); }
.pack-star .icon { width: 32px; height: 32px; }
.pack-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pack-credits { font-size: 18px; font-weight: 700; }
.pack-note { color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.35; }
.best-badge {
  position: absolute; top: -10px; right: 16px; padding: 2px 8px; border: 2px solid var(--outline); border-radius: 30px;
  background: var(--gold); color: var(--text); font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.restore { display: block; margin-top: 16px; padding: 24px 16px; color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; text-decoration: underline; }

/* ── Support (support.tsx) ──────────────────────────────────────────── */
.support-body { padding: 16px 16px calc(var(--home-h) + 32px); }
.card { background: var(--white); border-radius: 20px; border: 3px solid var(--outline); border-right-width: 8px; border-bottom-width: 8px; }
.info-card { padding: 24px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 18px; font-weight: 700; }
.card-head .icon { width: 22px; height: 22px; }
.info-label { margin-top: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.id-row {
  margin-top: 4px; padding: 10px 12px; border: 2px solid var(--outline); border-radius: 12px; background: var(--bg);
  font-size: 14px; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text;
}
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.info-row .info-label { margin-top: 0; }
.info-value { min-width: 0; font-size: 14px; text-align: right; overflow-wrap: anywhere; }
.info-hint { margin: 8px 0 24px; color: var(--muted); font-size: 13px; text-align: center; }
.section-title { margin-bottom: 8px; font-family: var(--title-font); font-size: 20px; font-weight: 700; }
.faq { overflow: hidden; margin-bottom: 24px; }
.faq-item + .faq-item { border-top: 1px solid rgba(45, 45, 45, .15); margin: 0 16px; }
.faq-item + .faq-item .faq-q { padding-left: 0; padding-right: 0; }
.faq-item + .faq-item .faq-a { padding-left: 0; padding-right: 0; }
.faq-q {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 16px; border: 0; background: none; color: var(--text);
  font-size: 15px; font-weight: 600; text-align: left; cursor: pointer;
}
.faq-q > span:first-child { flex: 1; }
.faq-q > span:last-child { flex: none; }
.faq-q .icon { width: 20px; height: 20px; color: var(--muted-icon); }
.faq-a { margin-top: -8px; padding: 0 16px 16px; color: var(--muted); font-size: 14px; line-height: 20px; }
.contact { margin-bottom: 16px; color: var(--muted); font-size: 14px; line-height: 20px; }
.email-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 32px; padding: 16px 0; border-radius: 20px;
  border: 3px solid var(--outline); border-right-width: 8px; border-bottom-width: 8px; background: var(--turquoise);
  color: var(--white); font-size: 16px; font-weight: 700; text-decoration: none; transition: transform var(--spring-ms) var(--spring);
}
.email-btn:active { transform: scale(.96); transition-duration: .15s; }
.email-btn .icon { width: 20px; height: 20px; }
/* Web only: who is signed in, the privacy policy, sign out. */
.account { overflow: hidden; }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 16px; }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 2px solid var(--outline); border-radius: 999px;
  background: var(--pink); color: var(--white); font-size: 20px; font-weight: 700;
}
.acct-text { display: flex; flex-direction: column; min-width: 0; }
.acct-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.acct-email { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.acct-link {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); margin: 0 16px; padding: 14px 0; border: 0;
  border-top: 1px solid rgba(45, 45, 45, .15); background: none; color: var(--text); font-size: 15px; font-weight: 600;
  text-align: left; text-decoration: none; cursor: pointer;
}
.acct-link:active { opacity: .55; }
.acct-link .icon { width: 22px; height: 22px; }
.acct-label { flex: 1; }
.acct-link .chev .icon { width: 20px; height: 20px; color: var(--muted-icon); }
.acct-link.danger { color: var(--danger); }
.acct-link:disabled { color: var(--muted); cursor: default; }

/* ── The viewer (GalleryViewer.tsx) ─────────────────────────────────── */
/* Over the whole phone, fading in; shown only while nothing behind it can
   scroll (the screens are inert), so it may cover the bottom edge. */
dialog.viewer {
  position: absolute; z-index: 30; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0;
  padding: calc(var(--status-h) + 24px) 24px calc(var(--home-h) + 24px); border: 0; background: rgba(0, 0, 0, .85); color: var(--text);
}
dialog.viewer[open] { display: flex; flex-direction: column; justify-content: center; gap: 24px; animation: fade-in .25s ease-out; }
dialog.viewer.closing { animation: fade-out .2s ease-in forwards; }
.viewer-image { flex: 1; min-height: 0; overflow: hidden; border: 4px solid var(--outline); border-radius: 20px; background: var(--dark); }
.viewer-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer-actions { display: flex; gap: 8px; }
.confirm {
  display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 3px solid var(--outline); border-radius: 20px;
  background: var(--bg); font-size: 16px; font-weight: 700; text-align: center;
}
.confirm-buttons { display: flex; gap: 8px; }

/* ── Toasts ─────────────────────────────────────────────────────────── */
/* app.js: at the top, over the nav row, centred, in the app's outlined
   look. A constant offset, no safe-area inset, no dvh, no promoted layer
   at rest (only the entry and exit animate). An error stays until its
   close button; a success fades after four seconds, paused under the
   pointer. */
.toasts {
  position: absolute; top: calc(var(--status-h) + 8px); left: 12px; right: 12px; z-index: 40;
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.toast-list { display: flex; flex-direction: column; align-items: center; width: 100%; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; max-width: 26rem; margin: 0 0 8px; padding: 12px 12px 12px 14px;
  border: 2px solid var(--outline); border-right-width: 3.5px; border-bottom-width: 3.5px; border-radius: 14px;
  background: #FFE3E8; color: var(--text); text-align: left; pointer-events: auto;
  animation: toast-in .3s var(--spring) backwards;
}
.toast.ok { background: #E4F9DD; animation: toast-in .3s var(--spring) backwards, toast-out .35s ease-in 4s forwards; }
.toast.ok:hover, .toast.ok:focus-within { animation-play-state: paused; }
.toast.leaving { animation: toast-out .2s ease-in forwards; }
.toast-icon {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: -1px;
  border: 2px solid var(--outline); border-radius: 999px; background: var(--pink);
}
.toast.ok .toast-icon { background: var(--green); }
.toast-icon svg { width: 14px; height: 14px; fill: none; stroke: var(--white); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.toast.ok .toast-icon svg { stroke: var(--outline); }
.toast-text { flex: 1; min-width: 0; margin: 0; padding-top: 1px; font-size: .95rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.toast-close {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin: -3px -2px -3px 0; padding: 0;
  border: 0; border-radius: 999px; background: rgba(45, 45, 45, .08); color: var(--text); cursor: pointer;
}
.toast-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.toast-close:active { background: rgba(45, 45, 45, .16); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px); } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }

/* Reduced motion: nothing slides, pops, bobs or flies; the spinners turn
   slowly. The jigsaw stays whole (the script does not move it) with a
   small spinner in its line, and the orbit stands still. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .spinner, .quip-spin { animation-duration: 3s !important; animation-iteration-count: infinite !important; }
  .quip-spin {
    display: inline-block; width: 16px; height: 16px; margin: 0 8px -2px 0; border: 3px solid rgba(255, 255, 255, .45);
    border-top-color: var(--white); border-radius: 999px; animation: spin 3s linear infinite;
  }
}
