:root {
  --bg: #0e0f13;
  --bg-2: #08090c;
  --surface: #171922;
  --surface-2: #20232f;
  --line: #2c3040;
  --text: #f2f3f7;
  --muted: #9aa0b4;
  --accent: #ff5c8a;
  --accent-2: #ffb347;
  --danger: #ff6b6b;
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
a { color: var(--muted); }
[hidden] { display: none !important; }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-lg { padding: 16px 26px; font-size: 17px; }
.btn-primary { background: var(--grad); color: #1a0d12; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); }
.btn-ghost:hover { background: #282c3b; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: transparent;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.pill-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; user-select: none; -webkit-user-select: none;
}
.link-btn { background: none; border: 0; color: var(--muted); padding: 8px 4px; font-size: 14px; }
.link-btn:hover { color: var(--text); }
.link-btn.danger { color: var(--danger); }

/* ---------- screens ---------- */
.screen { min-height: 100dvh; }

/* ---------- home ---------- */
#home { display: flex; justify-content: center; }
.home-wrap {
  width: 100%; max-width: 560px; padding: 32px 20px 24px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
h1 { font-size: clamp(36px, 9vw, 56px); line-height: 1.05; margin: 12px 0 0; letter-spacing: -.02em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 17px; margin: 0; max-width: 420px; }
.cta { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; margin-top: 8px; }
.cta.small { flex-direction: row; justify-content: center; margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.features {
  list-style: none; padding: 0; margin: 8px 0 0; width: 100%;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.features li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px;
}
.features span { color: var(--muted); font-size: 12px; }
.foot { color: var(--muted); font-size: 12px; margin-top: auto; padding-top: 16px; }
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } .desktop-only { display: none; } }

/* ---------- ads ---------- */
.ad-slot { width: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden; }
.ad-slot > ins { width: 100%; }
.ad-slot.ad-empty { display: none; }
.ad-placeholder {
  border: 1px dashed var(--line); border-radius: 10px; color: var(--muted);
  font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
}
.ad-banner { min-height: 100px; }
.ad-editor { min-height: 60px; }
.ad-rect { min-height: 250px; max-width: 336px; }

/* ---------- camera ---------- */
#camera { position: fixed; inset: 0; background: #000; overflow: hidden; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#video.mirror { transform: scaleX(-1); }
.cam-top, .cam-bottom {
  position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; padding-top: max(16px, env(safe-area-inset-top));
}
.cam-top { top: 0; background: linear-gradient(#0009, transparent); }
.cam-bottom {
  bottom: 0; padding: 24px 32px max(28px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #000a);
}
#camera .icon-btn { background: #0006; color: #fff; width: 48px; height: 48px; }
#camera .pill-btn { background: #0006; border-color: #fff3; color: #fff; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: #fff3;
  box-shadow: 0 0 0 3px #0004; transition: transform .1s;
}
.shutter::after { content: ""; display: block; margin: 5px; height: calc(100% - 10px); border-radius: 50%; background: #fff; }
.shutter:active { transform: scale(.92); }
.cam-countdown {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 140px; font-weight: 800;
  color: #fff; text-shadow: 0 4px 30px #0008; pointer-events: none;
}
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }

/* ---------- editor ---------- */
#editor {
  height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "ad" "stage" "panel";
}
.ed-top {
  grid-area: top; display: flex; align-items: center; gap: 4px; padding: 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line);
}
.ed-top .btn { margin-left: 8px; }
.ad-editor { grid-area: ad; padding: 6px 10px 0; }
.stage {
  grid-area: stage; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 14px; background: var(--bg-2); position: relative; overflow: hidden;
}
#view {
  display: block; max-width: 100%; max-height: 100%; border-radius: 4px;
  box-shadow: 0 10px 40px #0008; touch-action: none; cursor: default;
}
#view.can-drag { cursor: move; }
.panel {
  grid-area: panel; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; background: none; border: 0; padding: 12px 4px; color: var(--muted); font-weight: 600; font-size: 14px;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: 12px 14px 14px; height: 196px; overflow-y: auto; }

@media (min-width: 900px) {
  #editor {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "stage panel" "stage ad";
  }
  .panel { border-top: 0; border-left: 1px solid var(--line); overflow-y: auto; }
  .tab-body { height: auto; }
  .ad-editor { background: var(--surface); border-left: 1px solid var(--line); padding: 12px; min-height: 274px; }
  .filter-strip { flex-wrap: wrap; overflow: visible; }
}

/* sliders */
.slider-row { display: grid; grid-template-columns: 84px 1fr 38px; align-items: center; gap: 10px; margin: 6px 0 10px; }
.slider-row label { font-size: 13px; color: var(--muted); }
.slider-row output { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; margin-top: -8px;
  background: #fff; box-shadow: 0 1px 4px #0008;
}
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; }

/* filters */
.filter-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.filter {
  flex: none; width: 72px; background: none; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
}
.filter canvas { width: 68px; height: 68px; border-radius: 10px; outline: 2px solid transparent; outline-offset: 2px; background: var(--surface-2); }
.filter.active { color: var(--text); font-weight: 600; }
.filter.active canvas { outline-color: var(--accent); }

/* chips */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; flex-wrap: nowrap; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; position: relative;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.changed::after {
  content: ""; position: absolute; top: 4px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
@media (min-width: 900px) { .chip-row { flex-wrap: wrap; } }

/* tools */
.tool-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tool-row.compact { margin-top: 4px; }
.tool {
  flex: 1 1 70px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; font-size: 12px; color: var(--muted);
}
.tool:hover { color: var(--text); }
.emoji-row { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.emoji-row button { background: none; border: 0; font-size: 22px; padding: 4px 5px; border-radius: 8px; }
.emoji-row button:hover { background: var(--surface-2); }
#text-editor { margin-top: 10px; }
#text-input {
  width: 100%; resize: none; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; margin-bottom: 8px;
}
#text-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.swatch-row { display: flex; gap: 8px; margin: 2px 0 6px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.swatch.active { outline: 2px solid var(--text); outline-offset: 2px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.toggle.center { justify-content: center; }
#text-hint { margin-top: 10px; }

/* ---------- done ---------- */
#done { display: flex; justify-content: center; }
.done-wrap {
  width: 100%; max-width: 520px; padding: 28px 20px; display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.done-wrap h2 { margin: 0; font-size: 24px; }
.done-preview { width: 100%; display: flex; justify-content: center; }
.done-preview img { max-width: 100%; max-height: 48vh; border-radius: 10px; box-shadow: 0 10px 40px #0008; background: var(--surface); }

/* ---------- tabs overflow, stickers, layers, motion ---------- */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 1 0 auto; padding: 12px 12px; }
.section-label { margin: 2px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin-bottom: 8px; }
.sticker-grid button {
  aspect-ratio: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  display: grid; place-items: center;
}
.sticker-grid button:hover { border-color: var(--accent); }
.sticker-grid img { max-width: 100%; max-height: 100%; }
.layer-controls { padding: 10px 0 12px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.layer-controls .chip-row { margin: 2px 0 4px; }
#text-add { margin-bottom: 4px; }
.motion-badge {
  position: absolute; top: 20px; left: 20px; background: #000a; color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; pointer-events: none;
}
.motion-badge::first-letter { color: var(--accent); }
.chip-row.wrap { flex-wrap: wrap; }

/* ---------- graphic dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text);
  padding: 0; width: min(440px, calc(100% - 32px));
}
dialog::backdrop { background: #000b; }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body h3 { margin: 0; font-size: 20px; }
.bg-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.bg-grid button { aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; padding: 0; }
.bg-grid button.active { border-color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- done: share ---------- */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { background: none; border: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--text); color: var(--bg); }
.done-preview { position: relative; min-height: 120px; }
.done-preview video { max-width: 100%; max-height: 48vh; border-radius: 10px; box-shadow: 0 10px 40px #0008; background: #000; }
.done-busy {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: #0e0f13cc; border-radius: 10px; font-weight: 600; min-width: 220px;
}
.done-busy i { display: block; width: 60%; height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.done-busy b { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.share-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; width: 100%; max-width: 460px; }
.share {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 0;
}
.share:hover { color: var(--text); }
.share:disabled { opacity: .4; }
.si { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.si svg { width: 26px; height: 26px; }
.btn.wide { width: 100%; max-width: 340px; }

/* ---------- festive cards ---------- */
.btn-festive {
  background: linear-gradient(120deg, #0b5d3b, #c1121f 40%, #ffb703 75%, #3c096c);
  color: #fff; text-shadow: 0 1px 2px #0006;
}
.btn-festive:hover { filter: brightness(1.1); }
.fest-preview { font-size: 34px; text-align: center; letter-spacing: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-top: 8px; }
.card-thumb {
  padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--surface-2);
  aspect-ratio: 4 / 5;
}
.card-thumb canvas { width: 100%; height: 100%; display: block; }
.card-thumb.active { border-color: var(--accent); }
.card-thumb:hover { border-color: var(--line); }

.wish-list { display: grid; gap: 8px; max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.wish {
  text-align: left; white-space: pre-line; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font: italic 14px/1.5 "Playfair Display", Georgia, serif; color: var(--text);
}
.wish:hover { border-color: var(--accent); }
#text-add { margin-bottom: 0; }
.tab-body[data-body="text"] > .tool-row { margin-bottom: 4px; }

/* ---------- chat stickers ---------- */
.sticker-opts { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.chip-row.center { justify-content: center; }
#done-img.checker {
  background: repeating-conic-gradient(#2a2d3a 0 25%, #1f2230 0 50%) 0 0 / 22px 22px;
  box-shadow: none; max-height: 300px;
}
.sticker-guide {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; font-size: 14px;
}
.sticker-guide ol { margin: 8px 0; padding-left: 20px; display: grid; gap: 4px; }
.sticker-guide .hint { line-height: 1.5; }

/* ---------- spreading the word ---------- */
.welcome {
  width: 100%; background: linear-gradient(120deg, #ff5c8a22, #ffb34722); border: 1px solid #ff5c8a55;
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
}
.invite {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: center;
}
.invite p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.invite p b { color: var(--text); }
.invite-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.drop-overlay {
  position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 24px; background: #0e0f13e6;
  display: none; place-items: center; font-size: 28px; font-weight: 800; z-index: 40; pointer-events: none;
}
body.dragging .drop-overlay { display: grid; }

/* ---------- language switch ---------- */
.logo .lang-btn { margin-left: auto; font-size: 12px; font-weight: 600; padding: 6px 12px; }
.logo { width: 100%; }

/* ---------- WhatsApp Status button + card link ---------- */
.btn-status { background: #25d366; color: #06210f; font-weight: 800; }
.btn-status:hover { filter: brightness(1.06); }
.btn-wa { background: #25d366; color: #06210f; font-weight: 700; }
.kadlink {
  width: 100%; max-width: 420px; text-align: left; display: grid; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.kadlink .field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.kadlink textarea, .kadlink input[type=text] {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font: inherit; resize: vertical;
}
.kad-list { display: flex; flex-wrap: wrap; gap: 8px; }
.kad-list p { width: 100%; margin: 0; font-size: 13px; color: var(--muted); }
.kad-list .pill-btn.sent { opacity: .5; }

/* ---------- card link: the envelope ---------- */
#kad { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 50% 30%, var(--env-glow, #1d3b2e) 0%, var(--bg) 70%); }
#kad[hidden] { display: none !important; }
.kad-wrap { width: min(100%, 440px); display: grid; gap: 18px; justify-items: center; text-align: center; }
.envelope { position: relative; width: 100%; aspect-ratio: 3 / 2; cursor: pointer; perspective: 1000px; outline: none;
  animation: env-in .7s cubic-bezier(.2,1.4,.4,1) both, env-float 3s ease-in-out .7s infinite; }
.env-body, .env-pocket, .env-flap { position: absolute; inset: 0; border-radius: 14px; }
.env-body { background: var(--env, #0b5d3b); box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.env-pocket { background: var(--env2, #0e6b45); clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%); }
.env-flap { bottom: auto; height: 62%; background: var(--env3, #138a59); clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .6s ease-in; z-index: 3; border-radius: 14px 14px 0 0; }
.env-seal { position: absolute; left: 50%; top: 60%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: var(--gold, #e9c46a); display: grid; place-items: center; font-size: 30px; z-index: 4;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); animation: seal-pulse 1.4s ease-in-out infinite; transition: opacity .3s; }
.env-to { position: absolute; left: 0; right: 0; bottom: 9%; z-index: 2; color: var(--gold, #f6e3a1);
  font: 400 clamp(26px, 8vw, 38px)/1.1 "Great Vibes", cursive; padding: 0 12px; }
.env-from { position: absolute; left: 0; right: 0; top: 8%; z-index: 5; color: var(--ink, #fff); opacity: .85; font-size: 14px; font-weight: 700; transition: opacity .3s; }
.envelope.open { animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-seal, .envelope.open .env-from { opacity: 0; }
.envelope.gone { animation: env-out .45s ease-in forwards; }
.kad-tap { margin: 0; font-weight: 700; color: var(--text); animation: seal-pulse 1.4s ease-in-out infinite; }
#kad-canvas { width: 100%; height: auto; border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.55);
  animation: card-rise .8s cubic-bezier(.2,1.2,.4,1) both; }
.kad-actions { width: 100%; display: grid; gap: 10px; justify-items: center; animation: card-rise .6s .8s both; }
@keyframes env-in { from { transform: translateY(40px) scale(.8); opacity: 0; } }
@keyframes env-float { 50% { transform: translateY(-8px) rotate(-1deg); } }
@keyframes env-out { to { transform: translateY(60px) scale(.9); opacity: 0; } }
@keyframes seal-pulse { 50% { transform: scale(1.08); } }
@keyframes card-rise { from { transform: translateY(80px) scale(.85); opacity: 0; } }

/* ---------- link to the guides ---------- */
.guides-link { text-align: center; margin: 18px 0 0; font-weight: 600; }
.guides-link a { color: var(--accent-2); text-decoration: none; }
