/* The letter builder (letter/index.html). The look borrows the designer's mockup (2026-11-04: "just borrow the setup,
   colors"): the site's cream page around the paper, a white tool tray, brand red for the main action, gold for the
   active mode, the modes Çək / Aa Yaz / Bəzə at the bottom. Ours stay: the crayons, the stickers, the handwriting font
   on the paper. The interface uses the site's own font (css/tokens.css). */
@font-face {
  font-family: "Playpen Letter";
  src: url(/letter/PlaypenSans-Letter.woff) format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: block;
}
:root {
  --hand: "Playpen Letter", "Comic Sans MS", "Segoe Print", cursive;
  --top-h: 60px;
  --soft: #f3ede5;
  --night-text: #f8efe2;
  color-scheme: light;
}
[hidden] { display: none !important; }
html { box-sizing: border-box; height: 100%; overflow: hidden; }
*, *::before, *::after { box-sizing: inherit; }
html.i18n-pending body { visibility: hidden; animation: lb-reveal 0s 1.2s forwards; }
@keyframes lb-reveal { to { visibility: visible; } }
body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--c-bg); color: var(--c-ink); font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 3px solid var(--c-ink); outline-offset: 2px; }
img:not([src]) { visibility: hidden; }

/* ---------- buttons ---------- */
.lb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 22px; border: 0; border-radius: 999px;
  font-size: 16px; font-weight: 600; line-height: 1.25; text-align: center; text-wrap: balance;
}
.lb-btn svg { width: 20px; height: 20px; flex: none; }
.lb-btn-red { background: var(--c-red); color: var(--c-white); box-shadow: 0 8px 18px color-mix(in srgb, var(--c-red) 26%, transparent); }
.lb-btn-red:hover { background: var(--c-red-deep); }
.lb-btn-gold { background: var(--c-gold); color: var(--c-gold-button-text); }
.lb-btn-soft { background: color-mix(in srgb, var(--c-red) 8%, var(--c-white)); color: var(--c-red); }
.lb-btn-text { min-height: 44px; background: none; color: var(--c-muted); font-weight: 500; }
.lb-btn:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* ---------- press and hold (js/hold.js) ---------- */
.hold { position: relative; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: none; }
.hold-ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); transform: rotate(-90deg); pointer-events: none; overflow: visible; }
.hold-ring circle { fill: none; stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
.hold-track { stroke: transparent; }
.hold-fill { stroke: var(--c-gold-on-light); stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: calc(1 - var(--hold, 0)); opacity: 0; transition: opacity .15s; }
.holding .hold-fill { opacity: 1; }
.holding .hold-track { stroke: color-mix(in srgb, var(--c-ink) 14%, transparent); }

/* ---------- the parent's intro ---------- */
.lb-intro { height: 100%; overflow: auto; display: grid; place-items: center;
  padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.lb-intro-card { width: min(100%, 420px); display: grid; justify-items: center; gap: 14px; text-align: center; }
.lb-logo { display: block; height: 28px; width: auto; }
.lb-intro-env { width: 176px; height: 113px; margin: 22px 0 8px; transform: rotate(-5deg); filter: drop-shadow(0 12px 20px rgba(42, 26, 23, .18)); }
.lb-intro h1 { margin: 0; font-size: clamp(27px, 7.4vw, 34px); font-weight: 700; line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
.lb-intro p { margin: 0; max-width: 34ch; font-size: 17px; line-height: 1.55; color: var(--c-muted); text-wrap: pretty; }
.lb-privacy { display: inline-flex; align-items: center; justify-content: center; gap: 8px; max-width: none !important; font-size: 14px !important; line-height: 1.4 !important; color: var(--c-muted); }
.lb-privacy svg { width: 16px; height: 16px; flex: none; }
.lb-intro .lb-btn { width: 100%; margin-top: 12px; }

/* ---------- the child's part ---------- */
.lb-app { height: 100%; display: flex; flex-direction: column; }
.lb-top {
  flex: none; display: flex; align-items: center; gap: 6px; min-height: var(--top-h);
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--c-line); position: relative; z-index: 35; background: var(--c-bg);
}
.lb-title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; line-height: 1.2; text-wrap: balance; overflow-wrap: anywhere; }
.lb-acts { flex: none; display: flex; align-items: center; gap: 2px; }
body:not([data-screen="child"]) .lb-acts { visibility: hidden; }
.lb-ic { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--c-ink); }
.lb-ic svg { width: 22px; height: 22px; }
.lb-ic:disabled { color: color-mix(in srgb, var(--c-ink) 28%, transparent); cursor: default; }
.lb-send {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-left: 6px; padding: 0 18px 0 15px;
  border: 0; border-radius: 999px; background: var(--c-red); color: var(--c-white); font-size: 16px; font-weight: 700;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--c-red) 28%, transparent);
}
.lb-send svg { width: 19px; height: 19px; }
.lb-x { flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; margin-right: 4px;
  border: 1px solid var(--c-line); border-radius: 50%; background: var(--c-paper); color: var(--c-ink); }
.lb-x > svg:not(.hold-ring) { width: 20px; height: 20px; }

.lb-make { flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding: 0 max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.lb-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 14px 4px 8px; }
.paper {
  position: relative; flex: none; border-radius: 6px; background: var(--c-paper);
  box-shadow: 0 1px 2px rgba(42, 26, 23, .08), 0 10px 28px rgba(42, 26, 23, .12);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.paper canvas { display: block; width: 100%; height: 100%; border-radius: 6px; touch-action: none; }
.paper.drawing canvas { cursor: crosshair; }

/* the selection frame around a sticker or text */
.sel { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; border: 2px dashed var(--c-gold-on-light); border-radius: 8px; pointer-events: none; }
.h { position: absolute; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; pointer-events: auto; cursor: pointer; touch-action: none; display: grid; place-items: center; }
.h::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--c-white); box-shadow: 0 2px 6px rgba(42, 26, 23, .3); }
.h svg { position: relative; width: 18px; height: 18px; color: var(--c-ink); }
.h-del { left: -22px; top: -22px; }
.h-del::before { background: var(--c-red); }
.h-del svg { color: var(--c-white); }
.h-edit { right: -22px; top: -22px; }
.h-rot { right: -22px; bottom: -22px; cursor: nwse-resize; }
.h-rot::before { background: var(--c-gold); }

.lb-toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 8px 18px;
  border-radius: 999px; background: var(--c-ink); color: var(--night-text); font-size: 15px; white-space: nowrap;
  box-shadow: 0 8px 20px rgba(42, 26, 23, .25);
}
.lb-toast:has(button) { padding-right: 6px; }
.lb-toast button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px 0 10px; border: 0; border-radius: 999px;
  background: rgba(248, 239, 226, .16); color: inherit; font-weight: 700; }
.lb-toast button svg { width: 18px; height: 18px; }

/* the prompt chips: shown in «Yaz»; their row keeps its place in every mode, so the paper never changes size */
.lb-prompts { flex: none; height: 50px; display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 2px; visibility: hidden; }
.lb-prompts::-webkit-scrollbar { display: none; }
.lb-prompts > :first-child { margin-left: auto; }
.lb-prompts > :last-child { margin-right: auto; }
body.mode-text .lb-prompts { visibility: visible; }
.lb-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px 0 12px;
  border: 0; border-radius: 999px; background: var(--c-white); color: var(--c-ink); font-size: 15px; font-weight: 500; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(42, 26, 23, .08), 0 3px 10px rgba(42, 26, 23, .06);
}
.lb-chip svg { width: 14px; height: 14px; color: var(--c-gold-on-light); }
.lb-chip:active { transform: scale(.97); }

/* the dock: the tray for the mode, then the modes */
.lb-dock { flex: none; width: 100%; max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px;
  border-radius: 28px; background: var(--c-white); box-shadow: 0 10px 30px rgba(42, 26, 23, .10), 0 1px 2px rgba(42, 26, 23, .06); }
.lb-tray { min-width: 0; height: 56px; display: flex; align-items: center; }
.lb-row { width: 100%; min-width: 0; display: flex; align-items: center; gap: 6px; }
.lb-sep { flex: none; width: 1px; height: 30px; margin: 0 2px; background: var(--c-line); }
.lb-dot { flex: none; position: relative; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: var(--soft); color: var(--c-ink); }
.lb-dot svg { width: 22px; height: 22px; }
.lb-dot > span { width: var(--d, 11px); height: var(--d, 11px); border-radius: 50%; background: var(--c-ink); }
.lb-dot.on, .lb-dot[aria-pressed="true"] { background: var(--c-white); box-shadow: inset 0 0 0 2.5px var(--c-gold-on-light); }
.lb-crayons { flex: 1; min-width: 0; height: 50px; display: flex; align-items: flex-end; justify-content: space-between; gap: 3px; }
.sw { position: relative; flex: 0 1 22px; min-width: 15px; height: 42px; padding: 0; border: 0; background: none; transition: transform .15s ease; }
.sw i {
  position: absolute; inset: 0; border-radius: 0 0 5px 5px;
  background: linear-gradient(to bottom, var(--c) 0 50%, rgba(255, 255, 255, .38) 50% 61%, var(--c) 61%), var(--c);
  clip-path: polygon(34% 0, 66% 0, 100% 30%, 100% 100%, 0 100%, 0 30%);
}
.sw[aria-pressed="true"] { transform: translateY(-7px); }
.lb-inks { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 3px; }
.ink { flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: var(--c); }
.ink[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--c-white), 0 0 0 5px var(--c-gold-on-light); }
.lb-stickers { overflow-x: auto; scrollbar-width: none; gap: 8px; padding: 2px; }
.lb-stickers::-webkit-scrollbar { display: none; }
.stk { flex: none; width: 52px; height: 52px; padding: 6px; border: 0; border-radius: 14px; background: var(--soft); transition: transform .12s ease; }
.stk img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.stk:active { transform: scale(.92); }
.lb-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 22px; background: var(--soft); }
.lb-mode { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 6px; border: 0; border-radius: 18px;
  background: transparent; color: var(--c-ink); font-size: 16px; font-weight: 600; }
.lb-mode svg { width: 20px; height: 20px; flex: none; }
.lb-mode .aa { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.lb-mode.on { background: var(--c-gold); color: var(--c-gold-button-text); }

/* ---------- dialogs: the text box, the letter once more ---------- */
.lb-overlay { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: center; align-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--c-ink) 45%, transparent); }
.lb-top-sheet { align-items: flex-start; }
.lb-card { width: 100%; max-width: 460px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 20px;
  border-radius: 24px; background: var(--c-paper); box-shadow: 0 20px 50px rgba(42, 26, 23, .25); }
.lb-card h2 { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.25; text-align: center; text-wrap: balance; }
.lb-card label { font-size: 17px; font-weight: 600; }
textarea {
  width: 100%; min-height: 120px; resize: vertical; padding: 12px 14px; border: 1.5px solid var(--c-line); border-radius: 16px;
  background: var(--c-white); color: var(--ink, #1e4fb8); font: 500 22px/1.35 var(--hand);
}
.lb-preview { display: grid; place-items: center; min-height: 160px; padding: 14px; border-radius: 18px; background: var(--c-tab-track); }
.lb-preview img { max-width: 100%; max-height: 50vh; max-height: 50dvh; width: auto; background: var(--c-white); box-shadow: 0 8px 20px rgba(42, 26, 23, .18); }
.lb-row2 { display: flex; gap: 10px; }
.lb-row2 > .lb-btn { flex: 1 1 0; min-width: 0; padding: 0 14px; }
.lb-bubble { position: absolute; z-index: 50; max-width: calc(100vw - 24px); padding: 9px 14px; border-radius: 14px;
  background: var(--c-ink); color: var(--night-text); font-size: 14px; line-height: 1.35; text-align: center; box-shadow: 0 8px 20px rgba(42, 26, 23, .25); }
#closeHint { top: calc(var(--top-h) + env(safe-area-inset-top) + 6px); left: 12px; }

/* ---------- the sending moment ---------- */
.lb-flight { position: fixed; inset: 0; z-index: 38; display: flex; flex-direction: column; align-items: center; overflow: hidden auto;
  padding: max(22px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(120% 80% at 50% 0%, #3b2520 0%, #23150f 55%, #170d0a 100%); color: var(--night-text); }
.lb-env { position: absolute; left: 50%; top: 52%; width: min(70vw, 300px); transform: translate(-50%, -50%); }
.lb-env-box { position: relative; width: 100%; aspect-ratio: 300 / 192; }
.lb-env-box > * { position: absolute; display: block; }
.env-back, .env-front { inset: 0; width: 100%; height: 100%; }
.env-open { left: 0; bottom: 100%; width: 100%; height: 52%; transform-origin: 50% 100%; }
.env-letter { left: 9%; width: 82%; bottom: 14%; transform-origin: 50% 100%; background: var(--c-white); box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.env-flap { left: 0; top: 0; width: 100%; height: 58%; transform-origin: 50% 0; transform: scaleY(0); }
.env-seal { left: 50%; top: 54%; width: 24%; height: auto; aspect-ratio: 1; transform: translate(-50%, -50%) scale(0); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
.lb-spark { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; pointer-events: none;
  background: var(--c-gold); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.lb-after { width: 100%; max-width: 460px; margin: auto 0; display: grid; justify-items: center; gap: 12px; text-align: center; opacity: 0; }
.lb-santa { position: relative; width: 100%; margin: 0 0 6px; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 22px;
  background: radial-gradient(80% 70% at 50% 60%, #6b2a1f 0%, #3a1c15 60%, #24130e 100%); box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
.lb-santa img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lb-santa.ph::after { content: ""; position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%);
  background: var(--c-gold); opacity: .85; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.lb-sent { margin: 0; font-size: clamp(20px, 5.6vw, 24px); font-weight: 700; line-height: 1.3; text-wrap: balance; }
.lb-handback { margin: 0; font-size: 18px; line-height: 1.4; color: var(--c-gold); text-wrap: balance; }
.lb-door-wrap { position: relative; flex: none; margin-top: 22px; display: grid; justify-items: center; opacity: 0; visibility: hidden; }
.lb-door-wrap.on { visibility: visible; }
.lb-door { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 18px 0 12px; border: 0; border-radius: 999px;
  background: rgba(248, 239, 226, .08); color: rgba(248, 239, 226, .8); font-size: 15px; }
.lb-door .hold-ring { position: static; inset: auto; width: 22px; height: 22px; flex: none; }
.lb-door .hold-track { stroke: currentColor; opacity: .4; }
.lb-door .hold-fill { stroke: var(--c-gold); opacity: 1; }
.lb-door:focus-visible { outline-color: var(--c-gold); }
.lb-bubble-up { bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--night-text); color: var(--c-ink); }

/* ---------- the parent's part ---------- */
.lb-sheet { z-index: 45; align-items: flex-end; padding: 0; background: rgba(10, 5, 4, .55); }
.lb-sheet-card { width: 100%; max-width: 520px; max-height: 100%; overflow: auto; display: grid; gap: 12px;
  padding: 10px 20px max(20px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--c-paper); color: var(--c-ink);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); animation: lb-up .35s cubic-bezier(.2, .8, .2, 1); }
.lb-grab { justify-self: center; width: 44px; height: 5px; margin-bottom: 2px; border-radius: 3px; background: var(--c-line); }
.lb-sheet-card .lb-logo { justify-self: center; height: 24px; }
.lb-thumb { display: grid; place-items: center; padding: 14px; border-radius: 18px; background: var(--c-tab-track); }
.lb-thumb img { max-width: 100%; max-height: min(28vh, 240px); width: auto; background: var(--c-white); box-shadow: 0 6px 16px rgba(42, 26, 23, .16); }
.lb-sheet-card h2 { margin: 6px 0 0; font-size: 26px; font-weight: 700; line-height: 1.2; text-align: center; text-wrap: balance; }
.lb-sheet-card .lb-btn { width: 100%; }
.lb-sub { margin: -4px 0 4px; font-size: 14px; line-height: 1.4; color: var(--c-muted); text-align: center; }
.lb-sheet-card .lb-privacy { justify-self: center; text-align: center; }
@keyframes lb-up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- inside the order (?embed=1): the header with ✕ stays on top; the screens open under it ---------- */
.embed .lb-overlay, .embed .lb-flight { top: calc(var(--top-h) + env(safe-area-inset-top)); }
.embed .lb-top { padding-left: max(10px, env(safe-area-inset-left)); }

/* ---------- printing: the letter alone, A4, fitted to the page ---------- */
.lb-print { display: none; }
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body > :not(#print) { display: none !important; }
  .lb-print { display: block !important; }
  .lb-print img { display: block; margin: 0 auto; }
  .lb-print.portrait img { width: 194mm; height: auto; }
  .lb-print.landscape img { height: 194mm; width: auto; }
}

@media (max-width: 380px) {
  .lb-title { font-size: 16px; }
  .lb-send { padding: 0 14px 0 12px; }
  .lb-mode { font-size: 15px; gap: 6px; }
}
@media (min-width: 860px) {
  .lb-dock { display: flex; align-items: center; gap: 14px; width: auto; max-width: none; margin-bottom: 4px; padding: 8px 12px 8px 8px; border-radius: 999px; }
  .lb-modes { order: -1; flex: none; width: 360px; border-radius: 999px; }
  .lb-mode { min-height: 44px; border-radius: 999px; }
  .lb-tray { flex: none; width: 430px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .sw, .stk, .lb-chip { transition: none; }
  .lb-sheet-card { animation: none; }
}
