/* Melloq UI Core — shared design tokens & real app components (used by both Web App and Landing Page) */
:root {
  --green: #9fe870;          /* logo background */
  --green-soft: #eefbe4;
  --green-ink: #173404;      /* logo mark */
  --green-text: #2e7a12;     /* green that reads on white */
  --label: #1c1c1e;
  --secondary: #8a8a8e;
  --tertiary: #c7c7cc;
  --separator: rgba(60, 60, 67, 0.14);
  --fill: #f2f2f7;
  --grouped: #f2f2f7;
  --bg: #ffffff;
  --red: #ff3b30;
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Sukhumvit Set",
    "IBM Plex Sans Thai", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }

/* ---------- pills & badges ---------- */
.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font-size: 12px; font-weight: 600;
}
.pill { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: var(--fill); color: var(--secondary); font-size: 12px; font-weight: 500; }
.pill.green { background: var(--green-soft); color: var(--green-text); }

/* ---------- avatar & flags ---------- */
.avatar {
  flex: none;
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-grid; place-items: center; vertical-align: middle;
  background: var(--green-soft); color: var(--green-ink);
  font-weight: 600; font-size: 19px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.xl { width: 112px; height: 112px; font-size: 40px; }

.fi { border-radius: 3px; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12); }
.name-flag { flex: none; display: block; width: 1.25em; height: 0.94em; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14); }
.pill .fi { margin-right: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 0 20px;
  border-radius: 14px;
  background: var(--green); color: var(--green-ink);
  font-weight: 600;
  transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.98); filter: brightness(0.96); }
.btn.block { width: 100%; }
.btn.plain { background: var(--fill); color: var(--label); }
.btn.danger { background: var(--fill); color: var(--red); }
.btn.sm { min-height: 34px; padding: 0 14px; border-radius: 999px; font-size: 15px; }
.btn:disabled { opacity: 0.5; }

/* ---------- chat bubbles & details ---------- */
.msg { --tab: 40px; --tab-r: 14px; --bubble-bg: var(--fill); display: flex; flex-direction: column; max-width: 82%; }
.msg.mine { --bubble-bg: var(--green); align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg + .msg.gap { margin-top: 10px; }
.line { display: flex; align-items: flex-start; }
.mine .line { flex-direction: row-reverse; }
.line:not(.has-tab) { padding-left: var(--tab); }
.mine .line:not(.has-tab) { padding-left: 0; padding-right: var(--tab); }

.tab-avatar {
  position: relative;
  flex: none;
  width: var(--tab); height: var(--tab);
  display: grid; place-items: center;
  background: var(--bubble-bg);
  border-radius: var(--tab-r) 0 0 var(--tab-r);
}
.mine .tab-avatar { border-radius: 0 var(--tab-r) var(--tab-r) 0; }
.tab-avatar .avatar { width: 30px; height: 30px; font-size: 12px; box-shadow: 0 0 0 2px var(--bg); }

.bubble { min-width: 0; padding: 8px 14px; border-radius: 20px; background: var(--bubble-bg); white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; font-size: 17px; line-height: 22px; }
.has-tab .bubble {
  min-height: var(--tab);
  padding-top: 9px; padding-bottom: 9px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 20px clamp(0px, calc(100% - var(--tab)), 20px);
}
.mine .has-tab .bubble {
  border-top-left-radius: 20px; border-bottom-left-radius: 20px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 20px clamp(0px, calc(100% - var(--tab)), 20px);
}
.mine .bubble { color: var(--green-ink); }
.theirs .meta, .theirs .details { margin-left: calc(var(--tab) + 8px); }
.mine .meta, .mine .details { margin-right: calc(var(--tab) + 8px); }
.bubble.pending { color: var(--secondary); }
.bubble.pending .shimmer { display: block; margin-top: 2px; font-size: 13px; }
.meta { display: flex; align-items: center; gap: 4px; margin: 2px 8px 0; font-size: 11px; color: var(--secondary); }
.meta .ai { color: var(--green-text); font-weight: 500; display: inline-flex; align-items: center; gap: 2px; }
.details { margin: 4px 0 2px; padding: 8px 12px; border-radius: 14px; border: 0.5px solid var(--separator); font-size: 14px; background: var(--bg); }
.details dt { font-size: 11px; color: var(--secondary); margin-top: 6px; }
.details dt:first-child { margin-top: 0; }
.details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sender-name { display: flex; align-items: center; gap: 4px; margin: 6px 0 2px calc(var(--tab) + 10px); font-size: 12px; font-weight: 600; color: var(--green-text); }

.shimmer {
  background: linear-gradient(90deg, var(--secondary) 0%, var(--green-text) 50%, var(--secondary) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- typing dots ---------- */
.typing-row { animation: fade .18s ease-out; }
.bubble.typing { display: inline-flex; align-items: center; gap: 4px; padding: 12px 14px; min-height: 0; }
.bubble.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .35;
  animation: typingDot 1.2s ease-in-out infinite;
}
.bubble.typing i:nth-child(2) { animation-delay: .15s; }
.bubble.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-4px); opacity: .9; }
}

/* ---------- stickers ---------- */
.sticker { position: relative; display: inline-block; width: 100%; aspect-ratio: 1; line-height: 0; }
.sticker img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sticker .cap {
  position: absolute; left: 4%; right: 4%; top: 3%;
  text-align: center; line-height: 1.1;
  font-weight: 800; font-size: 1.05em; letter-spacing: -0.01em;
  color: var(--green-ink);
  -webkit-text-stroke: 0.22em #fff; paint-order: stroke fill;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
  overflow-wrap: anywhere; pointer-events: none;
}
.sticker .cap.bottom { top: auto; bottom: 3%; }
.sticker.big { width: min(170px, 46vw); font-size: 22px; }
.sticker.mini { width: 64px; font-size: 10px; }

/* ---------- expiring media ---------- */
.expiry { display: inline-flex; align-items: center; gap: 3px; padding: 0 8px 2px; font-size: 12px; color: var(--secondary); }
.mine .expiry { color: rgba(23, 52, 4, 0.7); }
.media.gone { display: flex; flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; font-size: 14px; color: var(--secondary); font-style: italic; }

/* ---------- language bridge (.bond) ---------- */
.bond { --bond-a: #6fcf3f; --bond-b: #b9f28f; --bond-track: rgba(23, 52, 4, 0.13); display: inline-flex; line-height: 0; }
.bond svg { display: block; overflow: visible; }
.bond-track path { fill: var(--bond-track); }
.bond-liquid {
  transform: translateX(calc(var(--fill) * var(--w)));
  transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  animation: bondPour 1.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@keyframes bondPour { from { transform: translateX(0); } }
.bond-wave { animation: bondWave 0.9s linear infinite; }
@keyframes bondWave { to { transform: translateY(12px); } }
.bond.full .bond-wave { display: none; }
.bond.full svg { filter: drop-shadow(0 0 6px rgba(159, 232, 112, 0.8)); animation: bondGlow 2.4s ease-in-out infinite; }
@keyframes bondGlow { 50% { filter: drop-shadow(0 0 2px rgba(159, 232, 112, 0.4)); } }
.bond.sm svg { width: 84px; height: 13px; }
.bond.lg svg { width: 176px; height: 26px; }
.bond.xl svg { width: 236px; height: 35px; }

/* ---------- postcards (.pc-card & .pc-slam) ---------- */
.pc-card { --pc-w: min(86vw, 420px); position: relative; width: var(--pc-w); aspect-ratio: 4 / 5; transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, 1.4, .5, 1); transform: rotate(-1.2deg); }
.pc-card.flipped { transform: rotate(1deg) rotateY(180deg); }
.pc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 6px; background: #fffdf7; padding: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden; }
.pc-back { transform: rotateY(180deg); display: flex; flex-direction: column; color: #2b2b2b;
  background: repeating-linear-gradient(-45deg, #e63946 0 10px, #fffdf7 10px 20px, #1d4ed8 20px 30px, #fffdf7 30px 40px) top/100% 8px no-repeat, #fffdf7; }
.pc-photo { position: absolute; inset: 12px 12px 12px 12px; border-radius: 3px; overflow: hidden; background: #ddd; }
.pc-photo img, .pc-photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-stamp { position: absolute; top: 22px; right: 22px; width: 58px; height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: #fffdf7; padding: 6px; transform: rotate(4deg);
  -webkit-mask: radial-gradient(circle 3px, transparent 98%, #000) -3px -3px / 8px 8px; mask: radial-gradient(circle 3px, transparent 98%, #000) -3px -3px / 8px 8px; }
.pc-stamp .fi { width: 40px; height: 30px; border-radius: 2px; }
.pc-stamp small { font-size: 8px; font-weight: 800; letter-spacing: .12em; color: #173404; }
.pc-postmark { position: absolute; top: 38px; right: 66px; width: 70px; height: 70px; border-radius: 50%; border: 2px solid rgba(23, 52, 4, .55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: rgba(23, 52, 4, .7); transform: rotate(-14deg);
  font-size: 9px; font-weight: 700; letter-spacing: .04em; text-align: center; mix-blend-mode: multiply; }
.pc-postmark b { font-size: 13px; }
.pc-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 40px 16px 14px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.72)); border-radius: 0 0 3px 3px; }
.pc-caption p { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.35; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.pc-caption p.shimmer { color: transparent; }
.pc-tr { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; padding: 3px 8px; border-radius: 99px; background: rgba(159, 232, 112, .92); color: #173404; font-size: 11px; font-weight: 700; }
.pc-lines { flex: 1; margin-top: 18px; padding: 10px 8px; background: repeating-linear-gradient(transparent 0 33px, rgba(29, 78, 216, .18) 33px 34px); }
.pc-hand { margin: 0; font-family: "Mali", "Caveat", cursive, var(--font, sans-serif); font-size: 22px; line-height: 34px; color: #1e3a8a; white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-back-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #555; }
.pc-slam { position: absolute; left: 50%; top: 42%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 16px; border: 3px solid #d62828; border-radius: 12px;
  color: #d62828; background: rgba(255,255,255,.18); font-weight: 900; text-transform: uppercase; letter-spacing: .04em; mix-blend-mode: multiply;
  transform: translate(-50%, -50%) rotate(-12deg); animation: slam .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.pc-slam span { font-size: 34px; }
@keyframes slam { from { transform: translate(-50%, -50%) rotate(-30deg) scale(2.4); opacity: 0; } }

/* ---------- QR code ---------- */
.qr-card { margin: 12px 16px 20px; padding: 20px 20px 16px; border-radius: 22px; background: var(--bg); text-align: center; box-shadow: 0 8px 30px rgba(23, 52, 4, 0.06); }
.qr-code { position: relative; width: min(240px, 64vw); margin: 0 auto; aspect-ratio: 1; }
.qr-code svg { width: 100%; height: 100%; display: block; }
.qr-code svg path, .qr-code svg rect[fill="black"], .qr-code svg rect:not([fill="white"]) { fill: var(--green-ink); }
.qr-logo { position: absolute; left: 50%; top: 50%; width: 22%; transform: translate(-50%, -50%); border-radius: 22%; box-shadow: 0 0 0 5px #fff; }

/* ---------- Melloq Pro card ---------- */
.pro-card { padding: 18px 16px; border-radius: 18px; background: linear-gradient(160deg, #0f1d08, #22400d 60%, #2f5a12); color: #e9ffd9; }
.pro-head { display: flex; align-items: center; gap: 8px; }
.pro-badge { padding: 3px 9px; border-radius: 8px; background: linear-gradient(135deg, #ffd66b, #ff9f43); color: #3b2300; font-weight: 900; font-size: 12px; letter-spacing: .08em; }
.pro-soon { font-size: 12px; opacity: .75; }
.pro-card h3 { margin: 10px 0 2px; font-size: 22px; }
.pro-tag { margin: 0 0 10px; opacity: .8; font-size: 14px; }
.pro-features { margin: 0 0 12px; padding-left: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.pro-features li::before { content: "✓"; color: #9fe870; font-weight: 900; margin-inline-end: 8px; }
.pro-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pro-price b { font-size: 26px; }
.pro-price span { font-size: 13px; opacity: .75; }
.pro-early { margin: 8px 0 12px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 214, 107, .14); color: #ffd66b; font-size: 13px; font-weight: 700; }
.pro-cta { background: linear-gradient(135deg, #ffd66b, #ff9f43) !important; color: #3b2300 !important; font-weight: 800; }
.pro-note { margin: 10px 0 0; font-size: 11.5px; opacity: .6; text-align: center; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40%); } }

@media (prefers-reduced-motion: reduce) {
  .shimmer, .bubble.typing i, .bond-liquid, .bond-wave, .bond.full svg, .pc-slam, .pc-card {
    animation: none !important;
    transition: none !important;
  }
}
