
@font-face {
    font-family: 'Brush Script MT';
    src: url('../fonts/BrushScript.ttf') format('truetype');
    font-weight: normal;
    font-style: italic;
}

#connection-status {
    font-family: 'Brush Script MT', cursive !important;
    font-style: italic !important;
    font-weight: normal !important;
    font-size: 3.06em !important; /* ۱۵٪ کوچک‌تر از ۳.۶em */
}

/* ================= متغیرهای تم و گلس‌مورفیسم ================= */

/* Screen Reader Only Utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

        :root {
            /* Dyo True OLED Dark Theme */
            --bg-base: #000000;
            --blob-1: #3730a3; /* Deep Indigo */
            --blob-2: #4c1d95; /* Deep Purple */
            --blob-3: #1e1b4b; /* Darkest Indigo */
            
            --glass-bg: rgba(15, 15, 15, 0.5);
            --glass-border: rgba(255, 255, 255, 0.05);
            --glass-shadow: rgba(0, 0, 0, 0.6);
            --glass-hover: rgba(255, 255, 255, 0.04);
            
            --text-main: #ffffff;
            --text-muted: #94a3b8;
            --primary: #7c3aed;
            --primary-hover: #8b5cf6;
            
            --msg-in: rgba(255, 255, 255, 0.06);
            --msg-out: #6366f1;
            --story-ring: linear-gradient(135deg, #4338ca, #6366f1, #a855f7);
            --online: #10b981;

            /* Chat font size - controlled by settings */
            --chat-font-size: 14.5px;
        }

        [data-theme="light"] {
            /* Light Mint Theme */
            --bg-base: #f2f9f5;
            --glass-bg: #ffffff;
            --glass-border: rgba(118, 194, 155, 0.2);
            --glass-shadow: rgba(118, 194, 155, 0.1);
            --glass-hover: #f2f9f5;
            
            --text-main: #18261f;
            --text-muted: #6b8074;
            --primary: #52c48a; 
            --primary-hover: #4bb37e;
            
            --msg-in: rgba(255, 255, 255, 0.45);
            --msg-out: #ffffff;
            --story-ring: linear-gradient(135deg, #52c48a, #76c29b, #9ed4b9);
            
            /* Flat UI Overrides */
            --chat-bg: #76c29b;
            --contacts-bg: #ffffff;
            --curve-bg: #ffffff;
            --text-msg-in: #124027;
            --text-msg-out: #124027;
        }

        [data-theme="dark"] {
            /* Premium Dark Forest Theme - Even Darker */
            --bg-base: #000000;
            --glass-bg: #050a07; /* Darker green */
            --glass-border: rgba(255, 255, 255, 0.03); 
            --glass-shadow: rgba(0, 0, 0, 0.8);
            --glass-hover: #0a120d; /* Darker hover */
            
            --text-main: #e1ede6;
            --text-muted: #74857b;
            --primary: #3da872;
            --primary-hover: #52c48a;
            
            --msg-in: rgba(255, 255, 255, 0.04);
            --msg-out: #0c1a12; /* Darker green out msg */
            --story-ring: linear-gradient(135deg, #3da872, #1c3022, #0c1a12);

            /* Flat UI Overrides */
            --chat-bg: #020403;
            --contacts-bg: #050a07; /* Darker green */
            --curve-bg: #050a07; /* Darker green */
            --text-msg-in: #e1ede6;
            --text-msg-out: #e1ede6;
        }


        /* ================= استایل‌های پایه ================= */
        * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Vazirmatn', 'Inter', Tahoma, 'Iranian Sans', 'B Nazanin', Arial, system-ui, -apple-system, sans-serif; }
        body { background: var(--bg-base); color: var(--text-main); height: 100vh; overflow: hidden; position: relative; transition: background 0.5s ease; }
        
        /* هاله‌های نوری پس‌زمینه (Blobs) */
        .bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; filter: blur(120px); opacity: 0.35; pointer-events: none; transition: 0.5s; }
        .blob { position: absolute; border-radius: 50%; animation: float 20s infinite alternate ease-in-out; }
        .blob-1 { width: 50vw; height: 50vw; background: var(--blob-1); top: -10%; right: -10%; }
        .blob-2 { width: 40vw; height: 40vw; background: var(--blob-2); bottom: -10%; left: -10%; animation-delay: -5s; }
        .blob-3 { width: 35vw; height: 35vw; background: var(--blob-3); top: 30%; left: 20%; animation-delay: -10s; }
        @keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(10%, 10%) scale(1.1); } }

        /* اسکرول‌بار مخفی و مدرن */
        ::-webkit-scrollbar { width: 5px; height: 5px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: rgba(150, 150, 150, 0.3); border-radius: 10px; }
        ::-webkit-scrollbar-thumb:hover { background: var(--primary); }

        /* کلاس گلس عمومی */
        .glass-panel {
            background: var(--glass-bg);
            backdrop-filter: blur(24px);
            -webkit-backdrop-filter: blur(24px);
            border: 1px solid var(--glass-border);
            box-shadow: 0 8px 32px 0 var(--glass-shadow);
            border-radius: 24px;
            transition: all 0.3s ease;
        }

        /* ================= لی‌آوت اصلی ================= */
        .app-container { display: flex; height: 100vh; padding: 20px; gap: 20px; }

        /* === سایدبار شناور === */
        .sidebar { 
            width: 90px; 
            display: flex; 
            flex-direction: column; 
            align-items: center; 
            padding: 30px 0; 
            gap: 25px; 
            z-index: 100; 
            flex-shrink: 0;
            border-left: 1px solid var(--glass-border);
            background: var(--glass-bg); /* Use consistent glass background */
            backdrop-filter: blur(40px);
            -webkit-backdrop-filter: blur(40px);
        }
        .nav-btn { width: 50px; height: 50px; border-radius: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); transition: 0.3s; background: transparent; border: none; }
        .nav-btn:hover { background: var(--glass-hover); color: var(--primary); transform: translateY(-3px); }
        .nav-btn.active { background: var(--primary); color: #fff; box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3); }

        /* Special styling for Games button to avoid color clash */
        #games-nav-btn {
            width: 64px !important;
            height: 64px !important;
            margin: 4px 0;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        #games-nav-btn.active {
            background: transparent !important;
            border: 2px solid var(--primary) !important;
            box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
            transform: scale(1.05);
        }
        #games-nav-btn img {
            transition: transform 0.3s ease;
        }
        #games-nav-btn.active img {
            filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
        }

        .sidebar .nav-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
        .sidebar .nav-btn svg.game-nav-icon { width: 150px !important; height: 150px !important; }

        /* === بدنه اصلی === */
        .main-wrapper { flex: 1; position: relative; display: flex; overflow: hidden; isolation: isolate; min-width: 0; }
        .section,
        .app-window {
            display: none;
            width: 100%;
            height: 100%;
            min-width: 0;
            min-height: 0;
            position: absolute;
            inset: 0;
            animation: fadeZoom 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }
        .section.active,
        .app-window.active { display: flex; }
        .app-window {
            flex-direction: column;
            z-index: 20;
            border-radius: 32px;
            overflow: hidden;
            background: var(--glass-bg);
            backdrop-filter: blur(30px);
            border: 1px solid var(--glass-border);
            box-shadow: 0 22px 60px var(--glass-shadow);
        }
        @keyframes fadeZoom { from { opacity: 0; transform: scale(0.98) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

        /* ================= تب چت (WhatsApp & Telegram Style) ================= */
        .chat-layout { display: flex; width: 100%; height: 100%; gap: 20px; }
        
        /* پنل مخاطبین */
        .contacts-panel { 
            width: 360px; 
            display: flex; 
            flex-direction: column; 
            overflow: hidden; 
            flex-shrink: 0;
            background: var(--glass-bg);
            backdrop-filter: blur(40px);
            -webkit-backdrop-filter: blur(40px);
            border-left: 1px solid var(--glass-border);
            z-index: 50;
        }
        
        /* استوری‌ها */
        .stories-container,
        .stories-horizontal {
            padding: 18px 20px;
            border-bottom: 1px solid var(--glass-border);
            display: flex;
            align-items: flex-start;
            gap: 14px;
            overflow-x: auto;
            overflow-y: hidden;
            scrollbar-width: none;
            -ms-overflow-style: none;
            white-space: nowrap;
            scroll-snap-type: x proximity;
        }
        .stories-container::-webkit-scrollbar,
        .stories-horizontal::-webkit-scrollbar { display: none; }
        .story,
        .stories-horizontal .story-item {
            display: inline-flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            gap: 8px;
            cursor: pointer;
            min-width: 72px;
            flex: 0 0 auto;
            text-align: center;
            scroll-snap-align: start;
        }
        .story-ring,
        .stories-horizontal .story-circle {
            width: 72px;
            height: 72px;
            border-radius: 50%;
            background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
            padding: 2.5px;
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            position: relative;
        }
        .story:hover .story-ring,
        .stories-horizontal .story-item:hover .story-circle {
            transform: scale(1.1) rotate(5deg);
            box-shadow: 0 12px 30px rgba(220, 39, 67, 0.35);
        }
        .story-avatar,
        .stories-horizontal .story-circle img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: var(--bg-base);
            border: 2px solid var(--glass-bg);
            background-size: cover;
            background-position: center;
            display:flex;
            align-items:center;
            justify-content:center;
            color: var(--text-muted);
            object-fit: cover;
        }
        .story-name,
        .stories-horizontal .story-item > div:last-child {
            max-width: 72px;
            font-size: 11px;
            line-height: 1.25;
            color: var(--text-main);
            font-weight: 500;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        @media (max-width: 768px) {
            .stories-container,
            .stories-horizontal {
                padding: 14px 14px 16px;
                gap: 12px;
            }
            .story,
            .stories-horizontal .story-item {
                min-width: 64px;
            }
            .story-ring,
            .stories-horizontal .story-circle {
                width: 60px;
                height: 60px;
            }
            .story-name,
            .stories-horizontal .story-item > div:last-child {
                max-width: 64px;
                font-size: 10px;
            }
        }

        /* لیست مخاطبین */

/* ================= Responsive: Tablet & Mobile ================= */
@media (max-width: 768px) {

    /* فیلتر تماس‌ها — افقی اسکرول */
    #contacts-tab .call-filter-btn {
        display: inline-flex !important;
        flex-shrink: 0 !important;
        width: auto !important;
        min-width: unset !important;
    }
    #call-filter-bar {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    #call-filter-bar::-webkit-scrollbar { display: none !important; }

    /* contacts-tab و community-tab — تمام عرض */
    #contacts-tab,
    #community-tab {
        flex-direction: column !important;
    }
    #contacts-tab > div:not(.mobile-contacts-topbar),
    #community-tab > div:not(.mobile-contacts-topbar) {
        width: 100% !important;
        max-width: 100% !important;
        flex-direction: column !important;
    }
    #contacts-tab .contacts-panel,
    #community-tab .contacts-panel {
        max-width: 100% !important;
        width: 100% !important;
        border-right: none !important;
    }
    /* پنل سمت راست خالی مخفی */
    #contacts-tab > div > div:last-child:not(.contacts-panel):not(#call-contacts-list):not(.chub-body):not(.chub-tabs):not(.call-hub-v2),
    #community-tab > div > div:last-child:not(.contacts-panel):not(#community-list) {
        display: none !important;
    }

    .app-container {
        padding: 0 !important;
        gap: 0 !important;
        flex-direction: column !important;
        padding-left: 0 !important;
    }

    /* --- Sidebar → bottom bar --- */
    .sidebar {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 56px !important;
        flex-direction: row !important;
        justify-content: space-evenly !important;
        align-items: center !important;
        padding: 4px 8px !important;
        gap: 2px !important;
        z-index: 1100 !important;
        border-radius: 0 !important;
        border-top: 1px solid rgba(255,255,255,0.1);
        border-left: none !important;
        overflow-x: auto !important;
        background: var(--glass-bg, rgba(15,23,42,0.95));
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease !important;
        /* Professional Click-through optimization */
        pointer-events: none !important;
    }

    /* Enable interaction only for buttons */
    .sidebar .nav-btn, 
    .sidebar button, 
    .sidebar a {
        pointer-events: auto !important;
    }

    /* Class to hide sidebar on scroll */
    .sidebar.smart-hide {
        transform: translateY(100%) !important;
        opacity: 0 !important;
    }

    /* لوگو → مخفی */
    .sidebar > div:first-child {
        display: none !important;
    }

    /* ابزارهای پایین (theme, games, settings) → ردیف افقی */
    .sidebar > div[style*="margin-top: auto"] {
        margin-top: 0 !important;
        flex-direction: row !important;
        gap: 2px !important;
    }

    .sidebar .nav-btn {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        padding: 8px !important;
        border-radius: 12px;
    }

    .sidebar .nav-btn svg {
        width: 22px !important;
        height: 22px !important;
    }

/* ﯽﻠﺻﺍ ﻪﻧﺪﺑ */
    .main-wrapper {
        flex: 1;
        width: 100% !important;
        min-height: 0;
        margin-left: 0 !important;
        padding-left: 0 !important;
        padding-bottom: 116px !important; /* 56px navbar + 60px input */
        border-radius: 0;
    }

    .chat-input-container {
        position: fixed !important;
        bottom: 56px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        height: 60px !important;
        z-index: 999 !important;
        flex-shrink: 0;
        width: 100% !important;
        box-sizing: border-box !important;
    }










    #desktop-container {
        flex-direction: column !important;
        padding-bottom: 0 !important;
    }
    #theme-icon {
        stroke: var(--text-main) !important;
        fill: var(--text-main) !important;
        opacity: 0.9 !important;
    }

    /* User avatar/profile → مخفی */
    .sidebar .user-avatar,
    .sidebar .sidebar-profile {
        display: none !important;
    }
    /* === Mobile Social-Style Navigation === */
    .main-wrapper {
        position: relative !important;
        overflow: hidden !important;
    }

    .contacts-panel {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        position: absolute !important;
        top: 0; left: 0; right: 0; bottom: 0;
        z-index: 10 !important;
        display: flex !important;
        flex-direction: column !important;
        transition: transform 0.3s ease !important;
        border-right: none !important;
    }

    .mobile-contacts-topbar {
        display: grid !important;
        grid-template-columns: 62px minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        padding: 12px 16px 10px;
        border-bottom: 1px solid var(--glass-border);
        background: var(--glass-bg);
        backdrop-filter: blur(40px);
        -webkit-backdrop-filter: blur(40px);
        flex-shrink: 0;
        position: relative;
        z-index: 10;
    }

    .mobile-contacts-spacer {
        min-width: 0;
        height: 1px;
    }

    .header-calendar-widget {
        min-width: 0;
        height: 46px;
        border: 1px solid var(--glass-border);
        border-radius: 18px;
        background: var(--glass-hover);
        color: var(--text-main);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 4px 10px;
        cursor: pointer;
        overflow: hidden;
        text-align: center;
    }

    .header-calendar-time {
        font-size: 16px;
        font-weight: 900;
        line-height: 1;
        letter-spacing: -0.02em;
    }

    .header-calendar-date {
        max-width: 100%;
        color: var(--text-muted);
        font-size: 10.5px;
        font-weight: 700;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-calendar-widget.is-emergency {
        align-items: stretch;
        gap: 3px;
        border-color: rgba(239, 68, 68, 0.45);
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.24), rgba(245, 158, 11, 0.14));
        box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.08);
    }

    .header-calendar-alert-label {
        color: #fca5a5;
        font-size: 10px;
        font-weight: 900;
        line-height: 1;
    }

    .header-calendar-alert-text {
        max-width: 100%;
        color: var(--text-main);
        font-size: 11px;
        font-weight: 800;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-brand-mark,
    .mobile-notif-btn {
        width: 44px;
        height: 44px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--glass-border);
        background: var(--glass-hover);
        color: var(--text-main);
        box-shadow: none;
    }

    .mobile-brand-mark {
        width: 62px;
        background: transparent;
        border-color: transparent;
        justify-content: flex-start;
    }

    .mobile-brand-mark img {
        width: 52px;
        height: 52px;
        object-fit: contain;
        display: block;
    }

    .mobile-notif-btn {
        position: relative;
        cursor: pointer;
        padding: 0;
    }

    .mobile-notif-dot {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 8px;
        height: 8px;
        border-radius: 999px;
        background: #ef4444;
        border: 2px solid var(--bg-base);
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.65);
    }

    .mobile-contact-segments {
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: center;
        gap: 4px;
        overflow: hidden;
        padding: 3px;
        border: 1px solid var(--glass-border);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.035);
    }

    .mobile-contact-segments::-webkit-scrollbar {
        display: none;
    }

    .mobile-contact-segments .filter-chip {
        width: 100%;
        justify-content: center;
        padding: 8px 4px;
        border-radius: 12px;
        font-size: 11.5px;
        line-height: 1;
        border-color: transparent;
        background: transparent;
        box-shadow: none;
    }

    .mobile-contact-segments .filter-chip.active {
        background: var(--primary);
        color: #fff;
        box-shadow: 0 8px 18px rgba(96, 165, 250, 0.26);
    }

    .contacts-filters-premium {
        display: none !important;
    }

    .contacts-header-premium {
        padding: 10px 12px 8px !important;
    }

    .chat-area {
        width: 100% !important;
        height: 100% !important;
        position: absolute !important;
        top: 0; left: 0; right: 0; bottom: 0;
        max-height: calc(100vh - 56px) !important;
    }

    /* وقتی چت باز نیست، chat-area مخفی */
    body:not(.mobile-chat-open) .chat-area {
        display: none !important;
    }

    /* وقتی چت باز شد، contacts-panel مخفی */
    body.mobile-chat-open .contacts-panel {
        transform: translateX(-100%) !important;
        pointer-events: none !important;
    }

    body.mobile-chat-open .chat-area {
        display: flex !important;
        flex-direction: column !important;
        z-index: 100 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: 100% !important;
        padding-bottom: 65px !important; /* Space for navbar */
        overflow: hidden !important;
    }

    /* وقتی چت باز است، padding-bottom روی main-wrapper صفر شود */
    /* چون chat-area با position:fixed خارج از جریان است و padding فضای مشکی می‌سازد */
    body.mobile-chat-open .main-wrapper {
        padding-bottom: 0 !important;
    body.mobile-chat-open #chat-tab {
        background: transparent !important;
    }

    @keyframes slideUpFade {
        from { opacity: 0; transform: translateY(20px) scale(0.95); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }

    .video-request-modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(8px); z-index: 100000; display: flex; align-items: center; justify-content: center; }
    .video-request-modal-content { background: rgba(15, 23, 42, 0.85); border: 1px solid rgba(255,255,255,0.15); border-radius: 24px; padding: 30px 20px; width: 85%; max-width: 320px; text-align: center; box-shadow: 0 25px 50px rgba(0,0,0,0.5); animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    .video-request-icon { font-size: 48px; margin-bottom: 16px; text-shadow: 0 4px 10px rgba(0,0,0,0.3); }
    .video-request-text { color: white; font-size: 16px; line-height: 1.6; margin-bottom: 24px; }
    .video-request-actions { display: flex; gap: 12px; justify-content: center; }
    .btn-request-accept { flex: 1; background: var(--primary); color: white; border: none; border-radius: 14px; padding: 12px 0; font-weight: bold; font-size: 15px; cursor: pointer; transition: all 0.2s; box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3); }
    .btn-request-reject { flex: 1; background: rgba(255,255,255,0.1); color: white; border: none; border-radius: 14px; padding: 12px 0; font-weight: bold; font-size: 15px; cursor: pointer; transition: all 0.2s; }
    .btn-request-accept:active { transform: scale(0.95); }
    .btn-request-reject:active { transform: scale(0.95); background: rgba(255,255,255,0.2); }

    /* Chat header mobile */
    body.mobile-chat-open .chat-area .chat-header {
        flex-shrink: 0 !important;
        position: relative !important;
        z-index: 10 !important;
        width: 100% !important;
    }
    body.mobile-chat-open .chat-area .chat-msgs {
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    body.mobile-chat-open .chat-area .input-bar {
        position: relative !important;
        bottom: auto !important;
        flex-shrink: 0 !important;
        z-index: 10 !important;
    }

    /* Input Bar for mobile */
    .input-bar {
        padding: 8px 10px !important;
        gap: 0 !important;
        background: transparent !important;
        backdrop-filter: none !important;
        border-top: none !important;
        min-height: unset !important;
    }

    body.mobile-chat-open .input-bar {
        position: relative !important;
        bottom: auto !important;
        width: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        z-index: 10 !important;
        background: transparent !important;
        padding: 8px 10px !important;
        min-height: unset !important;
    }
    body.mobile-chat-open .sidebar {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        z-index: 1100 !important;
    }
    body:not(.mobile-chat-open) .sidebar {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        z-index: 9999 !important;
        position: relative;
    }

    /* Game Window for mobile */
    #app-games {
        z-index: 500 !important;
        padding-bottom: 56px !important; /* Space for bottom bar */
    }

    .games-shell-header {
        padding: 12px 15px !important;
    }

    .games-shell-close {
        padding: 8px 12px !important;
        font-size: 18px !important;
    }

    #games-iframe-wrap {
        height: calc(100% - 60px) !important;
    }

    /* دکمه Back */
    .mobile-back-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        border: none;
        background: var(--glass-hover, rgba(255,255,255,0.1));
        color: var(--text-main, #fff);
        cursor: pointer;
        margin-left: 8px;
        flex-shrink: 0;
        transition: background 0.2s;
    }

    .mobile-back-btn:hover {
        background: var(--primary, #6366f1);
        color: #fff;
    }

    /* chat-input در حالت موبایل */
    body.mobile-chat-open .chat-input-container {
        position: fixed !important;
        bottom: 56px !important;
    }

    /* رفع گپ بین input و navbar — mci-root داخل chat-area flex */
    body.mobile-chat-open #mci-root {
        flex-shrink: 0 !important;
        margin-bottom: 0 !important;
        padding-bottom: 8px !important;
    }

    /* chat-msgs باید تمام فضای باقی‌مانده را بگیرد */
    body.mobile-chat-open .chat-msgs {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }

    /* هیچ فضایی بعد از mci-root نباشد */
    body.mobile-chat-open .chat-area > *:last-child {
        margin-bottom: 0 !important;
    }


}

@media (max-width: 480px) {
    .sidebar {
        height: 60px !important;
        padding: 6px 8px !important;
    }

    .sidebar .nav-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        padding: 6px !important;
        border-radius: 10px;
    }

    .sidebar .nav-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* در 480px sidebar = 60px پس chat-area باید 60px از پایین فاصله داشته باشد */
    body.mobile-chat-open .chat-area {
        padding-bottom: 70px !important;
    }

    .main-wrapper {
        padding-bottom: 116px !important; /* 60px navbar + 56px input */
    }
}

/* فیکس آیکون تم برای تم لایت */
[data-theme="light"] #theme-icon {
    fill: var(--text-main, #1e293b) !important;
    stroke: var(--text-main, #1e293b) !important;
}

/* === Mobile Back Button (hidden on desktop) === */
.mobile-back-btn {
    display: none;
}

.mobile-contacts-topbar {
    display: none;
}

        /* Contacts Header Premium */
        .contacts-header-premium {
            padding: 20px 20px 10px 20px;
            display: flex;
            align-items: center;
            gap: 12px;
            flex-shrink: 0;
        }

        .search-box {
            flex: 1;
            position: relative;
            background: var(--glass-hover);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
            display: flex;
            align-items: center;
            padding: 0 15px;
            height: 46px;
            transition: 0.3s;
        }

        .search-box:focus-within {
            border-color: var(--primary);
            background: rgba(255,255,255,0.08);
            box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
        }

        .search-box input {
            background: transparent;
            border: none;
            color: var(--text-main);
            font-size: 14px;
            width: 100%;
            height: 100%;
            padding: 0 10px;
            outline: none;
        }

        .search-box svg {
            color: var(--text-muted);
            flex-shrink: 0;
            opacity: 0.6;
        }

        .add-btn-premium {
            width: 46px;
            height: 46px;
            border-radius: 14px;
            background: var(--primary);
            color: #fff;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: 0.3s;
            flex-shrink: 0;
            box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
            position: relative;
            z-index: 1000;
        }

        .add-btn-premium:hover {
            transform: scale(1.05);
            background: #4f46e5;
        }

        .contacts-filters-premium {
            display: flex;
            gap: 8px;
            padding: 0 20px 15px 20px;
            border-bottom: 1px solid var(--glass-border);
            flex-shrink: 0;
            overflow-x: auto;
            scrollbar-width: none;
        }

        .contacts-filters-premium::-webkit-scrollbar { display: none; }

        .filter-chip {
            padding: 8px 18px;
            border-radius: 20px;
            background: var(--glass-hover);
            border: 1px solid var(--glass-border);
            color: var(--text-muted);
            font-size: 13px;
            cursor: pointer;
            transition: 0.3s;
            font-weight: 500;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .filter-chip.active {
            background: var(--primary);
            color: #fff;
            border-color: var(--primary);
            box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
        }

        .contact-list { 
            flex: 1; 
            overflow-y: auto; 
            padding: 10px 15px; 
            display: flex; 
            flex-direction: column; 
            gap: 4px;
            scrollbar-width: thin;
            scrollbar-color: var(--glass-border) transparent;
        }

        .contact-list::-webkit-scrollbar { width: 5px; }
        .contact-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

        .contact-item { 
            display: flex; 
            align-items: center; 
            gap: 15px; 
            padding: 14px 12px; 
            border-radius: 16px; 
            cursor: pointer; 
            transition: 0.3s; 
            position: relative; 
            border: none;
            border-bottom: none; /* Subtle separator removed */
            margin-bottom: 2px;
        }
        .contact-item:last-child { border-bottom-color: transparent; }
        .contact-item:hover { 
            background: var(--glass-hover); 
            border-color: var(--glass-border);
            transform: translateY(-1px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        .contact-item.active { 
            background: rgba(99, 102, 241, 0.15); 
            border-color: rgba(99, 102, 241, 0.4); 
            box-shadow: 0 10px 25px rgba(0,0,0,0.15);
        }
        .c-avatar, .contact-avatar { 
            width: 48px; 
            height: 48px; 
            border-radius: 18px; 
            background: var(--primary); /* Fallback */
            position: relative; 
            flex-shrink: 0; 
            display: flex; 
            align-items: center; 
            justify-content: center; 
            color: #fff; 
            font-weight: 700; 
            font-size: 18px;
            letter-spacing: 0.5px;
            box-shadow: 0 8px 20px rgba(0,0,0,0.15), inset 0 2px 4px rgba(255,255,255,0.25);
            border: 1.5px solid rgba(255,255,255,0.1);
            overflow: hidden;
            text-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        
        .c-avatar::after, .contact-avatar::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 100%);
            pointer-events: none;
        }

        .c-avatar img, .contact-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: inherit;
        }
        .c-online { position: absolute; bottom: -2px; right: -2px; width: 14px; height: 14px; background: var(--online); border: 3px solid var(--bg-base); border-radius: 50%; }
        .c-info { flex: 1; overflow: hidden; }
        .c-name { font-weight: 600; font-size: 14px; margin-bottom: 5px; display: flex; justify-content: space-between; color: var(--text-main); }
        .c-time { font-size: 11px; color: var(--text-muted); font-weight: normal; }
        .c-last-msg { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.9; }
        
        /* دکمه سه نقطه مخاطبین */
        .contact-menu-btn, .c-btn { 
            width: 32px; 
            height: 32px; 
            border-radius: 10px; 
            background: transparent; 
            border: none; 
            cursor: pointer; 
            display: flex; 
            align-items: center; 
            justify-content: center; 
            color: var(--text-muted); 
            transition: 0.2s; 
            opacity: 0.6;
            margin-right: auto; /* Push to far side */
        }
        .contact-item:hover .contact-menu-btn, .contact-item:hover .c-btn { opacity: 1; color: var(--primary); background: var(--glass-hover); }
        .contact-menu-btn svg, .c-btn svg { width: 18px; height: 18px; stroke-width: 2; }

        /* محیط چت */
        .chat-area { 
            flex: 1; 
            display: flex; 
            flex-direction: column; 
            position: relative; 
            overflow: hidden; 
            height: 100%; 
            background: var(--glass-bg);
            backdrop-filter: blur(50px);
            -webkit-backdrop-filter: blur(50px);
            min-width: 0;
        }

        /* Context Menu Premium Glass */
        .contact-context-menu {
            position: fixed;
            z-index: 10000;
            min-width: 180px;
            background: var(--glass-bg);
            backdrop-filter: blur(25px);
            -webkit-backdrop-filter: blur(25px);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
            box-shadow: 0 15px 35px rgba(0,0,0,0.3);
            padding: 6px;
            animation: menuFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        @keyframes menuFadeIn {
            from { opacity: 0; transform: scale(0.95) translateY(-10px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }

        .contact-context-menu button {
            width: 100%;
            padding: 8px 12px;
            border: none;
            background: transparent;
            color: var(--text-main);
            font-size: 13.5px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            flex-direction: row-reverse; /* Icon on the right for RTL */
            gap: 12px;
            cursor: pointer;
            border-radius: 8px;
            transition: 0.2s;
            text-align: right;
            white-space: nowrap;
        }

        .contact-context-menu button:hover {
            background: var(--glass-hover);
            color: var(--primary);
        }

        .contact-context-menu button svg {
            width: 18px !important;
            height: 18px !important;
            min-width: 18px;
            min-height: 18px;
            flex-shrink: 0;
            opacity: 0.8;
        }

        .contact-context-menu button.danger {
            color: #ff4d4d;
        }

        .contact-context-menu button.danger:hover {
            background: rgba(255, 77, 77, 0.1);
        }

        .menu-divider {
            height: 1px;
            background: var(--glass-border);
            margin: 4px 8px;
            opacity: 0.5;
        }

        .contact-context-menu button svg {
            opacity: 0.7;
        }
        .chat-header { 
            height: 90px; 
            padding: 0 35px; 
            border-bottom: 1px solid var(--glass-border); 
            display: flex; 
            align-items: center; 
            justify-content: space-between; 
            flex-shrink: 0; 
            z-index: 10;
            background: rgba(255, 255, 255, 0.03);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            direction: rtl;
        }
        
        .icon-circle { width: 38px; height: 38px; border-radius: 50%; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; transition: 0.2s; color: rgba(255,255,255,0.45); flex-shrink: 0; }
        .icon-circle:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.85); transform: none; box-shadow: none; }

        .chat-msgs { 
            flex: 1; 
            padding: 30px; 
            overflow-y: auto; 
            display: flex; 
            flex-direction: column; 
            gap: 20px; 
            position: relative; 
            scroll-behavior: smooth;
            direction: rtl;
        }
        .msg { 
            max-width: 75%; 
            padding: 16px 20px; 
            border-radius: 24px; 
            font-size: var(--chat-font-size, 14.5px); 
            line-height: 1.7; 
            position: relative; 
            display: flex; 
            flex-direction: column; 
            gap: 6px; 
            box-shadow: 0 10px 25px rgba(0,0,0,0.1); 
            transition: font-size 0.3s ease, background 0.3s ease;
        }
        
        /* Received messages (Left side) */
        .msg-in { 
            align-self: flex-end !important; 
            margin-right: auto !important;
            margin-left: 0 !important;
            background: rgba(255, 255, 255, 0.12) !important; 
            color: #ffffff !important; 
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 18px 18px 18px 2px !important;
            border: 1px solid rgba(255,255,255,0.15) !important;
        }

        /* Sent messages (Right side) */
        .msg-out { 
            align-self: flex-start !important; 
            margin-left: auto !important;
            margin-right: 0 !important;
            background: linear-gradient(135deg, #4f46e5, #6366f1) !important; 
            color: #ffffff !important; 
            border-radius: 18px 18px 2px 18px !important;
            box-shadow: 0 8px 25px rgba(99,102,241,0.35) !important;
        }
        .msg-meta { font-size: 11px; align-self: flex-end; opacity: 0.75; display: flex; align-items: center; gap: 5px; margin-top: 4px; }
        
        /* Drag & Drop Overlay چت */
        .dnd-overlay { position: absolute; inset: 10px; background: rgba(99, 102, 241, 0.2); backdrop-filter: blur(8px); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--primary); opacity: 0; pointer-events: none; transition: 0.3s; border: 3px dashed var(--primary); border-radius: 18px; }
        .dnd-overlay.active { opacity: 1; }

        /* ورودی متن */
        .input-bar { 
            min-height: unset;
            height: auto;
            padding: 10px 14px; 
            display: flex; 
            align-items: center; 
            gap: 6px; 
            border-top: 1px solid rgba(255,255,255,0.06); 
            flex-shrink: 0; 
            background: transparent;
        }
        .text-input { 
            flex: 1; 
            background: rgba(255, 255, 255, 0.07); 
            border: 1px solid rgba(255,255,255,0.12); 
            border-radius: 24px; 
            padding: 0 18px;
            height: 46px;
            color: var(--text-main); 
            outline: none; 
            transition: 0.2s; 
            font-size: 15px; 
            box-shadow: none;
        }
        .text-input:focus { 
            border-color: rgba(99, 179, 237, 0.45); 
            background: rgba(255, 255, 255, 0.09); 
            box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.08); 
        }
        .text-input::placeholder { color: var(--text-muted); opacity: 0.5; }
        .send-btn { 
            width: 42px; 
            height: 42px; 
            border-radius: 50%; 
            background: #4a9eff; 
            color: white; 
            border: none; 
            display: flex; 
            align-items: center; 
            justify-content: center; 
            cursor: pointer; 
            transition: 0.2s; 
            box-shadow: 0 2px 10px rgba(74,158,255,0.35);
            flex-shrink: 0;
        }
        .send-btn:hover { background: #2d86f0; transform: scale(1.06); box-shadow: 0 4px 14px rgba(74,158,255,0.5); }

        /* ================= تب مدیا و فید ================= */
        .media-layout { padding: 30px; display: flex; flex-direction: column; gap: 30px; overflow-y: auto; width: 100%; }
        
        /* پلیر ویدیو اختصاصی شیشه‌ای */
        .video-player-container { width: 100%; max-width: 1000px; margin: 0 auto; background: #000; border-radius: 24px; overflow: hidden; position: relative; aspect-ratio: 16/9; box-shadow: 0 20px 50px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.1); }
        .video-element { width: 100%; height: 100%; object-fit: cover; }
        .custom-controls { position: absolute; bottom: 20px; left: 20px; right: 20px; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 15px 20px; display: flex; flex-direction: column; gap: 12px; opacity: 0; transition: all 0.4s ease; transform: translateY(10px); }
        .video-player-container:hover .custom-controls { opacity: 1; transform: translateY(0); }
        
        .progress-bar { width: 100%; height: 6px; background: rgba(255,255,255,0.2); border-radius: 6px; cursor: pointer; position: relative; overflow: hidden; }
        .progress-filled { height: 100%; background: var(--primary); border-radius: 6px; width: 45%; position: relative; }
        .progress-filled::after { content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 12px; height: 12px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px rgba(0,0,0,0.5); }
        
        .controls-row { display: flex; justify-content: space-between; align-items: center; color: white; }
        .controls-left, .controls-right { display: flex; align-items: center; gap: 18px; }
        .ctrl-btn { background: none; border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0.8; transition: 0.2s; }
        .ctrl-btn:hover { opacity: 1; color: var(--primary); transform: scale(1.1); }
        .ctrl-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }
        .ctrl-btn.fill-icon svg { fill: currentColor; stroke: none; }
        
        /* فید محتوا (کارت‌های شیشه‌ای) */
        .feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; width: 100%; max-width: 1200px; margin: 0 auto; }
        .feed-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 20px; overflow: hidden; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); cursor: pointer; }
        .feed-card:hover { transform: translateY(-8px); box-shadow: 0 15px 30px var(--glass-shadow); border-color: rgba(255,255,255,0.2); }
        .feed-thumb { height: 180px; position: relative; background-size: cover; background-position: center; }
        .feed-thumb::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); }
        .play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transition: 0.3s; }
        .feed-card:hover .play-overlay { opacity: 1; }
        .play-overlay svg { width: 50px; height: 50px; fill: white; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
        .feed-duration { position: absolute; bottom: 12px; right: 12px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); color: white; padding: 4px 8px; border-radius: 8px; font-size: 12px; font-weight: 500; }
        .feed-info { padding: 20px; }
        .feed-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-main); line-height: 1.4; }
        .feed-meta { font-size: 13px; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; }

        /* ================= آپلود سنتر ================= */
        .upload-center { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 40px; text-align: center; }
        .upload-box { width: 100%; max-width: 650px; height: 350px; border: 2px dashed var(--glass-border); border-radius: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: var(--glass-hover); transition: 0.4s; cursor: pointer; position: relative; overflow: hidden; }
        .upload-box:hover, .upload-box.dragover { border-color: var(--primary); background: rgba(99, 102, 241, 0.08); transform: scale(1.02); }
        .upload-icon { width: 80px; height: 80px; background: var(--glass-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 25px rgba(0,0,0,0.1); border: 1px solid var(--glass-border); color: var(--primary); transition: 0.3s; }
        .upload-box:hover .upload-icon { transform: translateY(-10px); background: var(--primary); color: white; }
        .upload-box:hover .upload-icon svg { stroke: white; }

        /* ================= موزیک پلیر شناور ================= */
        .music-player { 
            position: absolute; bottom: 30px; left: 120px; 
            width: 320px; padding: 15px; 
            display: flex; align-items: center; gap: 15px;
            z-index: 1000;
        }
        .music-player.minimized { transform: translateY(150px); opacity: 0; pointer-events: none; }
        
        .album-art { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--blob-1), var(--blob-2)); flex-shrink: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 16px rgba(0,0,0,0.2); }
        .album-art svg { width: 28px; height: 28px; color: white; stroke-width: 1.5; }
        .track-info { flex: 1; overflow: hidden; }
        .track-name { font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--text-main); margin-bottom: 4px; }
        .track-sub { font-size: 12px; color: var(--text-muted); }

        .player-ctrls { display: flex; gap: 15px; margin-top: 8px; align-items: center; }
        .p-btn { background: none; border: none; color: var(--text-main); cursor: pointer; display: flex; align-items: center; opacity: 0.7; transition: 0.2s; }
        .p-btn:hover { opacity: 1; color: var(--primary); transform: scale(1.1); }
        .p-btn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }

        /* ================= مدال تماس (WebRTC Mock) ================= */
        /* ================= مدال تماس (WebRTC Overhaul & WhatsApp Style) ================= */
        .call-modal { position: fixed; inset: 0; height: 100dvh; background: rgba(5, 8, 16, 0.9); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); z-index: 999999; display: none; flex-direction: column; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); padding: 0; overflow: hidden; }
        .call-modal.active { display: flex !important; opacity: 1; pointer-events: auto; }
        
        .call-modal__body { width: 100%; height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; overflow: hidden; }
        
        /* سربرگ شناور تماس */
        .call-header { position: absolute; top: calc(24px + env(safe-area-inset-top, 0px)); left: 24px; right: 24px; z-index: 100; display: flex; justify-content: center; align-items: flex-start; pointer-events: none; width: calc(100% - 48px); }
        .call-header-meta { background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.08); padding: 5px 12px; border-radius: 12px; color: white; display: flex; flex-direction: column; align-items: center; gap: 0; pointer-events: auto; max-width: 60%; box-shadow: 0 6px 18px rgba(0,0,0,0.15); transition: 0.3s; }
        .call-header-meta:hover { background: rgba(15, 23, 42, 0.6); }
        
        .btn-call-minimize { width: 44px; height: 44px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; pointer-events: auto !important; transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 200; position: relative; }
        .btn-call-minimize:hover { background: rgba(255, 255, 255, 0.15); transform: translateY(-2px); border-color: rgba(255,255,255,0.2); }
        .btn-call-minimize svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.5; }

        /* استیج ویدئو تماس تصویری */
        .call-video-stage { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; overflow: hidden; background: #020617; z-index: 1; display: none; }
        .call-video-stage video { width: 100%; height: 100%; object-fit: cover; display: block; background: #020617; }
        
        /* استریم محلی خودمان به شکل کارت شناور در گوشه */
        #call-local-wrapper { position: absolute; right: 24px; top: calc(115px + env(safe-area-inset-top, 0px)); width: 110px; height: 165px; z-index: 10; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
        #call-local-wrapper:hover { transform: scale(1.04); }
        #call-local-video { transform: scaleX(-1); width: 100%; height: 100%; border-radius: 20px; border: 1.8px solid rgba(255, 255, 255, 0.22); box-shadow: 0 16px 36px rgba(2, 6, 23, 0.45); background: #070d19; cursor: pointer; object-fit: cover; transition: all 0.3s; }
        #call-local-close-btn { position: absolute; top: -8px; right: -8px; background: #e11d48; color: white; border: 2px solid #0f172a; border-radius: 50%; width: 26px; height: 26px; font-size: 14px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 11; box-shadow: 0 4px 10px rgba(0,0,0,0.4); transition: all 0.2s; padding:0; }
        #call-local-close-btn:hover { background: #f43f5e; transform: scale(1.1); }
        #call-local-wrapper.is-swapped { width: 100% !important; height: 100% !important; right: 0 !important; top: 0 !important; border-radius: 0 !important; border: none !important; z-index: 2 !important; box-shadow: none !important; cursor: default !important; transform: none !important; }
        
        /* تعویض استریم محلی و طرف مقابل (Swapped Class) */
        .call-video-stage video.remote-video.is-swapped { position: absolute !important; right: 24px !important; top: calc(115px + env(safe-area-inset-top, 0px)) !important; width: 110px !important; height: 165px !important; border-radius: 20px !important; border: 1.8px solid rgba(255, 255, 255, 0.22) !important; box-shadow: 0 16px 36px rgba(2, 6, 23, 0.45) !important; z-index: 10 !important; cursor: pointer !important; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important; object-fit: cover !important; }
        .call-video-stage video.remote-video.is-swapped:hover { transform: scale(1.04) !important; border-color: var(--primary) !important; }

        /* ظاهر تماس صوتی معمولی */
        .caller-avatar { width: 150px; height: 150px; border-radius: 50%; background: linear-gradient(135deg, #1e293b, #334155); border: 4px solid var(--primary); margin-bottom: 25px; animation: pulseCall 2.4s infinite; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 44px; font-weight: 800; box-shadow: 0 15px 35px rgba(99, 102, 241, 0.25); z-index: 5; }
        .caller-name { font-size: 14px; font-weight: 700; margin-bottom: 0; color: white; text-align: center; text-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 5; }
        .call-status { color: rgba(255, 255, 255, 0.7); margin-bottom: 0; font-size: 11px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; z-index: 5; }
        
        .quality-indicator { display: flex; align-items: flex-end; gap: 2.5px; height: 14px; width: 22px; }
        .quality-indicator .bar { width: 3px; background: rgba(255,255,255,0.25); border-radius: 1.5px; transition: 0.3s; }
        .quality-indicator .bar1 { height: 30%; }
        .quality-indicator .bar2 { height: 55%; }
        .quality-indicator .bar3 { height: 80%; }
        .quality-indicator .bar4 { height: 100%; }
        
        .quality-indicator.excellent .bar { background: #10b981; }
        .quality-indicator.good .bar1, .quality-indicator.good .bar2, .quality-indicator.good .bar3 { background: #10b981; }
        .quality-indicator.fair .bar1, .quality-indicator.fair .bar2 { background: #f59e0b; }
        .quality-indicator.poor .bar1 { background: #ef4444; }
        .quality-indicator.bad .bar { background: #ef4444; opacity: 0.3; }

        /* نوار دکمه‌های کنترل تماس متمرکز و شناور (Floating Control Bar) */
        .call-controls-bar { position: absolute; bottom: calc(-60px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; justify-content: center; gap: 14px; background: transparent; border: none; box-shadow: none; padding: 14px 28px; border-radius: 999px; transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16,1,0.3,1); pointer-events: auto; }
        .call-header { transition: opacity 0.4s ease; }
        /* ════ گرید کنفرانس چند نفره ════ */
        .call-conference-grid {
            position: absolute; inset: 0; z-index: 5;
            display: none; grid-template-columns: repeat(2, 1fr);
            gap: 6px; padding: 8px;
            padding-bottom: 120px; padding-top: 80px;
            background: #020617; align-content: center;
            overflow-y: auto;
        }
        .call-conference-grid .conf-tile {
            position: relative; width: 100%; aspect-ratio: 3/4;
            background: linear-gradient(160deg,#1e293b,#0f172a);
            border-radius: 16px; overflow: hidden;
            border: 1.5px solid rgba(255,255,255,0.1);
            display: flex; align-items: center; justify-content: center;
        }
        .call-conference-grid .conf-tile video {
            width: 100%; height: 100%; object-fit: cover; background: #0f172a;
        }
        .call-conference-grid .conf-tile-self {
            border-color: rgba(99,102,241,0.5);
        }
        .call-conference-grid .conf-tile .conf-name {
            position: absolute; bottom: 6px; right: 8px;
            font-size: 11px; font-weight: 600; color: #fff;
            background: rgba(0,0,0,0.55); padding: 2px 8px; border-radius: 8px;
            max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        /* انیمیشن دعوت روشن کردن دوربین */
        .btn-call-action.pulse-invite { animation: call-invite-pulse 1s ease-in-out infinite; background: rgba(96,165,250,0.35) !important; }
        @keyframes call-invite-pulse {
            0%,100% { box-shadow: 0 0 0 0 rgba(96,165,250,0.6); transform: scale(1); }
            50% { box-shadow: 0 0 0 12px rgba(96,165,250,0); transform: scale(1.08); }
        }
        
        .btn-call-action { width: 50px; height: 50px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.25s ease; position: relative; background: rgba(255, 255, 255, 0.08); color: white; border: 1px solid rgba(255, 255, 255, 0.08); }
        .btn-call-action:hover { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.2); transform: translateY(-3px); }
        .btn-mute.muted, .btn-speaker.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 0 15px rgba(99, 102, 241, 0.4); }
        .btn-hangup { background: #ef4444 !important; color: white !important; border-color: #ef4444 !important; box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4); width: 56px; height: 56px; }
        .btn-hangup:hover { background: #dc2626 !important; transform: scale(1.06) translateY(-3px) !important; }
        .btn-accept { background: #10b981 !important; color: white !important; border-color: #10b981 !important; box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4); width: 56px; height: 56px; display: none; } 
        .btn-accept:hover { background: #059669 !important; transform: scale(1.06) translateY(-3px) !important; }

        /* ================= حالت PiP شناور (Minimize) ================= */
        .call-modal.is-minimized {
            width: 160px; height: 200px;
            position: fixed !important;
            bottom: calc(90px + env(safe-area-inset-bottom, 0px));
            right: 16px; left: unset; inset: unset;
            display: flex !important;
            flex-direction: column; align-items: center; justify-content: center;
            border-radius: 22px; overflow: hidden;
            border: 2px solid rgba(255,255,255,0.18);
            box-shadow: 0 16px 40px rgba(0,0,0,0.7);
            z-index: 9999999; cursor: pointer; padding: 0;
            background: linear-gradient(160deg,#0f172a 60%,#1e3a5f);
            opacity: 1 !important; pointer-events: auto !important;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        .call-modal.is-minimized:hover { transform: scale(1.04); box-shadow: 0 20px 50px rgba(0,0,0,0.8); }

        /* در حالت PiP: تمام محتوای اصلی پنهان */
        .call-modal.is-minimized .call-controls-bar,
        .call-modal.is-minimized .call-header-meta,
        .call-modal.is-minimized #call-local-wrapper { display: none !important; }

        /* برای تماس تصویری: نمایش ویدئو */
        .call-modal.is-minimized .call-video-stage {
            display: block !important; width: 100% !important; height: 100% !important;
            position: absolute; inset: 0;
            border-radius: 0 !important; overflow: hidden;
        }

        /* برای تماس صوتی: نمایش آواتار + نام + تایمر */
        .call-modal.is-minimized .call-pip-voice {
            display: flex !important;
            flex-direction: column; align-items: center; justify-content: center; gap: 8px;
            padding: 16px 12px; width: 100%;
        }
        .call-pip-voice { display: none; }
        .call-pip-voice .pip-avatar {
            width: 56px; height: 56px; border-radius: 50%;
            background: linear-gradient(135deg,#6366f1,#8b5cf6);
            display: flex; align-items: center; justify-content: center;
            font-size: 22px; font-weight: 700; color: #fff;
            box-shadow: 0 4px 16px rgba(99,102,241,0.4);
        }
        .call-pip-voice .pip-name {
            font-size: 12px; font-weight: 600; color: #e2e8f0;
            text-align: center; max-width: 130px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .call-pip-voice .pip-timer {
            font-size: 11px; color: #4ade80; font-family: monospace; font-weight: 700;
        }
        .call-pip-voice .pip-wave {
            display: flex; gap: 3px; align-items: flex-end; height: 16px;
        }
        .call-pip-voice .pip-wave span {
            width: 3px; border-radius: 2px; background: #6366f1;
            animation: pip-wave-anim 0.8s ease-in-out infinite;
        }
        .call-pip-voice .pip-wave span:nth-child(2) { animation-delay: 0.1s; }
        .call-pip-voice .pip-wave span:nth-child(3) { animation-delay: 0.2s; }
        .call-pip-voice .pip-wave span:nth-child(4) { animation-delay: 0.3s; }
        @keyframes pip-wave-anim {
            0%,100% { height: 4px; opacity: 0.4; }
            50% { height: 14px; opacity: 1; }
        }

        /* دکمه‌های روی PiP */
        .call-modal.is-minimized .btn-call-minimize {
            position: absolute; bottom: 8px; left: 8px; z-index: 200;
            width: 28px; height: 28px; border-radius: 8px;
            background: rgba(0,0,0,0.55); pointer-events: auto;
        }
        .call-modal.is-minimized .btn-call-minimize svg { transform: rotate(180deg); width: 12px; height: 12px; }

        /* دکمه قطع سریع */
        .call-pip-close { display: none; position: absolute; bottom: 8px; right: 8px; z-index: 200;
            width: 28px; height: 28px; border-radius: 8px;
            background: rgba(239,68,68,0.85); border: none; color: white;
            align-items: center; justify-content: center; cursor: pointer; pointer-events: auto; }
        .call-modal.is-minimized .call-pip-close { display: flex !important; }
        .call-pip-close:hover { background: #ef4444; }

        /* ================= چیدمان تماس گروهی کنفرانسی (Mesh Grid) ================= */
        .call-video-stage.group-call { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; padding: 20px; width: 100%; height: 100%; box-sizing: border-box; align-content: center; justify-content: center; }
        .remote-video { position: relative; border-radius: 20px; border: 1.5px solid rgba(255, 255, 255, 0.08); overflow: hidden; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); cursor: pointer; aspect-ratio: 4 / 3; width: 100%; height: 100%; object-fit: cover; }
        .remote-video:hover { border-color: rgba(255,255,255,0.25); transform: scale(1.02); }
        .remote-video.is-speaking { border-color: #10b981 !important; box-shadow: 0 0 15px rgba(16, 185, 129, 0.35); }
        
        /* حالت پین شدن یکی از اعضا */
        .call-video-stage.has-pinned { display: flex !important; flex-direction: column; justify-content: space-between; padding: 16px; position: relative; gap: 16px; }
        .remote-video.pinned { flex: 1 !important; width: 100% !important; height: calc(100% - 130px) !important; aspect-ratio: unset !important; border-radius: 24px !important; border-color: var(--primary) !important; box-shadow: 0 15px 35px rgba(0,0,0,0.3) !important; }
        
        /* سینی تصاویر کوچک اعضای پین نشده در پایین */
        .call-thumbnails-tray { display: none; gap: 10px; overflow-x: auto; padding: 10px 16px; width: 100%; box-sizing: border-box; z-index: 20; pointer-events: auto; justify-content: flex-start; scrollbar-width: none; height: 110px; align-items: center; background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border-radius: 20px; border: 1px solid rgba(255, 255, 255, 0.06); margin-bottom: 120px; }
        .call-thumbnails-tray::-webkit-scrollbar { display: none; }
        .call-video-stage.has-pinned .call-thumbnails-tray { display: flex !important; }
        .call-video-stage.has-pinned .remote-video:not(.pinned) { flex: 0 0 110px !important; width: 110px !important; height: 82px !important; aspect-ratio: 4 / 3 !important; border-radius: 12px !important; border-width: 1px !important; }

        @media (max-width: 640px) {
            .call-thumbnails-tray { height: 90px; margin-bottom: 160px; }
            .call-video-stage.has-pinned .remote-video:not(.pinned) { flex: 0 0 90px !important; width: 90px !important; height: 68px !important; }
        }

        /* ================= مودال شیک انتخاب مخاطب دعوت (Glassmorphic Invite Selector) ================= */
        .call-invite-modal { position: fixed; inset: 0; z-index: 9999999; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); background: rgba(3, 5, 10, 0.6); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); }
        .call-invite-modal.active { opacity: 1; pointer-events: auto; }
        
        .call-invite-modal__body { background: var(--glass-bg, rgba(30, 41, 59, 0.7)); border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08)); border-radius: 28px; padding: 24px; width: min(90vw, 420px); box-shadow: 0 25px 60px rgba(0,0,0,0.5); display: flex; flex-direction: column; gap: 16px; transform: scale(0.9) translateY(20px); transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
        .call-invite-modal.active .call-invite-modal__body { transform: scale(1) translateY(0); }
        
        .call-invite-header { display: flex; justify-content: space-between; align-items: center; width: 100%; direction: rtl; }
        .call-invite-title { font-size: 17px; font-weight: 800; color: white; }
        .call-invite-close { background: none; border: none; color: rgba(255,255,255,0.5); font-size: 20px; cursor: pointer; transition: 0.2s; }
        .call-invite-close:hover { color: white; }
        
        .call-invite-search-wrap { position: relative; width: 100%; }
        .call-invite-search { width: 100%; background: rgba(255, 255, 255, 0.05); border: 1.5px solid var(--glass-border, rgba(255, 255, 255, 0.08)); border-radius: 14px; padding: 12px 16px; color: white; outline: none; font-size: 13.5px; text-align: right; box-sizing: border-box; transition: 0.25s; direction: rtl; }
        .call-invite-search:focus { border-color: var(--primary); background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }
        
        .call-invite-list { max-height: 290px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--glass-border) transparent; }
        .call-invite-list::-webkit-scrollbar { width: 4px; }
        .call-invite-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }
        
        .call-invite-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.02); border: 1px solid transparent; transition: all 0.25s ease; cursor: pointer; direction: rtl; }
        .call-invite-item:hover { background: var(--glass-hover, rgba(255, 255, 255, 0.05)); border-color: var(--glass-border, rgba(255, 255, 255, 0.08)); transform: translateY(-1px); }
        
        .call-invite-user-info { display: flex; align-items: center; gap: 12px; }
        .call-invite-avatar { width: 40px; height: 40px; border-radius: 14px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 15px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
        .call-invite-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
        .call-invite-name { font-size: 13.5px; font-weight: 600; color: white; text-align: right; }
        .call-invite-username { font-size: 11.5px; color: rgba(255, 255, 255, 0.45); text-align: right; }
        
        .btn-invite-send { padding: 8px 16px; border-radius: 10px; border: none; background: var(--primary); color: white; font-size: 12px; cursor: pointer; font-weight: 700; transition: all 0.2s ease; font-family: inherit; }
        .btn-invite-send:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(99, 102, 241, 0.35); }
        .btn-invite-send.invited { background: rgba(255, 255, 255, 0.08) !important; color: rgba(255, 255, 255, 0.4) !important; pointer-events: none !important; box-shadow: none !important; transform: none !important; }

        @media (max-width: 640px) { 
            .caller-avatar { width: 120px; height: 120px; font-size: 36px; margin-bottom: 15px; } 
            .caller-name { font-size: 22px; } 
            .call-status { margin-bottom: 25px; } 
            .call-controls-bar { gap: 12px; padding: 12px 20px; bottom: calc(130px + env(safe-area-inset-bottom, 0px)); width: calc(100% - 32px); max-width: 360px; } 
            .btn-call-action { width: 48px; height: 48px; } 
            .btn-hangup, .btn-accept { width: 54px; height: 54px; }
            #call-local-wrapper { right: 16px; top: calc(105px + env(safe-area-inset-top, 0px)); width: 88px; height: 132px; } 
            .call-modal.is-minimized { bottom: calc(85px + env(safe-area-inset-bottom, 0px)); left: 16px; width: 110px; height: 165px; border-radius: 18px; }
        }
        
        @keyframes pulseCall { 0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6); } 70% { box-shadow: 0 0 0 35px rgba(99, 102, 241, 0); } 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); } }
        @keyframes pulseCall { 0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6); } 70% { box-shadow: 0 0 0 40px rgba(99, 102, 241, 0); } 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); } }
        #app-games,
        #games-home,
        #games-iframe-wrap {
            position: relative;
            z-index: 1;
        }
        #app-games {
            inset: 0;
            width: 100%;
            height: 100%;
            max-height: none;
            border-radius: 0;
            border: 0;
            box-shadow: none;
            background: #0f172a;
        }
        #games-home,
        #games-iframe-wrap {
            width: 100%;
            height: 100%;
            flex: 1;
            flex-grow: 1;
            min-height: 0;
            background: #0f172a;
            margin: 0;
        }
        #hokm-game-frame {
            width: 100%;
            height: 100%;
            flex: 1 1 auto;
            display: block;
            margin: 0;
        }
        .games-shell-header,
        .games-frame-toolbar {
            flex-shrink: 0;
        }
        .games-home-card {
            width: min(100%, 360px);
        }
        .games-home-launch,
        .games-frame-btn,
        .games-shell-close {
            min-height: 44px;
            touch-action: manipulation;
            -webkit-tap-highlight-color: transparent;
        }
        .games-mobile-fab,
        .games-mobile-dock-handle {
            display: none;
        }
        .games-mobile-fab {
            position: fixed;
            top: calc(env(safe-area-inset-top, 0px) + 14px);
            right: 14px;
            width: 46px;
            height: 46px;
            border: 0;
            border-radius: 16px;
            background: linear-gradient(180deg, rgba(15, 23, 42, 0.86), rgba(15, 23, 42, 0.72));
            color: #fff;
            box-shadow: 0 16px 34px rgba(2, 6, 23, 0.36);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            z-index: 1205;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            border: 1px solid rgba(255,255,255,0.12);
        }
        .games-mobile-dock-handle {
            position: fixed;
            left: 50%;
            bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
            transform: translateX(-50%);
            z-index: 1250;
            align-items: center;
            gap: 10px;
        }
        .games-mobile-dock-tab {
            border: 0;
            color: #fff;
            background: rgba(15, 23, 42, 0.78);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
            box-shadow: 0 14px 30px rgba(2, 6, 23, 0.36);
            cursor: pointer;
        }
        .games-mobile-dock-tab {
            width: 76px;
            height: 28px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            animation: gamesDockHandleBounce 2.6s ease-in-out infinite;
        }
        .games-mobile-dock-grip {
            width: 32px;
            height: 4px;
            border-radius: 999px;
            background: rgba(255,255,255,0.82);
            box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
        }
        body.games-mobile-dock-visible .games-mobile-dock-tab {
            animation: none;
        }

        @keyframes gamesDockHandleBounce {
            0%, 100% {
                transform: translateY(0);
                box-shadow: 0 14px 30px rgba(2, 6, 23, 0.36);
            }
            12% {
                transform: translateY(-4px);
                box-shadow: 0 18px 34px rgba(2, 6, 23, 0.42);
            }
            24% {
                transform: translateY(0);
            }
            36% {
                transform: translateY(-2px);
            }
            48% {
                transform: translateY(0);
            }
        }

        @media (max-width: 640px) {
            .app-container {
                padding: 10px;
                gap: 10px;
            }
            .main-wrapper {
                border-radius: 22px;
            }
            #app-games {
                border-radius: 22px;
            }
            .games-shell-header,
            .games-frame-toolbar {
                padding: 12px 14px !important;
            }
            #games-home {
                padding: 14px !important;
                grid-template-columns: 1fr !important;
                gap: 14px !important;
            }
            .games-home-card {
                width: 100%;
                min-height: 0;
                border-radius: 20px;
            }
            .games-home-hero {
                height: 92px !important;
                border-radius: 18px !important;
                font-size: 42px !important;
            }
            .games-frame-actions {
                width: 100%;
                display: grid !important;
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
            .games-frame-btn {
                width: 100%;
            }
            #games-iframe-wrap {
                height: calc(100% - 73px) !important;
            }
            body.games-mobile-shell-active #games-iframe-wrap {
                height: 100% !important;
            }
        }

        /* Profile: edge-to-edge on mobile — drop the side gaps + card rounding.
           Top/bottom safe-area padding is preserved so content clears notches.
           Two selectors for robustness: the body class set by switchTab, AND
           :has() on the already-existing .active section (works even if the JS
           bundle is served from an older cached build). */
        @media (max-width: 768px) {
            body.profile-active .app-container {
                padding-left: 0 !important;
                padding-right: 0 !important;
                gap: 0 !important;
            }
            body.profile-active .main-wrapper {
                border-radius: 0 !important;
                padding-left: 0 !important;
                padding-right: 0 !important;
            }
            body:has(#profile-tab.active) .app-container {
                padding: 0 !important;
                gap: 0 !important;
            }
            body:has(#profile-tab.active) .main-wrapper {
                border-radius: 0 !important;
                padding: 0 !important;
            }
        }

        @media (max-width: 480px) {
            body, html {
                overflow: hidden;
            }
            .app-container {
                height: 100dvh;
                padding:
                    max(8px, env(safe-area-inset-top))
                    8px
                    max(8px, env(safe-area-inset-bottom))
                    8px;
                gap: 8px;
            }
            .sidebar {
                width: 62px;
                padding: 14px 0;
                gap: 10px;
                border-radius: 18px;
            }
            .sidebar > div:first-child {
                margin-bottom: 12px !important;
                padding: 10px !important;
            }
            .sidebar > div[style*="margin-top: auto"] {
                gap: 10px !important;
            }
            .sidebar .nav-btn {
                width: 42px;
                height: 42px;
                border-radius: 13px;
            }
            .sidebar .nav-btn svg {
                width: 19px;
                height: 19px;
            }
            .main-wrapper {
                border-radius: 18px;
            }
            #app-games {
                border-radius: 18px;
            }
            .games-shell-header {
                flex-wrap: wrap;
                align-items: flex-start !important;
                gap: 10px !important;
            }
            .games-shell-brand {
                min-width: 0;
                width: calc(100% - 54px);
                align-items: flex-start !important;
            }
            .games-shell-icon {
                width: 38px !important;
                height: 38px !important;
                border-radius: 12px !important;
                flex-shrink: 0;
            }
            .games-shell-close {
                min-width: 44px;
                padding: 10px 12px !important;
            }
            #games-home {
                padding: 10px !important;
                gap: 10px !important;
            }
            .games-home-card {
                padding: 14px !important;
                gap: 12px !important;
                border-radius: 18px !important;
            }
            .games-home-actions {
                display: block !important;
            }
            .games-home-launch {
                width: 100%;
            }
            .games-frame-toolbar {
                flex-direction: column;
                align-items: stretch !important;
            }
            .games-frame-actions {
                grid-template-columns: 1fr;
            }
            #games-module-status {
                line-height: 1.5;
            }
            #games-iframe-wrap {
                height: calc(100% - 108px) !important;
            }
            #hokm-game-frame {
                min-height: 0;
            }
        }

        @media (max-width: 768px) {
            body.games-mobile-shell-active .games-shell-header {
                display: flex !important;
                position: relative;
                z-index: 1002 !important;
            }
            body.games-mobile-shell-active .sidebar {
                transform: translateY(0) !important;
                opacity: 1 !important;
            }
            body.games-mobile-shell-active #games-mobile-dock-handle {
                display: none !important;
            }
            body.games-mobile-shell-active.games-mobile-dock-visible #games-mobile-dock-handle {
                display: none !important;
            }
            body.games-mobile-shell-active #app-games {
                z-index: 1 !important;
                padding-top: 0 !important;
            }
            body.games-mobile-shell-active #games-iframe-wrap {
                position: relative;
                z-index: 1;
                height: 100% !important;
            }
            body.games-mobile-shell-active #games-iframe-wrap .games-frame-toolbar {
                display: none !important;
            }
            body.games-mobile-shell-active #games-mobile-back {
                display: inline-flex;
            }
            body.games-mobile-shell-active .main-wrapper {
                padding-bottom: 0 !important;
            }
            body.games-mobile-shell-active #games-home {
                height: 100% !important;
            }
        }

/* Call Quality Indicator */
#call-quality-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 4px 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  z-index: 10;
}
#call-quality-indicator .bar {
  width: 4px;
  border-radius: 2px;
  background: #4caf50;
  transition: height 0.3s, background 0.3s;
}
#call-quality-indicator .bar:nth-child(1) { height: 6px; }
#call-quality-indicator .bar:nth-child(2) { height: 10px; }
#call-quality-indicator .bar:nth-child(3) { height: 14px; }
#call-quality-indicator.poor .bar { background: #f44336; }
#call-quality-indicator.fair .bar { background: #ff9800; }

/* ===== FIX: Theme icon visibility ===== */
#theme-icon {
    fill: var(--text-main, #e2e8f0);
    stroke: none;
    transition: fill 0.3s ease;
}



/* مخفی کردن دکمه toggle در موبایل روی صفحه مخاطبین */
@media (max-width: 768px) {
    /* وقتی چت باز نیست، دکمه toggle مخفی شود */
    body:not(.mobile-chat-open) #contacts-toggle-btn {
        display: none !important;
    }
    
    /* وقتی چت باز است، دکمه toggle نمایش داده شود */
    body.mobile-chat-open #contacts-toggle-btn {
        display: flex !important;
    }
}
/* مخفی کردن دکمه toggle در موبایل روی صفحه مخاطبین */
@media (max-width: 768px) {
    /* وقتی چت باز نیست، دکمه toggle مخفی شود */
    body:not(.mobile-chat-open) #contacts-toggle-btn {
        display: none !important;
    }
    
    /* وقتی چت باز است، دکمه toggle نمایش داده شود */
    body.mobile-chat-open #contacts-toggle-btn {
        display: flex !important;
    }
}

/* ================= Room Creation ================= */
.rooms-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid var(--glass-border);
    background:
        radial-gradient(circle at top right, rgba(139, 92, 246, 0.2), transparent 58%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.14), transparent 50%);
}

.rooms-toolbar__copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.rooms-toolbar__eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a78bfa;
}

.rooms-toolbar__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.rooms-create-btn {
    width: 52px;
    height: 52px;
    border: 1px solid rgba(167, 139, 250, 0.28);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.92), rgba(16, 185, 129, 0.78));
    color: #fff;
    box-shadow: 0 16px 30px rgba(76, 29, 149, 0.32);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.rooms-create-btn:hover,
.rooms-create-btn:focus-visible {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 18px 34px rgba(16, 185, 129, 0.26);
    filter: saturate(1.1);
    outline: none;
}

.rooms-create-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
    stroke-linecap: round;
}

.create-room-modal {
    position: fixed;
    inset: 0;
    z-index: 10030;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.create-room-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.74);
    backdrop-filter: blur(22px);
}

.create-room-modal__dialog {
    position: relative;
    width: min(720px, 100%);
    max-height: min(92vh, 860px);
    padding: 28px;
    overflow: auto;
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(6, 10, 24, 0.92)), rgba(15, 23, 42, 0.72);
}

.create-room-modal__orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(6px);
    pointer-events: none;
    opacity: 0.85;
}

.create-room-modal__orb--purple {
    top: -24px;
    right: 10%;
    width: 170px;
    height: 170px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.28), transparent 70%);
}

.create-room-modal__orb--mint {
    left: -32px;
    bottom: 6%;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.22), transparent 70%);
}

.create-room-modal__header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.create-room-modal__eyebrow {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #c4b5fd;
    margin-bottom: 8px;
}

.create-room-modal__header h3 {
    font-size: 30px;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 8px;
}

.create-room-modal__header p {
    color: #ffffff;
    font-size: 14px;
    line-height: 1.7;
    max-width: 440px;
}

.create-room-modal__close {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.create-room-modal__close:hover,
.create-room-modal__close:focus-visible {
    background: rgba(255, 255, 255, 0.09);
    transform: rotate(90deg);
    outline: none;
}

.create-room-form {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.create-room-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

/* نسخه فشرده: کارت‌های کوچک افقی کنار هم */
.create-room-types--compact {
    gap: 10px;
    margin-bottom: 4px;
}
.create-room-types--compact .create-room-type-card {
    flex-direction: row;
    padding: 12px 14px;
    border-radius: 14px;
    gap: 8px;
    justify-content: center;
}
.create-room-types--compact .create-room-type-card.active {
    transform: none;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.3);
}
.create-room-types--compact .create-room-type-card:hover {
    transform: none;
}
.create-room-types--compact .create-room-type-card__icon {
    font-size: 18px;
}
.create-room-types--compact .create-room-type-card__title {
    font-size: 14px;
}
.create-room-types--compact .create-room-type-card.active::after {
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    font-size: 10px;
}

.create-room-type-card {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 22px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.create-room-type-card:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-4px);
}

.create-room-type-card.active {
    border-color: #a78bfa;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(16, 185, 129, 0.2));
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
    transform: translateY(-4px) scale(1.02);
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

.create-room-type-card.active::after {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 10px;
    background: #a78bfa;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.create-room-type-card__icon {
    font-size: 26px;
}

.create-room-type-card__title {
    font-size: 18px;
    font-weight: 700;
}

.create-room-type-card__desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
}

.create-room-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.create-room-grid--media {
    align-items: end;
}

.create-room-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.create-room-field > span {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.create-room-field input,
.create-room-field textarea,
.create-room-field select {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
    padding: 14px 16px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
/* select هماهنگ با تم تیره */
.create-room-field select {
    color-scheme: dark;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 38px;
}
.create-room-field select option { background: #1a1f2e; color: #fff; }

.create-room-field textarea {
    resize: vertical;
    min-height: 110px;
}

.create-room-field input:focus,
.create-room-field textarea:focus {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.create-room-slug {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    padding: 0 14px;
}

.create-room-slug__prefix {
    color: #34d399;
    font-weight: 700;
}

.create-room-slug input {
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 14px 0;
}

.create-room-field__hint {
    font-size: 12px;
    color: var(--text-muted);
}

.create-room-field__hint.is-checking {
    color: #cbd5e1;
}

.create-room-field__hint.is-success {
    color: #34d399;
}

.create-room-field__hint.is-error {
    color: #fda4af;
}

.create-room-privacy {
    display: inline-flex;
    gap: 8px;
    padding: 6px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.create-room-privacy__option {
    min-width: 110px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text-muted);
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.create-room-privacy__option.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.7), rgba(16, 185, 129, 0.5));
    color: #fff;
    transform: translateY(-1px);
}

.create-room-avatar-picker {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 78px;
    border-radius: 20px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(167, 139, 250, 0.34);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.create-room-avatar-picker:hover,
.create-room-avatar-picker:focus-within {
    border-color: rgba(52, 211, 153, 0.5);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.create-room-avatar-picker__preview {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.65), rgba(16, 185, 129, 0.45));
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 26px;
    overflow: hidden;
}

.create-room-avatar-picker__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.create-room-avatar-picker__preview.is-uploading {
    animation: pulseRoomPreview 1.1s infinite ease-in-out;
}


@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulseRoomPreview {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.96); opacity: 0.7; }
}

.create-room-avatar-picker__copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.create-room-avatar-picker__copy strong {
    font-size: 14px;
    color: #f8fafc;
}

.create-room-avatar-picker__copy small {
    color: var(--text-muted);
    font-size: 12px;
}

.create-room-feedback {
    border-radius: 16px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.create-room-feedback.is-success {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.24);
}

.create-room-feedback.is-error {
    color: #fda4af;
    border-color: rgba(251, 113, 133, 0.22);
}

.create-room-feedback.is-info {
    color: #cbd5e1;
}

.create-room-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.create-room-btn {
    min-width: 138px;
    min-height: 50px;
    border-radius: 16px;
    padding: 0 20px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.create-room-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.create-room-btn--ghost {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
}

.create-room-btn--primary {
    background: linear-gradient(135deg, #7c3aed, #10b981);
    color: #fff;
    border-color: rgba(167, 139, 250, 0.25);
    box-shadow: 0 12px 28px rgba(76, 29, 149, 0.3);
}

.create-room-btn--primary:not(:disabled):hover,
.create-room-btn--primary:not(:disabled):focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(16, 185, 129, 0.22);
    outline: none;
}

.create-room-btn--danger {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.94), rgba(190, 24, 93, 0.9));
    color: #fff;
    border-color: rgba(251, 113, 133, 0.28);
    box-shadow: 0 12px 28px rgba(136, 19, 55, 0.28);
}

.create-room-btn--danger:not(:disabled):hover,
.create-room-btn--danger:not(:disabled):focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(190, 24, 93, 0.28);
    outline: none;
}

.create-room-btn__spinner {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    display: none;
    animation: roomSpin 0.8s linear infinite;
}

.create-room-btn.is-loading .create-room-btn__spinner {
    display: inline-block;
}

.create-room-btn.is-loading .create-room-btn__label {
    opacity: 0.9;
}

@keyframes roomSpin {
    to { transform: rotate(360deg); }
}

.room-welcome-state {
    min-height: 100%;
    display: grid;
    place-content: center;
    text-align: center;
    gap: 14px;
    padding: 40px 24px;
}

.room-welcome-state__badge {
    justify-self: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.18);
    border: 1px solid rgba(167, 139, 250, 0.26);
    color: #c4b5fd;
    font-size: 12px;
    font-weight: 700;
}

.room-welcome-state h3 {
    font-size: 28px;
    color: #f8fafc;
}

.room-welcome-state p {
    max-width: 420px;
    color: var(--text-muted);
    line-height: 1.8;
}

.room-welcome-state__meta {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.room-welcome-state__meta span {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    font-size: 12px;
}

.chat-header-actions {
    display: flex;
    gap: 12px;
}

.room-settings-modal {
    position: fixed;
    inset: 0;
    z-index: 10040;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.room-settings-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    backdrop-filter: blur(20px);
}

.room-settings-modal__dialog {
    position: relative;
    width: min(960px, 100%);
    max-height: min(92vh, 900px);
    padding: 28px;
    overflow: auto;
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(6, 10, 24, 0.94));
}

.room-settings-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.room-settings-modal__eyebrow {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #86efac;
    margin-bottom: 8px;
}

.room-settings-modal__header h3 {
    font-size: 17px;
    color: #f8fafc;
    margin-bottom: 0;
}

/* هدرِ نوار‌مانند با فلشِ بازگشت — چسبیده به بالای کادر (داخل قاب) */
.room-settings-modal__header--bar {
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 6;
    margin: -28px -28px 14px -28px;
    padding: 14px 22px;
    background: rgba(12, 18, 34, 0.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    border-radius: 30px 30px 0 0;
}
.room-settings-modal__back {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.room-settings-modal__back:hover { background: rgba(255, 255, 255, 0.1); }

.room-settings-modal__header p {
    color: var(--text-muted);
    font-size: 14px;
}

.room-settings-modal__close {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.room-settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    gap: 18px;
}

.room-settings-card {
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    padding: 18px;
}

.room-settings-section-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c4b5fd;
    margin-bottom: 16px;
}

.room-settings-avatar-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.room-settings-avatar {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    flex: 0 0 64px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.72), rgba(16, 185, 129, 0.52));
    color: #fff;
    font-weight: 700;
    font-size: 20px;
}

.room-settings-avatar img,
.room-member-row__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.room-settings-avatar-copy {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.room-settings-avatar-copy strong {
    color: #f8fafc;
    font-size: 16px;
}

.room-settings-avatar-copy small,
.room-member-row__identity small {
    color: var(--text-muted);
    font-size: 12px;
}

.room-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.room-settings-role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 16px;
    border: 1px solid rgba(52, 211, 153, 0.2);
    background: rgba(16, 185, 129, 0.12);
    color: #a7f3d0;
    text-transform: capitalize;
    font-weight: 700;
}

.room-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.room-settings-members-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 520px;
    overflow: auto;
}

.room-settings-member-add {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.room-settings-member-add input {
    flex: 1 1 auto;
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 0 14px;
    outline: none;
}

.room-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.room-member-row__identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.room-member-row__identity strong {
    color: #f8fafc;
    display: block;
    margin-bottom: 3px;
}

.room-member-row__avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    flex: 0 0 44px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: rgba(139, 92, 246, 0.18);
    color: #e9d5ff;
    font-weight: 700;
}

.room-member-row__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.room-member-action {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(167, 139, 250, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    cursor: pointer;
}

.room-member-action--danger {
    color: #fecdd3;
    border-color: rgba(251, 113, 133, 0.2);
}

.room-member-action:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.room-settings-loading,
.room-settings-error,
.room-settings-empty {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 768px) {
    .rooms-toolbar {
        padding: 12px 14px 10px;
    }

    .rooms-toolbar__title {
        font-size: 15px;
    }

    .rooms-create-btn {
        width: 48px;
        height: 48px;
        border-radius: 16px;
    }

    .create-room-modal {
        align-items: flex-end;
        padding: 0;
    }

    .create-room-modal__dialog {
        width: 100%;
        max-height: min(92vh, 820px);
        border-radius: 28px 28px 0 0;
        padding: 22px 18px 18px;
    }

    .create-room-modal__header h3 {
        font-size: 24px;
    }

    .create-room-types,
    .create-room-grid {
        grid-template-columns: 1fr;
    }

    .create-room-privacy {
        width: 100%;
    }

    .create-room-privacy__option {
        flex: 1 1 0;
        min-width: 0;
    }

    .create-room-actions {
        position: sticky;
        bottom: 0;
        background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.92) 32%);
        padding-top: 12px;
    }

    .create-room-btn {
        flex: 1 1 0;
        min-width: 0;
    }

    .room-welcome-state h3 {
        font-size: 24px;
    }

    .chat-header-actions {
        gap: 8px;
    }

    .room-settings-modal {
        padding: 0;
        align-items: flex-end;
    }

    .room-settings-modal__dialog {
        width: 100%;
        max-height: min(94vh, 900px);
        border-radius: 28px 28px 0 0;
        padding: 22px 18px 18px;
    }
    .room-settings-modal__header--bar {
        margin: -22px -18px 14px -18px;
        padding: 12px 16px;
        border-radius: 28px 28px 0 0;
    }

    .room-settings-layout,
    .room-settings-grid {
        grid-template-columns: 1fr;
    }

    .room-settings-avatar-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .room-settings-actions {
        position: sticky;
        bottom: 0;
        padding-top: 12px;
        background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.94) 36%);
    }

    /* اعضا روی موبایل هم به‌صورت ردیفی بمانند: نام راست، آیکن‌ها روبرو (چپ) */
    .room-member-row {
        flex-direction: row;
        align-items: center;
    }

    .room-settings-member-add {
        flex-direction: column;
    }

    .room-member-row__actions {
        width: auto;
        flex-wrap: nowrap;
    }

    .room-member-action {
        flex: 0 0 auto;
    }
}

/* ===============================================
   Theme Toggle Icon Animation
   =============================================== */
#theme-icon {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#theme-icon .sun-rays {
    transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

#theme-icon .sun-moon {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme - show moon */
[data-theme="dark"] #theme-icon .sun-rays {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

[data-theme="dark"] #theme-icon .sun-moon {
    transform: translateX(-3px);
    fill: currentColor;
}

[data-theme="dark"] #theme-icon {
    transform: rotate(-30deg);
}

/* Light theme - show sun */
[data-theme="light"] #theme-icon .sun-rays {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] #theme-icon .sun-moon {
    transform: translateX(0);
    fill: none;
}

[data-theme="light"] #theme-icon {
    transform: rotate(0deg);
}

/* Hover effect */
.nav-btn:hover #theme-icon {
    transform: rotate(180deg) scale(1.1);
}

[data-theme="dark"] .nav-btn:hover #theme-icon {
    transform: rotate(150deg) scale(1.1);
}

        /* === Contacts Manager Premium UI === */
        .contacts-manager-header {
            padding: 15px 20px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            border-bottom: 1px solid var(--glass-border);
            background: transparent;
        }

        .contacts-search-wrapper {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .search-input-container {
            flex: 1;
            position: relative;
            display: flex;
            align-items: center;
        }

        .search-icon {
            position: absolute;
            right: 15px;
            width: 18px;
            height: 18px;
            color: var(--text-muted);
            pointer-events: none;
        }

        #contactsSearch {
            width: 100%;
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
            padding: 12px 45px 12px 15px;
            color: var(--text-main);
            font-size: 14px;
            outline: none;
            transition: 0.3s;
        }
        #contactsSearch::placeholder {
            color: var(--text-muted);
            opacity: 0.7;
        }

        #contactsSearch:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
            background: var(--glass-hover);
        }

        .add-btn-premium {
            width: 44px;
            height: 44px;
            border-radius: 14px;
            background: var(--primary);
            color: #fff;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: 0.3s;
            box-shadow: 0 8px 15px rgba(99, 102, 241, 0.2);
        }

        .add-btn-premium:hover {
            transform: translateY(-2px);
            box-shadow: 0 12px 20px rgba(99, 102, 241, 0.3);
            filter: brightness(1.1);
        }

        /* Message Shadow Refinement */

        /* Message Shadow Refinement */
        .msg-out {
            box-shadow: 0 8px 25px rgba(99, 102, 241, 0.25) !important;
        }

        /* Custom Scrollbar for Glass Theme */
        .chat-msgs::-webkit-scrollbar,
        .contact-list::-webkit-scrollbar,
        .sidebar::-webkit-scrollbar {
            width: 6px;
        }

        .chat-msgs::-webkit-scrollbar-track,
        .contact-list::-webkit-scrollbar-track {
            background: transparent;
        }

        .chat-msgs::-webkit-scrollbar-thumb,
        .contact-list::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.1);
            border-radius: 10px;
        }

        [data-theme="dark"] .chat-msgs::-webkit-scrollbar-thumb,
        [data-theme="dark"] .contact-list::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.1);
        }

        /* Tablet & Mobile Chat Optimization */
        @media (max-width: 1024px) {
            .chat-layout { gap: 0; }
            .contacts-panel { width: 320px; }
            .chat-msgs { padding: 20px; }
            .input-bar { padding: 10px 14px; min-height: unset; }
            .chat-header { height: 80px; padding: 0 20px; }
        }

        @media (max-width: 768px) {
            .contacts-panel { 
                position: absolute; 
                left: -100%; 
                top: 0; 
                bottom: 0; 
                width: 85%; 
                transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
                box-shadow: 20px 0 50px rgba(0,0,0,0.2);
            }
            .contacts-panel.active { left: 0; }
            .chat-area { width: 100%; }
            .sidebar { width: 70px; }
            .msg { max-width: 78% !important; }
            .msg-out { margin-left: auto !important; margin-right: 0 !important; align-self: flex-start !important; }
            .msg-in { margin-right: auto !important; margin-left: 0 !important; align-self: flex-end !important; }
        }

/* Modern Nav Icon Enhancements */
.nav-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge-new {
    position: absolute;
    top: -8px;
    right: -12px;
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    color: white;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 5px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(255, 75, 43, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0% { transform: scale(1); box-shadow: 0 2px 8px rgba(255, 75, 43, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 2px 12px rgba(255, 75, 43, 0.6); }
    100% { transform: scale(1); box-shadow: 0 2px 8px rgba(255, 75, 43, 0.4); }
}

.nav-btn:hover .nav-icon-wrapper svg {
    filter: drop-shadow(0 0 8px var(--primary)) !important;
    transform: translateY(-2px);
}

.nav-btn .nav-icon-wrapper svg {
    transition: all 0.3s ease;
}

/* Header Calendar / Reminders */
.calendar-widget-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.calendar-widget-dialog {
    width: min(92vw, 430px);
    max-height: 86vh;
    overflow-y: auto;
    position: relative;
    padding: 24px;
    border-radius: 28px;
}

.calendar-widget-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--glass-hover);
    color: var(--text-main);
    cursor: pointer;
    font-size: 20px;
}

.calendar-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.calendar-modal-eyebrow,
.calendar-field span {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.calendar-modal-head h3 {
    margin: 5px 0 0;
    color: var(--text-main);
    font-size: 18px;
}

.calendar-select,
.calendar-field input,
.calendar-note-form input[type="text"],
.calendar-note-form input[type="time"] {
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: var(--glass-hover);
    color: var(--text-main);
    padding: 10px 12px;
    outline: none;
}

.calendar-field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.calendar-note-list {
    display: grid;
    gap: 8px;
    margin: 12px 0 16px;
}

.calendar-empty {
    padding: 16px;
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
    color: var(--text-muted);
    text-align: center;
    font-size: 13px;
}

.calendar-note-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
}

.calendar-note-item button {
    border: 0;
    border-radius: 12px;
    background: var(--glass-hover);
    color: var(--text-main);
    padding: 8px;
    cursor: pointer;
}

.calendar-note-item strong {
    display: block;
    color: var(--text-main);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-note-item small {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 3px;
}

.calendar-note-item.is-done strong {
    text-decoration: line-through;
    color: var(--text-muted);
}

.calendar-note-form {
    display: grid;
    gap: 10px;
}

.calendar-note-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.calendar-primary-btn {
    border: 0;
    border-radius: 16px;
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.calendar-emergency-dialog {
    text-align: center;
}

.calendar-emergency-badge {
    display: inline-flex;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    font-weight: 900;
    margin-bottom: 12px;
}

.calendar-emergency-dialog h3 {
    color: var(--text-main);
    margin: 0 0 10px;
}

.calendar-emergency-dialog p {
    color: var(--text-main);
    line-height: 1.8;
    margin-bottom: 14px;
}

.calendar-emergency-dialog small {
    display: block;
    color: var(--text-muted);
    margin-bottom: 16px;
}


/* ═══════════════════════════════════════════
   CLAUDE-STYLE INPUT BAR
   ═══════════════════════════════════════════ */

.input-bar {
    padding: 10px 14px !important;
    background: transparent !important;
    border-top: none !important;
    min-height: unset !important;
    height: auto !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 0 !important;
}

/* باکس اصلی - گرد مثل Claude */
.claude-input-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 20px;
    padding: 12px 14px 10px 14px;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.claude-input-box:focus-within {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

/* input متن */
.claude-input-box .text-input {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 15px !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 24px !important;
    width: 100% !important;
    box-shadow: none !important;
    font-family: inherit !important;
    line-height: 1.5 !important;
}

.claude-input-box .text-input::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}

/* ردیف پایین: دکمه‌ها */
.claude-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.claude-input-left,
.claude-input-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* دکمه‌های آیکون کوچک */
.claude-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.claude-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

/* دکمه ارسال - مثل Claude */
.claude-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    padding: 0;
    flex-shrink: 0;
}

.claude-send-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.claude-send-btn.active {
    background: #c96442;
    color: #fff;
    transform: scale(1.05);
}

/* موبایل */
@media (max-width: 768px) {
    body.mobile-chat-open .input-bar {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        z-index: 10 !important;
        padding: 8px 12px !important;
        background: rgba(10, 10, 20, 0.97) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(255,255,255,0.06) !important;
        min-height: unset !important;
        height: auto !important;
    }
}

/* textarea در claude-input-box */
.claude-input-box textarea.text-input {
    resize: none !important;
    overflow-y: hidden !important;
    min-height: 24px !important;
    max-height: 120px !important;
    height: auto !important;
    line-height: 1.5 !important;
    padding: 0 !important;
    display: block !important;
    width: 100% !important;
}

/* ── Attach Menu ── */
.claude-input-left {
    position: relative !important;
}

.attach-menu {
    position: fixed !important;
    bottom: 130px !important;
    left: 16px !important;
    background: rgba(20, 20, 35, 0.97) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 16px !important;
    padding: 8px !important;
    flex-direction: column !important;
    gap: 2px !important;
    min-width: 150px !important;
    z-index: 9999 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
}

.attach-menu.open {
    display: flex !important;
}

.attach-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 14px !important;
    border: none !important;
    background: transparent !important;
    color: rgba(255,255,255,0.85) !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-family: inherit !important;
    text-align: right !important;
    direction: rtl !important;
    transition: background 0.15s !important;
    width: 100% !important;
}

.attach-menu-item:hover {
    background: rgba(255,255,255,0.08) !important;
}

.attach-icon {
    font-size: 18px !important;
    flex-shrink: 0 !important;
}

/* آیکون‌های attach menu */
.attach-icon svg {
    stroke: rgba(255, 255, 255, 0.75) !important;
}

.attach-menu-item:hover .attach-icon svg {
    stroke: #fff !important;
}


/* ── Fix call icons clickability ── */
.icon-circle {
  pointer-events: all !important;
  position: relative !important;
  z-index: 10 !important;
  cursor: pointer !important;
}
.chat-header {
  position: relative !important;
  z-index: 5 !important;
}

/* ── Fix dnd-overlay blocking clicks ── */
.dnd-overlay {
  pointer-events: none !important;
  display: none !important;
}
.dnd-overlay.active {
  pointer-events: all !important;
  display: flex !important;
}

/* chat-header-bar mobile back button */
@media (max-width: 768px) {
    #chat-back-btn {
        display: flex !important;
    }
}

/* fix: call-controls invisible overlay */
.call-modal:not(.active) * {
    pointer-events: none !important;
}

/* fix: prevent call-controls from overlapping chat */
.call-modal:not(.active) .call-controls-bar {
    display: none !important;
}
.call-modal:not(.active) .call-pip-close {
    display: none !important;
}

/* fix: hide ALL call-modal content when inactive */
.call-modal:not(.active) > * {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* FINAL FIX: call-modal complete isolation */
#call-modal[style*="display: none"],
#call-modal:not([style*="display: flex"]) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
#call-modal[style*="display: none"] *,
#call-modal:not([style*="display: flex"]) * {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* fix: hide ALL call-modal content when inactive */
.call-modal:not(.active) > * {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Fix: force-hide non-active sections */
#profile-tab:not(.active),
#settings:not(.active) { display: none !important; }

/* Mobile Hamburger Button */
.mobile-hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 10px;
    flex-shrink: 0;
}
.mobile-hamburger-btn:hover {
    background: var(--glass-hover, rgba(255,255,255,0.1));
}
.mobile-hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-main, #fff);
    border-radius: 2px;
    transition: 0.2s;
}

#dnd-overlay { display: none !important; pointer-events: none !important; }


/* Chat handler contact items - no border */
.contact-item.ci-simple {
    border: none !important;
    background: transparent !important;
}
.contact-item.ci-simple.active {
    background: rgba(99, 102, 241, 0.15) !important;
}

/* Remove separators between simple contact items */
.contact-item.ci-simple + .contact-item.ci-simple {
    border-top: none !important;
}

/* ci-simple: completely borderless and clean */
.contact-item.ci-simple,
.contact-item.ci-simple:last-child,
.contact-item.ci-simple + .contact-item.ci-simple {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* ci-simple: no border when active, no separator lines */
.contact-item.ci-simple.active,
.contact-item.ci-simple:focus {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}
.contacts-panel .contact-list .contact-item.ci-simple {
    border-bottom: none !important;
    border-top: none !important;
    border: none !important;
}

/* Final fix: remove all borders from ci-simple items */
.contacts-panel .contact-list .contact-item.ci-simple,
.contacts-panel .contact-list .contact-item.ci-simple:last-child,
.contacts-panel .contact-list .contact-item.ci-simple.active,
.contacts-panel .contact-list .contact-item.ci-simple:hover {
    border: none !important;
    border-bottom: none !important;
    border-top: none !important;
    box-shadow: none !important;
    outline: none !important;
    margin-bottom: 0 !important;
}

/* community panel items - no border */
#community-list div {
    border: none !important;
    box-shadow: none !important;
}

/* fix: remove separator between regular contact items */
.contact-item:not(.ci-simple) {
    border-bottom: none !important;
}

/* fix navbar spacing after removing contacts button */
@media (max-width: 768px) {
    .sidebar .nav-btn[style*="display:none"],
    .sidebar .nav-btn[style*="display: none"] {
        display: none !important;
        width: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    .sidebar > div:first-child { display: none !important; }
    .sidebar > div[style*="margin-top"] { display: none !important; }

    #profile-nav-btn   { grid-column: 5 !important; }
    #community-nav-btn { grid-column: 4 !important; }
    #games-nav-btn     { grid-column: 3 !important; display: flex !important; }
    #chat-nav-btn      { grid-column: 2 !important; }
    #trade-nav-btn     { grid-column: 1 !important; display: flex !important; }

    /* مخفی کردن بقیه */
    #upload-nav-btn,
    #story-nav-btn,
    #wallet-nav-btn { display: none !important; width:0 !important; }
}

/* ── fix navbar 5-slot grid — games always center ── */
@media (max-width: 768px) {
    .sidebar {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-evenly !important;
        align-items: center !important;
        gap: 0 !important;
    }
    .sidebar > div:first-child { display: none !important; }
    .sidebar > div[style*="margin-top"] { display: none !important; }

    #upload-nav-btn,
    #story-nav-btn,
    #wallet-nav-btn { 
        display: none !important; 
        width: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    #games-nav-btn { display: flex !important; }
    #trade-nav-btn { display: flex !important; }
}

/* ========================================================
   DYO MOCKUP FLAT UI OVERRIDES 
   ======================================================== */

/* Override glass-panel for Chat and Contacts */
body[data-theme="light"] .chat-area, 
body[data-theme="dark"] .chat-area {
    background: var(--chat-bg) !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

body[data-theme="light"] .contacts-panel, 
body[data-theme="dark"] .contacts-panel {
    background: var(--contacts-bg) !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

body[data-theme="light"] .bg-blobs, 
body[data-theme="dark"] .bg-blobs {
    display: none !important;
}

/* Flawless S-Curve Inverted Corner for Chat Header */
.corner-shape-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 150px; 
    height: 100%; 
    background: #ffffff;
    border-bottom-right-radius: 40px; 
    z-index: 0;
}
.corner-shape-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 100%; 
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 100% 100%, transparent 40px, #ffffff 41px);
}

/* Chat Area Background override for green theme */
body[data-theme="light"] .chat-area {
    background: #52c48a !important;
}
body[data-theme="dark"] .chat-area {
    background: #0d291e !important; /* Dark Elegant Green */
}

/* Fix chat bubbles */
body[data-theme="light"] .chat-msgs .msg,
body[data-theme="dark"] .chat-msgs .msg {
    border-radius: 24px;
    font-weight: 500;
}

/* Incoming (Right) - Translucent green */
body[data-theme="light"] .chat-msgs .msg-in,
body[data-theme="dark"] .chat-msgs .msg-in {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    border-radius: 24px 24px 8px 24px !important;
    border: none !important;
    box-shadow: none !important;
}

/* Outgoing (Left) - Solid white */
body[data-theme="light"] .chat-msgs .msg-out,
body[data-theme="dark"] .chat-msgs .msg-out {
    background: #ffffff !important;
    color: #1a4a38 !important;
    border-radius: 24px 24px 24px 8px !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
}

/* Timestamp styles inside bubbles */
.chat-msgs .msg-in .msg-meta {
    color: rgba(255, 255, 255, 0.8) !important;
}
.chat-msgs .msg-out .msg-meta {
    color: rgba(26, 74, 56, 0.6) !important;
}
.chat-msgs .msg-out .msg-meta svg {
    color: #52c48a !important;
}

/* ========================================================
   CONTACTS PANEL MOCKUP RE-STRUCTURE
   ======================================================== */
.header-top { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; margin-bottom: 16px; padding: 6px 24px 0; }
.greeting { display: flex; align-items: center; gap: 12px; }
.main-logo { width: 45px; height: 45px; border-radius: 12px; object-fit: contain; background: var(--glass-hover); padding: 4px; }
.greeting-text span { font-size: 13px; color: var(--text-muted); font-weight: 500; display: block; }
.greeting-text h1 { font-size: 22px; color: var(--text-main); font-weight: 800; margin-top: 2px; }

.header-actions { display: flex; gap: 8px; }
.header-actions button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--glass-border); background: var(--glass-hover); display: flex; justify-content: center; align-items: center; color: var(--text-main); cursor: pointer; transition: 0.2s; padding: 0; }
.header-actions button:hover { background: var(--glass-bg); }

.modern-tabs { background: var(--glass-hover); border-radius: 30px; display: flex; padding: 4px; margin: 0 24px 25px; border: 1px solid var(--glass-border); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.modern-tabs::-webkit-scrollbar { display: none; }
.modern-tabs .tab { flex: 1; text-align: center; padding: 10px 15px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-radius: 25px; cursor: pointer; transition: 0.3s; min-width: 80px; border: none; background: transparent; white-space: nowrap; }
.modern-tabs .tab.active { background: var(--primary); color: #000 !important; box-shadow: 0 6px 16px rgba(0,0,0,0.1); font-weight: 700; }

.modern-search { margin: 0 24px 15px; border-radius: 20px !important; background: var(--glass-hover) !important; border: 1px solid var(--glass-border) !important; }
.modern-search input { background: transparent !important; color: var(--text-main) !important; }

.fab { position: absolute; bottom: 120px; left: 25px; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #000; display: flex; justify-content: center; align-items: center; box-shadow: 0 10px 20px rgba(0,0,0,0.2); cursor: pointer; border: none; transition: transform 0.2s; z-index: 99; }
.fab:hover { transform: scale(1.05); }

/* Override contact item to look like mockup */
.modern-contact-list { padding: 0 24px 100px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
body[data-theme="light"] .modern-contact-list .contact-item,
body[data-theme="dark"] .modern-contact-list .contact-item { padding: 12px 0; border: none !important; background: transparent !important; box-shadow: none !important; margin-bottom: 0; display: flex; align-items: center; gap: 14px; border-radius: 0 !important; }
.modern-contact-list .contact-item .contact-avatar,
html body .c-avatar, html body .contact-avatar, html body .user-avatar { width: 52px !important; height: 52px !important; border-radius: 50% !important; border: 1px solid var(--glass-border) !important; }
.modern-contact-list .contact-item .contact-info { flex: 1; min-width: 0; }
.modern-contact-list .contact-item .contact-name { font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.modern-contact-list .contact-item .contact-status { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modern-contact-list .contact-item .contact-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; min-width: 40px; }
.modern-contact-list .contact-item .contact-time { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.modern-contact-list .contact-item .unread-badge { background: var(--primary); color: #000; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: flex; justify-content: center; align-items: center; }

/* Hide legacy buttons in contacts panel to match clean mockup */
.modern-contact-list .contact-item .contact-actions { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 5px; min-width: 40px; border: none; background: transparent; }
.modern-contact-list .contact-item .contact-call-btn,
.modern-contact-list .contact-item .contact-menu-btn { display: none !important; }

/* =========================================================
   Fix for Chat Input Gap (Mobile)
   ========================================================= */
@media (max-width: 768px) {
  body.mobile-chat-open .chat-area {
    max-height: 100% !important;
    padding-bottom: 56px !important;
  }
}
@media (max-width: 480px) {
  body.mobile-chat-open .chat-area {
    max-height: 100% !important;
    padding-bottom: 60px !important;
  }
  body.mobile-chat-open #mci-root {
    margin-bottom: 0 !important;
    bottom: 0 !important;
    transform: translateY(0) !important;
  }
}


/* ── فاصله و جمع‌و‌جوری تنظیمات اتاق (اصلاحات UI) ── */
.room-settings-form { display: flex; flex-direction: column; gap: 18px; }
.room-settings-form .create-room-field { gap: 7px; }
.room-settings-form .room-settings-actions { margin-top: 4px; display: flex; gap: 10px; }
/* ردیف اعضا جمع‌و‌جورتر */
.room-member-row { padding: 10px 12px !important; border-radius: 14px !important; }
.room-member-row__avatar { width: 38px !important; height: 38px !important; flex: 0 0 38px !important; border-radius: 12px !important; }
.room-member-row__identity strong { margin-bottom: 1px !important; font-size: 14px; }
.room-member-row__actions { flex-wrap: nowrap !important; gap: 4px !important; }
/* فاصلهٔ برچسب از فیلد قبلی (بیو و …) با gap فرم تأمین شد؛ این برای اطمینان */
.room-settings-form .rs-label-row { line-height: 1.6; }

/* شناسه (آیدی) به‌صورت LTR: @ سمت چپ، متن از چپ */
.create-room-slug--ltr { direction: ltr; justify-content: flex-start; }
.create-room-slug--ltr input { text-align: left; direction: ltr; font-size: 16px; letter-spacing: .3px; }
.create-room-slug--ltr .create-room-slug__prefix { font-size: 16px; }

/* افزودن عضو: ورودی جستجو + آیکن + */
.room-settings-member-add { display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.room-settings-member-add input { flex: 1; }
.rs-add-icon { flex: 0 0 auto; width: 46px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--primary, #6366f1); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.rs-add-icon:hover { filter: brightness(1.08); }

/* ════════ استوری‌بارِ جمع‌شونده (مثل تلگرام) ════════ */
.story-shell { transition: max-height .35s cubic-bezier(.22,1,.36,1), opacity .3s ease; overflow: hidden; }
.story-shell.story-shell--collapsed { max-height: 0 !important; opacity: 0; margin-top: 0 !important; margin-bottom: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important; }
.story-shell.story-shell--open { max-height: 140px; opacity: 1; }
.story-collapsed-indicator { display: inline-flex; align-items: center; cursor: pointer; margin-right: 10px; vertical-align: middle; }
.story-collapsed-indicator img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg-main, #0f1117); margin-right: -22px; box-shadow: 0 0 0 2px #22c55e; }
.story-collapsed-indicator img:first-child { margin-right: 0; }
.story-collapsed-indicator .sci-more { font-size: 11px; color: var(--text-muted, #94a3b8); margin-right: 8px; font-weight: 700; }

/* جداکننده‌ی تاریخِ روز در گفتگو */
.msg-date-divider { display: flex !important; align-items: center; justify-content: center; width: 100%; margin: 16px 0 12px; position: relative; z-index: 3; }
.msg-date-divider span { display: inline-block; background: #2b3550; color: #fff; font-size: 13px; font-weight: 800;
  padding: 6px 18px; border-radius: 16px; font-family: Vazir, sans-serif;
  border: 1px solid rgba(255,255,255,.16); box-shadow: 0 2px 8px rgba(0,0,0,.35); letter-spacing: .2px; cursor: pointer; transition: transform .15s, background .15s; }
.msg-date-divider .mdd-pill:hover { background: rgba(99,102,241,.35); transform: translateY(-1px); }
.msg-date-divider.flash span { background: var(--primary, #818cf8) !important; color:#fff !important; box-shadow:0 0 0 4px rgba(129,140,248,.25); }

/* ── هدرِ تاریخِ چسبان (سبکِ تلگرام) ── */
.chat-area { position: relative; }
.chat-sticky-date { position: absolute; top: 74px; left: 0; right: 0; display: flex; justify-content: center;
  pointer-events: none; z-index: 15; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
.chat-sticky-date.visible { opacity: 1; transform: translateY(0); }
.chat-sticky-date .csd-pill { pointer-events: auto; cursor: pointer; background: #2b3550; color: #fff;
  font: 800 13px/1 Vazir, sans-serif; padding: 7px 18px; border-radius: 16px;
  border: 1px solid rgba(255,255,255,.16); box-shadow: 0 4px 16px rgba(0,0,0,.4); letter-spacing: .2px; }
.chat-sticky-date .csd-pill:hover { background: #6366f1; }
html[data-theme="light"] .chat-sticky-date .csd-pill { background: #2b3550; color:#fff; }

/* ── گروه‌بندیِ هوشمندِ پیام‌ها ── */
.chat-msgs .msg.grp-cont { margin-top: 2px !important; }
.chat-msgs .msg.grp-cont .msg-sender { display: none !important; }
.chat-msgs .msg.grp-start { margin-top: 10px; }

/* ── زمانِ هر پیام + تولتیپِ تاریخِ کامل ── */
.chat-msgs .msg-time { cursor: help; border-bottom: 1px dotted transparent; transition: border-color .15s; }
.chat-msgs .msg-time:hover { border-bottom-color: currentColor; }
.msg-time-tip { position: fixed; z-index: 100000; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .15s, transform .15s; background: rgba(15,23,42,.96); color: #f1f5f9; border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; padding: 8px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); font-family: Vazir, sans-serif; text-align: center; max-width: 80vw; }
.msg-time-tip.visible { opacity: 1; transform: translateY(0); }
.msg-time-tip .mtt-1 { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.msg-time-tip .mtt-2 { font-size: 11px; color: #94a3b8; margin-top: 3px; direction: ltr; }

/* ── پنجره‌ی پرش به تاریخ ── */
.chat-datepicker-overlay { position: fixed; inset: 0; z-index: 100001; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); animation: cdpFade .18s ease; }
@keyframes cdpFade { from { opacity: 0; } to { opacity: 1; } }
.cdp-sheet { width: min(420px, 92vw); max-height: 76vh; display: flex; flex-direction: column; background: var(--glass, #11162a);
  border: 1px solid rgba(255,255,255,.1); border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); font-family: Vazir, sans-serif; }
.cdp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; font-weight: 800; font-size: 15px;
  color: var(--text-main,#f1f5f9); border-bottom: 1px solid rgba(255,255,255,.07); }
.cdp-close { background: none; border: none; color: var(--text-muted,#94a3b8); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.cdp-close:hover { background: rgba(255,255,255,.08); color:#fff; }
.cdp-body { overflow-y: auto; padding: 12px 16px 18px; }
.cdp-month { font-size: 13px; font-weight: 800; color: var(--primary,#818cf8); margin: 14px 2px 8px; }
.cdp-days { display: flex; flex-wrap: wrap; gap: 8px; }
.cdp-day { min-width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04); color: var(--text-main,#e2e8f0); font: 700 14px Vazir, sans-serif; cursor: pointer; transition: .15s; }
.cdp-day:hover { background: var(--primary,#818cf8); color: #fff; transform: translateY(-2px); }
html[data-theme="light"] .cdp-sheet { background:#fff; border-color: rgba(15,23,42,.1); }
html[data-theme="light"] .cdp-day { background: rgba(15,23,42,.04); color:#334155; border-color: rgba(15,23,42,.08); }

/* جداکننده‌ی پیام‌های خوانده‌نشده */
.msg-unread-divider { display: flex; align-items: center; justify-content: center; margin: 12px 0; position: relative; }
.msg-unread-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(99,102,241,.3); }
.msg-unread-divider span { position: relative; background: var(--bg-main, #0f1117); color: var(--primary, #818cf8); font-size: 12px; font-weight: 700;
  padding: 3px 14px; border-radius: 12px; font-family: Vazir, sans-serif; border: 1px solid rgba(99,102,241,.3); }

/* وقتی استوری‌ویوئر باز است، داکِ پایین مخفی شود تا آیکن‌های استوری زیر آن نروند */
body.story-viewer-open .sidebar { display: none !important; }
/* آیکن‌های استوری کمی بالاتر از لبه‌ی پایین تا با safe-area تداخل نکنند */
.story-actions { bottom: calc(5rem + env(safe-area-inset-bottom)) !important; z-index: 2147483647 !important; }

/* جهتِ آیکن‌های هدر گفتگو: چپ‌به‌راست، سه‌نقطه سمت راست */
.chat-header .chat-header-actions, .chat-header > div:last-child { }

/* ════════ اصلاحات بازخوردی (هدر/پنل/استوری) ════════ */
/* #4 آیکن‌های هدر چت هم‌تراز */
#chat-header-bar { align-items: center !important; }
#chat-header-bar > div { display: flex; align-items: center; }
#chat-header-bar button { display: inline-flex !important; align-items: center !important; justify-content: center !important; }
/* #5 آواتار مخاطب در هدر چت کوچکتر */
#chat-header-bar #active-chat-avatar { width: 40px !important; height: 40px !important; font-size: 15px !important; }
/* #6 آیکن بازی در پنل کوچکتر */
#games-nav-btn { width: 50px !important; height: 50px !important; }
/* #1 آیکن‌های استوری بالاتر تا زیر پنل نروند */
.story-actions { bottom: calc(7rem + env(safe-area-inset-bottom)) !important; }
body.story-viewer-open .sidebar, body.story-viewer-open #games-mobile-dock-handle { display: none !important; }

/* #7 پنل برنامه‌ها بدون اسکرول روی موبایل (آیکن‌ها جمع‌وجورتر تا جا شوند) */
@media (max-width: 768px) {
  .sidebar { overflow-x: hidden !important; gap: 0 !important; justify-content: space-around !important; padding-left: 4px !important; padding-right: 4px !important; }
  .sidebar .nav-btn { width: 42px !important; height: 42px !important; }
  .sidebar #games-nav-btn { width: 46px !important; height: 46px !important; }
  .sidebar .nav-btn svg { width: 20px; height: 20px; }
}

/* ════════ اصلاحات بازخوردی دور ۲ ════════ */
/* #5 پنل برنامه‌ها قطعاً بدون اسکرول + آیکن بازی ۱۰٪ کوچکتر */
html body .app-container .sidebar { overflow-x: hidden !important; }
@media (max-width: 768px) {
  html body .app-container .sidebar { overflow-x: hidden !important; gap: 0 !important; justify-content: space-around !important; padding-left: 2px !important; padding-right: 2px !important; }
  html body .app-container .sidebar .nav-btn { width: 40px !important; height: 40px !important; }
  html body .app-container .sidebar #games-nav-btn { width: 44px !important; height: 44px !important; }
  html body .app-container .sidebar .nav-btn svg { width: 19px !important; height: 19px !important; }
}
html body #games-nav-btn { width: 45px !important; height: 45px !important; }
/* #6 آیکن‌های اکشن پست هم‌تراز */
.xr-card__actions { align-items: center !important; }
.xr-card__actions button svg { width: 24px; height: 24px; display: block; }
/* #15 هدر پست زیر عکس نرود */
.xr-card__head { position: relative; z-index: 2; flex-shrink: 0; }
.xr-card__mediawrap { z-index: 1; }

/* ════════════════════════════════════════════════════════════
   پالتِ رنگیِ یکپارچه + قابلِ انتخاب (Dyo Palette System) v2
   رفعِ باگ: قوانینِ تم با html[data-theme] نوشته می‌شوند (نه body)
   accent از طریق html[data-accent] کلِ --primary را می‌راند
   ════════════════════════════════════════════════════════════ */

/* ── پالت‌های accent (مستقل از تیره/روشن) ── */
html[data-accent="emerald"]{ --primary:#1f9d73; --primary-hover:#178a64; --accent-grad:linear-gradient(135deg,#178a64,#27a07b); --story-ring:linear-gradient(135deg,#2bb389,#1f9d73,#147a59); }
html[data-accent="blue"]   { --primary:#3390ec; --primary-hover:#2b7cd3; --accent-grad:linear-gradient(135deg,#2b7cd3,#3aa0f5); --story-ring:linear-gradient(135deg,#5aa9f0,#3390ec,#2b7cd3); }
html[data-accent="violet"] { --primary:#8b7cf6; --primary-hover:#7c6cd6; --accent-grad:linear-gradient(135deg,#7c6cd6,#9a8bf8); --story-ring:linear-gradient(135deg,#a78bfa,#8b7cf6,#7c6cd6); }
html[data-accent="rose"]   { --primary:#f43f5e; --primary-hover:#e11d48; --accent-grad:linear-gradient(135deg,#e11d48,#fb6f86); --story-ring:linear-gradient(135deg,#fb7185,#f43f5e,#e11d48); }
html[data-accent="amber"]  { --primary:#f59e0b; --primary-hover:#d97706; --accent-grad:linear-gradient(135deg,#d97706,#fbb024); --story-ring:linear-gradient(135deg,#fbbf24,#f59e0b,#d97706); }
/* پیش‌فرض اگر چیزی ست نشده باشد */
html:not([data-accent]){ --primary:#1f9d73; --primary-hover:#178a64; --accent-grad:linear-gradient(135deg,#178a64,#27a07b); --story-ring:linear-gradient(135deg,#2bb389,#1f9d73,#147a59); }

/* ── تمِ تیره (پاک و خوش‌کنتراست) ── */
html[data-theme="dark"]{
  --bg-base:#0b0f14; --chat-bg:#0a0d11; --contacts-bg:#11161d; --curve-bg:#11161d;
  --glass-bg:#11161d; --glass-hover:rgba(255,255,255,0.05); --glass-border:rgba(255,255,255,0.06); --glass-shadow:rgba(0,0,0,0.5);
  --text-main:#e6edf3; --text-muted:#8b98a5;
  --msg-in:#1c2632; --text-msg-in:#e9eff4; --text-msg-out:#ffffff;
}
/* ── تمِ روشن (پاک و خوش‌کنتراست) ── */
html[data-theme="light"]{
  --bg-base:#dde3ec; --chat-bg:#e9edf2; --contacts-bg:#ffffff; --curve-bg:#ffffff;
  --glass-bg:#ffffff; --glass-hover:#eef2f7; --glass-border:rgba(15,23,42,0.14); --glass-shadow:rgba(15,23,42,0.10);
  --text-main:#0f172a; --text-muted:#64748b;
  --msg-in:#ffffff; --text-msg-in:#0f172a; --text-msg-out:#ffffff;
}

/* ── تمِ روشن: تمایزِ واضحِ کادرها/پنل‌ها/مودال‌ها از پس‌زمینه ── */
html[data-theme="light"] .glass-panel {
  border:1px solid rgba(15,23,42,0.12) !important;
  box-shadow:0 4px 18px rgba(15,23,42,0.10), 0 1px 4px rgba(15,23,42,0.06) !important;
}
html[data-theme="light"] .settings-section {
  border:1px solid rgba(15,23,42,0.10) !important;
  box-shadow:0 2px 12px rgba(15,23,42,0.07) !important;
}
html[data-theme="light"] .stat-card,
html[data-theme="light"] .storage-card-pro,
html[data-theme="light"] .games-home-card,
html[data-theme="light"] .section {
  border:1px solid rgba(15,23,42,0.10) !important;
  box-shadow:0 2px 12px rgba(15,23,42,0.07) !important;
}
/* مودال‌ها و کاغذهای شناور: سایهٔ پررنگ‌تر برای جداییِ واضح */
html[data-theme="light"] .modal,
html[data-theme="light"] .plans-modal,
html[data-theme="light"] .plans-modal-content,
html[data-theme="light"] [class*="-sheet__panel"],
html[data-theme="light"] .attach-menu,
html[data-theme="light"] .cdp-sheet {
  border:1px solid rgba(15,23,42,0.12) !important;
  box-shadow:0 16px 48px rgba(15,23,42,0.20) !important;
}

/* ── تمِ روشن: غلبه بر تمِ تیرهٔ تلگرام (telegram-theme.css دارک‌اونلیِ !important است) ── */
html[data-theme="light"] body,
html[data-theme="light"] .app-container,
html[data-theme="light"] #chat-tab,
html[data-theme="light"] #community-tab,
html[data-theme="light"] #feed-tab,
html[data-theme="light"] #contacts-tab { background: var(--bg-base) !important; }
html[data-theme="light"] #community-list,
html[data-theme="light"] #community-list > div { background: transparent !important; }
html[data-theme="light"] .cm-item { background: var(--glass-bg) !important; color: var(--text-main) !important; border:1px solid rgba(15,23,42,0.07) !important; }
html[data-theme="light"] .cm-item:hover { background: var(--glass-hover) !important; }
html[data-theme="light"] .cm-section { color: var(--text-muted) !important; }
html[data-theme="light"] .cm-item *, html[data-theme="light"] #community-list strong { color: var(--text-main) !important; }
html[data-theme="light"] .cm-item small, html[data-theme="light"] .cm-item .cm-sub { color: var(--text-muted) !important; }

/* ── کامپوننتِ انجمن (components/community.html دارک‌فرستِ هاردکد) در تمِ روشن ── */
html[data-theme="light"] #community-root,
html[data-theme="light"] #community-root .cm-sidebar { background: var(--contacts-bg,#fff) !important; color: var(--text-main) !important; }
html[data-theme="light"] #community-root .cm-chat-container { background: var(--bg-base) !important; }
html[data-theme="light"] #community-root .cm-section { color: #94a3b8 !important; }
html[data-theme="light"] #community-root .cm-item:hover { background: rgba(15,23,42,0.05) !important; }
html[data-theme="light"] #community-root .cm-tab:not(.active) { border-color: rgba(15,23,42,0.12) !important; color: #64748b !important; }
html[data-theme="light"] #community-search-input { color: #0f172a !important; }
/* غلبه بر استایل‌های inlineِ سفید (متن/پس‌زمینه/مرز) داخلِ انجمن */
html[data-theme="light"] #community-root [style*="color:#fff"],
html[data-theme="light"] #community-root [style*="color: #fff"] { color: #0f172a !important; }
html[data-theme="light"] #community-root [style*="color:rgba(255,255,255,0.2)"],
html[data-theme="light"] #community-root [style*="color:rgba(255,255,255,0.5)"] { color: #64748b !important; }
html[data-theme="light"] #community-root [style*="background:rgba(255,255,255,0.04)"],
html[data-theme="light"] #community-root [style*="background:rgba(255,255,255,0.05)"] { background: rgba(15,23,42,0.04) !important; border-color: rgba(15,23,42,0.10) !important; }
html[data-theme="light"] #community-root [style*="border:1px solid rgba(255,255,255"] { border-color: rgba(15,23,42,0.10) !important; }
html[data-theme="light"] #community-root svg[stroke*="rgba(255,255,255"] { stroke: #64748b !important; }

/* ── حباب‌های پیام: بدونِ کادر، کنتراستِ درست، رنگِ accent برای پیامِ من ── */
html[data-theme] .chat-msgs .msg{ box-shadow:0 2px 8px rgba(0,0,0,0.10) !important; border:none !important; }
html[data-theme] .chat-msgs .msg-in{
  background:var(--msg-in) !important; color:var(--text-msg-in) !important;
  border:none !important; backdrop-filter:none !important; -webkit-backdrop-filter:none !important;
}
html[data-theme="light"] .chat-msgs .msg-in{ box-shadow:0 1px 4px rgba(15,23,42,0.08) !important; }
html[data-theme] .chat-msgs .msg-out{
  background:var(--accent-grad) !important; color:var(--text-msg-out) !important;
  border:none !important; box-shadow:0 4px 14px rgba(0,0,0,0.12) !important;
}

/* ── حذفِ کادرِ دور عکس/مدیا داخل پیام و محتوا ── */
.chat-msgs .media-wrapper, .chat-msgs .media-wrapper img,
.chat-msgs .msg img, .chat-msgs .msg video{ border:none !important; box-shadow:none !important; }
.chat-msgs .media-wrapper img, .chat-msgs .msg img{ border-radius:14px !important; }

/* ── پس‌زمینه‌ی چت/پنل‌ها هماهنگ با تم ── */
html[data-theme="dark"]  .chat-area{ background:var(--chat-bg) !important; }
html[data-theme="light"] .chat-area{ background:var(--chat-bg) !important; }

/* انتخابگرِ پالتِ رنگی در تنظیمات */
.accent-picker { display:flex; gap:14px; flex-wrap:wrap; padding:4px 2px; }
.accent-swatch { width:34px; height:34px; border-radius:50%; border:2px solid transparent; cursor:pointer; padding:0; transition:transform .15s ease, box-shadow .15s ease; position:relative; }
.accent-swatch:hover { transform:scale(1.1); }
.accent-swatch--active { border-color:var(--text-main); box-shadow:0 0 0 3px var(--glass-bg), 0 0 0 5px currentColor; }
.accent-swatch--active::after { content:'✓'; position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#fff; font-size:15px; font-weight:800; text-shadow:0 1px 2px rgba(0,0,0,.4); }

/* ════════════════════════════════════════════════════════════
   v3 — خوانایی حالت روشن + حلقه‌ی گرادیانِ استوری + حذف کادرها
   ════════════════════════════════════════════════════════════ */

/* ── حالت روشن: متنِ تیره روی سطوحِ روشن (به‌جز حباب accent و دکمه‌ها) ── */
html[data-theme="light"] body { color:#0f172a; }
html[data-theme="light"] .contacts-panel,
html[data-theme="light"] .contact-list,
html[data-theme="light"] .chat-header,
html[data-theme="light"] #chat-header-bar,
html[data-theme="light"] .input-bar,
html[data-theme="light"] .settings-panel,
html[data-theme="light"] .settings-drawer { background:var(--contacts-bg) !important; }
html[data-theme="light"] .chat-msgs { background:var(--chat-bg) !important; }

/* متنِ عمومی روی سطوحِ روشن → تیره */
html[data-theme="light"] .contact-item,
html[data-theme="light"] .contact-item div,
html[data-theme="light"] .contact-item strong,
html[data-theme="light"] .contact-item span,
html[data-theme="light"] #chat-header-bar strong,
html[data-theme="light"] #chat-header-bar small,
html[data-theme="light"] .chat-header strong,
html[data-theme="light"] .chat-header small,
html[data-theme="light"] .msg-in,
html[data-theme="light"] .msg-in div,
html[data-theme="light"] .msg-in span,
html[data-theme="light"] .settings-item h3,
html[data-theme="light"] .settings-item p,
html[data-theme="light"] .settings-section-title,
html[data-theme="light"] .input-bar .text-input,
html[data-theme="light"] #mci-editor { color:#0f172a !important; }

/* متن‌های کم‌رنگ/زیرنویس در روشن → خاکستریِ خوانا */
html[data-theme="light"] .contact-item div[style*="rgba(255,255,255"],
html[data-theme="light"] small,
html[data-theme="light"] .c-preview { color:#64748b !important; }

/* آیکن‌های هدر/پنل در روشن قابل‌دیدن */
html[data-theme="light"] #chat-header-bar button,
html[data-theme="light"] .sidebar .nav-btn,
html[data-theme="light"] .icon-circle { color:#334155 !important; }
html[data-theme="light"] #chat-header-bar button svg,
html[data-theme="light"] .sidebar .nav-btn svg { stroke:#334155; }
/* دکمه‌ها/حباب رویِ accent: متن سفید بماند */
html[data-theme="light"] .msg-out, html[data-theme="light"] .msg-out * { color:#fff !important; }

/* ── حلقه‌ی گرادیانِ استوری (هماهنگ با accent) ── */
.story-bar__item.is-unread .story-bar__ring,
#story-bar .story-ring,
.ig-profile__avatar-wrap--ring {
  background:var(--story-ring) !important;
  border:none !important;
  padding:3px !important;
}
.story-bar__item.is-unread .story-bar__ring img,
#story-bar .story-ring img,
.ig-profile__avatar-wrap--ring img,
.ig-profile__avatar-wrap--ring .ig-profile__avatar {
  border:2px solid var(--bg-base) !important;
  box-sizing:border-box;
}

/* ── حذفِ کادرهای باقی‌مانده دور مطالب ── */
.xr-card { border-bottom:none !important; }
.chat-msgs .msg, .chat-msgs .msg-in, .chat-msgs .msg-out { border:none !important; }

/* ── جداکننده‌ی تاریخ در حالت روشن خوانا ── */
html[data-theme="light"] .msg-date-divider span { background:#2b3550 !important; color:#fff !important; border-color:rgba(255,255,255,.16) !important; }

/* ════════════════════════════════════════════════════════════
   v4 — نرمال‌سازیِ کاملِ تم: همه‌ی سطوح هماهنگ با حالت روشن/تیره
   ════════════════════════════════════════════════════════════ */
html[data-theme="dark"]  { --surf:#11161d; --surf2:#171e27; --surf-text:#e6edf3; --surf-muted:#8b98a5; --surf-border:rgba(255,255,255,0.08); --surf-hover:rgba(255,255,255,0.06); }
html[data-theme="light"] { --surf:#ffffff; --surf2:#ffffff; --surf-text:#0f172a; --surf-muted:#64748b; --surf-border:rgba(15,23,42,0.10); --surf-hover:#f1f4f8; }

/* سطوحِ پنجره/منو/شیت/کشو/پیکر — پس‌زمینه و حاشیه‌ی هماهنگ با تم
   (سلکتورهای عمومیِ .modal/.modal-content/.modal-overlay/.menu حذف شدند تا به iframe ترید نشت نکنند) */
html[data-theme] [class*="modal__dialog"], html[data-theme] [class*="modal__header"], html[data-theme] [class*="modal__body"],
html[data-theme] .calendar-widget-modal, html[data-theme] .create-room-modal__dialog,
html[data-theme] .room-settings-modal__dialog, html[data-theme] .room-settings-modal__header--bar,
html[data-theme] .attach-menu, html[data-theme] .contact-context-menu, html[data-theme] .cx-menu,
html[data-theme] .menu-content, html[data-theme] .simple-menu,
html[data-theme] .xr-sheet, html[data-theme] .sa-sheet, html[data-theme] .settings-drawer,
html[data-theme] .emoji-picker, html[data-theme] .mcr-picker, html[data-theme] .reaction-picker,
html[data-theme] .rs-tabpane, html[data-theme] .room-settings-content {
  background: var(--surf2) !important;
  color: var(--surf-text) !important;
  border-color: var(--surf-border) !important;
}

/* متنِ داخلِ این سطوح → رنگِ تمِ جاری (به‌جز دکمه‌های رنگیِ accent) */
html[data-theme] .modal h1, html[data-theme] .modal h2, html[data-theme] .modal h3, html[data-theme] .modal h4, html[data-theme] .modal p, html[data-theme] .modal label, html[data-theme] .modal span, html[data-theme] .modal li,
html[data-theme] [class*="modal__"] h1, html[data-theme] [class*="modal__"] h2, html[data-theme] [class*="modal__"] h3, html[data-theme] [class*="modal__"] h4, html[data-theme] [class*="modal__"] p, html[data-theme] [class*="modal__"] label, html[data-theme] [class*="modal__"] span,
html[data-theme] .menu-item, html[data-theme] .contact-context-menu *, html[data-theme] .cx-menu *, html[data-theme] .simple-menu *, html[data-theme] .attach-menu-item,
html[data-theme] .xr-sheet h1, html[data-theme] .xr-sheet h2, html[data-theme] .xr-sheet h3, html[data-theme] .xr-sheet p, html[data-theme] .xr-sheet span, html[data-theme] .xr-sheet b, html[data-theme] .xr-sheet__title,
html[data-theme] .settings-drawer h1, html[data-theme] .settings-drawer h2, html[data-theme] .settings-drawer h3, html[data-theme] .settings-drawer p, html[data-theme] .settings-drawer label, html[data-theme] .settings-drawer span,
html[data-theme] .sa-sheet * {
  color: var(--surf-text) !important;
}

/* زیرنویس‌ها/eyebrow داخلِ سطوح → کم‌رنگِ خوانا */
html[data-theme] [class*="eyebrow"], html[data-theme] .modal small, html[data-theme] .xr-sheet small, html[data-theme] .settings-drawer small { color: var(--surf-muted) !important; }

/* ورودی‌ها داخلِ سطوح هماهنگ با تم */
html[data-theme] .modal input, html[data-theme] .modal textarea, html[data-theme] .modal select,
html[data-theme] [class*="modal__"] input, html[data-theme] [class*="modal__"] textarea,
html[data-theme] .xr-sheet input, html[data-theme] .settings-drawer input {
  background: var(--surf-hover) !important; color: var(--surf-text) !important; border-color: var(--surf-border) !important;
}

/* hover آیتم‌های منو/فهرست */
html[data-theme] .menu-item:hover, html[data-theme] .contact-context-menu *:hover, html[data-theme] .cx-menu *:hover, html[data-theme] .xr-urow:hover { background: var(--surf-hover) !important; }

/* بک‌دراپِ پنجره‌ها در هر دو تم تیره (برای تمرکز) */
html[data-theme] [class*="__backdrop"], html[data-theme] [class*="__scrim"] { background: rgba(0,0,0,0.5) !important; }

/* نوارِ نوشتنِ پیام و نوار استوری هماهنگ با تم */
html[data-theme] .input-bar, html[data-theme] #mci-root, html[data-theme] .chat-input-container { background: var(--surf) !important; border-color: var(--surf-border) !important; }
html[data-theme] .story-bar { background: transparent !important; }
html[data-theme="light"] .input-bar *, html[data-theme="light"] #mci-root .text-input, html[data-theme="light"] #mci-editor { color: #0f172a !important; }
html[data-theme="light"] .input-bar svg { stroke: #334155 !important; }

/* ── کنتراستِ نوارِ ورودیِ مدرن (#mci-root) در تمِ روشن ── */
/* پس‌زمینهٔ ورودی روشن شود (غلبه بر telegram-theme var(--tg-in)) */
html[data-theme="light"] #mci-root { background: #ffffff !important; }
html[data-theme="light"] #mci-wrap { background: #f1f5f9 !important; border: 1.5px solid #d8dee9 !important; }
html[data-theme="light"] #mci-wrap:focus-within { border-color: rgba(99,102,241,.55) !important; }
html[data-theme="light"] #mci-editor { color: #0f172a !important; }
html[data-theme="light"] #mci-editor:empty::before { color: #94a3b8 !important; }   /* placeholder خوانا */
html[data-theme="light"] #mci-root .mci-t,
html[data-theme="light"] #mci-root .mci-fmt,
html[data-theme="light"] #mci-root #mci-voice { color: #475569 !important; background: rgba(15,23,42,.06) !important; }
html[data-theme="light"] #mci-root .mci-t svg,
html[data-theme="light"] #mci-root #mci-voice svg,
html[data-theme="light"] #mci-root svg { stroke: #475569 !important; }
html[data-theme="light"] #mci-root .mci-t:hover,
html[data-theme="light"] #mci-root .mci-fmt:hover { color: #0f172a !important; background: rgba(15,23,42,.12) !important; }
html[data-theme="light"] #mci-root .mci-t:hover svg { stroke: #0f172a !important; }
html[data-theme="light"] #mci-reply-bar,
html[data-theme="light"] #mci-cc { color: #64748b !important; }
html[data-theme="light"] #mci-root .mci-fmt.on,
html[data-theme="light"] #mci-root .mci-t.on { color: var(--primary,#6366f1) !important; }
html[data-theme="light"] #mci-root .mci-t.on svg { stroke: var(--primary,#6366f1) !important; }
/* دکمهٔ ارسال: همیشه پس‌زمینهٔ پررنگ و آیکونِ سفید (غلبه بر telegram-theme و حالتِ disabled) */
html[data-theme="light"] #mci-send {
    background: linear-gradient(135deg,#6366f1,#8b5cf6) !important;
    color:#fff !important; opacity:1 !important; box-shadow:0 4px 14px rgba(99,102,241,.35) !important;
}
html[data-theme="light"] #mci-send svg { color:#fff !important; stroke:#fff !important; }
html[data-theme="light"] #mci-send:disabled {
    background:#94a3b8 !important; box-shadow:none !important; opacity:1 !important;
}
html[data-theme="light"] #mci-send:disabled svg { stroke:#fff !important; }

/* ── سگمنتِ انتخابِ تم (روشن/خودکار/تیره) ── */
.theme-mode-seg { display:inline-flex; gap:4px; background:rgba(255,255,255,.06); padding:4px; border-radius:12px; }
.theme-mode-seg .tms-btn {
    border:none; background:transparent; color:var(--text-muted,#94a3b8); font-family:Vazir,sans-serif; font-size:13px; font-weight:700;
    padding:7px 14px; border-radius:9px; cursor:pointer; transition:.15s; white-space:nowrap;
}
.theme-mode-seg .tms-btn:hover { color:var(--text-main,#fff); }
.theme-mode-seg .tms-btn--active { background:var(--primary,#6366f1); color:#fff !important; box-shadow:0 2px 8px rgba(99,102,241,.35); }
html[data-theme="light"] .theme-mode-seg { background:rgba(15,23,42,.06); }
html[data-theme="light"] .theme-mode-seg .tms-btn { color:#64748b; }
html[data-theme="light"] .theme-mode-seg .tms-btn:hover { color:#0f172a; }
html[data-theme="light"] .theme-mode-seg .tms-btn--active { color:#fff; }

/* ── پنل «دانلود/نصب اپ» در تنظیمات: تم روشن (استایل‌های inline تیره را override می‌کند) ── */
html[data-theme="light"] #appDownloadBody > div { background:#ffffff !important; border-color:#e2e8f0 !important; }
html[data-theme="light"] #appDownloadBody div[style*="background:#1e293b"] { background:#f1f5f9 !important; border-color:#e2e8f0 !important; color:#334155 !important; }
html[data-theme="light"] #appDownloadBody [style*="color:#cbd5e1"] { color:#334155 !important; }
html[data-theme="light"] #appDownloadBody [style*="color:#e2e8f0;line-height"] { color:#334155 !important; }
html[data-theme="light"] #appDownloadBody [style*="border-top:1px solid #1e2a44"] { border-top-color:#e2e8f0 !important; }

/* ════════════════════════════════════════════════════════════
   v5 — رفعِ پروفایل/تنظیمات/آیکن انجمن در حالت روشن
   ════════════════════════════════════════════════════════════ */
/* تعریفِ --bg-main که هیچ‌جا نبود (روی پروفایل/اکسپلور fallback تیره می‌داد) */
html[data-theme="dark"]  { --bg-main:#0e1217; --bg-elev:#171e27; }
html[data-theme="light"] { --bg-main:#ffffff; --bg-elev:#ffffff; }

/* ── آیکن‌های پنلِ کناری: یکدست در هر تم (شاملِ انجمن) ── */
html[data-theme="light"] .sidebar .nav-btn,
html[data-theme="light"] .sidebar .nav-btn svg { color:#475569 !important; stroke:#475569 !important; }
html[data-theme="dark"]  .sidebar .nav-btn,
html[data-theme="dark"]  .sidebar .nav-btn svg { color:#cbd5e1 !important; stroke:#cbd5e1 !important; }
.sidebar .nav-btn.active, .sidebar .nav-btn.active svg { color:#fff !important; stroke:#fff !important; }

/* ── پروفایل در حالت روشن: متنِ تیره روی سطحِ روشن ── */
html[data-theme="light"] .ig-profile__topbar,
html[data-theme="light"] .ig-profile__tabs { background:#ffffff !important; }
html[data-theme="light"] .ig-profile__topbar-user,
html[data-theme="light"] .ig-profile__stat-num,
html[data-theme="light"] .ig-profile__name,
html[data-theme="light"] .ig-profile__tab--active { color:#0f172a !important; }
html[data-theme="light"] .ig-profile__tab--active { border-bottom-color:#0f172a !important; }
html[data-theme="light"] .ig-profile__bio,
html[data-theme="light"] .ig-profile__stat-label,
html[data-theme="light"] .ig-profile__tab,
html[data-theme="light"] .ig-profile__empty,
html[data-theme="light"] .ig-profile__hl-name { color:#475569 !important; }
html[data-theme="light"] .ig-profile__topbar-btn,
html[data-theme="light"] .ig-profile__btn { color:#0f172a !important; }
html[data-theme="light"] .ig-profile__topbar-btn svg,
html[data-theme="light"] .ig-profile__topbar-actions svg { stroke:#334155 !important; }
html[data-theme="light"] .ig-profile__btn,
html[data-theme="light"] .ig-profile__btn--secondary { background:#eef1f5 !important; border-color:rgba(15,23,42,0.1) !important; }
html[data-theme="light"] .ig-profile__divider { background:rgba(15,23,42,0.08) !important; }
/* پروفایل در دارک خوانا بماند (متن روشن) */
html[data-theme="dark"] .ig-profile__topbar, html[data-theme="dark"] .ig-profile__tabs { background:var(--bg-main) !important; }

/* ── تنظیمات در حالت روشن: کارت‌ها روشن + متنِ تیره ── */
html[data-theme="light"] #settings,
html[data-theme="light"] .settings-section,
html[data-theme="light"] .settings-item { background:#ffffff !important; }
html[data-theme="light"] .settings-section { border:1px solid rgba(15,23,42,0.08) !important; }
html[data-theme="light"] .settings-item { border-bottom:1px solid rgba(15,23,42,0.06) !important; }
html[data-theme="light"] .settings-section-title,
html[data-theme="light"] .settings-item-text h3 { color:#0f172a !important; }
html[data-theme="light"] .settings-item-text p { color:#64748b !important; }
html[data-theme="light"] .settings-item-icon svg { stroke:#334155 !important; }
html[data-theme="light"] .settings-item-icon { background:#eef1f5 !important; color:#334155 !important; }

/* ════════ v6 — رفع باگ‌های قطعی ════════ */
/* آیکن بازی ۵٪ کوچک‌تر (۴۵→۴۳) */
html body #games-nav-btn { width: 43px !important; height: 43px !important; }
html[data-theme] .app-container .sidebar #games-nav-btn { width: 42px !important; height: 42px !important; }

/* آواتارِ بی‌عکس → آدمکِ پیش‌فرض (به‌جای سیاه) */
.c-avatar:empty, .ig-profile__avatar:not([src]), .ig-profile__avatar[src=""],
.story-bar__ring img:not([src]), .story-bar__ring img[src=""] {
  background-image: url('/img/default-avatar.svg') !important; background-size: cover !important; background-position: center !important;
}
img.ig-profile__avatar[src=""], img.c-avatar[src=""] { content: url('/img/default-avatar.svg'); }

/* آیکن‌های استوری: کوچک‌تر و سمت چپ (مثل اینستاگرام) */
.story-actions { left: 0.6rem !important; right: auto !important; gap: 0.7rem !important; }
.story-action-btn svg { width: 20px !important; height: 20px !important; }
.story-action-btn__count, .story-action-btn__text { font-size: 11px !important; }

/* تفاوتِ استوریِ دیده‌شده/نشده: نشده=گرادیانِ accent، دیده‌شده=خاکستریِ کم‌رنگ */
.story-bar__item.is-read .story-bar__ring,
#story-bar .story-ring.is-read {
  background: #4b5563 !important; opacity: 0.55 !important;
}
html[data-theme="light"] .story-bar__item.is-read .story-bar__ring { background: #cbd5e1 !important; }

/* باگ خروج از آمار استوری: شیت‌ها باید بالاتر از آیکن‌های استوری باشند */
#story-insights-sheet, #story-comment-sheet { z-index: 2147483647 !important; }
#story-insights-sheet .story-comment-sheet__scrim, #story-comment-sheet .story-comment-sheet__scrim { pointer-events: auto !important; }
#story-insights-sheet .story-comment-sheet__close { position: relative; z-index: 5; pointer-events: auto !important; }
/* چون داکِ پایین هنگام استوری مخفی است، z-indexِ آیکن‌ها را پایین می‌آوریم تا روی شیت نیفتند */
body.story-viewer-open .story-actions { z-index: 1200 !important; }

/* اسپینرِ ارسالِ عکس + حبابِ در حال آپلود */
@keyframes dyoSpin { to { transform: rotate(360deg); } }
.msg-uploading { opacity: 0.95; }
.msg-uploading .media-wrapper { box-shadow: 0 2px 10px rgba(0,0,0,0.2); }

/* ════ مرکز اعلان (Notification Center) ════ */
#notif-panel { position: fixed; width: 320px; max-width: 92vw; max-height: 70vh; background: var(--surf2, #171e27); color: var(--surf-text, #e6edf3); border: 1px solid var(--surf-border, rgba(255,255,255,0.08)); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,0.4); z-index: 2147483600; display: none; flex-direction: column; overflow: hidden; }
#notif-panel.is-open { display: flex; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.08)); font-weight: 700; font-size: 14px; }
.notif-panel__readall { background: none; border: none; color: var(--primary, #10b981); cursor: pointer; font-size: 12px; font-weight: 700; }
.notif-panel__list { overflow-y: auto; }
.notif-row { display: flex; gap: 10px; padding: 10px 14px; align-items: center; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.05)); }
.notif-row--unread { background: rgba(16,185,129,0.07); }
.notif-row__av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.notif-row__text { font-size: 13px; line-height: 1.5; }
.notif-row__time { font-size: 11px; color: var(--surf-muted, #8b98a5); margin-top: 2px; }
.notif-empty { text-align: center; padding: 30px 14px; color: var(--surf-muted, #8b98a5); font-size: 13px; }

/* ════ مرکز اعلانِ X-مانند (تب/تجمیع/پیش‌نمایش) ════ */
#notif-panel { width: 340px; }
.notif-tabs { display: flex; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.08)); }
.notif-tab { flex: 1; background: none; border: none; padding: 10px 6px; color: var(--surf-muted, #8b98a5); font-size: 13px; font-weight: 700; cursor: pointer; font-family: Vazir, sans-serif; border-bottom: 2px solid transparent; }
.notif-tab--active { color: var(--surf-text, #e6edf3); border-bottom-color: var(--primary, #10b981); }
.notif-row { align-items: flex-start; }
.notif-row--link { cursor: pointer; }
.notif-row--link:hover { background: var(--surf-hover, rgba(255,255,255,0.05)); }
.notif-row__avwrap { position: relative; flex-shrink: 0; }
.notif-row__avs { display: flex; flex-direction: row-reverse; }
.notif-row__badge { position: absolute; bottom: -2px; left: -2px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surf2, #171e27); }
.notif-row__preview { display: flex; align-items: center; gap: 8px; margin-top: 5px; padding: 6px 8px; border-radius: 8px; background: var(--surf-hover, rgba(255,255,255,0.05)); }
.notif-row__preview img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.notif-row__preview span { font-size: 12px; color: var(--surf-muted, #8b98a5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ════ Saved Messages ════ */
.saved-msgs-pin { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; margin-bottom: 4px; background: rgba(16,185,129,0.07); }
.saved-msgs-pin:hover { background: rgba(16,185,129,0.12); }
.saved-pin__av { width: 44px; height: 44px; border-radius: 16px; background: var(--primary, #10b981); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#saved-panel { position: fixed; inset: 0; background: var(--surf, #0e1217); z-index: 2147483500; display: none; align-items: stretch; justify-content: center; }
#saved-panel.is-open { display: flex; }
.saved-panel__sheet { width: 100%; max-width: 620px; height: 100dvh; background: var(--surf, #0e1217); color: var(--surf-text, #e6edf3); display: flex; flex-direction: column; overflow: hidden; }
.saved-panel__head { padding-top: calc(26px + env(safe-area-inset-top)) !important; padding-bottom: 14px !important; }
.saved-panel__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.08)); font-weight: 700; }
.saved-panel__back { background: none; border: none; color: var(--surf-text, #e6edf3); font-size: 24px; cursor: pointer; width: 32px; }
.saved-panel__list { flex: 1; overflow-y: auto; padding: 10px 14px; }
.saved-item { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border-radius: 12px; background: var(--surf-hover, rgba(255,255,255,0.05)); margin-bottom: 8px; }
.saved-item__body { flex: 1; min-width: 0; }
.saved-item__text { font-size: 14px; line-height: 1.6; word-break: break-word; }
.saved-item__del { background: none; border: none; cursor: pointer; opacity: 0.6; font-size: 15px; }
.saved-empty { text-align: center; padding: 40px 14px; color: var(--surf-muted, #8b98a5); }
.saved-panel__compose { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--surf-border, rgba(255,255,255,0.08)); }
.saved-panel__compose input { flex: 1; height: 42px; border-radius: 21px; border: 1px solid var(--surf-border, rgba(255,255,255,0.1)); background: var(--surf-hover, rgba(255,255,255,0.05)); color: var(--surf-text, #e6edf3); padding: 0 16px; font-family: Vazir, sans-serif; outline: none; }
.saved-panel__compose button { background: var(--primary, #10b981); color: #fff; border: none; border-radius: 21px; padding: 0 20px; cursor: pointer; font-weight: 700; font-family: Vazir, sans-serif; }

/* دکمه‌ی پاک‌کردنِ همه‌ی اعلان‌ها */
.notif-panel__clear { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 12px; font-weight: 700; font-family: Vazir, sans-serif; }

/* فاصله‌ی ردیفِ «پیام‌های ذخیره‌شده» از هدرِ بالا */
#saved-msgs-pin { margin-top: 10px !important; }

/* در گروه/کانال/پیام‌های ذخیره‌شده: آیکن‌های تماس صوتی/تصویری/فالو قطعاً مخفی */
#chat-header-bar.chat-header--restricted #chat-call-voice-btn,
#chat-header-bar.chat-header--restricted #chat-call-video-btn,
#chat-header-bar.chat-header--restricted #chat-follow-btn { display: none !important; }

/* حذفِ دکمه‌ی شناورِ ضربدر/همبرگرِ جمع‌کردنِ پنل مخاطبین (فلشِ برگشت کافی است) */
html body #contacts-toggle-btn,
html body.mobile-chat-open #contacts-toggle-btn,
html body:not(.mobile-chat-open) #contacts-toggle-btn { display: none !important; }

/* ════ رسانه‌های مشترک (Shared Media) ════ */
#sharedmedia-panel { position: fixed; inset: 0; background: var(--surf, #0e1217); z-index: 2147483500; display: none; }
#sharedmedia-panel.is-open { display: block; }
.sm-sheet { width: 100%; height: 100dvh; display: flex; flex-direction: column; color: var(--surf-text, #e6edf3); }
.sm-head { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 14px 12px; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.08)); font-weight: 700; }
.sm-back { background: none; border: none; color: var(--surf-text, #e6edf3); font-size: 26px; cursor: pointer; width: 32px; }
.sm-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.08)); }
.sm-tab { white-space: nowrap; background: none; border: none; color: var(--surf-muted, #8b98a5); font-family: Vazir, sans-serif; font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 16px; cursor: pointer; }
.sm-tab--active { color: #fff; background: var(--primary, #10b981); }
.sm-tab i { font-style: normal; opacity: 0.7; font-size: 11px; }
.sm-body { flex: 1; overflow-y: auto; padding: 8px; }
.sm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.sm-cell { position: relative; aspect-ratio: 1/1; overflow: hidden; border-radius: 6px; background: #000; cursor: pointer; }
.sm-cell img, .sm-cell video { width: 100%; height: 100%; object-fit: cover; }
.sm-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.sm-list { display: flex; flex-direction: column; }
.sm-row { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-bottom: 1px solid var(--surf-border, rgba(255,255,255,0.05)); color: inherit; text-decoration: none; }
.sm-row__ic { width: 42px; height: 42px; border-radius: 10px; background: var(--surf-hover, rgba(255,255,255,0.06)); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.sm-row__t { flex: 1; min-width: 0; }
.sm-row__title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-row__sub { font-size: 12px; color: var(--surf-muted, #8b98a5); }
.sm-empty { text-align: center; padding: 50px 14px; color: var(--surf-muted, #8b98a5); }

/* ════ کارتِ فایلِ غیرعکس در چت (تمِ تلگرامی) ════ */
.chat-file-card { display: flex; align-items: center; gap: 11px; min-width: 220px; max-width: 300px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.08); text-decoration: none; color: inherit; }
.chat-file-card:hover { background: rgba(255,255,255,0.12); }
.chat-file-card .cfc-ic { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.3px; flex-shrink: 0; }
.chat-file-card .cfc-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-file-card .cfc-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-file-card .cfc-sub { font-size: 11.5px; opacity: 0.65; margin-top: 2px; }
.chat-file-card .cfc-dl { flex-shrink: 0; opacity: 0.7; }
html[data-theme="light"] .chat-file-card { background: rgba(15,23,42,0.06); }
html[data-theme="light"] .chat-file-card:hover { background: rgba(15,23,42,0.1); }

/* ── هماهنگی تم روشن و تیره در صفحه تماس ── */
html[data-theme="light"] .call-modal { background: rgba(248, 250, 252, 0.95) !important; color: #0f172a !important; }
html[data-theme="light"] .call-modal__body { background: transparent !important; color: #0f172a !important; border-color: transparent !important; }
html[data-theme="light"] .call-header-meta { background: rgba(15, 23, 42, 0.06) !important; color: #0f172a !important; border: 1px solid rgba(0, 0, 0, 0.08) !important; }
html[data-theme="light"] .call-modal .caller-name, html[data-theme="light"] .call-modal .call-status { color: #0f172a !important; text-shadow: none !important; }
html[data-theme="light"] .call-modal .caller-avatar { color: #0f172a !important; background: #e2e8f0 !important; border-color: #cbd5e1 !important; box-shadow: 0 10px 25px rgba(0,0,0,0.05) !important; }
html[data-theme="light"] .call-modal .btn-call-action { background: rgba(15, 23, 42, 0.06) !important; border-color: rgba(15, 23, 42, 0.1) !important; color: #0f172a !important; }
html[data-theme="light"] .call-modal .btn-call-action:hover { background: rgba(15, 23, 42, 0.12) !important; }
html[data-theme="light"] .call-modal .btn-call-action svg { stroke: #0f172a !important; }
html[data-theme="light"] .call-modal .btn-call-minimize { background: rgba(15, 23, 42, 0.06) !important; border-color: rgba(15, 23, 42, 0.1) !important; color: #0f172a !important; }
html[data-theme="light"] .call-modal .btn-call-minimize svg { stroke: #0f172a !important; }
html[data-theme="light"] .call-modal .btn-hangup { background: #ef4444 !important; }
html[data-theme="light"] .call-modal .btn-hangup svg { stroke: white !important; }
html[data-theme="light"] .call-modal .btn-accept { background: #10b981 !important; }
html[data-theme="light"] .call-modal .btn-accept svg { stroke: white !important; }

html[data-theme="dark"] .call-modal { background: rgba(5, 8, 16, 0.9) !important; color: white !important; }
html[data-theme="dark"] .call-modal__body { background: transparent !important; color: white !important; border-color: transparent !important; }
html[data-theme="dark"] .call-header-meta { background: rgba(15, 23, 42, 0.4) !important; color: white !important; border: 1px solid rgba(255, 255, 255, 0.08) !important; }
html[data-theme="dark"] .call-modal .caller-name, html[data-theme="dark"] .call-modal .call-status { color: white !important; text-shadow: 0 4px 12px rgba(0,0,0,0.3) !important; }
html[data-theme="dark"] .call-modal .caller-avatar { color: white !important; }
