/* LenaMiu Photo Booth: page styles. Always light: pastel pink, lavender, cream, ivory, caramel.
   Desktop: frames sidebar | card | photo + stickers + download.  Phone: card on top, bottom sheet with 3 tabs. */

:root {
  color-scheme: light;
  --ink: #2b2030; --muted: #7a6b80; --line: rgba(120, 70, 110, .14);
  --pink: #ff6fa8; --pink-d: #d63a78; --lav: #9a6bff; --lav-d: #7447dc;
  --cream: #fff6e8; --ivory: #fbf7f1; --caramel: #c98a4b;
  --glass: rgba(255, 255, 255, .64); --glass-edge: rgba(255, 255, 255, .85);
  --shadow: 0 1px 2px rgba(90, 40, 70, .05), 0 16px 36px -18px rgba(120, 50, 100, .38);
  --grad: linear-gradient(135deg, #ff7cb0 0%, #e86ab8 45%, #a77cff 100%);
  --r: 22px;
  --sheet-h: 204px;
  --ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: #fbf5f3; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; color: var(--ink); background: #fbf5f3;
  font: 400 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
/* soft pastel light behind everything */
body::before {
  content: ""; position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 38% at 8% 4%, #ffd6e7 0%, rgba(255, 214, 231, 0) 70%),
    radial-gradient(40% 40% at 96% 10%, #e6dcff 0%, rgba(230, 220, 255, 0) 70%),
    radial-gradient(50% 45% at 70% 100%, #ffeed8 0%, rgba(255, 238, 216, 0) 70%),
    radial-gradient(40% 40% at 0% 90%, #f3e4ff 0%, rgba(243, 228, 255, 0) 70%);
}
button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
svg { flex: none; }
button svg, .btn svg, .privacy svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
a:focus-visible, button:focus-visible, input:focus-visible, .tab:focus-visible { outline: 2px solid var(--pink-d); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid rgba(214, 58, 120, .16); background: rgba(255, 255, 255, .8);
  font-weight: 700; font-size: .95rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
  box-shadow: 0 6px 16px -12px rgba(120, 50, 100, .6);
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, opacity .2s ease;
}
.btn:hover { background: #fff; }
.btn:active { transform: scale(.97); }
.btn.primary {
  border: 0; color: #fff; background: var(--grad);
  box-shadow: 0 10px 24px -10px rgba(214, 58, 120, .65), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn[disabled], .btn.busy { opacity: .7; cursor: progress; }
.link-btn { border: 0; background: none; padding: 6px 4px; color: var(--pink-d); font-size: .85rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- header ---------- */
.top { grid-area: top; display: flex; align-items: center; gap: 12px 18px; min-width: 0; padding: 14px 2px 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; flex: none; text-decoration: none; color: var(--ink); border-radius: 12px; }
.brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 6px 14px -8px rgba(160, 60, 140, .7); }
.brand-txt { display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.brand-name { font-size: 1.28rem; font-weight: 800; letter-spacing: -.015em; }
.brand-sub {
  font-family: "Dancing Script", cursive; font-weight: 700; font-size: 1.62rem; line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-right: 2px;
}
.tagline { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--muted); font-size: .92rem; font-weight: 500; }
.dl-top { flex: none; margin-left: auto; min-height: 40px; padding: 8px 16px; font-size: .9rem; }

/* ---------- glass panels ---------- */
.pane {
  min-width: 0; padding: 18px; border-radius: var(--r);
  background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
}
.pane-title { margin: 0 0 12px; font-size: 1rem; font-weight: 700; letter-spacing: -.005em; }
.sub-title { margin: 18px 0 10px; font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.pane-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }

/* frames */
.frame-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.frame-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 8px 8px 9px;
  border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.frame-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 22px -16px rgba(120, 50, 100, .6); }
.frame-btn canvas { display: block; width: 100%; height: auto; border-radius: 4px; box-shadow: 0 4px 12px -6px rgba(90, 40, 70, .45); background: #f3ece8; }
.frame-btn span { font-size: .8rem; font-weight: 600; line-height: 1.25; text-align: center; }
.frame-btn[aria-pressed="true"] {
  border-color: transparent;
  background: linear-gradient(#fff, #fff) padding-box, var(--grad) border-box; border: 2px solid transparent; padding: 7px 7px 8px;
  box-shadow: 0 12px 26px -16px rgba(214, 58, 120, .7);
}
.frame-btn[aria-pressed="true"] span { color: var(--pink-d); }
.frame-btn[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--grad) center/14px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"), var(--grad);
  box-shadow: 0 3px 8px -3px rgba(214, 58, 120, .8);
}

/* sizes */
.sizes { display: grid; gap: 8px; }
.size-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 8px 14px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7); text-align: left;
}
.size-btn b { font-size: .88rem; font-weight: 700; }
.size-btn small { color: var(--muted); font-size: .76rem; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.size-btn i { position: relative; display: block; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(120, 70, 110, .3); background: #fff; }
.size-btn[aria-checked="true"] { border-color: rgba(214, 58, 120, .5); background: #fff; box-shadow: inset 0 0 0 1px rgba(214, 58, 120, .35); }
.size-btn[aria-checked="true"] b { color: var(--pink-d); }
.size-btn[aria-checked="true"] i { border-color: transparent; background: var(--grad); box-shadow: 0 2px 6px -2px rgba(214, 58, 120, .8); }
.size-btn[aria-checked="true"] i::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #fff; }
.size-btn .sz-l { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* ---------- stage + card ---------- */
.stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; padding: 8px; }
.card-wrap {
  position: relative; width: 300px; max-width: 100%; aspect-ratio: 4 / 5; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.card {
  display: block; width: 100%; height: 100%; border-radius: 3px; cursor: grab;
  box-shadow: 0 2px 4px rgba(90, 40, 70, .08), 0 28px 60px -24px rgba(110, 40, 90, .5), 0 10px 24px -14px rgba(110, 40, 90, .3);
  background: #f6efe9;
}
.card-wrap.dragging .card { cursor: grabbing; }
.card-wrap.no-photo .card { cursor: default; }
.add-photo {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(78%, 270px); padding: 18px 14px 16px;
  border-radius: 20px; border: 1.5px dashed rgba(214, 58, 120, .45); background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--ink); text-align: center;
  box-shadow: 0 14px 30px -18px rgba(120, 50, 100, .7); transition: transform .2s ease, background-color .2s ease;
}
.add-photo:hover { background: rgba(255, 255, 255, .88); transform: translate(-50%, -50%) scale(1.02); }
.add-ico { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(214, 58, 120, .8); }
.add-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.add-t { font-weight: 700; font-size: 1rem; }
.add-s { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.drop-hint {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 4px; pointer-events: none;
  background: rgba(255, 240, 247, .82); border: 3px dashed var(--pink); color: var(--pink-d); font-weight: 800; font-size: 1.1rem;
}
.busy {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(255, 250, 252, .66); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  color: var(--pink-d); font-weight: 700; font-size: .95rem;
}
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3.5px solid rgba(214, 58, 120, .2); border-top-color: var(--pink-d); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* selected sticker: dashed box + one corner handle (drag = resize + rotate) */
.sel {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  border: 1.5px dashed rgba(255, 255, 255, .95); border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(214, 58, 120, .55), inset 0 0 0 1px rgba(214, 58, 120, .25);
}
.sel-handle {
  position: absolute; right: -17px; bottom: -17px; width: 34px; height: 34px; border-radius: 50%; pointer-events: auto;
  display: grid; place-items: center; background: #fff; color: var(--pink-d); cursor: nwse-resize; touch-action: none;
  box-shadow: 0 4px 12px -3px rgba(120, 40, 90, .55), 0 0 0 1.5px rgba(214, 58, 120, .5);
}
.sel-handle::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; }   /* 50px touch target */
.sel-handle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }

/* floating toolbar for the selected sticker */
.stk-bar {
  position: absolute; left: 0; top: 0; z-index: 5; display: flex; gap: 2px; padding: 4px;
  border-radius: 999px; background: rgba(255, 255, 255, .9); border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 14px 30px -14px rgba(110, 40, 90, .55), 0 2px 6px rgba(110, 40, 90, .08);
  animation: pop .18s ease;
}
.stk-bar button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink);
  transition: background-color .15s ease, color .15s ease;
}
.stk-bar button:hover { background: rgba(255, 111, 168, .12); color: var(--pink-d); }
.stk-bar button:active { background: rgba(255, 111, 168, .2); }
.stk-bar button.danger { color: #c43a5c; }
.stk-bar button[disabled] { opacity: .3; cursor: default; background: none; }
.stk-bar svg { width: 21px; height: 21px; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.96); } }

/* ---------- photo controls ---------- */
.upload-big { width: 100%; min-height: 52px; font-size: 1rem; }
.photo-tools { margin-top: 14px; }
.photo-tools.off { opacity: .45; pointer-events: none; }
.tool-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 58px; padding: 7px 4px;
  border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .75);
  font-size: .72rem; font-weight: 600; line-height: 1.15; text-align: center; white-space: nowrap;
  transition: background-color .15s ease, transform .15s ease, color .15s ease;
}
.tool:hover { background: #fff; color: var(--pink-d); }
.tool:active { transform: scale(.96); }
.tool[aria-pressed="true"] { color: var(--pink-d); border-color: rgba(214, 58, 120, .4); background: #fff; }
.tool svg { width: 22px; height: 22px; }
.slider { display: grid; grid-template-columns: 56px minmax(0, 1fr) 46px; align-items: center; gap: 8px; min-height: 40px; }
.slider-l { font-size: .82rem; font-weight: 600; }
.slider output { font-size: .78rem; font-weight: 600; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; margin: 0; background: transparent; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, #ffc2da, #dcccff); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: #fff; border: 2px solid var(--pink); box-shadow: 0 3px 10px -2px rgba(214, 58, 120, .55);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, #ffc2da, #dcccff); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--pink); box-shadow: 0 3px 10px -2px rgba(214, 58, 120, .55); }
.privacy { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .55); color: var(--muted); font-size: .78rem; line-height: 1.4; }
.privacy svg { width: 16px; height: 16px; margin-top: 1px; color: var(--caramel); }

/* ---------- stickers ---------- */
.cats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.cat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; min-height: 54px; padding: 5px 4px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7); font-size: .74rem; font-weight: 700; line-height: 1.2;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.cat img { width: 26px; height: 26px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(98, 42, 78, .15)); }
.cat span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat[aria-selected="true"] { color: #fff; border-color: transparent; background: var(--cat, var(--grad)); box-shadow: 0 8px 18px -10px rgba(140, 50, 110, .8); }
.cat[data-cat="lena"] { --cat: linear-gradient(135deg, #ff8ab8, #e0558c); }
.cat[data-cat="miu"] { --cat: linear-gradient(135deg, #b99cff, #7f58e0); }
.cat[data-cat="lumi"] { --cat: linear-gradient(135deg, #e9b57c, #c98a4b); }
.stk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; align-content: start; }
.stk-btn {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; min-height: 0; padding: 8px; border-radius: 16px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .75);
  transition: transform .15s ease, background-color .15s ease, box-shadow .2s ease;
}
.stk-btn:hover { background: #fff; transform: translateY(-2px) rotate(-2deg); box-shadow: 0 10px 20px -14px rgba(120, 50, 100, .7); }
.stk-btn:active { transform: scale(.94); }
.stk-btn img, .stk-btn canvas { width: 100%; height: 100%; min-height: 0; object-fit: contain; filter: drop-shadow(0 3px 4px rgba(98, 42, 78, .18)); }
.stk-btn img, .stk-btn canvas { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); }
.stk-btn.wide { grid-column: span 2; aspect-ratio: 2.1 / 1; }   /* long text stickers: two tiles wide so they stay legible */
.stk-btn.added { animation: added .4s ease; }
@keyframes added { 40% { transform: scale(.9); background: #ffe6f0; } }

/* ---------- download ---------- */
.pane-dl { text-align: center; }
.dl-big { width: 100%; min-height: 54px; font-size: 1.05rem; }
.dl-meta { margin: 8px 0 0; color: var(--muted); font-size: .8rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.dl-private { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 0; color: var(--muted); font-size: .74rem; }
.dl-private svg { width: 13px; height: 13px; fill: none; stroke: var(--caramel); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- toast + ready dialog ---------- */
.toast {
  position: fixed; left: 50%; top: 74px; z-index: 50; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px;
  background: rgba(43, 32, 48, .9); color: #fff; font-size: .88rem; font-weight: 600; text-align: center;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5); transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.ready {
  width: min(440px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: 0; border-radius: 24px;
  background: #fffafc; color: var(--ink); box-shadow: 0 30px 70px -20px rgba(80, 20, 60, .55);
}
.ready::backdrop { background: rgba(40, 18, 40, .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.ready-in { padding: 16px 18px max(18px, env(safe-area-inset-bottom)); }
.ready-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ready-head h2 { margin: 0; font-size: 1.05rem; }
.icon-btn { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #f4e9ef; }
.ready-img {
  display: block; width: auto; max-width: 100%; max-height: min(52vh, 460px); margin: 0 auto; border-radius: 6px;
  box-shadow: 0 16px 34px -18px rgba(90, 30, 70, .6); -webkit-touch-callout: default;
}
.ready-hint { margin: 10px 0 12px; color: var(--muted); font-size: .8rem; text-align: center; }
.ready-actions { display: grid; gap: 8px; }
.ready-actions .btn { width: 100%; }
.noscript { position: fixed; inset: auto 16px 16px; padding: 12px; border-radius: 12px; background: #fff; text-align: center; }

/* ---------- desktop (≥ 900px): three columns ---------- */
@media (min-width: 900px) {
  .app {
    height: 100vh; height: 100dvh; display: grid; gap: 16px 22px;
    grid-template-columns: minmax(232px, 272px) minmax(0, 1fr) minmax(300px, 344px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top top" "frames stage photo" "frames stage stickers" "frames stage dl";
    padding: 0 max(22px, env(safe-area-inset-right)) 22px max(22px, env(safe-area-inset-left));
  }
  .pane-frames { grid-area: frames; overflow: auto; align-self: start; max-height: 100%; }
  .pane-photo { grid-area: photo; }
  .pane-stickers { grid-area: stickers; display: flex; flex-direction: column; min-height: 250px; }
  .pane-stickers .stk-grid { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 2px 4px 4px 2px; margin: 0 -4px 0 -2px; }
  .pane-dl { grid-area: dl; padding: 16px 18px; }
  .tabs, .grabber, .dl-top { display: none !important; }
  .top { padding-top: 16px; }
  .tagline { text-align: right; }
  .stage { padding: 0 4px; }
}
/* laptops (≤ 860 px tall): tighter panels so the sticker grid keeps 3 rows */
@media (min-width: 900px) and (max-height: 860px) {
  .app { gap: 12px 20px; padding-bottom: 16px; }
  .top { padding-top: 12px; padding-bottom: 2px; }
  .pane { padding: 14px 16px; }
  .pane-title { margin-bottom: 8px; }
  .pane-photo .hint, .pane-stickers .hint { display: none; }
  .tool { min-height: 50px; padding: 5px 4px; }
  .tool-row { margin-bottom: 4px; }
  .slider { min-height: 34px; }
  .cat { min-height: 48px; }
  .pane-stickers .stk-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stk-btn { padding: 6px; border-radius: 14px; }
  .pane-dl { padding: 12px 16px; }
  .dl-big { min-height: 48px; }
  .dl-meta { margin-top: 6px; }
}
/* short desktop windows: let the page scroll instead of squeezing the panels */
@media (min-width: 900px) and (max-height: 700px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; grid-template-rows: auto auto auto auto; }
  .stage { min-height: 560px; }
  .pane-stickers .stk-grid { max-height: 300px; }
}

/* ---------- phone / tablet (< 900px): card + bottom sheet ---------- */
@media (max-width: 899px) {
  .app {
    height: 100vh; height: 100dvh; display: grid; overflow: hidden;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "top" "stage" "grab" "sheet" "tabs";
  }
  .top {
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 6px max(14px, env(safe-area-inset-left));
    flex-wrap: wrap; row-gap: 0;
  }
  .top { column-gap: 10px; }
  .brand { gap: 8px; min-width: 0; }
  .brand img { width: 30px; height: 30px; }
  .brand-name { font-size: 1rem; }
  .brand-sub { font-size: 1.24rem; }
  .brand-txt { gap: 5px; }
  .dl-top { gap: 6px; min-height: 38px; padding: 7px 14px; font-size: .86rem; }
  .dl-top svg { width: 18px; height: 18px; }
  .tagline { order: 3; flex-basis: 100%; font-size: .78rem; margin-top: 1px; }
  .stage { padding: 6px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
  .pane {
    grid-area: sheet; display: none; height: var(--sheet-h); overflow: auto; overscroll-behavior: contain;
    padding: 4px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    border-radius: 0; border: 0; box-shadow: none; background: rgba(255, 255, 255, .78);
  }
  .app[data-pane="photo"] .pane-photo,
  .app[data-pane="frames"] .pane-frames { display: block; }
  .app[data-pane="stickers"] .pane-stickers { display: flex; flex-direction: column; }
  .app.sheet-closed .pane { display: none !important; }
  .pane-dl { display: none !important; }
  .pane-title { display: none; }
  .pane-head { min-height: 0; }
  .pane-head { display: none; }
  .pane-stickers .stk-grid { flex: 1 1 auto; min-height: 0; overflow: auto; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); padding-bottom: 4px; }
  .pane-stickers .hint { display: none; }
  .cats { margin: 4px 0 8px; }
  .cat { min-height: 50px; }
  .grabber {
    grid-area: grab; position: relative; display: grid; place-items: center; height: 22px; padding: 0; border: 0;
    border-radius: 22px 22px 0 0; background: rgba(255, 255, 255, .78);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    box-shadow: 0 -12px 30px -20px rgba(120, 50, 100, .5); border-top: 1px solid var(--glass-edge);
  }
  .grabber span { width: 42px; height: 5px; border-radius: 99px; background: rgba(120, 70, 110, .28); }
  .app.sheet-closed .grabber span { background: rgba(214, 58, 120, .55); }
  .pane { -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
  .tabs {
    grid-area: tabs; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
    padding: 6px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, .9); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 4px;
    border: 0; border-radius: 16px; background: none; color: var(--muted); font-size: .74rem; font-weight: 700;
    transition: background-color .2s ease, color .2s ease;
  }
  .tab svg { width: 23px; height: 23px; }
  .tab[aria-selected="true"] { color: var(--pink-d); background: linear-gradient(135deg, rgba(255, 124, 176, .16), rgba(167, 124, 255, .16)); }
  .app.sheet-closed .tab[aria-selected="true"] { background: none; }
  .frame-list { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
  .frame-list::-webkit-scrollbar { display: none; }
  .frame-list { justify-content: space-between; }
  .frame-btn { flex: 1 1 0; min-width: 72px; max-width: 96px; padding: 6px 5px 6px; gap: 4px; }
  .frame-btn[aria-pressed="true"] { padding: 5px 4px 5px; }
  .frame-btn canvas { width: 58px; }
  .frame-btn span { font-size: .68rem; line-height: 1.2; }
  .frame-btn[aria-pressed="true"]::after { width: 18px; height: 18px; background-size: 11px; }
  .sub-title { display: none; }
  .sizes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
  .size-btn { flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 5px 4px; min-height: 44px; text-align: center; }
  .size-btn .sz-l { gap: 6px; }
  .size-btn b { font-size: .78rem; }
  .size-btn small { font-size: .68rem; }
  .size-btn i { width: 15px; height: 15px; }
  .size-btn[aria-checked="true"] i::after { inset: 4px; }
  .upload-big { margin-top: 8px; }
  .photo-tools { margin-top: 6px; }
  .tool { min-height: 54px; font-size: .7rem; }
  .privacy { margin-top: 10px; padding: 8px 10px; }
  .pane-photo .hint { display: none; }
  .toast { top: 64px; }
  .ready { width: 100%; max-width: none; max-height: 94%; margin: auto 0 0; border-radius: 24px 24px 0 0; }
}
@media (max-width: 899px) and (min-width: 600px) {
  :root { --sheet-h: 240px; }
  .tagline { order: 0; flex-basis: auto; font-size: .85rem; }
}
@media (max-width: 380px) {
  .tool span { font-size: .66rem; }
  .slider { grid-template-columns: 50px minmax(0, 1fr) 42px; }
  .dl-top { padding: 7px 12px; }
}
@media (max-width: 374px) {
  .brand-name { display: none; }   /* the logo already says LM; keeps Download on the first row */
}
@media (max-height: 640px) and (max-width: 899px) {
  :root { --sheet-h: 186px; }
  .tagline { display: none; }
}
/* phone held sideways: card on the left, panel + tabs on the right */
@media (max-width: 899px) and (max-height: 540px) and (orientation: landscape) {
  .app {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 46%);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "stage grab" "stage sheet" "stage tabs";
  }
  .top { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 2px; }
  .pane { height: auto; min-height: 0; }
  .app.sheet-closed .grabber { align-self: end; }
  .tabs .tab { min-height: 44px; }
  .stage { padding-top: 2px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
