/* Layout: card stage on the left (sticky on desktop), step panel on the right; stacked on phones. The page stays quiet so the card is the star. */
:root {
  --bg: #efeeea;
  --surface: #f9f8f5;
  --surface-2: #ffffff;
  --fg: #1d1f24;
  --muted: #5e616b;
  --line: #d9d7d0;
  --line-strong: #b9b6ad;
  --paper: #fbf8f1;
  --air-red: #c8312f;
  --air-blue: #1f4fa0;
  --focus: #1f4fa0;
  --danger: #b3261e;
  --on-danger: #fff;
  --shadow: 0 1px 2px rgba(20, 20, 30, .14), 0 18px 40px -18px rgba(20, 20, 30, .45);
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Figtree", "Helvetica Neue", system-ui, sans-serif;
  --hand: "Caveat", "Bradley Hand", cursive;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --surface: #1f2024; --surface-2: #26282d; --fg: #ecebe7; --muted: #a4a6ae;
    --line: #34363c; --line-strong: #4c4f57; --focus: #8fb3f0; --danger: #ff8a80; --on-danger: #1d1f24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 18px 40px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a; --surface: #1f2024; --surface-2: #26282d; --fg: #ecebe7; --muted: #a4a6ae;
  --line: #34363c; --line-strong: #4c4f57; --focus: #8fb3f0; --danger: #ff8a80; --on-danger: #1d1f24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 18px 40px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 600; text-decoration: none; }
.skip:focus { top: calc(10px + env(safe-area-inset-top, 0px)); }
.panel:focus { outline: none; }
.face-front:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
@media (forced-colors: active) {
  .chip.on, .anim.on, .seg button.on, .tpl.on, .font-opt.on, .emo.on, .sw.on, .sw-custom.on { outline: 3px solid Highlight; outline-offset: 2px; }
  .step-tab.on { border-bottom-color: Highlight; }
}
svg { stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.top, .app, .foot {
  max-width: 1240px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
/* Product Hunt launch-day bar (index.html shows it on launch day only) */
.ph-bar { position: relative; display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 12px; padding: 6px 50px 6px 16px; border-radius: 999px; background: var(--air-red); color: #fff; }
.ph-bar[hidden] { display: none; }
.ph-bar a { flex: 0 1 auto; color: inherit; font-weight: 600; text-decoration: none; line-height: 1.35; padding-block: 6px; }
.ph-bar a:hover, .ph-bar a:focus-visible { text-decoration: underline; }
.ph-badge { flex: none; display: block; line-height: 0; }
.ph-badge[hidden] { display: none; }
.ph-badge img { display: block; width: auto; height: 34px; }
@media (max-width: 900px) { .ph-badge { display: none; } }
.ph-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .16); color: inherit; cursor: pointer; }
.ph-x:hover { background: rgba(255, 255, 255, .28); }
.ph-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.ph-bar a:focus-visible, .ph-x:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 18px 10px; }
.brand-h { margin: 0; font: inherit; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand span { font: 700 26px/1 var(--display); letter-spacing: -.02em; }
.brand em { font: 600 1.15em var(--hand); font-style: normal; color: var(--air-red); }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.theme-btn .i-sun { display: none; }
.theme-btn[aria-pressed="true"] .i-sun { display: block; }
.theme-btn[aria-pressed="true"] .i-moon { display: none; }

/* ---------- app grid ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); gap: 28px; align-items: start; padding-block: 8px 40px; }
@media (max-width: 880px) { .app { grid-template-columns: minmax(0, 1fr); gap: 18px; } }

.stage { min-width: 0; }
.stage-sticky { position: sticky; top: calc(12px + env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 880px) { .stage-sticky { position: static; } }

.card-wrap { perspective: 2200px; padding: 6px; }
/* tools for the selected item, floating next to it on the card (placed by placeFloatBar in app.js) */
.card-wrap { position: relative; }
.float-bar {
  position: absolute; z-index: 6; display: flex; gap: 2px; padding: 4px; border-radius: 999px;
  background: #1d1f24; color: #fff; border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .55); white-space: nowrap;
}
.float-bar button {
  min-width: 40px; height: 40px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: inherit;
  display: inline-grid; place-items: center; cursor: pointer; font-weight: 600; font-size: 14px;
}
.float-bar button:hover { background: rgba(255, 255, 255, .12); }
.float-bar button:focus-visible { outline: 2px solid #8fb3f0; outline-offset: -2px; }
.float-bar svg { width: 18px; height: 18px; }
.float-bar .fb-text { padding: 0 12px; }
.float-bar .fb-del { color: #ff8a80; }
.float-bar [aria-pressed="true"] { background: #fff; color: #1d1f24; }
.float-bar [aria-pressed="true"]:hover { background: #ecebe7; }
.face-front.pan { cursor: move; }
.flipper {
  position: relative; width: 100%; max-width: 100%; aspect-ratio: 3 / 2;
  transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.3, .1, .2, 1.15);
}
.flipper.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 6px; box-shadow: var(--shadow);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--paper);
}
.face-front { touch-action: none; cursor: default; }
.face-front.grab { cursor: grab; }
.face-front.grabbing { cursor: grabbing; }
.face-back { transform: rotateY(180deg); }
.flipper.flipped .face-front, .flipper:not(.flipped) .face-back { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .flipper { transition: none; } }

.face-back { cursor: pointer; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bar-right { display: flex; align-items: center; gap: 6px; }
.bar-right .icon-btn { width: 40px; height: 40px; }
.hint { margin: 0; color: var(--muted); font-size: 13.5px; }

/* Phones: keep the card pinned at the top while the options scroll,
   and show the tools for the selected item as a sheet at the bottom. */
@media (max-width: 880px) and (min-height: 560px) {
  .stage {
    position: sticky; top: 0; z-index: 20;
    margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
    padding: calc(6px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-left, 0px)) 8px;
    background: var(--bg);
    box-shadow: 0 10px 14px -12px rgba(0, 0, 0, .35);
  }
  .stage-sticky { gap: 8px; }
  .card-wrap { width: 100%; max-width: calc(36dvh * 1.5); margin-inline: auto; padding: 4px; }
  .hint { font-size: 12.5px; text-align: center; }
  .selection {
    position: fixed; z-index: 40;
    left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px));
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-height: 44dvh; overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface-2); box-shadow: 0 -6px 30px rgba(0, 0, 0, .28);
    border-radius: 16px;
  }
  .sel-head { position: sticky; top: -12px; background: var(--surface-2); margin: -12px -14px 0; padding: 12px 14px 8px; z-index: 1; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-2);
  font-weight: 600; font-size: 14px; cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--fg); }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--air-red); border-color: var(--air-red); color: #fff; }
.btn.primary:hover { background: #ad2725; border-color: #ad2725; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { border-color: var(--fg); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger { color: var(--danger); }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--fg); color: var(--bg); }
.seg.small button { font-size: 13px; padding: 5px 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
  padding: 6px 12px; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); }
.chip.on { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.chip.more { border-style: dashed; color: var(--muted); }
.chip.more::after { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 0 2px 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.chip.more[aria-expanded="true"]::after { transform: rotate(-135deg); margin-bottom: -2px; }

/* Opening animation tiles: each has a tiny looping-once scene, played when picked or hovered. */
.anim-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.anim {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 6px 6px 7px; cursor: pointer;
  display: flex; flex-direction: column; gap: 5px; align-items: stretch; color: var(--fg); font: inherit; min-width: 0;
}
.anim:hover { border-color: var(--line-strong); }
.anim.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }
.anim small { font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; }
.mini { position: relative; aspect-ratio: 3 / 2; background: var(--bg); border-radius: 5px; overflow: hidden; }
.mini i { position: absolute; display: block; }
.mini .m-card {
  left: 22%; right: 22%; top: 22%; bottom: 22%; border-radius: 2px; z-index: 2;
  background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.25);
  border: 2px solid transparent;
  border-image: repeating-linear-gradient(45deg, var(--air-red) 0 4px, var(--paper) 4px 6px, var(--air-blue, #2a4d8f) 6px 10px, var(--paper) 10px 12px) 2;
}
.mini .m-card::after { content: ""; position: absolute; left: 14%; right: 40%; top: 30%; height: 2px; background: var(--muted); opacity: .5; box-shadow: 0 5px 0 var(--muted), 0 10px 0 var(--muted); }
.anim.play .mini * { animation-duration: 1.5s; animation-timing-function: cubic-bezier(.3, .1, .2, 1); animation-fill-mode: both; }

/* envelope: the card rises out of the pocket */
.mini-envelope .m-card { top: 12%; bottom: 32%; }
.mini-envelope .m-env { left: 16%; right: 16%; top: 42%; bottom: 8%; background: #d9caa8; border-radius: 2px; z-index: 3; }
.mini-envelope .m-flap { left: 16%; right: 16%; top: 42%; height: 30%; background: #cbb88f; clip-path: polygon(0 0, 100% 0, 50% 100%); z-index: 4; transform-origin: top; transform: rotateX(180deg); opacity: .0; }
.anim.play .mini-envelope .m-card { animation-name: m-rise; }
.anim.play .mini-envelope .m-flap { animation-name: m-flap; }
@keyframes m-rise { 0%, 35% { transform: translateY(45%); } 100% { transform: none; } }
@keyframes m-flap { 0% { transform: none; opacity: 1; } 30% { transform: rotateX(180deg); opacity: 1; } 40%, 100% { opacity: 0; transform: rotateX(180deg); } }

/* wax seal: the seal cracks and falls away */
.mini-waxseal .m-seal { left: 50%; top: 50%; width: 22%; aspect-ratio: 1; margin: -11% 0 0 -11%; border-radius: 50%; z-index: 3; background: radial-gradient(circle at 40% 35%, #d9534f, #8e1f1d); box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.anim.play .mini-waxseal .m-seal { animation-name: m-seal; }
@keyframes m-seal { 0%, 30% { opacity: 1; transform: none; } 45% { transform: scale(1.15); opacity: 1; } 100% { opacity: 0; transform: translateY(160%) rotate(40deg); } }

/* scratch: a silver layer wipes away */
.mini-scratch .m-foil { left: 22%; right: 22%; top: 22%; bottom: 22%; z-index: 3; border-radius: 2px; background: repeating-linear-gradient(135deg, #b8bcc4 0 3px, #cfd2d8 3px 6px); clip-path: inset(0 0 0 45%); }
.anim.play .mini-scratch .m-foil { animation-name: m-wipe; }
@keyframes m-wipe { 0%, 20% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(0 0 0 100%); } }

/* air mail: the card swoops in from the side */
.mini-airmail .m-trail { left: 0; right: 40%; top: 50%; height: 0; border-top: 2px dashed var(--muted); opacity: .6; z-index: 1; }
.mini-airmail .m-card { transform: translateX(10%) rotate(-8deg); }
.anim.play .mini-airmail .m-card { animation-name: m-swoop; }
.anim.play .mini-airmail .m-trail { animation-name: m-trail; }
@keyframes m-swoop { 0% { transform: translate(-160%, 60%) rotate(-25deg) scale(.6); } 70% { transform: translate(6%, -4%) rotate(4deg); } 100% { transform: none; } }
@keyframes m-trail { 0%, 20% { opacity: 0; } 50% { opacity: .6; } 100% { opacity: 0; } }

/* confetti: the card pops and bits fly out */
.mini-confetti .m-bit { left: 50%; top: 50%; width: 5px; height: 5px; border-radius: 1px; z-index: 3; transform: translate(var(--x), var(--y)) rotate(30deg); }
.mini-confetti .m-bit:nth-of-type(2) { background: #e0483e; --x: -260%; --y: -220%; }
.mini-confetti .m-bit:nth-of-type(3) { background: #f2b632; --x: 300%; --y: -260%; }
.mini-confetti .m-bit:nth-of-type(4) { background: #3a7bd5; --x: -340%; --y: 180%; }
.mini-confetti .m-bit:nth-of-type(5) { background: #3bb273; --x: 320%; --y: 220%; }
.mini-confetti .m-bit:nth-of-type(6) { background: #b05cc8; --x: 40%; --y: -380%; }
.anim.play .mini-confetti .m-card { animation-name: m-pop; }
.anim.play .mini-confetti .m-bit { animation-name: m-burst; }
@keyframes m-pop { 0% { transform: scale(.3); opacity: 0; } 40% { transform: scale(1.12); opacity: 1; } 60%, 100% { transform: none; } }
@keyframes m-burst { 0%, 30% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(200deg); } }

/* hearts: the card fades in as hearts float up */
.mini-hearts .m-heart { bottom: 4%; z-index: 3; font-size: 11px; line-height: 1; color: #e0483e; font-style: normal; transform: translateY(-120%); }
.mini-hearts .m-heart:nth-of-type(3) { transform: translateY(-260%); }
.mini-hearts .m-heart::before { content: "♥"; }
.mini-hearts .m-heart:nth-of-type(2) { left: 12%; }
.mini-hearts .m-heart:nth-of-type(3) { left: 46%; animation-delay: .25s; }
.mini-hearts .m-heart:nth-of-type(4) { left: 80%; animation-delay: .1s; }
.anim.play .mini-hearts .m-card { animation-name: m-fade; }
.anim.play .mini-hearts .m-heart { animation-name: m-float; }
@keyframes m-fade { 0% { opacity: 0; transform: translateY(10%); } 60%, 100% { opacity: 1; transform: none; } }
@keyframes m-float { 0% { opacity: 0; transform: none; } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-380%); } }

@media (prefers-reduced-motion: reduce) { .anim.play .mini * { animation: none !important; } }

/* A checkbox drawn as an on/off switch. */
.toggle.switch input {
  appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 22px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--line-strong); position: relative; transition: background .2s;
}
.toggle.switch input::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s;
}
.toggle.switch input:checked { background: var(--air-red); }
.toggle.switch input:checked::before { transform: translateX(14px); }
.toggle.switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (forced-colors: active) { .toggle.switch input { border: 1px solid CanvasText; } .toggle.switch input:checked::before { background: Highlight; } }

.note.small { font-size: 12.5px; }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.sw {
  width: 30px; height: 30px; border-radius: 999px; cursor: pointer; padding: 0;
  border: 1px solid rgba(0, 0, 0, .18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.swatches.big .sw { width: 38px; height: 38px; border-radius: 8px; }
.sw.on { outline: 2px solid var(--fg); outline-offset: 2px; }
.sw-custom {
  position: relative; width: 30px; height: 30px; border-radius: 999px; overflow: hidden; cursor: pointer;
  background: conic-gradient(#e74c3c, #f1c40f, #2ecc71, #3498db, #9b59b6, #e74c3c);
  border: 1px solid rgba(0, 0, 0, .18);
}
.swatches.big .sw-custom { width: 38px; height: 38px; border-radius: 8px; }
.sw-custom input { position: absolute; inset: -8px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.sw-custom.on { outline: 2px solid var(--fg); outline-offset: 2px; }

input[type="color"] { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .range > span, .label { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.field input:not([type="color"]), .field textarea, .field select, #emojiSearch {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
.field textarea { resize: vertical; }
.range { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 12px; }
.range input { width: 100%; accent-color: var(--air-red); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--air-red); }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.row-wrap.end { justify-content: flex-end; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 420px) { .two { grid-template-columns: minmax(0, 1fr); } .range { grid-template-columns: 1fr; gap: 4px; } }
.note { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- selection tools ---------- */
.selection { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.sel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sel-head strong { font: 700 16px var(--display); }
.sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sel-body, .sel-group { display: flex; flex-direction: column; gap: 10px; }
/* Desktop: one thin row (size, turn, layer order, done). Swap, Duplicate, Delete and Move picture are
   on the floating bar, so they are hidden here (the buttons stay in the page: keyboard shortcuts and
   the floating bar click them). Text and photo options show under the row. */
@media (min-width: 881px) {
  .selection {
    display: grid; align-items: center; gap: 8px 16px; padding: 8px 10px 8px 16px;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "title size turn actions";
  }
  .sel-head, .sel-body { display: contents; }
  .sel-head strong { grid-area: title; }
  .sel-actions { grid-area: actions; flex-wrap: nowrap; }
  .sel-body > .range { display: flex; gap: 8px; min-width: 0; }
  .sel-body > .range:first-of-type { grid-area: size; }
  .sel-body > .range:nth-of-type(2) { grid-area: turn; }
  .sel-body > .range input { flex: 1; min-width: 60px; }
  .sel-group { grid-column: 1 / -1; padding: 6px 4px 6px 0; border-top: 1px solid var(--line); }
  #selDup, #selDel, #selEmoji, #selPan { display: none; }
}
@media (min-width: 881px) and (max-width: 1080px) {
  .selection { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "title . actions" "size size size" "turn turn turn"; }
}

/* ---------- panel ---------- */
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: clip; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.step-tab {
  border: 0; background: transparent; padding: 14px 8px; cursor: pointer; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-bottom: 3px solid transparent;
}
.step-tab b { width: 22px; height: 22px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 12px; border: 1.5px solid currentColor; }
.step-tab.on { color: var(--fg); border-bottom-color: var(--air-red); }
.step-tab.on b { background: var(--air-red); border-color: var(--air-red); color: #fff; }
.step { display: flex; flex-direction: column; padding: 6px 18px 12px; }
.group { border-bottom: 1px solid var(--line); padding-block: 4px; }
.group:last-of-type { border-bottom: 0; }
.group > summary {
  list-style: none; cursor: pointer; padding: 12px 0; font: 700 16px var(--display);
  display: flex; justify-content: space-between; align-items: center;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "+"; font: 400 22px var(--body); color: var(--muted); }
.group[open] > summary::after { content: "–"; }
.group[open] { padding-bottom: 16px; }
.group[open] > :not(summary) + :not(summary) { margin-top: 14px; }
.group.static { padding-block: 16px; display: flex; flex-direction: column; gap: 12px; }
.group.static h2 { margin: 0; font: 700 18px var(--display); }
.step-nav {
  display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--surface);
  position: sticky; bottom: 0; z-index: 5; border-radius: 0 0 14px 14px;
}

.templates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tpl { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; line-height: 0; }
.tpl canvas { width: 100%; aspect-ratio: 3 / 2; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.tpl.on { border-color: var(--fg); }

.tray { display: flex; flex-wrap: wrap; gap: 6px; }
.emo {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; padding: 4px; font-size: 26px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emo img { width: 100%; height: 100%; object-fit: contain; }
.emo:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.emo.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }

.layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.lay { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.lay:hover { border-color: var(--line-strong); }
.lay .thumb { position: relative; aspect-ratio: 3 / 2; background: var(--bg); border-radius: 3px; }
.lay .thumb i { position: absolute; background: var(--muted); opacity: .45; border-radius: 1px; }
.lay small { font-size: 11.5px; color: var(--muted); text-align: center; }

.fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.font-opt { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.font-opt .sample { font-size: 22px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-opt small { font-size: 11.5px; color: var(--muted); }
.font-opt.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-radius: 8px; background: var(--bg); }

/* ---------- emoji dialog ---------- */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 40px));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface); color: var(--fg);
  display: none; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
dialog[open] { display: flex; }
dialog::backdrop { background: rgba(10, 10, 20, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font: 700 18px var(--display); }
.cats { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.cats .chip { white-space: nowrap; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; overflow-y: auto; min-height: 200px; flex: 1; align-content: start; }
.emoji-grid .emo { width: auto; aspect-ratio: 1; height: auto; border-color: transparent; background: transparent; }
.emoji-grid .emo:hover { background: var(--surface-2); border-color: var(--line); }
.dlg-foot { font-size: 12px; }

/* ---------- about: the words under the editor (and each landing page's own copy) ---------- */
.about { max-width: 1240px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.about h2 { margin: 0 0 8px; font: 700 20px/1.25 var(--display); letter-spacing: -.01em; }
.about h2 + p, .about p + p { margin-top: 0; }
.about p { max-width: 68ch; margin: 0 0 12px; line-height: 1.55; color: var(--fg); }
.about h3 { margin: 14px 0 4px; font: 600 16px/1.3 var(--body); }
.about ol { max-width: 68ch; margin: 0 0 12px; padding-left: 1.3em; line-height: 1.55; }
.about section + section, .about nav { margin-top: 22px; }
.about nav h2 { font-size: 16px; }
.about nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.about nav a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--fg); text-decoration: none; font-size: 14px; background: var(--surface); }
.about nav a:hover { border-color: var(--line-strong); }
.about nav a[aria-current="page"] { border-color: var(--fg); font-weight: 600; }
h1.tagline { font-weight: 500; }

.foot { padding-block: 10px 30px; color: var(--muted); font-size: 13px; }
.foot p { margin: 0; }
.foot .credit { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.foot .links { display: inline-flex; flex-wrap: wrap; }
.foot .links a::before { content: "·"; display: inline-block; margin: 0 8px; color: var(--muted); text-decoration: none; }
.foot .links a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.foot .links a:hover { text-decoration-color: currentColor; }
@media (max-width: 480px) {
  .foot .credit { flex-direction: column; align-items: flex-start; }
  .foot .links a:first-child::before { content: none; margin: 0; }
}

.foot .legal { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot .legal a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.foot .legal a:hover { color: var(--fg); text-decoration-color: currentColor; }

/* ---------- share ---------- */
.share-out { display: flex; flex-direction: column; gap: 8px; }
.tip { margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.tip a { color: var(--fg); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.tip a:hover { text-decoration-color: currentColor; }
/* "How to print and post it" under the download buttons (Finish step) */
.how-print a { color: var(--fg); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.how-print a:hover { text-decoration-color: currentColor; }
.preview-dlg { width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
.preview-stage { padding: 8px 6px 76px; width: 100%; max-width: max(260px, calc((100dvh - 230px) * .95)); margin-inline: auto; }
.preview-foot { justify-content: center; }
.sched { display: flex; flex-direction: column; gap: 10px; }
.sched-fields { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.sched-fields input[type="date"], .sched-fields input[type="time"] { font: inherit; color: inherit; }
.sched-fields .note.bad { color: var(--danger); }

/* ---------- About, Privacy, Terms, Contact ---------- */
.doc { max-width: 760px; padding-bottom: 32px; }
.doc h1 { margin: 8px 0 14px; font: 700 32px/1.15 var(--display); letter-spacing: -.02em; }
.doc h2 { margin-top: 26px; }
.doc ul { max-width: 68ch; margin: 0 0 12px; padding-left: 1.3em; line-height: 1.55; }
.doc li + li { margin-top: 6px; }
.doc a:not(.btn) { color: var(--fg); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.doc .btn { text-decoration: none; }
.foot .legal a[aria-current="page"] { color: var(--fg); font-weight: 600; }
.contact-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.doc .btn:not(.primary) { color: var(--fg); }

/* ---------- share box (js/share.js) ---------- */
.share-dlg { width: min(380px, calc(100vw - 24px)); }
.share-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.share-opts:has([data-native]:not([hidden])) { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.share-opts:has([data-native]:not([hidden])) > * { font-size: 11.5px; }
.share-opts [hidden] { display: none; }
.share-opts a, .share-opts button {
  font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); text-decoration: none; font-size: 12.5px; font-weight: 600;
}
.share-opts a:hover, .share-opts button:hover { border-color: var(--line-strong); }
.share-opts svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.share-opts [data-to="whatsapp"] svg { color: #1f9d55; }
.share-opts [data-to="facebook"] svg { color: #1877f2; }
.share-copy { display: flex; gap: 8px; }
.share-copy input { flex: 1; min-width: 0; border: 1px solid var(--line-strong); background: var(--surface-2); color: inherit; border-radius: 8px; padding: 9px 11px; font: inherit; }
.share-dlg .icon-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* a button that reads as a link, for "Share Dear You" in running text */
.linkish { border: 0; padding: 0; background: none; font: inherit; cursor: pointer; color: var(--fg); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.linkish:hover { text-decoration-color: currentColor; }
.foot .legal .linkish { color: var(--muted); font-weight: inherit; }
.foot .legal .linkish:hover { color: var(--fg); }
.tip:has(+ .tip:not([hidden])) { border-bottom: 0; padding-bottom: 0; }
.tip + .tip { padding-top: 6px; }

/* ---------- Finish: link first ---------- */
.rec { display: inline-block; margin-left: 6px; padding: 2px 9px; border-radius: 999px; vertical-align: 3px;
  font: 600 11.5px/1.5 var(--body); letter-spacing: .01em; background: color-mix(in srgb, var(--air-blue) 14%, transparent); color: var(--air-blue); }
:root[data-theme="dark"] .rec { color: #9dbcf0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rec { color: #9dbcf0; } }
/* The folded link options: one row you can tap anywhere, showing the chosen animation's picture. */
.share-sum {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px 8px 8px; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--fg); font: inherit; font-size: 14px; text-align: left;
}
.share-sum:hover { border-color: var(--fg); }
.share-sum b { font-weight: 600; }
.share-sum .mini { flex: none; width: 54px; }
.share-sum-text { flex: 1; min-width: 0; line-height: 1.35; }
.share-sum-text small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.share-sum .chev { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.share-sum[aria-expanded="true"] .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .share-sum .chev { transition: none; } }
.share-opts-panel { display: flex; flex-direction: column; gap: 12px; }
.share-opts-panel[hidden] { display: none; }

/* ---------- phones: the panel as a sheet with a tab per section (app.js adds .sheet) ---------- */
.sheet-tabs { display: none; }
.panel.sheet { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "steps nav" "step step" "tabs tabs"; }
.panel.sheet .steps { grid-area: steps; display: flex; align-items: center; gap: 2px; padding-left: 8px; }
.panel.sheet .step-tab { padding: 12px 6px; border-bottom: 0; font-size: 0; gap: 0; }
.panel.sheet .step-tab b { font-size: 12px; }
.panel.sheet .step-tab.on { font-size: 14px; gap: 6px; }
.panel.sheet .step-nav { grid-area: nav; position: static; border-top: 0; border-bottom: 1px solid var(--line); background: none; border-radius: 0; padding: 8px 12px 8px 0; }
.panel.sheet #prevStep { display: none; }
.panel.sheet .step { grid-area: step; }
.panel.sheet .group.tab-off { display: none; }
.panel.sheet details.group { border-bottom: 0; }
.panel.sheet details.group > summary { cursor: default; padding-bottom: 4px; }
.panel.sheet details.group > summary::after { content: none; }
.panel.sheet .sheet-tabs:not([hidden]) {
  grid-area: tabs; position: sticky; bottom: 0; z-index: 15; display: flex;
  background: var(--surface-2); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-tabs button {
  flex: 1 1 0; min-width: 0; min-height: 60px; padding: 6px 2px; border: 0; background: none; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 500; color: var(--muted);
}
.sheet-tabs svg { width: 22px; height: 22px; stroke-width: 1.9; }
.sheet-tabs button.on { color: var(--fg); font-weight: 700; }
.sheet-tabs button.on::before { content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 3px; background: var(--air-red); }
@media (forced-colors: active) { .sheet-tabs button.on::before { background: Highlight; } }

/* ---------- desktop: the same tabs in a column down the left of the panel (app.js adds .rail) ---------- */
.panel.rail { display: grid; grid-template-columns: 84px minmax(0, 1fr); grid-template-areas: "steps steps" "tabs step" "nav nav"; }
.panel.rail .steps { grid-area: steps; }
.panel.rail .step { grid-area: step; padding-top: 2px; }
.panel.rail .step-nav { grid-area: nav; }
.panel.rail .group.tab-off { display: none; }
.panel.rail details.group { border-bottom: 0; }
.panel.rail details.group > summary { cursor: default; padding-bottom: 4px; }
.panel.rail details.group > summary::after { content: none; }
.panel.rail .sheet-tabs:not([hidden]) {
  grid-area: tabs; display: flex; flex-direction: column; align-self: stretch;
  background: var(--bg); border-right: 1px solid var(--line); padding-top: 4px;
}
.panel.rail .sheet-tabs button { flex: 0 0 auto; min-height: 68px; padding: 8px 4px; }
.panel.rail .sheet-tabs button.on { background: var(--surface); }
.panel.rail .sheet-tabs button.on::before { top: 0; bottom: 0; left: 0; right: auto; width: 3px; height: auto; }
.panel.rail .sheet-tabs button:not(.on):hover { color: var(--fg); }
