/* ============================================================
   Doostin | دوستین - Styles (Local, RTL, Mobile First)
   No external CDN. Vazirmatn loaded locally; system fallback.
   ============================================================ */

/* ---- Local variable font (single Vazirmatn variable woff2) ---- */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn[wght].woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --bg: #0f1117;
    --bg-soft: #171a23;
    --card: #1e222e;
    --card-2: #252a38;
    --text: #f3f4f8;
    --muted: #9aa0b0;
    --primary: #ff4d79;
    --primary-2: #ff7aa0;
    --accent: #6c5ce7;
    --gold: #ffd166;
    --green: #2ecc71;
    --red: #ff5b5b;
    --line: #2a2f3d;
    --radius: 18px;
    --nav-h: 64px;
    /* Telegram safe-area top inset (selfie camera / clock / window controls).
       Updated at runtime from TG.contentSafeAreaInset; falls back to the CSS
       env() value so non-Telegram browsers still get a sane inset. */
    --tg-safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: 'Vazirmatn', system-ui, 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    direction: rtl;
    overscroll-behavior: none;
}
a { color: var(--primary-2); text-decoration: none; }

/* ---------- Iconir icons (bundled, offline) ---------- */
.iconir { vertical-align: -0.15em; }
.bottom-nav button .ico { display: inline-flex; align-items: center; justify-content: center; }
.icon-btn .iconir { font-size: 18px; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
    font-family: inherit; width: 100%; background: var(--bg-soft);
    color: var(--text); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; font-size: 15px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 13px; }

/* ---------- Layout ---------- */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh;
    display: flex; flex-direction: column; background: var(--bg); }
#view { flex: 1; padding: 12px; padding-bottom: calc(var(--nav-h) + 62px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }

/* The home feed is a fixed viewport, not a document section. Keep the body
   from rubber-banding when a user drags over the cards, while other views
   remain normally scrollable. */
body.home-open { overflow: hidden; }
body.home-open #app {
    height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
}
body.home-open #view,
body.home-open #view-home { min-height: 0; overflow: hidden; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    /* Push the header content below Telegram's top safe area (selfie camera,
       clock, native buttons) when running fullscreen. The 36px base (was 28px,
       +8 for extra clearance) keeps clear of Telegram's floating UI controls. */
    padding-top: calc(36px + var(--tg-safe-top));
    background: linear-gradient(180deg, var(--bg-soft), rgba(23,26,35,.85));
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; font-size: 18px; flex: 0 0 auto; white-space: nowrap; }
.topbar .brand span { color: var(--primary); }
.topbar .actions { display: flex; gap: 8px; align-items: center; min-width: 0; margin-right: auto; }
/* Header pills (online count / premium / boost) — were unstyled and overflowed */
.pill {
    display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
    font-size: 12px; font-weight: 700; white-space: nowrap;
    padding: 5px 10px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--line); color: var(--text);
    max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.pill .iconir { font-size: 14px; flex: none; }
.pill.gold { color: var(--gold); border-color: rgba(255, 209, 102, .4); }
.pill.boost { color: var(--primary-2); border-color: rgba(255, 77, 121, .4); }
/* Small screens: keep header on one row — hide the online-count text pill first */
@media (max-width: 380px) {
    .topbar .brand { font-size: 16px; }
    .topbar .pill { display: none; }
    .topbar .pill.gold, .topbar .pill.boost { display: inline-flex; padding: 5px 8px; }
}
.icon-btn {
    position: relative; background: var(--card); border: 1px solid var(--line);
    color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
}
.badge {
    position: absolute; top: -4px; left: -4px; background: var(--red); color: #fff;
    font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
/* Telegram connection status button */
.tg-status {
    position: relative;
}
.tg-status .tg-dot {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-soft);
}
.tg-status.tg-connected .tg-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}
.tg-status.tg-disconnected .tg-dot {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}
.tg-status .iconir { font-size: 18px; }

/* Segmented control (e.g. payment method choice: two buttons, not a select) */
.seg { display: flex; gap: 8px; margin: 4px 0 6px; }
.seg-btn { flex: 1; padding: 11px 8px; border-radius: 12px; border: 1px solid var(--line);
    background: var(--card); color: var(--text); font-size: 14px; cursor: pointer; }
.seg-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }


/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; min-height: var(--nav-h);
    display: flex; background: var(--bg-soft); border-top: 1px solid var(--line);
    z-index: 30;
    /* Extra bottom clearance so the nav never sits under Android's gesture /
       3-button navigation bar (env() covers devices that report it). */
    padding-top: 6px;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
}
.bottom-nav button {
    flex: 1; background: none; border: none; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 11px; position: relative;
    padding: 8px 4px; min-height: 48px; white-space: nowrap;
}
.bottom-nav button .ico { font-size: 20px; }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button.active .ico { transform: translateY(-1px); }
.bottom-nav .nbadge {
    position: absolute; top: 6px; right: 50%; transform: translateX(14px);
    background: var(--red); color: #fff; font-size: 10px; min-width: 16px; height: 16px;
    border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px; margin-bottom: 12px;
}
.card-2 { background: var(--card-2); }
.rounded { border-radius: var(--radius); overflow: hidden; }

/* ---------- Swipe card (minimal, Reels style, always fits the viewport) ---------- */
#feed {
    position: relative;
    width: 100%;
    /* JS sizes this to exactly fill the viewport between the header/tabs and
       the bottom nav (including #view's paddings). Keep the pre-JS placeholder
       small so first paint never pushes content. */
    min-height: 260px;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    border-radius: 24px;
}
.swipe-card {
    position: absolute;
    inset: 0;
    background: var(--card); border: 1px solid var(--line);
    border-radius: 24px; overflow: hidden;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
    will-change: transform, opacity;
    display: flex; flex-direction: column;
}
/* Behind card: sits below, slightly scaled down. It is a static backdrop —
   the incoming card animates to full size itself (see renderFeed rise-in). */
.swipe-card.behind {
    transform: scale(.95) translateY(6px);
    opacity: .6;
    pointer-events: none;
    z-index: 1;
}
/* Active card sits on top */
.swipe-card.active { z-index: 2; }
/* Rise-in of the incoming card: short, composited motion keeps the stack
   responsive after a like/dislike tap. */
.swipe-card.active:not(.dragging):not(.flying) {
    transition: transform .32s cubic-bezier(.22, 1.12, .36, 1), opacity .24s ease;
}
.swipe-card.active.incoming {
    transition: none;
    transform: scale(.96) translateY(10px);
    opacity: .42;
}
/* Flying: card glides out on an upward arc, fading near the end */
.swipe-card.flying {
    transition: transform .3s cubic-bezier(.16, 1, .3, 1), opacity .24s ease;
    z-index: 3;
}

/* Photo fills the card's remaining height (card = full feed height).
   Solid placeholder bg avoids a white flash / layout shift before the image loads. */
.sc-photo { position: relative; width: 100%; flex: 1 1 auto; min-height: 150px; background: var(--card-2); }
.sc-photo .cover { width: 100%; height: 100%; object-fit: cover; background: var(--card-2); }
.sc-gradient {
    position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to top, rgba(10, 12, 18, .92) 0%, rgba(10, 12, 18, .55) 28%, rgba(10, 12, 18, 0) 55%);
}

/* Badges (boost / premium) top-right — icon-only glass chips */
.sc-badges { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 3; }
.sc-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; font-size: 15px;
    border-radius: 999px; backdrop-filter: blur(6px);
    background: rgba(0, 0, 0, .4); color: #fff; border: 1px solid rgba(255, 255, 255, .15);
}
.sc-badge.gold { color: var(--gold); }
.sc-badge.boost { color: var(--primary-2); }
.sc-badge.vrf, .pill.vrf { color: #229ED9; }
/* Blue tick next to verified names */
.vbadge { color: #229ED9; font-size: .95em; vertical-align: -1px; }

/* Online dot top-left */
.sc-online-wrap { position: absolute; top: 12px; left: 12px; z-index: 3; }
.sc-online {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 999px;
    background: rgba(0, 0, 0, .4); border: 1px solid rgba(255, 255, 255, .15);
    backdrop-filter: blur(6px);
}
.sc-online .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
.sc-online.recent .dot { background: var(--gold); box-shadow: none; }

/* Shared attributes / interests — single gold pill next to the city */
.sc-common-count {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 700; color: var(--gold);
    background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 209, 102, .35);
    padding: 3px 10px; border-radius: 999px; backdrop-filter: blur(4px);
}
.sc-common-count .iconir { font-size: 13px; }
.common-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.common-chip {
    display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(46, 204, 113, .16); border: 1px solid rgba(46, 204, 113, .4); color: #d6ffe6;
}
.common-chip.int { background: rgba(255, 77, 121, .16); border-color: rgba(255, 77, 121, .4); color: #ffd7e2; }
.common-chip .iconir { font-size: 13px; }
/* On the profile sheet the chips sit on the dark card background */
.common-card .common-chip { color: var(--text); }
.common-card .common-chip.int { color: var(--text); }


/* Info overlay — minimal: name/age + one meta row (city · common count).
   Fluid sizes adapt to any phone width via clamp(). */
.sc-info { position: absolute; left: 0; right: 0; bottom: 0; padding: clamp(12px, 3.5vw, 16px); color: #fff; z-index: 2; cursor: pointer; }
.sc-name { font-size: clamp(19px, 5.5vw, 23px); font-weight: 800; display: flex; align-items: baseline; gap: 8px; text-shadow: 0 1px 6px rgba(0,0,0,.5); min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sc-name .sc-age { font-size: clamp(15px, 4.2vw, 18px); font-weight: 600; opacity: .9; flex: none; }
.sc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.sc-city { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; opacity: .92; text-shadow: 0 1px 4px rgba(0,0,0,.5); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sc-city .iconir { font-size: 14px; flex: none; }

/* Like / Nope drag hints */
.sc-like-hint, .sc-nope-hint {
    position: absolute; top: 26px; z-index: 4; opacity: 0;
    width: 74px; height: 74px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 38px; color: #fff;
    border: 3px solid #fff; backdrop-filter: blur(2px);
}
.sc-like-hint { left: 22px; background: rgba(46, 204, 113, .55); }
.sc-nope-hint { right: 22px; background: rgba(255, 91, 91, .55); }

/* Action buttons — like / dislike are the primary pair: colored, side by
   side, filling the full width between the two corners. Chat / gift are
   secondary glass squares at the edges (slightly rounded, not circles). */
.swipe-actions {
    display: flex; gap: 10px; align-items: stretch;
    /* Horizontal inset keeps the corner (chat/gift) buttons clear of the
       card borders — matches the info overlay padding above the row. */
    padding: 12px clamp(12px, 3.5vw, 16px) 6px; position: relative; z-index: 2;
}
.sc-act {
    border: none; border-radius: 14px; color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .25); transition: transform .15s ease, box-shadow .15s ease;
}
.sc-act .iconir { font-size: 22px; }
.sc-act:active { transform: scale(.97); }
/* Secondary corner buttons (chat / gift) */
.sc-act.side {
    flex: 0 0 58px; height: 58px;
    background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
    backdrop-filter: blur(8px); color: var(--text);
}
.sc-act.side.chat { color: var(--primary-2); }
.sc-act.side.gift { color: var(--gold); }
/* Primary pair (dislike / like) — share the full remaining width */
.sc-main { flex: 1 1 auto; display: flex; gap: 10px; min-width: 0; }
.sc-act.main { flex: 1 1 0; height: 58px; min-width: 0; }
.sc-act.main.dislike { background: linear-gradient(145deg, #ff6b6b, #ff3d3d); }
.sc-act.main.like { background: linear-gradient(145deg, #3ee08a, #23c46e); }

/* Empty feed card — shown when there is nothing left to swipe */
.feed-empty {
    background: linear-gradient(180deg, var(--card), var(--bg-soft));
    display: flex; align-items: center; justify-content: center;
}
.fe-body { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fe-icon {
    width: 76px; height: 76px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 34px;
    color: var(--primary-2); background: rgba(255, 77, 121, .1); border: 1px solid rgba(255, 77, 121, .25);
}
.fe-title { font-size: 18px; font-weight: 800; }
.fe-sub { color: var(--muted); font-size: 13px; line-height: 1.9; max-width: 32ch; }
.fe-btn {
    margin-top: 6px; display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--card);
    color: var(--text); font-weight: 700; font-size: 14px; padding: 11px 24px;
    transition: transform .15s ease;
}
.fe-btn:active { transform: scale(.96); }
.fe-btn .iconir { font-size: 16px; }

/* Feed skeleton — placeholder card with pulsing blocks while the first batch
   of profiles loads. Opacity-only pulse: composited, no repaint per frame. */
.sk-card { background: var(--card); }
.sk-photo { position: relative; flex: 1 1 auto; background: var(--card-2); }
.sk-lines { position: absolute; right: clamp(12px, 3.5vw, 16px); left: clamp(12px, 3.5vw, 16px); bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.sk-line { position: relative; overflow: hidden; border-radius: 9px; background: rgba(255, 255, 255, .07); }
.sk-line.w1 { height: 22px; width: 52%; }
.sk-line.w2 { height: 14px; width: 74%; }
.sk-box {
    position: relative; overflow: hidden; flex: 1 1 0; min-width: 0; height: 58px;
    border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
}
.sk-box.side { flex: 0 0 58px; }
.sk-photo::after, .sk-line::after, .sk-box::after {
    content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, .07);
    animation: skPulse 1.4s ease-in-out infinite;
}
@keyframes skPulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* LIKE / NOPE stamp — pops centered over the feed while the card flies out */
.sc-stamp {
    position: absolute; top: 50%; left: 50%; z-index: 6;
    width: 112px; height: 112px; margin: -56px 0 0 -56px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 56px; color: #fff; pointer-events: none;
    animation: stampPop .65s cubic-bezier(.22, 1, .36, 1) forwards;
}
.stamp-like { background: rgba(46, 204, 113, .88); box-shadow: 0 0 44px rgba(46, 204, 113, .45); }
.stamp-nope { background: rgba(255, 91, 91, .88); box-shadow: 0 0 44px rgba(255, 91, 91, .45); }
@keyframes stampPop {
    0% { transform: scale(.4) rotate(-14deg); opacity: 0; }
    30% { transform: scale(1.12) rotate(-4deg); opacity: 1; }
    50% { transform: scale(1) rotate(-6deg); opacity: 1; }
    100% { transform: scale(1.22) rotate(-10deg); opacity: 0; }
}


/* ---------- Buttons ---------- */
.btn {
    display: block; width: 100%; text-align: center; padding: 13px;
    border-radius: 14px; border: none; font-weight: 700; font-size: 15px;
    background: var(--primary); color: #fff; margin-top: 12px;
}
.btn:active { transform: scale(.99); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.gold { background: var(--gold); color: #1a1a1a; }
.btn.accent { background: var(--accent); }
.btn:disabled { opacity: .5; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 10px; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: 1fr 1fr 1fr; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--card-2); }
/* Letter monogram fallback when no profile photo (Telegram-style) */
.avatar-fb {
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 18px; line-height: 1;
    user-select: none; -webkit-user-select: none; overflow: hidden;
}
span.chat-peer-avatar { font-size: 16px; }
/* Anonymous chats: identity icon on a fixed distinct background */
.avatar-fb.anon {
    background: linear-gradient(135deg, #5b6b8c, #38455c) !important;
    color: #fff;
}
.avatar-fb.anon .iconir { font-size: 24px; width: 1em; height: 1em; }
span.chat-peer-avatar.avatar-fb.anon .iconir { font-size: 20px; }
.avatar.sm { width: 38px; height: 38px; }
.avatar.lg { width: 96px; height: 96px; }

/* ---------- Chat ---------- */
.conv { display: flex; gap: 10px; align-items: center; padding: 12px;
    border-bottom: 1px solid var(--line); }
.conv .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px;
    padding: 1px 7px; min-width: 18px; text-align: center; }

/* ---- Chat list: pin indicator ---- */
.conv.pinned { background: rgba(var(--primary-rgb, 110,86,207), .06); }
.conv-pin { display: inline; margin-right: 4px; color: var(--primary); font-size: 12px; }
.conv-mute { display: inline; margin-right: 4px; color: var(--muted); font-size: 12px; opacity: .7; }

/* ---- Chat tabs (all / normal / anonymous) ---- */
.chat-tabs {
    display: flex; gap: 4px; padding: 4px;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    margin: 0 0 12px;
}
.chat-tabs button {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: none; border: none; color: var(--muted);
    font-size: 13px; font-weight: 700; padding: 10px 6px; border-radius: 10px;
    transition: background .15s, color .15s;
}
.chat-tabs button.on { background: var(--primary); color: #fff; }

/* ---- Anonymous badge in chat list ---- */
.conv-anon-badge {
    display: inline-block; font-size: 10px; font-weight: 700;
    background: var(--accent, #6e56cf); color: #fff; border-radius: 8px;
    padding: 1px 6px; margin-right: 4px; vertical-align: middle;
}

/* ---- Chat context menu (long-press / right-click) ---- */
.conv-menu { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card);
    border-radius: 16px 16px 0 0; padding: 12px 0 20px; z-index: 999;
    box-shadow: 0 -4px 20px rgba(0,0,0,.25); }
.conv-menu-btn { display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 14px 20px; border: none; background: none; color: var(--text);
    font-size: 15px; cursor: pointer; text-align: right; direction: rtl; }
.conv-menu-btn:active { background: rgba(255,255,255,.06); }
.conv-menu-btn.danger { color: var(--red, #e74c3c); }

/* When a conversation is open the mini app's default header and bottom nav are
   hidden; the conversation takes over the whole viewport with its own header
   and a fixed input bar pinned to the bottom. */
body.chat-open .topbar,
body.chat-open .bottom-nav { display: none !important; }
body.chat-open #view { padding: 0; padding-bottom: 0; }

/* Conversation container fills the viewport: header (top) + scrollable messages
   + fixed composer (bottom). */
#conv-box { display: flex; flex-direction: column; }
body.chat-open #conv-box {
    position: fixed; inset: 0; z-index: 40; max-width: 480px; margin: 0 auto;
    background: var(--bg);
}

/* Dedicated conversation header (replaces the default mini app header) */
.chat-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;     padding-top: calc(26px + var(--tg-safe-top));
    background: linear-gradient(180deg, var(--bg-soft), rgba(23,26,35,.92));
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
    flex: 0 0 auto; z-index: 2;
}
.chat-back {
    background: var(--card); border: 1px solid var(--line); color: var(--text);
    width: 38px; height: 38px; border-radius: 12px; font-size: 18px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
}
.chat-peer-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--card-2); flex: 0 0 auto; }
.chat-peer-meta { flex: 1; min-width: 0; }
.chat-peer-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-status { font-size: 12px; color: var(--muted); }
/* Typing indicator: three pulsing dots next to "در حال نوشتن..." */
.typing-ind { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 4px; }
.typing-ind i {
    width: 5px; height: 5px; border-radius: 50%; background: var(--primary);
    animation: typingPulse 1.1s infinite ease-in-out;
}
.typing-ind i:nth-child(2) { animation-delay: .18s; }
.typing-ind i:nth-child(3) { animation-delay: .36s; }
@keyframes typingPulse {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

/* Messages area: scrolls between header and composer.
   The FIRST bubble is pushed to the bottom (margin-top:auto) so short
   conversations start at the bottom of the screen like every messenger,
   instead of hugging the top with a large empty gap below. */
.chat-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.chat-box > .msg:first-child { margin-top: auto !important; }
.msg.pending { opacity: .55; }
body.chat-open .chat-box { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.msg { position: relative; max-width: 78%; padding: 9px 13px 9px; border-radius: 16px;
    font-size: 14px; word-break: break-word; }
.msg.me { margin-left: auto; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.them { margin-right: auto; background: var(--card-2); border-bottom-left-radius: 4px; }
/* Time + read receipts sit in a meta row BELOW the message body (not beside
   the text), pinned to the bubble's visual end (left side in RTL). */
.msg-meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 3px; line-height: 1; }
/* Grouped chat notification counter ("۳ پیام از این کاربر") */
.notif-cnt { display: inline-block; font-size: 10px; font-weight: 700; color: var(--primary-2);
    background: rgba(255,77,121,.12); border-radius: 999px; padding: 1px 8px; margin-right: 6px; vertical-align: middle; }
.msg-time { display: inline-block; font-size: 10px; opacity: .7; }
.msg-checks { display: inline-flex; align-items: center; font-size: 10px; opacity: .7; }
.msg-checks .iconir { width: 13px; height: 13px; display: inline-block; }
.msg-checks.seen { opacity: 1; color: #7dd3fc; }
.msg-media { border-radius: 12px; max-width: 220px; max-height: 260px; width: 100%;
    object-fit: cover; cursor: pointer; display: block; }
.msg:has(.msg-media) { padding: 4px 4px 6px; }
.msg-quote {
    border-right: 3px solid var(--primary); background: rgba(0,0,0,.06);
    border-radius: 8px; padding: 5px 9px; margin-bottom: 6px; cursor: pointer;
    max-width: 100%; overflow: hidden;
}
.msg.them .msg-quote { border-right-color: var(--primary); background: rgba(0,0,0,.05); }
.msg.me .msg-quote { border-right-color: rgba(255,255,255,.7); background: rgba(255,255,255,.18); }
.msg-quote-name { font-size: 11px; font-weight: 700; color: var(--primary); margin-bottom: 1px; }
.msg.me .msg-quote-name { color: rgba(255,255,255,.95); }
.msg-quote-text {
    font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 100%;
}
@keyframes flashHi { 0%,100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } 30% { box-shadow: 0 0 0 3px var(--primary); } }
.msg.flash { animation: flashHi .9s ease; }

/* Quote-reply bar above the composer */
.reply-bar {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--bg-soft); border-top: 1px solid var(--line); flex: 0 0 auto;
}
.reply-bar-body { flex: 1 1 auto; min-width: 0; }
.reply-bar-name { font-size: 11px; font-weight: 700; color: var(--primary); }
.reply-bar-text {
    font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 100%;
}
.reply-bar-cancel {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: none;
    background: var(--card-2); color: var(--text); display: flex; align-items: center;
    justify-content: center; cursor: pointer;
}

/* Smooth entrance for newly sent / received messages */
.msg.enter { animation: msgIn .28s cubic-bezier(.22, 1, .36, 1); }
.msg.me.enter { transform-origin: bottom left; }
.msg.them.enter { transform-origin: bottom right; }
@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Quick-reply chips: short canned messages shown above the composer
   until the conversation has its first messages. */
.quick-chips {
    display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 0;
    background: var(--bg-soft); border-top: 1px solid var(--line);
    flex: 0 0 auto; scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }
.quick-chip {
    flex: 0 0 auto; border: 1px solid var(--line); background: var(--card-2);
    color: var(--text); border-radius: 999px; padding: 7px 13px; font-size: 13px;
    cursor: pointer; white-space: nowrap; font-family: inherit;
}
.quick-chip:active { transform: scale(.95); background: var(--primary); color: #fff; border-color: var(--primary); }

/* Fixed input bar pinned to the bottom of the conversation */
.composer {
    display: flex; gap: 8px; align-items: center;
    margin: 8px 12px calc(10px + env(safe-area-inset-bottom));
    padding: 6px 8px;
    background: rgba(30, 34, 46, .96); border: 1px solid var(--line);
    border-radius: 999px; box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
    flex: 0 0 auto;
}
body.chat-open .composer { position: sticky; bottom: 0; z-index: 2; }
.composer input {
    border: none; border-radius: 999px; background: transparent;
    padding: 10px 6px; flex: 1 1 auto; min-width: 0;
}
.composer input:focus { border-color: transparent; }
.composer-media, .composer-send, .composer-mic {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: none;
    color: #fff; font-size: 18px; display: flex; align-items: center; justify-content: center;
    transition: transform .12s ease;
}
.composer-media { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.composer-send { background: var(--primary); }
.composer-mic { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.composer-media:active, .composer-send:active, .composer-mic:active { transform: scale(.9); }
/* The paper-plane send icon points right by default; in the RTL chat composer
   the send button sits on the left, so mirror the icon to point left. */
.composer-send .iconir { transform: scaleX(-1); }

/* Telegram pattern: mic while the input is empty, send once there is text. */
.composer.has-text .composer-mic { display: none; }

/* Recording mode: the normal composer row is replaced by the rec indicator */
.composer-rec { display: none; flex: 1 1 auto; align-items: center; gap: 10px; min-width: 0; }
.composer.recording .composer-media,
.composer.recording .composer input,
.composer.recording .composer-send,
.composer.recording .composer-mic { display: none; }
.composer.recording .composer-rec { display: flex; }
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: recPulse 1.1s ease infinite; }
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.rec-time { flex: none; font-weight: 700; font-size: 13px; min-width: 40px; }
.rec-hint { flex: 1 1 auto; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-trash, .rec-send {
    flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
    transition: transform .12s ease;
}
.rec-trash { background: var(--card-2); color: var(--red); }
.rec-send { background: var(--primary); color: #fff; border: none; }
.rec-send .iconir { transform: scaleX(-1); }
.rec-trash:active, .rec-send:active { transform: scale(.9); }

/* ---------- Media upload bubble (image / voice progress + retry) ---------- */
.msg-upload { display: flex; gap: 8px; align-items: center; max-width: 86%; }
.up-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; }
.up-voice { flex: none; width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.up-body { flex: 1 1 auto; min-width: 130px; }
.up-label { font-size: 11px; opacity: .9; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.28); overflow: hidden; }
.up-fill { height: 100%; width: 0%; background: #fff; border-radius: 999px; transition: width .2s ease; }
.up-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; }
.up-pct { opacity: .85; }
.up-actions { display: flex; gap: 6px; }
.up-btn { border: none; background: rgba(255,255,255,.2); color: #fff; font-family: inherit;
    font-size: 11px; padding: 3px 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.up-btn .iconir { font-size: 11px; }
.up-btn:active { transform: scale(.95); }
/* Failed state: bubble flips to neutral card colors, bar turns red, retry shows */
.msg-upload.failed { background: var(--card-2); color: var(--text); }
.msg-upload.failed .up-bar { background: rgba(255,91,91,.25); }
.msg-upload.failed .up-fill { background: var(--red); }
.msg-upload.failed .up-btn { background: var(--primary); }

/* ---------- Voice message player ---------- */
.voice-msg { display: flex; align-items: center; gap: 8px; min-width: 168px; padding: 3px 0; }
.voice-play { flex: none; width: 36px; height: 36px; border-radius: 50%; border: none;
    background: rgba(255,255,255,.22); color: #fff; font-size: 14px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; }
.voice-play:active { transform: scale(.92); }
.msg.them .voice-play { background: rgba(0,0,0,.07); color: var(--text); }
.voice-wave { flex: 1 1 auto; height: 4px; border-radius: 999px; background: rgba(255,255,255,.32); overflow: hidden; }
.msg.them .voice-wave { background: rgba(0,0,0,.1); }
.voice-fill { height: 100%; width: 0%; background: #fff; border-radius: 999px; transition: width .15s linear; }
.msg.them .voice-fill { background: var(--primary); }
.voice-dur { flex: none; font-size: 11px; opacity: .85; }

/* Full-size image viewer overlay (tap a chat image) */
.img-viewer { align-items: center; padding: 20px; }
.img-viewer img { max-width: 100%; max-height: 90vh; border-radius: 12px; object-fit: contain; }

/* Gallery (profile sheet + manager) */
.gal-item { position: relative; }
.gal-lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column;
    gap: 2px; background: rgba(0,0,0,.45); color: #fff; border: none; border-radius: 12px; font-size: 13px; font-weight: 700; }
.gal-lock.premium { background: rgba(120,90,0,.55); }
.gal-lock.paid { cursor: pointer; }
.gal-lock i { font-size: 22px; }

.gal-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.gal-row { display: flex; gap: 10px; align-items: center; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.gal-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; }
.gal-ctrl { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.gal-price { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); }
.gal-price:disabled { opacity: .5; }
.radio-group.small .radio span { font-size: 12px; padding: 3px 8px; }
.btn.tiny { padding: 4px 8px; font-size: 12px; width: auto; margin: 0; }
.btn.tiny.danger { color: var(--red); border-color: var(--red); }

/* ---------- Gifts ---------- */
.gift-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gift-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px; text-align: center; }
.gift-item .emoji { font-size: 30px; }
.gift-item .gname { font-size: 13px; margin-top: 4px; }
.gift-item .gprice { font-size: 12px; color: var(--gold); margin-top: 2px; }

/* ---------- Forms / misc ---------- */
.section-title { font-size: 16px; font-weight: 700; margin: 14px 4px 8px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.tag { display: inline-block; background: var(--card-2); border: 1px solid var(--line);
    border-radius: 999px; padding: 4px 10px; font-size: 12px; margin: 3px; }
.profile-attribute-tags, .profile-relationship-tags { margin: 10px 0; }
.profile-attribute-tags .section-title, .profile-relationship-tags .section-title { margin-top: 8px; }

/* ---------- Radio group (gender etc.) ---------- */
.radio-group { display: flex; gap: 8px; margin: 6px 0 2px; }
.radio-group .radio {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 8px; cursor: pointer; color: var(--muted); font-size: 14px;
    transition: background .15s, border-color .15s, color .15s;
    margin: 0;
}
.radio-group .radio input { display: none; }
.radio-group .radio:active { transform: scale(.99); }
.radio-group .radio.on {
    background: rgba(255, 77, 121, .12);
    border-color: var(--primary);
    color: var(--text);
    font-weight: 700;
}
/* In-app new-message banner (top of screen, slides down) */
.msg-banner {
    position: fixed; top: calc(10px + var(--tg-safe-top, 0px)); left: 10px; right: 10px; z-index: 100;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
    cursor: pointer; opacity: 0; transform: translateY(-16px);
    transition: opacity .25s ease, transform .25s ease;
    max-width: 420px; margin: 0 auto;
}
.msg-banner.on { opacity: 1; transform: translateY(0); }
.msg-banner .mb-row { display: flex; align-items: center; justify-content: space-between; }
.msg-banner .mb-name { font-weight: 700; font-size: 14px; }
.msg-banner .mb-close {
    background: none; border: none; color: var(--muted); font-size: 16px;
    cursor: pointer; padding: 0 2px; line-height: 1;
}
.msg-banner .mb-text {
    font-size: 13px; color: var(--muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}

.toast {
    position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
    background: var(--card-2); color: var(--text); border: 1px solid var(--line);
    padding: 10px 16px; border-radius: 12px; z-index: 90; opacity: 0; transition: opacity .25s;
    max-width: 90%; pointer-events: none; text-align: center; word-break: break-word;
}
.toast.show { opacity: 1; }
/* While a conversation is open the bottom nav is hidden — keep the toast visible */
body.chat-open .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50;
    display: flex; align-items: flex-end; justify-content: center;
    animation: fadeIn .18s ease;
}
.modal .sheet { width: 100%; max-width: 480px; background: var(--bg-soft);
    border-top-left-radius: 22px; border-top-right-radius: 22px; padding: 18px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); max-height: 86vh; max-height: 86dvh; overflow: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    animation: sheetUp .24s cubic-bezier(.22, 1, .36, 1); }
.modal .sheet h3 { margin: 0 0 12px; }
/* Fullscreen profile view (instead of the half-page bottom sheet) */
.modal.full { align-items: stretch; }
.modal.full .sheet {
    position: relative; max-width: 480px; height: 100%; max-height: none; border-radius: 0;
    border-top: none; padding-top: calc(14px + var(--tg-safe-top, 0px));
    animation: fadeIn .18s ease;
}
/* Other users' profiles open as a full-screen sheet. Keep the title/content
   comfortably below Telegram's top chrome and safe-area inset. */
.modal.full.profile-other .sheet {
    padding-top: calc(28px + var(--tg-safe-top, 0px));
}
.sheet-close {
    position: absolute; top: calc(10px + var(--tg-safe-top, 0px)); left: 12px; z-index: 2;
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--card); color: var(--text); display: inline-flex; align-items: center;
    justify-content: center; cursor: pointer;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
/* Lock background scroll while a sheet/menu is open (toggled from JS) */
body.modal-open { overflow: hidden; }
.skel { background: linear-gradient(90deg,var(--card),var(--card-2),var(--card));
    background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; height: 16px; }
@keyframes sk { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Register overlay */
#register { position: fixed; inset: 0; background: var(--bg); z-index: 80; overflow: auto; padding: 20px; padding-top: calc(20px + var(--tg-safe-top)); }
#register .hero { text-align: center; margin: 18px 0 10px; }
#register .hero h1 { font-size: 30px; margin: 0; }
#register .hero h1 span { color: var(--primary); }
.preview-avatar { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px;
    border: 3px solid var(--primary); background: var(--card-2); }

/* chips (interests) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px;
    padding: 7px 12px; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* city picker / interest chips were registration-only and removed (bot handles registration) */

/* ---------- Search: input + horizontal filter bar ---------- */
.search-head { margin-bottom: 8px; }
.search-input {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
    padding: 0 12px;
}
.search-input .iconir { color: var(--muted); font-size: 18px; }
.search-input input { border: none; background: transparent; padding: 12px 0; }
.search-input input:focus { border: none; }

/* Horizontal scrolling filter bar (chips) - keeps filters off the main page area */
.filter-bar {
    display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; padding: 4px 2px 10px;
    margin: 0 -12px 6px; padding-left: 12px; padding-right: 12px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    touch-action: pan-x; user-select: none; cursor: grab;
}
.filter-bar:active { cursor: grabbing; }
.filter-bar::-webkit-scrollbar { display: none; }
.fchip {
    flex: 0 0 auto; white-space: nowrap;
    background: var(--card); border: 1px solid var(--line); color: var(--muted);
    border-radius: 999px; padding: 8px 13px; font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 5px;
}
.fchip .iconir { font-size: 15px; }
.fchip .tiny { font-size: 11px; opacity: .7; }
.fchip.on {
    background: rgba(255, 77, 121, .14); border-color: var(--primary); color: var(--text);
}
/* Premium-locked filter chips */
.fchip.locked { opacity: .65; }
.fchip.locked .iconir-lock { opacity: .9; }
.fchip.clear { color: var(--red); border-color: var(--red); }

/* Option list used inside filter sheets */
.opt-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 2px; }
.opt {
    width: 100%; text-align: right; background: var(--bg-soft); border: 1px solid var(--line);
    color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.opt.on { background: rgba(255, 77, 121, .12); border-color: var(--primary); font-weight: 700; }

/* ---------- Referral box (profile) ---------- */
.ref-box { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.ref-box input {
    direction: ltr; text-align: left; font-size: 13px; background: var(--bg-soft);
}
.ref-box .btn { flex: 0 0 auto; padding: 12px 14px; }
.ref-count {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px;
    color: var(--muted); font-size: 13px; font-weight: 600;
}
.ref-count span { color: var(--gold); font-size: 18px; font-weight: 700; }
.anon-link-card { margin-top: 12px; }
.anon-link-card .section-title { margin-top: 0; }
.anon-link-strip {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
    padding: 10px 12px; background: var(--card); border: 1px solid var(--line);
    border-radius: 16px;
}
.anon-link-main { flex: 1 1 auto; min-width: 0; }
.anon-link-title { font-size: 13px; font-weight: 700; color: var(--text); }
.anon-link-title .iconir { color: var(--primary-2); }
.anon-link-strip .ref-box { margin-top: 6px; }
.anon-link-strip .ref-box input { padding-top: 8px; padding-bottom: 8px; font-size: 11px; }
.anon-link-strip .ref-box .btn,
.anon-link-card .ref-box .btn { padding: 10px 13px; }



/* ---------- Interest picker chips (profile editor) ---------- */
.chips { display: flex; flex-wrap: wrap; }
.tag.pick { cursor: pointer; opacity: .55; transition: opacity .15s, background .15s, color .15s; user-select: none; }
.tag.pick.on { opacity: 1; background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Home tabs (cards | anonymous chat) ---------- */
.home-tabs {
    display: flex; gap: 4px; padding: 4px; margin-bottom: 12px;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.home-tabs button {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: none; border: none; color: var(--muted);
    font-size: 13px; font-weight: 700; padding: 10px 6px; border-radius: 10px;
    transition: background .15s, color .15s;
}
.home-tabs button.on { background: var(--primary); color: #fff; }

/* ---------- Anonymous chat tab: 2×4 tile grid, fits one screen ---------- */
/* #home-anon fills exactly the space between the chrome above (topbar + home
   tabs + view padding ≈ 151px) and the fixed bottom nav below (its clearance
   in #view padding-bottom ≈ 135px). Tiles then stretch into that space, so
   all 8 buttons are visible without scrolling. The vh line is the fallback
   for webviews without dvh support. */
#home-anon {
    height: calc(100vh - 286px);
    height: calc(100dvh - 286px - var(--tg-safe-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: 340px; /* very short screens: scroll a little, never crush */
    display: flex; flex-direction: column;
}
.anon-hero { text-align: center; margin-bottom: 10px; }
.anon-hero h2 { margin: 0 0 4px; font-size: 16px; }
.anon-hero p { margin: 0; color: var(--muted); font-size: 12px; }
.anon-tiles {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.anon-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 7px; padding: 8px 6px; border-radius: 22px;
    background: var(--card); border: 1px solid var(--line); color: var(--text);
    font-family: inherit; font-weight: 700; font-size: 13.5px; line-height: 1.3;
    text-align: center; cursor: pointer;
    transition: transform .12s ease, filter .15s ease;
    -webkit-user-select: none; user-select: none;
}
.anon-tile:active { transform: scale(.95); filter: brightness(1.12); }
.anon-tile-ico {
    flex: none; width: 40px; height: 40px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 21px; font-style: normal; line-height: 1;
}
/* Color coding: the two headline modes get gradient fills, the filter tiles
   get tinted cards (girl=pink, boy=blue, same-city=teal, same-age=gold). */
.anon-tile.is-featured {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-color: transparent; color: #fff;
    box-shadow: 0 6px 18px rgba(255, 77, 121, .25);
}
.anon-tile.is-anon {
    background: linear-gradient(135deg, #7d6bff, #5240d6);
    border-color: transparent; color: #fff;
    box-shadow: 0 6px 18px rgba(108, 92, 231, .25);
}
.anon-tile.is-featured .anon-tile-ico, .anon-tile.is-anon .anon-tile-ico { background: rgba(255, 255, 255, .18); }
.anon-tile.is-girl { background: rgba(255, 77, 121, .09); border-color: rgba(255, 77, 121, .32); }
.anon-tile.is-girl .anon-tile-ico { background: rgba(255, 77, 121, .16); }
.anon-tile.is-boy { background: rgba(77, 148, 255, .09); border-color: rgba(77, 148, 255, .32); }
.anon-tile.is-boy .anon-tile-ico { background: rgba(77, 148, 255, .16); }
.anon-tile.is-city { background: rgba(45, 212, 191, .09); border-color: rgba(45, 212, 191, .32); }
.anon-tile.is-city .anon-tile-ico { background: rgba(45, 212, 191, .16); }
.anon-tile.is-age { background: rgba(255, 209, 102, .09); border-color: rgba(255, 209, 102, .32); }
.anon-tile.is-age .anon-tile-ico { background: rgba(255, 209, 102, .16); }
/* Short viewports (small phones / Telegram with keyboard open): tighten the
   hero and icons so the grid still fits without scrolling. */
@media (max-height: 640px) {
    .anon-hero { margin-bottom: 8px; }
    .anon-hero p { display: none; }
    .anon-tiles { gap: 8px; }
    .anon-tile { gap: 5px; font-size: 12.5px; border-radius: 18px; }
    .anon-tile-ico { width: 32px; height: 32px; font-size: 17px; border-radius: 11px; }
}

/* Lobby (searching state): radar rings + criteria chip, centered vertically */
.anon-lobby {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 10px;
}
.anon-radar {
    position: relative; width: 120px; height: 120px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.anon-radar-ring {
    position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid var(--primary); opacity: 0;
    animation: anonping 2.4s cubic-bezier(0, .55, .45, 1) infinite;
}
.anon-radar-ring.r2 { animation-delay: .8s; }
.anon-radar-ring.r3 { animation-delay: 1.6s; }
@keyframes anonping {
    0% { transform: scale(.32); opacity: .85; }
    100% { transform: scale(1.12); opacity: 0; }
}
.anon-radar-core {
    width: 64px; height: 64px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-size: 26px;
    box-shadow: 0 8px 24px rgba(255, 77, 121, .35);
    animation: anoncore 2.4s ease-in-out infinite;
}
.anon-radar-core .iconir { font-size: 26px; }
@keyframes anoncore { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@media (prefers-reduced-motion: reduce) {
    .anon-radar-ring { animation: none; opacity: .3; transform: scale(1); }
    .anon-radar-core { animation: none; }
}
.anon-lobby h3 { margin: 0 0 6px; font-size: 16px; }
.anon-lobby-crit {
    display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--text);
    background: var(--card); border: 1px solid var(--line);
    padding: 5px 14px; border-radius: 999px; margin-bottom: 8px;
}
.anon-lobby .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.anon-time {
    display: inline-block; font-size: 14px; font-weight: 700; color: var(--gold);
    background: rgba(255, 209, 102, .08); border: 1px solid rgba(255, 209, 102, .25);
    padding: 4px 14px; border-radius: 999px; margin-bottom: 16px;
}
.anon-lobby .btn { width: auto; margin-top: 0; padding-left: 26px; padding-right: 26px; }

/* Common-count badge on the swipe card (number only) */
.sc-common-count.num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 26px; padding: 0 9px; border-radius: 999px;
    background: rgba(255, 209, 102, .16); border: 1px solid rgba(255, 209, 102, .45);
    color: var(--gold); font-size: 13px; font-weight: 800;
}

/* ---------- Match (جفت و جور) ---------- */
.match-head { text-align: center; margin-bottom: 12px; }
.match-head h2 { margin: 0 0 4px; font-size: 17px; }
.match-head h2 .iconir { color: var(--primary); }
.match-head p { margin: 0; color: var(--muted); font-size: 13px; }
.match-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.match-row .avatar { width: 48px; height: 48px; flex: none; }
.match-row .btn.tiny { flex: none; margin: 0; }
.mr-main { flex: 1; min-width: 0; }
.mr-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-name .iconir-star-solid { color: var(--gold); }
.mr-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.mr-chips .common-chip { font-size: 10.5px; padding: 2px 8px; }
.mr-chips .common-chip .iconir { font-size: 10px; }
/* Score ring: conic fill tracks the percentage via the inline --score var */
.match-score {
    flex: none; width: 54px; height: 54px; border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    background:
        radial-gradient(closest-side, var(--card) 73%, transparent 74% 100%),
        conic-gradient(var(--primary) calc(var(--score, 0) * 1%), var(--line) 0);
}
.match-score b { font-size: 12.5px; line-height: 1.1; color: var(--primary-2); }
.match-score span { font-size: 8.5px; color: var(--muted); line-height: 1; }
.match-group-title {
    margin: 14px 0 8px; color: var(--muted); font-size: 13px;
    display: flex; align-items: center; gap: 6px;
}
.match-empty { text-align: center; color: var(--muted); padding: 26px 14px; }
.match-empty-ico { font-size: 30px; margin-bottom: 6px; }

/* ---------- Antispam suspension sheet ---------- */
.susp-until {
    display: inline-block; margin: 10px auto 4px; padding: 7px 16px;
    background: rgba(255, 91, 91, .08); border: 1px solid rgba(255, 91, 91, .3);
    border-radius: 999px; color: var(--red); font-size: 13px; font-weight: 700;
}

/* ---------- Performance & a11y ---------- */
/* Long lists (chats / search / wallet) skip offscreen rendering work */
.conv, .card, .gift-item {
    content-visibility: auto;
    contain-intrinsic-size: auto 72px;
}
/* Never let images blow up layout while loading */
img { height: auto; }
.avatar, .chat-peer-avatar, .gal-thumb, .msg-media { flex: none; }
/* Visible keyboard focus (a11y) without hurting tap UX */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
/* Respect users who prefer less motion: kill decorative animation */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    .swipe-card.behind, .swipe-card.active:not(.dragging):not(.flying), .swipe-card.flying { transition: none; }
}
