/* ─────────────────────────────────────────────────────────────
   هم‌دل — Telegram Mini App
   Design system: Untitled UI (per Dating-App-UI.dc.html)
   Brand #7F56D9 · Vazirmatn/Inter · RTL
   ───────────────────────────────────────────────────────────── */

:root {
  --brand-25: #FCFAFF;
  --brand-50: #F9F5FF;
  --brand-100: #F4EBFF;
  --brand-200: #E9D7FE;
  --brand-300: #D6BBFB;
  --brand-400: #B692F6;
  --brand-500: #9E77ED;
  --brand-600: #7F56D9;
  --brand-700: #6941C6;
  --brand-800: #53389E;
  --gray-25: #FCFCFD;
  --gray-50: #F9FAFB;
  --gray-100: #F2F4F7;
  --gray-200: #EAECF0;
  --gray-300: #D0D5DD;
  --gray-400: #98A2B3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1D2939;
  --gray-900: #101828;
  --error-600: #D92D20; --error-500: #F04438; --error-300: #FDA29B; --error-700: #B42318;
  --error-50: #FEF3F2; --error-100: #FEE4E2;
  --warn-500: #F79009; --warn-600: #DC6803; --warn-300: #FEC84B; --warn-50: #FFFCF5; --warn-100: #FEF0C7; --warn-700: #B54708; --warn-200: #FDE68A;
  --succ-500: #12B76A; --succ-600: #039855; --succ-700: #027A48; --succ-50: #ECFDF3; --succ-200: #A6F4C5; --succ-950: #053321; --succ-400: #32D583; --succ-300: #75E0A7;
  --blue-500: #53B1FD; --blue-600: #1570EF; --blue-700: #175CD3; --blue-900: #0B4A6F; --blue-200: #B2DDFF; --blue-50: #F5FAFF;
  --tg: #229ED9;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 10px -2px rgba(16,24,40,.12);
  --shadow-lg: 0 12px 28px -10px rgba(16,24,40,.35);
  --font: Vazirmatn, Inter, system-ui, sans-serif;
  /* Telegram Fullscreen mode: prefer Telegram's own inset (set via JS in
     telegram.js) over the browser's native env(), which Telegram's WebView
     does not report reliably. */
  --safe-t: var(--tg-safe-top, env(safe-area-inset-top, 0px));
  --safe-b: var(--tg-safe-bottom, env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: #fff; color: var(--gray-900);
  font-family: var(--font); direction: rtl;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
a { color: var(--brand-700); text-decoration: none; }
svg { display: block; }
button { font-family: var(--font); }
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* ── Screens & layout ── */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: #fff; overflow: hidden; }
.screen.active { display: flex; }
.scr-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.stack { display: flex; flex-direction: column; }

.appbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--gray-100); flex: none; }
.appbar .ttl { font-weight: 600; font-size: 16px; color: var(--gray-900); }
.appbar .ttl.big { font-size: 20px; font-weight: 700; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--gray-700); flex: none; background: none; border: 0; cursor: pointer; }
.iconbtn:active { background: var(--gray-100); }

/* ── Buttons / fields (Untitled UI) ── */
.btn {
  border: 1px solid transparent; border-radius: 10px; font: 600 16px var(--font);
  padding: 12px 18px; display: flex; align-items: center; justify-content: center; gap: 9px;
  cursor: pointer; box-shadow: var(--shadow-sm); width: 100%; transition: filter .12s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.pri { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn.grad { background: linear-gradient(var(--brand-600), var(--brand-700)); border-color: transparent; color: #fff; }
.btn.tg { background: var(--tg); border-color: var(--tg); color: #fff; }
.btn.sec { background: #fff; border-color: var(--gray-300); color: var(--gray-700); }
.btn.link { background: transparent; box-shadow: none; color: var(--brand-700); width: auto; padding: 6px 8px; border: 0; font-size: 14px; }
.btn.destructive { background: #fff; border-color: var(--error-300); color: var(--error-700); }
.btn.white { background: #fff; border-color: #fff; color: var(--brand-700); }
.btn.ghost-white { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }

.field {
  border: 1px solid var(--gray-300); border-radius: 10px; padding: 11px 14px;
  font: 400 16px var(--font); color: var(--gray-900); background: #fff; box-shadow: var(--shadow-sm);
  width: 100%; outline: none;
}
.field:focus { border-color: var(--brand-300); box-shadow: 0 0 0 4px var(--brand-100); }
.field::placeholder { color: var(--gray-500); }
select.field { appearance: none; text-align: center; }
.lbl { font: 500 14px var(--font); color: var(--gray-700); margin-bottom: 6px; }
.hint { font: 400 13px var(--font); color: var(--gray-500); }

.feat { border-radius: 12px; display: grid; place-items: center; flex: none; }
.feat.brand { background: var(--brand-50); color: var(--brand-600); border: 8px solid var(--brand-100); }
.feat.danger { background: var(--error-50); color: var(--error-500); border: 8px solid var(--error-100); }

.chip {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--gray-300); background: #fff;
  color: var(--gray-700); font: 500 14px var(--font); display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip.on { border: 1.4px solid var(--brand-600); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.chip.mini { padding: 6px 12px; font-size: 13px; background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }
.chip.add { border-style: dashed; color: var(--gray-500); background: #fff; }

.progress-dots { display: flex; gap: 5px; flex: 1; }
.progress-dots i { height: 5px; flex: 1; border-radius: 3px; background: var(--gray-200); }
.progress-dots i.on { background: var(--brand-600); }

.divider { height: 1px; background: var(--gray-200); }
.note-box { display: flex; gap: 8px; align-items: flex-start; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 10px; padding: 10px 12px; }

/* ── Tab bar (WF-08 bottom) ── */
.tabbar { display: flex; border-top: 1px solid var(--gray-100); padding: 6px 4px calc(8px + var(--safe-b)); background: #fff; flex: none; }
.tab { flex: 1; text-align: center; color: var(--gray-400); background: none; border: 0; cursor: pointer; padding: 2px 0; position: relative; }
.tab svg { margin: 0 auto; }
.tab .tl { font: 500 10px var(--font); margin-top: 2px; }
.tab.on { color: var(--brand-700); }
.tab.on .tl { font-weight: 600; }
.tab .badge { position: absolute; top: -2px; right: calc(50% - 18px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--brand-600); color: #fff; font: 700 9px Inter; display: grid; place-items: center; padding: 0 4px; }

/* ── Deck (WF-08) ── */
.deck-wrap { flex: 1; display: flex; flex-direction: column; padding: 14px 16px 0; overflow: hidden; }
.card-stack { position: relative; flex: 1; min-height: 300px; }
.dcard {
  position: absolute; inset: 0; border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lg); background: linear-gradient(150deg, var(--brand-400), var(--brand-600) 60%, var(--brand-800));
  touch-action: pan-y;
}
.dcard.under { transform: scale(.96) translateY(10px); filter: brightness(.97); }
.dcard img.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dcard .super-badge { position: absolute; top: 14px; right: 14px; display: flex; align-items: center; gap: 6px; background: rgba(16,24,40,.55); backdrop-filter: blur(4px); color: #fff; padding: 5px 11px; border-radius: 999px; font: 600 11px var(--font); z-index: 3; }
.dcard .dots { position: absolute; top: 14px; left: 14px; display: flex; gap: 4px; z-index: 3; }
.dcard .dots i { width: 34px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.4); }
.dcard .dots i.on { background: #fff; }
.dcard .grad { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 16px 16px; background: linear-gradient(to top, rgba(16,24,40,.8), transparent); z-index: 2; }
.dcard .nm { color: #fff; font-weight: 700; font-size: 24px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.dcard .dist { color: var(--gray-100); font: 400 13px var(--font); display: flex; align-items: center; gap: 6px; margin: 5px 0 8px; }
.dcard .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dcard .tags span { background: rgba(255,255,255,.22); color: #fff; padding: 4px 10px; border-radius: 999px; font: 500 11.5px var(--font); }
.dcard .stamp { position: absolute; top: 40px; font: 800 34px/1 var(--font); padding: 6px 16px; border: 4px solid; border-radius: 12px; opacity: 0; z-index: 4; transform: rotate(-12deg); }
.dcard .stamp.like { color: var(--succ-400); border-color: var(--succ-400); right: 22px; }
.dcard .stamp.nope { color: var(--error-500); border-color: var(--error-500); left: 22px; transform: rotate(12deg); }
.dcard .bio-peek { color: #E9D7FE; font: 400 12.5px var(--font); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.deck-actions { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 18px 0 10px; flex: none; }
.act { border: 1px solid var(--gray-200); background: #fff; border-radius: 50%; display: grid; place-items: center; box-shadow: var(--shadow-md); cursor: pointer; }
.act:active { transform: scale(.92); }
.act.pass { width: 52px; height: 52px; color: var(--error-500); }
.act.super { width: 44px; height: 44px; color: var(--blue-500); }
.act.like { width: 52px; height: 52px; border: 0; background: linear-gradient(var(--brand-600), var(--brand-700)); color: #fff; box-shadow: 0 6px 14px -2px rgba(105,65,198,.5); }
.deck-meta { display: flex; align-items: center; justify-content: center; gap: 10px; font: 400 13px var(--font); color: var(--gray-500); padding-bottom: 10px; flex: none; }
.deck-meta .bt { display: flex; align-items: center; gap: 4px; color: var(--brand-700); background: none; border: 0; font: 500 13px var(--font); cursor: pointer; }

/* ── Sheets & overlays ── */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; }
.overlay.open { display: block; }
.overlay .dim { position: absolute; inset: 0; background: rgba(16,24,40,.4); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(26px + var(--safe-b)); max-height: 88dvh; overflow-y: auto;
  animation: sheet-up .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 3px; background: var(--gray-200); margin: 0 auto 18px; }
.fullscreen { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; }
.fullscreen.open { display: flex; }

/* ── Chat (WF-14) ── */
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--gray-50); }
.msg { max-width: 74%; border-radius: 14px; padding: 9px 13px; font: 400 13.5px var(--font); line-height: 1.6; word-break: break-word; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--gray-200); border-bottom-right-radius: 4px; color: var(--gray-900); }
.msg.out { align-self: flex-end; background: var(--brand-600); color: #fff; border-bottom-left-radius: 4px; }
.msg .meta { font-size: 10px; opacity: .7; margin-top: 3px; display: flex; gap: 4px; justify-content: flex-end; }
.chat-pill { align-self: center; font: 500 11px var(--font); padding: 5px 12px; border-radius: 999px; display: flex; align-items: center; gap: 5px; }
.chat-input-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px calc(11px + var(--safe-b)); border-top: 1px solid var(--gray-200); background: #fff; flex: none; }
.chat-input-row .field { flex: 1; padding: 9px 14px; }
.send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-600); display: grid; place-items: center; flex: none; border: 0; cursor: pointer; }
.send-btn:disabled { background: var(--gray-300); }

/* ── Lists ── */
.convo { display: flex; align-items: center; gap: 12px; padding: 10px 0; border: 0; background: none; width: 100%; text-align: right; cursor: pointer; font-family: var(--font); }
.convo + .convo { border-top: 1px solid var(--gray-100); }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(150deg, var(--brand-300), var(--brand-400)); flex: none; object-fit: cover; }
.match-story { text-align: center; flex: none; background: none; border: 0; cursor: pointer; font-family: var(--font); }
.match-ring { width: 64px; height: 64px; border-radius: 50%; padding: 2.5px; background: linear-gradient(150deg, var(--brand-400), var(--brand-600)); }
.match-ring.urgent { background: linear-gradient(150deg, var(--error-300), var(--error-500)); }
.match-ring .av { width: 100%; height: 100%; border-radius: 50%; border: 2px solid #fff; object-fit: cover; background: linear-gradient(150deg, var(--brand-100), var(--brand-300)); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 14px 2px; border-bottom: 1px solid var(--gray-100); font: 500 14.5px var(--font); background: none; border-inline: 0; border-top: 0; width: 100%; text-align: right; cursor: pointer; color: var(--gray-900); }

/* ── Beeline (WF-13) ── */
.bee-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.bee-card { aspect-ratio: 4/5; border-radius: 14px; overflow: hidden; position: relative; background: linear-gradient(150deg, var(--brand-300), var(--brand-400)); border: 0; padding: 0; cursor: pointer; }
.bee-card img { width: 100%; height: 100%; object-fit: cover; }
.bee-card.blurred img, .bee-card.blurred .ph { filter: blur(10px); }
.bee-card .nm { position: absolute; bottom: 8px; right: 10px; color: #fff; font: 600 13px var(--font); text-shadow: 0 1px 4px rgba(16,24,40,.6); }
.bee-card .star { position: absolute; top: 8px; right: 8px; color: var(--warn-300); font-size: 18px; filter: none; }

/* ── Shop (WF-26) ── */
.wallet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.wallet-card { border-radius: 14px; padding: 14px; text-align: center; }
.pack-row { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--gray-200); border-radius: 12px; padding: 12px 14px; font: 500 14px var(--font); background: #fff; width: 100%; cursor: pointer; font-family: var(--font); }
.pack-row.best { border: 1.5px solid var(--brand-600); background: var(--brand-50); font-weight: 600; }
.stars-pill { background: var(--brand-50); color: var(--brand-700); font: 600 13px var(--font); padding: 5px 12px; border-radius: 999px; display: flex; align-items: center; gap: 3px; }
.stars-pill.solid { background: var(--brand-600); color: #fff; }
.star-ico { color: var(--warn-300); }

/* ── Paywall (WF-19..25) ── */
.paywall { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 2px 2px; }
.paywall h3 { font-weight: 600; font-size: 18px; letter-spacing: -.02em; margin: 0; }
.paywall .hint { line-height: 1.6; }

/* ── Photo grid (WF-05/07) ── */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.pslot { aspect-ratio: 4/5; border-radius: 12px; position: relative; overflow: hidden; border: 0; padding: 0; background: none; cursor: pointer; }
.pslot img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.pslot .main-badge { position: absolute; top: 6px; right: 6px; background: var(--gray-900); color: #fff; font: 600 10px var(--font); padding: 2px 7px; border-radius: 6px; }
.pslot .del { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(16,24,40,.6); color: #fff; display: grid; place-items: center; border: 0; cursor: pointer; }
.pslot.empty { border: 1.5px dashed var(--gray-300); background: var(--brand-25); display: grid; place-items: center; color: var(--brand-600); }
.pslot.empty.far { border-color: var(--gray-200); background: var(--gray-50); color: var(--gray-300); }

/* ── Sliders (WF-09) ── */
.range-wrap { position: relative; height: 24px; display: flex; align-items: center; }
.range-track { position: absolute; left: 0; right: 0; height: 6px; background: var(--gray-200); border-radius: 4px; }
.range-fill { position: absolute; height: 6px; background: var(--brand-600); border-radius: 4px; }
input[type="range"].rng { position: absolute; left: 0; right: 0; width: 100%; appearance: none; background: transparent; pointer-events: none; height: 24px; margin: 0; }
input[type="range"].rng::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 1.5px solid var(--brand-600); box-shadow: 0 1px 3px rgba(16,24,40,.2); pointer-events: auto; cursor: pointer; }

/* ── Misc ── */
.toast { position: fixed; bottom: calc(84px + var(--safe-b)); left: 16px; right: 16px; z-index: 99; background: var(--gray-900); color: #fff; border-radius: 12px; padding: 12px 16px; font: 500 13.5px var(--font); text-align: center; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.spin { width: 22px; height: 22px; border: 3px solid var(--brand-100); border-top-color: var(--brand-600); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-fill { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.badge-verified { color: var(--blue-500); flex: none; }
.completion-ring { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.completion-ring .inner { width: 34px; height: 34px; border-radius: 50%; background: #fff; display: grid; place-items: center; font: 700 11px Inter; color: var(--succ-600); }
.empty-icon-wrap { width: 64px; height: 64px; }
