/* ================================================================
 *  B.Grimm Father's Day — styles
 *  Look: warm paper, ink line doodles with watercolor washes, postcards & stamps,
 *  editorial serif — B.Grimm Orange (main) with B.Grimm Pink & Green touches.
 * ================================================================ */

:root {
  /* Brand */
  --primary: #FF6727;            /* B.Grimm orange */
  --primary-dark: #D94D16;
  --primary-soft: #FFE6D8;

  /* Accents: B.Grimm Pink + B.Grimm Green (one place to change them) */
  --pink: #F28CA8;               /* ⚠ placeholder — replace with the official CI hex */
  --pink-soft: #FCE3EA;
  --green: #CEDCCA;              /* Sage Green (B.Grimm CI heritage palette) */
  --green-soft: #E8EFE5;
  --green-deep: #6E8F69;         /* darker green for small details on paper */

  /* Paper & ink */
  --paper: #FAF6EF;
  --card-paper: #FFFDF8;
  --ink: #63666F;                /* drawing lines & borders — no black anywhere: all ink is #63666F */
  --text-strong: #63666F;
  --text: #63666F;
  --muted: #989AA5;
  --line: #E6DFD3;

  --danger: #FF3B30;
  --danger-text: #C62828;

  /* Type */
  --font-display: 'Trirong', 'Noto Sans Thai', Georgia, serif;
  --font-accent: 'Trirong', 'Noto Sans Thai', serif;   /* italic serif for notes & letters */
  --font-body: 'Noto Sans Thai', 'Open Sans', -apple-system, BlinkMacSystemFont, Arial, sans-serif;

  --ease: cubic-bezier(.16, 1, .3, 1);
  /* fine paper grain (page + postcard) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35  0 0 0 0 .3  0 0 0 0 .24  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --cw: 200px;
  --ch: 267px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; background: var(--paper); }
body {
  margin: 0; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column;
  color: var(--text-strong); font-family: var(--font-body); line-height: 1.6;
  overflow-x: hidden; overflow-x: clip;
  background-color: var(--paper);
  /* fine paper grain */
  background-image: var(--grain);
}
/* (no blanket Thai line-height: `:lang(th)` matched EVERY element and blew up the headline's spacing in Thai) */
img, svg { display: block; }
button { font: inherit; color: inherit; }
.defs { position: absolute; width: 0; height: 0; }

/* Signature right-edge orange strip */
.edge-strip { position: fixed; top: 0; right: 0; bottom: 0; width: 6px; background: var(--primary); z-index: 40; }

/* ---------- Header: logo + language toggle ---------- */
.top { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 30px 0 26px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; background: #fff; padding: 5px 9px; border: 1.5px solid var(--ink); border-radius: 8px; }
.logo { height: 34px; width: auto; }
.brand-text { font-family: var(--font-display); font-weight: 600; font-size: 22px; color: var(--text-strong); }
.top-right { display: flex; align-items: center; gap: 10px; }
.demo { font-size: 11px; font-weight: 700; color: #8A6D00; background: #FFF9E6; border-radius: 999px; padding: 4px 9px; }
.lang {
  display: inline-flex; padding: 3px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card-paper);
  box-shadow: 2px 2px 0 var(--ink);
}
.lang button {
  border: 0; background: none; cursor: pointer; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--text-strong); transition: background 200ms, color 200ms;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.lang button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- QR code (desktop only): "scan to open on your phone", taped under the logo ---------- */
.qr {
  position: absolute; left: 26px; top: calc(100% + 24px); width: 184px; padding: 12px 12px 9px;
  background: var(--card-paper); border: 1.5px solid var(--ink); border-radius: 12px; box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-3deg); text-align: center;
}
.qr[hidden] { display: none; }
.qr::before {                                   /* a strip of pink tape holding it to the page */
  content: ''; position: absolute; left: 50%; top: -12px; width: 76px; height: 21px; transform: translateX(-50%) rotate(4deg);
  background: rgba(242, 140, 168, .85); border-left: 2px dashed rgba(255, 255, 255, .6); border-right: 2px dashed rgba(255, 255, 255, .6);
}
.qr-code svg { width: 100%; height: auto; }
.qr-label { margin: 7px 0 0; font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--text-strong); }
body.is-ready .qr:not([hidden]) { animation: qrIn 700ms var(--ease) 900ms both; }
@keyframes qrIn { from { opacity: 0; transform: translateY(-12px) rotate(-9deg); } to { opacity: 1; transform: rotate(-3deg); } }
/* not enough room beside the headline / above the cards */
@media (max-width: 1199px), (max-height: 699px) { .qr { width: 148px; padding: 9px 9px 7px; } .qr-label { font-size: 12.5px; } .qr::before { width: 62px; height: 18px; top: -11px; } }
@media (max-width: 959px), (max-height: 559px) { .qr { display: none !important; } }

/* ---------- Doodles floating around the page ---------- */
.fest { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.doodle { position: absolute; opacity: 0; }
.doodle svg { width: 100%; height: 100%; overflow: visible; }
body.is-ready .doodle { animation: doodleIn 800ms var(--ease) var(--d, 600ms) forwards, bob var(--b, 6s) ease-in-out calc(var(--d, 600ms) + 800ms) infinite alternate; }
@keyframes doodleIn { from { opacity: 0; transform: scale(.3) rotate(calc(var(--r, 0deg) - 40deg)); } to { opacity: 1; transform: rotate(var(--r, 0deg)); } }
@keyframes bob { from { opacity: 1; transform: translateY(-5px) rotate(calc(var(--r, 0deg) - 4deg)); } to { opacity: 1; transform: translateY(6px) rotate(calc(var(--r, 0deg) + 5deg)); } }
.pop { position: absolute; width: 0; height: 0; z-index: 4; pointer-events: none; }
/* while a finger is on the cards, pause decorations so dragging gets every frame */
body.is-touching .fest *, body.is-touching .hint-dot, body.is-touching .scribble { animation-play-state: paused !important; }

/* ---------- Hero: editorial poster ---------- */
.main { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; overflow-x: hidden; overflow-x: clip; }
.hero {
  position: relative; text-align: center; padding: clamp(2px, 1vh, 14px) 24px 0; width: 100%; max-width: 920px;
  /* min-height is set by app.js to the TALLER of the Thai / English versions, so switching language never moves
     the cards. The content starts at the top of that space, so the headline and stamp stay put too (the shorter
     language just leaves a little more room under its last line). */
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.hl-row { display: flex; align-items: flex-end; justify-content: center; gap: .3em; }
.note {
  display: inline-flex; align-items: flex-end; gap: 2px; margin-bottom: .55em; white-space: nowrap;
  font-family: var(--font-accent); font-style: italic; font-weight: 500; font-size: clamp(17px, min(1.9vw, 3vh), 26px); line-height: 1.2; color: var(--primary);
  transform: rotate(-6deg);
}
.note-arrow { width: clamp(32px, 3.2vw, 46px); height: auto; margin-bottom: -14px; fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.headline { margin: 0; display: flex; flex-direction: column; align-items: center; font-family: var(--font-display); color: var(--text-strong); }
.hl { display: block; }
.hl-2 { position: relative; display: inline-block; margin: .1em 0 0; font-size: clamp(40px, min(5.2vw, 8.8vh), 84px); font-weight: 700; line-height: 1.08; color: var(--primary); }
.nw { white-space: nowrap; }                   /* "Father's Day" stays together when the headline wraps */
.hl-word { position: relative; z-index: 1; display: inline-block; padding: 0 .12em; }
.hl-word { font-style: italic; font-weight: 600; }   /* same in both languages (the phrase is English in both) */
.hl-aside {                                   /* "From the B.Grimm family, to every dad and…" */
  display: block; margin-top: .75em; padding: 0 12px; max-width: 880px;
  font-family: var(--font-display); font-style: italic; font-weight: 500; letter-spacing: .005em;
  font-size: clamp(15px, min(1.7vw, 2.6vh), 21px); line-height: 1.5;
  color: var(--primary-dark);
}
.hl-aside-text {                               /* highlighter follows each line when it wraps */
  padding: 0 .3em; background: linear-gradient(transparent 58%, var(--pink-soft) 58%, var(--pink-soft) 92%, transparent 92%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
body.is-ready .hl-aside { animation: rise 600ms var(--ease) 1250ms both; }

/* hand-drawn circle around the big word */
/* hand-drawn pink underline under the headline (drawn left → right; same stroke as the postcard's signature) */
.scribble { position: absolute; left: 2%; bottom: -.12em; width: 96%; height: .26em; overflow: visible; z-index: 0; clip-path: inset(-60% 100% -60% -2%); }
.scribble path { fill: none; stroke: var(--pink); stroke-width: 3.4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
body.is-ready .scribble { animation: wipeRight 900ms var(--ease) 900ms forwards; }
@keyframes drawIn { to { stroke-dashoffset: 0; } }

/* perforated postage stamp stuck beside the big word */
.pstamp {
  position: absolute; left: 100%; bottom: .14em; margin-left: .12em; width: clamp(46px, .8em, 96px); aspect-ratio: 5 / 6;   /* anchored at the bottom: grows up, never into the line below */
  display: grid; place-items: center; transform: rotate(9deg); z-index: 2;
}
.pstamp-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(2px 3px 0 rgba(99, 102, 111, .85)); }
.pstamp-text {
  position: relative; padding: 0 3px; font-family: var(--font-body); font-style: normal; font-weight: 600;
  font-size: clamp(8.5px, .15em, 14px); line-height: 1.15; color: var(--ink); text-align: center;
}
.sub { margin: 6px auto 0; max-width: 680px; font-size: clamp(14px, 1.3vw, 16px); color: var(--text); line-height: 1.6; }
.sub br { display: none; }               /* one line on desktop, two on phones */

/* entrance */
body.is-loading .hero > *, body.is-loading .top { opacity: 0; }
body.is-loading .hero > * { animation: show 0s 3s forwards; }       /* safety: show even if JS fails */
body.is-ready .top { animation: rise 600ms var(--ease) both; }
body.is-ready .note { animation: noteIn 700ms var(--ease) 700ms both; }
body.is-ready .hl-2 { animation: pop 650ms cubic-bezier(.2, 1.4, .4, 1) 260ms both; }
body.is-ready .pstamp { animation: stampIn 650ms cubic-bezier(.2, 1.5, .4, 1) 1100ms both; }
body.is-ready .sub { animation: rise 700ms var(--ease) 560ms both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(1.35) rotate(-4deg); } to { opacity: 1; transform: none; } }
@keyframes stampIn { from { opacity: 0; transform: translate(30px, -40px) scale(1.5) rotate(-30deg); } to { opacity: 1; transform: rotate(9deg); } }
@keyframes noteIn { from { opacity: 0; transform: translateX(-12px) rotate(-12deg); } to { opacity: 1; transform: rotate(-5deg); } }
@keyframes show { to { opacity: 1; } }

/* ---------- Stage: cards glide along a half-oval ---------- */
.stage {
  position: relative; width: 100%; flex: 1 0 auto; min-height: calc(var(--ch) * 1.52 + 30px);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; outline: none;
}
body.is-ring .stage { cursor: grab; }
/* Phones & tablets: lock vertical scrolling. The page is laid out to fit one screen, so nothing is lost.
   touch-action: none hands every gesture on the cards to our drag code — a slightly diagonal swipe no longer
   turns into a page scroll halfway (which cancelled the drag and made the cards jump). */
html.no-scroll, html.no-scroll body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.no-scroll .stage, html.no-scroll .card { touch-action: none; }
body.is-dragging .stage { cursor: grabbing; }

.floor { position: absolute; left: 50%; top: 70%; width: min(1120px, 92%); height: 1px; transform: translateX(-50%); z-index: 3; }
.pile-shadow {
  position: absolute; left: 50%; top: 0; width: calc(var(--cw) * 1.25); height: 18px;
  transform: translate(-50%, -50%) scale(.3); opacity: 0; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(99, 102, 111, .22), transparent);
  transition: transform 700ms var(--ease), opacity 600ms;
}
body.is-dropping .pile-shadow { transform: translate(-50%, -50%) scale(1); opacity: 1; transition-delay: 500ms; }
body.is-dealing .pile-shadow { opacity: 0; transform: translate(-50%, -50%) scale(1.8); transition-delay: 0ms; }

/* the ground: paper band + one hand-drawn ink line — cards sink behind it */
.ground { position: absolute; left: 0; width: 100%; z-index: 2; pointer-events: none; overflow: visible; opacity: 0; transition: opacity 700ms 250ms; }
body.is-ready .ground { opacity: 1; }
.ground .ink-line { stroke-dasharray: 1; stroke-dashoffset: 1; }
body.is-ready .ground .ink-line { animation: drawIn 1400ms var(--ease) 300ms forwards; }
body.is-ready .ground.is-drawn .ink-line { animation: none; stroke-dashoffset: 0; }

.ring { position: absolute; left: 0; right: 0; top: calc(var(--ro, 0px) * -1); bottom: 0; pointer-events: none; overflow: hidden; overflow: clip;
  z-index: 1; }   /* own layer BELOW the ground (z 2): the intro's card stacking order (z 0–7) can't lift a card over it */
.measure { position: absolute; width: 0; height: 0; overflow: hidden; }

/* The motion itself: each card rides an oval track (CSS Motion Path), spaced by --i/--n */
.ring.is-moving .card {
  transform: none;
  offset-path: var(--path); offset-rotate: auto; offset-anchor: center;
  animation: travel var(--dur) linear infinite;
  animation-delay: calc(var(--dur) * var(--i) / var(--n) * -1);
  will-change: transform;                     /* own graphics layer: moving it needs no repaint */
}
/* --end > 100% when there are more cards than fit: past 100% a card simply waits, hidden, at the end */
@keyframes travel { from { offset-distance: 0%; } to { offset-distance: var(--end, 100%); } }

.card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  padding: 0; border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; pointer-events: auto; touch-action: pan-y;
  transform: translateY(-200vh);
}
.face {
  position: absolute; inset: 0; border-radius: 12px; overflow: hidden; background: var(--card-paper);
  border: 1.5px solid var(--ink);
  box-shadow: 0 12px 26px rgba(99, 102, 111, .14), 0 2px 5px rgba(99, 102, 111, .08);
  transition: transform 500ms var(--ease), box-shadow 400ms var(--ease), opacity 400ms;
}
.face img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.card.is-front .face { box-shadow: 5px 6px 0 var(--primary), 0 16px 30px rgba(99, 102, 111, .14); }
.card:focus-visible { outline: none; }
.card:focus-visible .face { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--primary); }

/* roulette hop */
.card.is-hop .face { transform: translateY(-8px) scale(1.04); box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--primary); transition-duration: 120ms; }
/* the lucky card: lift, orange ring + pink print shadow, wiggle, hand-written badge */
.card.is-lucky .face {
  transform: translateY(var(--lift, -22px)) scale(var(--grow, 1.15));
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 7px var(--primary), 8px 10px 0 9px var(--pink);
  animation: wiggle 900ms var(--ease) 200ms 2;
}
/* "This one?" — one bubble for the whole stage, placed by app.js (showBubble) so it is always fully on screen */
.bubble {
  position: absolute; left: 0; top: 0; z-index: 4; transform: translateY(8px) scale(.6) rotate(-4deg); opacity: 0;
  white-space: nowrap; padding: 4px 14px 5px; border-radius: 10px; border: 1.5px solid var(--ink);
  background: var(--primary); color: #fff; font-family: var(--font-body); font-weight: 600; font-size: 15px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform 400ms var(--ease), opacity 250ms; pointer-events: none;
}
.bubble.is-on { opacity: 1; transform: scale(1) rotate(-3deg); }
.sp { position: absolute; width: 26px; height: 26px; opacity: 0; transform: scale(0); pointer-events: none; }
.sp svg { width: 100%; height: 100%; overflow: visible; }
.sp1 { left: -20px; top: 10%; } .sp2 { right: -22px; top: 36%; width: 20px; height: 20px; } .sp3 { left: -14px; bottom: 12%; width: 18px; height: 18px; }
.card.is-lucky .sp { animation: twinkle 1100ms var(--ease) infinite; }
.card.is-lucky .sp2 { animation-delay: 220ms; } .card.is-lucky .sp3 { animation-delay: 440ms; }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -3deg; } 60% { rotate: 2.5deg; } }
@keyframes twinkle { 0% { opacity: 0; transform: scale(0) rotate(0); } 40% { opacity: 1; transform: scale(1) rotate(25deg); } 100% { opacity: 0; transform: scale(.4) rotate(50deg); } }
body.has-pick .card:not(.is-picked) .face { opacity: .3; }
.card.is-picked .face { transform: translateY(-24px) scale(1.14); box-shadow: 6px 8px 0 var(--primary); }

/* hint under the horizon */
.hint {
  position: absolute; left: 50%; top: 72%; z-index: 3; margin: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap;
  transform: translate(-50%, 6px); opacity: 0; font-family: var(--font-body); font-weight: 600; font-size: 14px; color: var(--text-strong);
  transition: opacity 600ms, transform 600ms var(--ease);
}
.hint-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 0 rgba(255, 103, 39, .5); animation: pulse 1.8s infinite; }
body.is-ring .hint { opacity: 1; transform: translate(-50%, 0); }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(255, 103, 39, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 103, 39, 0); } }

/* ---------- Dialog ---------- */
.dlg {
  width: min(880px, calc(100% - 32px)); max-width: none; max-height: calc(100svh - 32px);
  padding: 0; border: 0; overflow: visible; background: transparent; color: var(--text-strong);
}
.dlg[open] { animation: dlgIn 450ms var(--ease); }
.dlg::backdrop { background: rgba(99, 102, 111, .35); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.dlg-inner {
  position: relative; background-color: var(--card-paper); border: 1px solid rgba(99, 102, 111, .12); border-radius: 18px;
  box-shadow: 0 26px 70px rgba(99, 102, 111, .22), 0 3px 10px rgba(99, 102, 111, .08); max-height: calc(100svh - 32px); overflow-y: auto;
}
@keyframes dlgIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
.dlg-close {
  position: absolute; top: 14px; right: 14px; z-index: 6; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(99, 102, 111, .16); background: var(--card-paper); cursor: pointer; display: grid; place-items: center;
}
.dlg-close svg { width: 18px; height: 18px; fill: none; stroke: var(--text-strong); stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) { .dlg-close:hover { background: var(--pink-soft); } }

.step[hidden] { display: none !important; }
.step-form { display: grid; grid-template-columns: minmax(230px, 310px) 1fr; }
.dlg-card { position: relative; margin: 0; background: var(--green-soft); border-right: 1px solid rgba(99, 102, 111, .08); border-radius: 17px 0 0 17px; display: flex; align-items: center; justify-content: center; padding: 34px 30px; }
.dlg-card img { width: 100%; max-width: 240px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; border: 1px solid rgba(99, 102, 111, .14); transform: rotate(-3deg); box-shadow: 0 14px 30px rgba(99, 102, 111, .18); }
.tape { position: absolute; z-index: 2; width: 74px; height: 22px; background: rgba(255, 103, 39, .78); border-left: 2px dashed rgba(255, 255, 255, .6); border-right: 2px dashed rgba(255, 255, 255, .6); }
.tape.t1 { top: 26px; left: 30px; transform: rotate(-24deg); }
.tape.t2 { bottom: 28px; right: 30px; transform: rotate(-20deg); background: rgba(242, 140, 168, .85); }
.dlg-body { position: relative; padding: 34px 36px 30px; }
.step-no { margin: 0 0 4px; font-family: var(--font-accent); font-style: italic; font-weight: 500; font-size: 16px; color: var(--primary); }
.dlg-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, 3vw, 31px); line-height: 1.3; color: var(--text-strong); }
.dlg-sub { margin: 4px 0 18px; font-size: 14px; color: var(--text); }

.field { display: block; margin-bottom: 13px; }
.field > span:first-child { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; color: var(--text-strong); }
.field[hidden] { display: none; }
.field b { color: var(--primary-dark); font-weight: 600; }

/* email domain suggestions */
.combo { position: relative; display: block; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; margin: 0; padding: 4px; list-style: none;
  max-height: 216px; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid #D8D0C4; border-radius: 10px; box-shadow: 0 12px 28px rgba(99, 102, 111, .16);
}
.suggest[hidden] { display: none; }
.suggest li {
  padding: 9px 12px; border-radius: 7px; font-size: 15px; line-height: 1.35; color: var(--muted); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest li b { color: var(--text-strong); font-weight: 600; }
.suggest li[aria-selected="true"] { background: var(--primary-soft); }
@media (hover: hover) { .suggest li:hover { background: var(--pink-soft); } }
.field .opt { font-style: normal; font-weight: 400; color: var(--muted); }
.field input, .field select {
  width: 100%; height: 48px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--text-strong);
  background: #fff; border: 1px solid #D8D0C4; border-radius: 10px; outline: none;
  transition: border-color 160ms, box-shadow 160ms; -webkit-appearance: none; appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2363666F' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; padding-right: 40px;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field .is-invalid { border-color: var(--danger); background-color: #FFEBEA; }
.privacy { margin: 4px 0 0; font-size: 12px; line-height: 1.55; color: var(--text); }
.privacy:empty { display: none; }
.msg { margin: 10px 0 0; font-size: 13px; color: var(--danger-text); }
.msg:empty { display: none; }
.msg.is-info { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 52px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 111, .10); transition: transform 140ms var(--ease), box-shadow 140ms, background 160ms;
}
.btn:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(99, 102, 111, .12); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { width: 100%; margin-top: 16px; background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(255, 103, 39, .30); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-ghost { background: var(--card-paper); color: var(--text-strong); border-color: #D8D0C4; }
@media (hover: hover) { .btn-primary:hover { background: var(--primary-dark); } .btn-ghost:hover { background: var(--pink-soft); } }

/* ---------- Step 2: the postcard (same look as the rest: paper grain, ink outline, offset print shadow,
              tape, highlighter, hand-drawn lines and watercolor doodles) ---------- */
.step-share { padding: 34px 36px 30px; }
.pc-wrap { perspective: 1400px; display: flex; justify-content: center; padding: 10px 0 6px; }
.postcard {
  position: relative; container-type: inline-size; width: min(560px, calc(100% - 10px)); aspect-ratio: 3 / 2;
  background-color: var(--card-paper); background-image: var(--grain);
  border: 1.5px solid var(--ink); border-radius: 12px;
  box-shadow: 6px 7px 0 var(--primary), 0 18px 34px rgba(99, 102, 111, .12);
  font-family: var(--font-accent); font-style: italic; font-weight: 500; color: var(--ink);
}
/* cqw only measures the postcard from INSIDE it — so the spacing lives on this inner layer, not on .postcard */
.pc-inner {
  position: absolute; inset: 0; overflow: hidden; border-radius: 11px;
  display: grid; grid-template-columns: minmax(0, 1fr) 2.2cqw minmax(0, 1fr); gap: 0 3.6cqw; padding: 6cqw 6cqw 5.5cqw;
}

/* left: the letter */
.pc-left { display: flex; flex-direction: column; justify-content: center; gap: 1.7cqw; min-height: 0; }
.pc-kicker {
  margin: 0 0 .4cqw; font-family: var(--font-body); font-style: normal; font-weight: 700; font-size: max(9px, 2.3cqw);
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink);
}
.pc-kicker-star { color: var(--primary); }
:lang(th) .pc-kicker { letter-spacing: .02em; }   /* Thai is never letter-spaced: it pulls vowels/tone marks apart */
.pc-dear { margin: 0; font-size: 5.4cqw; font-weight: 600; color: var(--text-strong); }
.pc-name {                                     /* the name on a pink highlighter stroke, like the hero's aside */
  color: var(--primary); padding: 0 .08em; margin-right: -.04em;
  background: linear-gradient(transparent 56%, var(--pink-soft) 56%, var(--pink-soft) 92%, transparent 92%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.pc-msg { margin: 0; font-size: 4cqw; line-height: 1.45; color: var(--text-strong); }
.pc-sign { position: relative; align-self: flex-start; max-width: 100%; padding-bottom: 1.6cqw; }
.pc-from { margin: 0; font-size: 4.3cqw; font-weight: 600; color: var(--green-deep); }
.pc-swash { position: absolute; left: -2%; bottom: 0; width: 78%; height: 2.6cqw; overflow: visible; clip-path: inset(-50% 100% -50% -5%); }
.pc-swash path { fill: none; stroke: var(--pink); stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
/* names can be long (to: 40 chars, name: 100): at most 2 lines, then "…", and a smaller size when long */
.pc-dear, .pc-from, .pc-to {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere; line-height: 1.4; flex: none;
}
.pc-dear.is-long { font-size: 4.4cqw; }
.pc-from.is-long { font-size: 3.6cqw; }

/* hand-drawn divider */
.pc-divider { width: 100%; height: 100%; overflow: visible; }
.pc-divider { clip-path: inset(0 -50% 100% -50%); }
.pc-divider path { fill: none; stroke: var(--ink); stroke-opacity: .55; stroke-width: 1.4; stroke-linecap: round; vector-effect: non-scaling-stroke; }

/* right: stamp, postmark, address */
.pc-right { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; padding-bottom: 1cqw; }
.pc-stamp { position: absolute; top: -1.5cqw; right: -1cqw; width: 26cqw; aspect-ratio: 5 / 6; display: grid; place-items: center; transform: rotate(5deg); }
.pc-stamp-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(2px 3px 0 rgba(99, 102, 111, .85)); }
.pc-stamp img { position: relative; width: 76%; height: 78%; object-fit: cover; border: 1px solid rgba(99, 102, 111, .5); }
.pc-postmark { position: absolute; top: 11cqw; right: 17cqw; width: 29cqw; aspect-ratio: 8 / 5; transform: rotate(-10deg); pointer-events: none; }
.pc-postmark svg { width: 100%; height: 100%; overflow: visible; }
.pc-heart { position: absolute; left: -1cqw; top: 1cqw; width: 9cqw; height: 9cqw; transform: rotate(-12deg); }
.pc-heart svg { width: 100%; height: 100%; overflow: visible; }
.pc-to { margin: 0 0 .4cqw; font-size: 4.3cqw; font-weight: 600; -webkit-line-clamp: 1; line-clamp: 1; }   /* 1 line under the stamp */
.pc-to.is-long { font-size: 3.6cqw; }
.pc-addr { margin: 0; font-size: 3.5cqw; color: var(--text); }
.pc-line { display: block; height: 0; margin-top: 4.2cqw; border-top: 1.5px dashed rgba(99, 102, 111, .32); }

/* tape strips on two corners (as on the card in step 1) */
.pc-tape {
  position: absolute; z-index: 3; width: 21cqw; height: 6cqw; pointer-events: none;
  border-left: 2px dashed rgba(255, 255, 255, .6); border-right: 2px dashed rgba(255, 255, 255, .6);
}
.pc-tape-a { top: -2.4cqw; left: -3.6cqw; background: rgba(255, 103, 39, .78); transform: rotate(-24deg); }
.pc-tape-b { bottom: -2.2cqw; right: -3.4cqw; background: rgba(242, 140, 168, .85); transform: rotate(-20deg); }

/* the letter animation (plays once each time the card is saved) */
.postcard, .pc-kicker, .pc-write, .pc-msg, .pc-stamp, .pc-postmark, .pc-heart, .pc-tape { opacity: 0; }
.step-share.is-playing .postcard { animation: flipIn 750ms var(--ease) both, thump 260ms ease-out 2120ms; }
.step-share.is-playing .pc-tape-a { animation: tapeStickA 420ms cubic-bezier(.2, 1.3, .4, 1) 520ms both; }
.step-share.is-playing .pc-divider { animation: wipeDown 800ms var(--ease) 450ms forwards; }
.step-share.is-playing .pc-kicker { animation: rise 450ms var(--ease) 600ms both; }
.step-share.is-playing .pc-dear { animation: writeIn 520ms ease-out 750ms both; }
.step-share.is-playing .pc-msg { animation: inkIn 650ms var(--ease) 1050ms both; }
.step-share.is-playing .pc-from { animation: writeIn 460ms ease-out 1450ms both; }
.step-share.is-playing .pc-swash { animation: wipeRight 480ms var(--ease) 1850ms forwards; }
.step-share.is-playing .pc-stamp { animation: stampDrop 560ms cubic-bezier(.2, 1.35, .45, 1) 1650ms both; }
.step-share.is-playing .pc-postmark { animation: postmark 340ms cubic-bezier(.3, 1.5, .5, 1) 2100ms both; }
.step-share.is-playing .pc-heart { animation: heartPop 520ms cubic-bezier(.2, 1.5, .4, 1) 2300ms both; }
.step-share.is-playing .pc-tape-b { animation: tapeStickB 420ms cubic-bezier(.2, 1.3, .4, 1) 2450ms both; }
@keyframes flipIn { from { opacity: 0; transform: rotateY(-95deg) rotate(-6deg) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes writeIn { from { opacity: 1; clip-path: inset(-20% 100% -20% 0); } to { opacity: 1; clip-path: inset(-20% -4% -20% 0); } }
@keyframes inkIn { from { opacity: 0; transform: translateY(1.2cqw); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes stampDrop { from { opacity: 0; transform: translate(-40%, -130%) rotate(-34deg) scale(1.5); } to { opacity: 1; transform: rotate(5deg); } }
@keyframes postmark { from { opacity: 0; transform: rotate(-10deg) scale(1.9); } to { opacity: .92; transform: rotate(-10deg) scale(1); } }
@keyframes heartPop { from { opacity: 0; transform: scale(.3) rotate(-50deg); } to { opacity: 1; transform: rotate(-12deg); } }
@keyframes tapeStickA { from { opacity: 0; transform: translate(-3cqw, -3cqw) rotate(-38deg) scale(1.25); } to { opacity: 1; transform: rotate(-24deg); } }
@keyframes tapeStickB { from { opacity: 0; transform: translate(3cqw, 3cqw) rotate(-6deg) scale(1.25); } to { opacity: 1; transform: rotate(-20deg); } }
@keyframes thump { 0%, 100% { transform: none; } 40% { transform: translateY(3px) scale(.99); } }
@keyframes wipeDown { to { clip-path: inset(0 -50% 0 -50%); } }
@keyframes wipeRight { to { clip-path: inset(-50% -5% -50% -5%); } }

.share-panel { margin: 22px auto 0; max-width: 560px; text-align: center; opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity 500ms var(--ease), transform 500ms var(--ease); }
.share-panel.is-in { opacity: 1; transform: none; pointer-events: auto; }
.share-panel .dlg-sub { margin-bottom: 14px; }
.apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.app {
  display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 14px;
  background: #fff; border: 1px solid #D8D0C4; border-radius: 12px; box-shadow: 0 3px 10px rgba(99, 102, 111, .07);
  font-size: 15px; font-weight: 700; color: var(--text-strong); cursor: pointer; text-align: left;
  transition: transform 140ms var(--ease), box-shadow 140ms, background 160ms;
}
.app span { flex: 1; }
.app em { font-style: normal; color: var(--muted); }
.app:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(99, 102, 111, .1); }
.app:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (hover: hover) { .app:hover { background: var(--pink-soft); } .save:hover { text-decoration: underline; } }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot-line { background: #06C755; } .dot-wa { background: #25D366; } .dot-ms { background: #0084FF; }
.save { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--primary-dark); text-decoration: none; }
/* Two flows: phones & tablets share through an app; computers (mouse / trackpad) download only */
body.is-desktop .flow-mobile, body:not(.is-desktop) .flow-desktop { display: none; }
.btn-dl { width: auto; min-width: 260px; margin-top: 4px; text-decoration: none; }
.save svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Done ---------- */
.step-done { padding: 40px 36px 36px; text-align: center; }
.done-plane { width: 120px; height: 120px; margin: 0 auto 10px; }
.done-plane svg { width: 100%; height: 100%; overflow: visible; }
.step-done:not([hidden]) .done-plane { animation: fly-in 1100ms var(--ease) both; }
@keyframes fly-in { from { opacity: 0; transform: translate(-140px, 60px) rotate(-30deg) scale(.6); } to { opacity: 1; transform: none; } }
.step-done .dlg-sub { margin-bottom: 22px; }

/* celebration burst */
.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 5; }
.bit { position: absolute; width: var(--sz); height: var(--sz); margin: calc(var(--sz) / -2); animation: fly 1300ms var(--ease) forwards; }
.bit svg { width: 100%; height: 100%; overflow: visible; }
@keyframes fly { 0% { transform: translate(0, 0) scale(.2) rotate(0deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(var(--x), var(--y)) scale(1) rotate(var(--r)); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.noscript { text-align: center; color: var(--text); }

/* Footer: last row of the page (the card stage measures the space left above it) */
.foot {
  position: relative; z-index: 1; flex: none; margin: 0; padding: 4px 16px calc(8px + env(safe-area-inset-bottom));
  background: #FAF6EF;                                  /* same flat paper as the ground band above it: no seam */
  text-align: center; font-family: var(--font-body); font-size: 11.5px; line-height: 1.4; letter-spacing: .02em;
  color: var(--text); opacity: .75; white-space: nowrap;
}
body.is-loading .foot { opacity: 0; }
body.is-ready .foot { animation: footIn 600ms var(--ease) 1400ms both; }
@keyframes footIn { from { opacity: 0; } to { opacity: .75; } }
@media (max-height: 560px) { .foot { padding: 1px 16px calc(3px + env(safe-area-inset-bottom)); font-size: 10.5px; } }

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
  .top { padding: 14px 20px 0 16px; }
  .logo { height: 27px; }
  .brand { padding: 4px 7px; }
  .lang button { padding: 4px 10px; font-size: 12px; }
  .sub br { display: inline; }
  /* Phones: in the empty space right of "Happy" (line 1), sized to that line so it never covers "Father's Day" or the note.
     1.9em = half the width of "Happy" + a gap (em = headline size); --l1 = middle of line 1. */
  .hl-word .nw { display: block; }   /* always "Happy" / "Father's Day" on two lines (wide iPhones would fit one line) */
  /* app.js (placeStamp) sets left/top from the measured end of "Happy"; these are the starting values */
  .pstamp { --sw: 40px; width: var(--sw); left: calc(50% + 1.9em); right: auto; top: calc(var(--l1, .54em) - var(--sw) * .6); bottom: auto; margin-left: 0; }
  .pstamp-text { font-size: 8.5px; padding: 0 3px; }
  .sub { font-size: 14px; margin-top: 8px; padding: 0 6px; }

  /* dialog becomes a bottom sheet */
  .dlg { width: 100%; max-height: 94svh; margin: auto 0 0; }
  .dlg[open] { animation: sheetIn 480ms var(--ease); }
  .dlg-inner { border-radius: 18px 18px 0 0; max-height: 94svh; box-shadow: 0 -10px 40px rgba(99, 102, 111, .18); border-bottom: 0; }
  /* one fixed sheet height for every step: the sheet no longer jumps when "Save" swaps the form for the postcard */
  .dlg-inner { height: 94svh; display: flex; flex-direction: column; overscroll-behavior: contain; }
  .step-done:not([hidden]) { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .step-form { grid-template-columns: 1fr; }
  .dlg-card { border-right: 0; border-bottom: 1px solid rgba(99, 102, 111, .08); border-radius: 17px 17px 0 0; padding: 22px 0 18px; }
  .dlg-card img { width: 118px; box-shadow: 0 10px 22px rgba(99, 102, 111, .18); }
  .tape { width: 54px; height: 17px; } .tape.t1 { top: 16px; left: calc(50% - 90px); } .tape.t2 { bottom: 14px; right: calc(50% - 90px); }
  .dlg-body { padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); }
  .step-share { padding: 56px 16px calc(22px + env(safe-area-inset-bottom)); }
  .apps { grid-template-columns: 1fr; }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
}
/* Laptop widths, where the QR card stands beside the headline: keep the long English line clear of it */
@media (min-width: 960px) and (max-width: 1399px) { .hl-aside { font-size: clamp(14px, min(1.5vw, 2.6vh), 21px); } }

/* Short screens (phones in landscape, short laptop windows): compress the hero so the cards still fit above the fold */
@media (max-height: 560px) {
  .top { padding-top: 8px; }
  .logo { height: 24px; }
  .brand { padding: 3px 7px; }
  .note { font-size: 15px; margin-bottom: .2em; }
  .note-arrow { width: 28px; margin-bottom: -8px; }
  .hl-2 { font-size: clamp(30px, 8.6vh, 56px); line-height: 1.02; }
  .hl-aside { font-size: 13px; margin-top: .15em; }
  .pstamp { --sw: 34px; --l1: .51em; width: var(--sw); }
  .pstamp-text { font-size: 7px; padding: 0 2px; }
  .sub { margin-top: 2px; font-size: 13px; line-height: 1.45; }
  .sub br { display: none; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .pstamp { left: 100%; right: auto; top: auto; bottom: .1em; margin-left: .12em; }
  .hl-word .nw { display: inline; }   /* phones held sideways: one-line headline (the two-line rule above is for portrait), so the cards, hint and footer fit */
}
@media (max-height: 420px) {
  .hl-aside { font-size: 12px; }
}
@media (max-width: 360px) { .note { font-size: 14.5px; } .pstamp { --sw: 36px; } .pstamp-text { font-size: 7.5px; padding: 0 2px; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0ms !important; animation-delay: 0ms !important; }
  .ring.is-moving .card { animation-duration: var(--dur) !important; animation-iteration-count: infinite !important; animation-delay: calc(var(--dur) * var(--i) / var(--n) * -1) !important; }
}
