        @font-face {
            font-family: 'Vazirmatn';
            src: url('../../fonts/Vazirmatn-Regular.woff2') format('woff2'),
                 url('../../fonts/Vazirmatn-Regular.woff') format('woff');
            font-weight: 100 900;
            font-style: normal;
            font-display: swap;
        }
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Vazirmatn', sans-serif;
            outline: none;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
            -webkit-user-select: none;
        }
        input, textarea {
            user-select: text;
            -webkit-user-select: text;
        }
        /* --- متغیرهای تم (لایت و دارک) --- */
        :root {
            --radius-2xl: 22px;
            --radius-xl: 18px;
            --radius-lg: 14px;
            --bg-body: #0b141b;
            --bg-chat: #0b141b;
            --bg-pattern: radial-gradient(1200px 600px at 10% -20%, rgba(42, 171, 238, 0.1), transparent 60%),
                          radial-gradient(900px 500px at 110% 10%, rgba(114, 167, 255, 0.06), transparent 55%),
                          repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 22px);
            --chat-wallpaper: radial-gradient(900px 400px at 15% -10%, rgba(42, 171, 238, 0.08), transparent 60%),
                              radial-gradient(700px 400px at 90% 10%, rgba(114, 167, 255, 0.05), transparent 60%),
                              repeating-linear-gradient(135deg, rgba(255,255,255,0.025) 0px, rgba(255,255,255,0.025) 1px, transparent 1px, transparent 24px);
            --bg-header: #17212b;
            --bg-input: #17212b;
            --bg-msg-user: #2b5278;
            --bg-msg-other: #182533;
            --text-primary: #e9f1f7;
            --text-secondary: #8fa2b7;
            --border-color: rgba(255,255,255,0.06);
            --primary: #2AABEE;
            --primary-dark: #1b84c2;
            --shadow-msg: 0 2px 6px rgba(0,0,0,0.2);
            --shadow-glow: 0 0 14px rgba(42, 171, 238, 0.25);
            --status-online: #33d17a;
            --status-offline: #ff6b6b;
            --neon-text-color: #cfe8ff;
            --neon-text-shadow: none;
            --danger: #ff4757;
            --reaction-bg: rgba(255,255,255,0.08);
            --reaction-text: #e7eef7;
            --reaction-count: #e7eef7;
            --reaction-border: rgba(255,255,255,0.08);
            --seen-tooltip-bg: #1b2633;
            --seen-tooltip-border: rgba(255,255,255,0.08);
            --seen-tooltip-shadow: 0 10px 28px rgba(0,0,0,0.35);
            --seen-tooltip-arrow: #1b2633;
        }
        /* کلاس لایت مود */
        body.light-mode {
            --bg-body: #e7edf3;
            --bg-chat: #edf2f7;
            --bg-pattern: radial-gradient(1200px 600px at 10% -20%, rgba(42, 171, 238, 0.12), transparent 60%),
                          radial-gradient(900px 500px at 110% 10%, rgba(114, 167, 255, 0.08), transparent 55%),
                          repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 22px);
            --chat-wallpaper: radial-gradient(800px 400px at 20% 0%, rgba(42, 171, 238, 0.07), transparent 60%),
                              radial-gradient(600px 400px at 90% 20%, rgba(114, 167, 255, 0.04), transparent 60%),
                              repeating-linear-gradient(135deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 24px);
            --bg-header: rgba(255, 255, 255, 0.96);
            --bg-input: #ffffff;
            --bg-msg-user: #d9ebff;
            --bg-msg-other: #ffffff;
            --text-primary: #111827;
            --text-secondary: #677788;
            --border-color: rgba(17,24,39,0.08);
            --primary: #2AABEE;
            --primary-dark: #1b84c2;
            --shadow-msg: 0 2px 8px rgba(16,24,40,0.1);
            --shadow-glow: 0 0 12px rgba(42, 171, 238, 0.2);
            --status-online: #2eb872;
            --status-offline: #d24d57;
            --neon-text-color: #2AABEE;
            --neon-text-shadow: none;
            --danger: #ff4757;
            --reaction-bg: rgba(17,24,39,0.08);
            --reaction-text: #111827;
            --reaction-count: #1f2937;
            --reaction-border: rgba(17,24,39,0.08);
            --seen-tooltip-bg: #ffffff;
            --seen-tooltip-border: rgba(17,24,39,0.12);
            --seen-tooltip-shadow: 0 10px 24px rgba(16,24,40,0.12);
            --seen-tooltip-arrow: #ffffff;
        }
        body {
            background: var(--bg-body);
            /* اعمال پترن روی بادی برای اطمینان از پوشش کامل */
            background-image: var(--bg-pattern);
            background-size: auto;
            background-attachment: fixed;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            overflow: hidden;
            color: var(--text-primary);
            transition: background 0.3s ease, color 0.3s ease;
        }
        /* --- انیمیشن‌ها --- */
        @keyframes containerFadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        @keyframes messageSlideIn {
            0% { opacity: 0; transform: translateY(8px); }
            100% { opacity: 1; transform: translateY(0); }
        }
        @keyframes neon-flicker {
            0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
                text-shadow: var(--neon-text-shadow);
            }
            20%, 24%, 55% {
                text-shadow: none;
            }
        }
        @keyframes pulse-status {
            0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7); }
            70% { box-shadow: 0 0 0 6px rgba(0, 255, 136, 0); }
            100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
        }
        @keyframes progressShine {
            0% { background-position: 200% 0; }
            100% { background-position: -200% 0; }
        }
        /* --- کانتینر اصلی --- */
        #main-container {
            width: 100%;
            max-width: 1400px;
            height: 90vh;
            background: var(--bg-chat);
            /* پترن روی کانتینر چت هم تکرار می‌شود برای یکپارچگی */
            background-image: var(--bg-pattern);
            background-size: auto;
            background-position: center;
            background-blend-mode: overlay;
            border-radius: var(--radius-2xl, 24px);
            box-shadow: 0 20px 50px rgba(0,0,0,0.5);
            border: 1px solid var(--border-color);
            display: none;
            flex-direction: column;
            overflow: hidden;
            position: relative;
            animation: containerFadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
        }
        /* --- هدر --- */
        .header {
            background: var(--bg-header);
            backdrop-filter: blur(10px);
            color: var(--text-primary);
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border-color);
            z-index: 10;
            flex-shrink: 0;
            transition: background 0.3s, color 0.3s;
        }
        .header-content {
            display: flex;
            flex-direction: column;
            justify-content: center;
            flex: 1;
            min-width: 0;
        }
        .header-content h1 {
            font-size: 1.4rem;
            font-weight: 800;
            letter-spacing: -0.5px;
            background: linear-gradient(90deg, var(--text-primary), var(--text-secondary));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            line-height: 1.2;
        }
        .header-content .byline {
            font-size: 0.75rem;
            color: var(--text-secondary);
            margin-top: 2px;
            white-space: nowrap; /* جلوگیری از شکستن کلمات */
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }
        .neon-text {
            font-family: 'Courier New', monospace;
            font-weight: bold;
            color: var(--neon-text-color);
            font-size: 0.9rem;
            margin-right: 10px;
            animation: neon-flicker 1.5s infinite alternate;
        }
        .header-actions {
            display: flex;
            gap: 15px;
            flex-shrink: 0;
        }
        .action-btn {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            border: none;
            background: rgba(128,128,128,0.1);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            position: relative;
            overflow: hidden;
        }
        .action-btn::before {
            content: '';
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
            transform: scale(0);
            transition: transform 0.4s ease;
        }
        .action-btn:hover::before {
            transform: scale(1.5);
        }
        .action-btn:hover {
            background: rgba(128,128,128,0.2);
            color: var(--primary);
            transform: scale(1.1) rotate(5deg);
            box-shadow: 0 0 15px rgba(42, 171, 238, 0.3);
        }
        .action-btn svg {
            width: 22px;
            height: 22px;
            stroke-width: 2;
            stroke: currentColor;
            z-index: 1;
        }
        /* --- چت --- */
        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 0;
            background: var(--tg-bg);
            position: relative;
            overflow: hidden;
            min-height: 0;
        }
        #chat-messages {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 14px 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            scroll-behavior: smooth;
        }
        #chat-messages::-webkit-scrollbar {
            width: 6px;
        }
        #chat-messages::-webkit-scrollbar-thumb {
            background-color: rgba(128,128,128,0.3);
            border-radius: 10px;
        }
        /* --- پیام‌ها (Messenger Style) --- */
        .message {
            max-width: 65%;
            padding: 6px 10px 8px;
            border-radius: 12px;
            position: relative;
            font-size: 0.94rem;
            line-height: 1.45;
            cursor: pointer;
            transition: background 0.15s ease;
            animation: messageSlideIn 0.2s ease-out;
            display: flex;
            flex-direction: column;
            word-wrap: break-word;
            border: none;
            touch-action: pan-y;
            box-shadow: 0 1px 1px rgba(0,0,0,0.06);
        }
        .message:hover {
            transform: none;
            filter: none;
        }
        .user-message {
            align-self: flex-end !important;
            background: var(--tg-bubble-out);
            color: #ffffff;
            border-bottom-left-radius: 4px;
        }
        .other-message {
            align-self: flex-start !important;
            background: var(--tg-bubble-in);
            color: var(--tg-text);
            border-bottom-right-radius: 4px;
        }
        .message-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 4px;
            font-size: 0.75rem;
            opacity: 0.9;
            gap: 10px;
        }
        .username {
            font-weight: 600;
            font-size: 0.82rem;
            color: var(--tg-accent);
        }
        /* Username color palette */
        .username[data-color="red"] { color: #e53935; }
        .username[data-color="orange"] { color: #fb8c00; }
        .username[data-color="purple"] { color: #8e24aa; }
        .username[data-color="green"] { color: #43a047; }
        .username[data-color="cyan"] { color: #00acc1; }
        .username[data-color="blue"] { color: #1e88e5; }
        .username[data-color="pink"] { color: #d81b60; }
        .user-message .username {
            color: rgba(255,255,255,0.95);
        }
        .timestamp {
            font-size: 0.65rem;
            opacity: 0.75;
            display: flex;
            align-items: center;
            gap: 4px;
            white-space: nowrap;
            color: var(--tg-text-secondary);
            margin-right: 8px;
            margin-inline-start: auto;
        }
        .user-message .timestamp {
            color: rgba(255,255,255,0.7);
        }
        .edited-badge {
            font-size: 0.6rem;
            background: none;
            padding: 0;
            border-radius: 0;
            color: var(--tg-muted);
            display: none;
        }
        .message-text {
            white-space: pre-wrap;
        }
        .message-image {
            max-width: 100%;
            height: auto;
            max-height: 280px;
            border-radius: 10px;
            margin-top: 4px;
            cursor: pointer;
            display: block;
        }
        .message-video {
            max-width: 100%;
            height: auto;
            max-height: 360px;
            border-radius: 10px;
            margin-top: 4px;
            cursor: pointer;
            display: block;
        }
        .message-audio {
            width: 100%;
            margin-top: 5px;
            height: 40px;
        }
        .message-file {
            display: flex;
            align-items: center;
            gap: 12px;
            background: rgba(128,128,128,0.1);
            padding: 12px;
            border-radius: 12px;
            margin-top: 5px;
            text-decoration: none;
            color: inherit;
            transition: background 0.2s;
        }
        .message-file:hover { background: rgba(128,128,128,0.2); }
        .file-icon { font-size: 1.8rem; }
        .file-info { display: flex; flex-direction: column; }
        .file-name { font-weight: bold; font-size: 0.9rem; }
        .file-size { font-size: 0.75rem; opacity: 0.6; }
        /* --- استایل ریپلای داخل باکس پیام --- */
        .reply-indicator {
            background: var(--tg-hover);
            border-right: 2px solid var(--tg-accent);
            padding: 4px 8px;
            margin-bottom: 4px;
            font-size: 0.75rem;
            border-radius: 4px;
            color: var(--tg-text-secondary);
            display: none;
        }
        .reply-indicator strong {
            color: var(--tg-accent);
        }
        /* --- استایل‌های ری‌اکشن (Reaction) --- */
        .reaction-bar {
            display: flex;
            gap: 4px;
            margin-top: 6px;
            padding-top: 6px;
            border-top: none;
            flex-wrap: wrap;
        }
        .reaction-item {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            background: var(--tg-hover);
            padding: 2px 6px;
            border-radius: 10px;
            font-size: 0.82rem;
            cursor: pointer;
            transition: transform 0.15s ease, background 0.15s ease;
            user-select: none;
            color: var(--tg-text);
            border: none;
        }
        .reaction-item:hover {
            transform: scale(1.05);
            background: var(--tg-accent);
            color: #fff;
        }
        .reaction-count {
            font-size: 0.72rem;
            font-weight: 500;
            color: inherit;
        }
        .reaction-item.is-active {
            background: var(--tg-accent);
            color: #ffffff;
        }
        .reaction-item.is-active .reaction-count {
            color: #ffffff;
        }
        /* --- استایل‌های Seen --- */
        .seen-indicator {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            margin-inline-start: 6px;
            position: relative;
            font-size: 0.65rem;
            color: var(--text-secondary);
            opacity: 0.85;
            line-height: 1;
        }
        .user-message .seen-indicator {
            color: rgba(0,0,0,0.55);
        }
        .seen-indicator .seen-checks {
            display: inline-flex;
            gap: 1px;
            font-size: 0.7rem;
            line-height: 1;
        }
        .seen-indicator .seen-checks span {
            display: inline-block;
            transform: translateY(1px);
        }
        .seen-indicator[data-empty="false"] .seen-checks {
            color: var(--primary);
        }
        .seen-indicator[data-empty="true"] .seen-checks span:last-child {
            display: none;
        }
        .seen-indicator[data-empty="true"] .seen-checks {
            opacity: 0.5;
        }
        .seen-indicator .seen-count {
            min-width: 14px;
            height: 14px;
            padding: 0 4px;
            border-radius: 999px;
            background: rgba(42, 171, 238, 0.16);
            color: var(--primary);
            font-weight: 700;
            font-size: 0.6rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .seen-indicator[data-empty="true"] .seen-count,
        .seen-indicator[data-count="0"] .seen-count,
        .seen-indicator[data-count="1"] .seen-count {
            display: none;
        }
        .seen-indicator .seen-tooltip {
            --tooltip-shift-x: 0px;
            position: absolute;
            bottom: calc(100% + 8px);
            right: 0;
            background: var(--seen-tooltip-bg);
            border: 1px solid var(--seen-tooltip-border);
            box-shadow: var(--seen-tooltip-shadow);
            color: var(--text-primary);
            padding: 10px 12px;
            border-radius: 12px;
            font-size: 0.75rem;
            line-height: 1.6;
            white-space: pre-line;
            text-align: right;
            overflow-wrap: anywhere;
            word-break: break-word;
            display: block;
            box-sizing: border-box;
            opacity: 0;
            transform: translate(var(--tooltip-shift-x), 6px);
            pointer-events: none;
            transition: all 0.2s ease;
            width: max-content;
            min-width: 140px;
            max-width: min(240px, 70vw);
            max-height: min(240px, 45vh);
            overflow-y: auto;
            z-index: 30;
        }
        .seen-indicator .seen-tooltip::-webkit-scrollbar {
            width: 4px;
        }
        .seen-indicator .seen-tooltip::-webkit-scrollbar-thumb {
            background-color: rgba(128,128,128,0.4);
            border-radius: 10px;
        }
        .seen-indicator .seen-tooltip::after {
            content: '';
            position: absolute;
            bottom: -6px;
            right: 16px;
            width: 12px;
            height: 12px;
            background: var(--seen-tooltip-arrow);
            border-right: 1px solid var(--seen-tooltip-border);
            border-bottom: 1px solid var(--seen-tooltip-border);
            transform: rotate(45deg);
        }
        .seen-indicator .seen-tooltip.is-bottom {
            top: calc(100% + 8px);
            bottom: auto;
        }
        .seen-indicator .seen-tooltip.is-bottom::after {
            top: -6px;
            bottom: auto;
        }
        @media (max-width: 768px) {
            .seen-indicator .seen-tooltip {
                font-size: 0.78rem;
                max-width: min(300px, 86vw);
                max-height: min(260px, 40vh);
            }
        }
        .seen-indicator:hover .seen-tooltip,
        .seen-indicator.is-open .seen-tooltip {
            opacity: 1;
            transform: translate(var(--tooltip-shift-x), 0);
            pointer-events: auto;
        }
        /* --- Typing Indicator --- */
        .typing-indicator {
            display: none;
            align-items: center;
            gap: 6px;
            padding: 8px 12px;
            background: var(--tg-bubble-in);
            border-radius: 12px;
            border-bottom-right-radius: 4px;
            margin: 4px 0;
            max-width: fit-content;
            animation: fadeIn 0.2s ease;
        }
        .typing-indicator.visible {
            display: inline-flex;
        }
        .typing-indicator-name {
            font-size: 0.8rem;
            color: var(--tg-accent);
            font-weight: 500;
        }
        .typing-dots {
            display: flex;
            align-items: center;
            gap: 3px;
        }
        .typing-dots span {
            width: 6px;
            height: 6px;
            background: var(--tg-muted);
            border-radius: 50%;
            animation: typingBounce 1.4s infinite ease-in-out;
        }
        .typing-dots span:nth-child(1) { animation-delay: 0s; }
        .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
        .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
        @keyframes typingBounce {
            0%, 60%, 100% { transform: translateY(0); }
            30% { transform: translateY(-4px); }
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(5px); }
            to { opacity: 1; transform: translateY(0); }
        }
        /* --- Message Status Check Marks --- */
        .message-status {
            display: inline-flex;
            align-items: center;
            margin-inline-start: 4px;
            color: var(--tg-muted);
        }
        .message-status svg {
            width: 16px;
            height: 12px;
        }
        .message-status.sent svg {
            color: var(--tg-muted);
        }
        .message-status.delivered svg {
            color: var(--tg-muted);
        }
        .message-status.read svg {
            color: var(--tg-accent);
        }
        .user-message .message-status {
            color: rgba(255,255,255,0.7);
        }
        .user-message .message-status.read svg {
            color: rgba(255,255,255,0.9);
        }
        /* منوی انتخاب ری‌اکشن */
        .reaction-picker {
            position: fixed;
            background: var(--bg-header);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            padding: 10px;
            display: none;
            z-index: 9999;
            gap: 10px;
            animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            flex-wrap: wrap;
            max-width: 300px;
        }
        @keyframes popIn {
            from { opacity: 0; transform: scale(0.5); }
            to { opacity: 1; transform: scale(1); }
        }
        .reaction-picker-emoji {
            font-size: 1.8rem;
            cursor: pointer;
            transition: transform 0.2s;
            display: inline-block;
            line-height: 1;
        }
        .reaction-picker-emoji:hover { transform: scale(1.3); }
        /* --- ورودی پیام --- */
        .input-area-wrapper {
            padding: 1.5rem 2rem;
            background: var(--bg-header);
            backdrop-filter: blur(10px);
            border-top: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            gap: 12px;
            position: relative;
            z-index: 20;
            flex-shrink: 0;
            transition: background 0.3s;
        }
        .desktop-input-row {
            display: flex;
            gap: 12px;
            align-items: center;
            position: relative;
        }
        .desktop-input {
            flex: 1;
            padding: 14px 24px;
            border: 1px solid var(--border-color);
            border-radius: 24px;
            font-size: 1rem;
            transition: all 0.3s ease;
            background: var(--bg-input);
            color: var(--text-primary);
            height: 54px;
        }
        .desktop-input:focus {
            border-color: var(--primary);
            background: var(--bg-header);
            box-shadow: 0 0 15px rgba(42, 171, 238, 0.2);
        }
        .send-btn {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: white;
            width: auto;
            padding: 0 2.5rem;
            border-radius: 24px;
            font-weight: 700;
            font-size: 1rem;
            border: none;
            height: 54px;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            box-shadow: 0 4px 15px rgba(42, 171, 238, 0.4);
            position: relative;
            overflow: hidden;
        }
        .send-btn:hover {
            transform: translateY(-2px) scale(1.05);
            box-shadow: 0 8px 25px rgba(42, 171, 238, 0.6);
        }
        .send-btn::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            transform: translate(-50%, -50%);
            transition: width 0.6s ease, height 0.6s ease;
        }
        .send-btn:active::after {
            width: 300px;
            height: 300px;
        }
        /* --- ایموجی پیکر --- */
        .emoji-picker {
            position: absolute;
            bottom: 80px;
            right: 0;
            background: var(--bg-header);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.3);
            padding: 10px;
            display: none;
            z-index: 1000;
            width: 350px;
            height: 120px;
            overflow-x: auto;
            overflow-y: hidden;
            white-space: nowrap;
            animation: slideUpFade 0.3s ease;
        }
        @keyframes slideUpFade {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .emoji-grid {
            display: flex;
            flex-wrap: nowrap;
            gap: 8px;
            height: 100%;
            align-items: center;
        }
        .emoji {
            font-size: 1.8rem;
            cursor: pointer;
            text-align: center;
            padding: 5px;
            border-radius: 8px;
            transition: all 0.2s;
            text-decoration: none;
            color: inherit;
            flex-shrink: 0;
            display: inline-block;
        }
        .emoji:hover {
            background: rgba(128,128,128,0.2);
            transform: scale(1.2);
        }
        /* --- مودال‌ها --- */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            backdrop-filter: blur(3px);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 3000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
        }
        .modal-overlay.active {
            opacity: 1;
            visibility: visible;
        }
        .modal-content {
            background: var(--tg-surface);
            padding: 24px;
            border-radius: 16px;
            width: 90%;
            max-width: 400px;
            text-align: center;
            box-shadow: 0 16px 48px rgba(0,0,0,0.3);
            border: none;
            transform: scale(0.95) translateY(10px);
            transition: transform 0.2s ease;
            color: var(--text-primary);
        }
        .modal-overlay.active .modal-content {
            transform: scale(1) translateY(0);
        }
        .login-input {
            width: 100%;
            padding: 16px;
            margin-bottom: 25px;
            border: 1px solid var(--border-color);
            border-radius: 16px;
            font-size: 1.1rem;
            text-align: center;
            background: var(--bg-input);
            color: var(--text-primary);
            transition: 0.3s;
        }
        .login-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 15px rgba(42, 171, 238, 0.3);
        }
        .login-btn {
            width: 100%;
            padding: 14px;
            border-radius: 12px;
            font-size: 1rem;
            background: var(--tg-accent);
            color: white;
            border: none;
            cursor: pointer;
            font-weight: 600;
            box-shadow: none;
            transition: background 0.15s ease;
        }
        .login-btn:hover { 
            background: var(--tg-accent-2);
        }
        /* --- منوی زمینه (Context Menu) --- */
        .message-context-menu {
            position: fixed;
            background: var(--tg-surface);
            border-radius: 12px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.25);
            padding: 6px 0;
            min-width: 160px;
            max-width: 220px;
            z-index: 2000;
            display: none;
            border: 1px solid var(--tg-divider);
            animation: menuPop 0.15s ease;
        }
        @keyframes menuPop {
            from { opacity: 0; transform: scale(0.95); }
            to { opacity: 1; transform: scale(1); }
        }
        .menu-item {
            padding: 10px 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 10px;
            color: var(--tg-text);
            font-size: 0.9rem;
            transition: background 0.15s ease;
        }
        .menu-item:hover {
            background: var(--tg-hover);
        }
        .menu-item svg { width: 18px; height: 18px; stroke: currentColor; }
        .menu-item.delete-item:hover {
            background: rgba(239, 68, 68, 0.15);
            color: #ef4444;
        }
        /* --- لایت‌باکس --- */
        .lightbox-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.95);
            z-index: 5000;
            display: none;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .lightbox-modal.active { display: flex; opacity: 1; }
        .lightbox-img {
            max-width: 90%;
            max-height: 85vh;
            border-radius: 8px;
            box-shadow: 0 0 50px rgba(0,0,0,0.8);
            object-fit: contain;
            animation: zoomIn 0.3s ease;
        }
        @keyframes zoomIn { from { transform: scale(0.9); } to { transform: scale(1); } }
        .lightbox-close {
            position: absolute;
            top: 30px;
            right: 30px;
            color: white;
            font-size: 3rem;
            cursor: pointer;
            background: none;
            border: none;
            z-index: 5001;
            transition: transform 0.2s;
        }
        .lightbox-close:hover { transform: rotate(90deg); color: var(--primary); }
        /* --- فوتر --- */
        .footer {
            padding: 10px 2rem;
            background: var(--bg-header);
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.8rem;
            color: var(--text-secondary);
            transition: background 0.3s;
        }
        .connection-status {
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: bold;
            font-size: 0.85rem;
            padding: 6px 12px;
            border-radius: 20px;
            background: rgba(128,128,128,0.1);
            transition: all 0.3s;
        }
        .status-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background-color: var(--status-offline);
            box-shadow: 0 0 5px var(--status-offline);
            transition: all 0.3s;
        }
        .connection-status.online .status-dot {
            background-color: var(--status-online);
            box-shadow: 0 0 8px var(--status-online);
            animation: pulse-status 2s infinite;
        }
        .connection-status.online {
            color: var(--status-online);
            border: 1px solid rgba(0, 255, 136, 0.2);
        }
        .connection-status.offline {
            color: var(--status-offline);
            border: 1px solid rgba(255, 75, 75, 0.2);
        }
        /* --- مدیا کوئری موبایل --- */
        @media (max-width: 1024px) {
            body {
                padding: 0;
                background: var(--bg-body);
                height: 100vh;
                width: 100vw;
                position: fixed;
                overflow: hidden;
            }
            #main-container {
                border-radius: 0;
                height: 100vh;
                width: 100%;
                max-width: none;
                border: none;
                box-shadow: none;
                display: none;
            }
            .header {
                padding: 10px 15px;
                background: var(--bg-header);
                flex-shrink: 0;
                height: auto;
                min-height: 60px;
            }
            .header-content {
                flex-direction: column;
                align-items: flex-start;
                text-align: right;
            }
            .header-content h1 {
                font-size: 1.1rem;
                line-height: 1.2;
            }
            .header-content .byline {
                font-size: 0.65rem;
                margin-top: 2px;
                display: flex;
                align-items: center;
                flex-wrap: nowrap;
                justify-content: flex-start;
            }
            .neon-text {
                font-size: 0.7rem;
                margin-right: 5px;
            }
            #notif-btn { display: none !important; }
            .chat-container {
                padding: 0;
                flex-grow: 1;
                display: flex;
                flex-direction: column;
                overflow: hidden;
                background: transparent;
                position: relative;
                height: calc(100vh - 60px);
            }
            #chat-messages {
                flex-grow: 1;
                width: 100%;
                height: calc(100vh - 200px);
                border: none;
                border-radius: 0;
                background: transparent;
                padding: 15px;
                padding-bottom: 200px;
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
                scroll-behavior: smooth;
            }
            .message {
                max-width: 85%;
                padding: 10px 14px;
                margin-bottom: 8px;
                border-radius: 20px;
                box-shadow: var(--shadow-msg);
                display: flex;
                flex-direction: column;
                animation: slideInMobile 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
            }
            @keyframes slideInMobile {
                from { opacity: 0; transform: translateY(10px) scale(0.95); }
                to { opacity: 1; transform: translateY(0) scale(1); }
            }
            .user-message {
                background: var(--bg-msg-user);
                color: #000000;
                margin-right: auto;
                margin-left: 0;
                border-bottom-right-radius: 4px;
            }
            .other-message {
                background: var(--bg-msg-other);
                margin-left: auto;
                margin-right: 0;
                border-bottom-left-radius: 4px;
            }
            .message-header {
                display: flex;
                align-items: center;
                margin-bottom: 4px;
                font-size: 0.7rem;
                color: var(--text-secondary);
                margin-top: 2px;
            }
            .username {
                font-weight: 600;
                color: var(--primary);
                margin-left: 8px;
                font-size: 0.8rem;
            }
            .user-message .username {
                color: #000000;
                opacity: 0.7;
            }
            .timestamp {
                font-size: 0.65rem;
                color: var(--text-secondary);
            }
            .message-text {
                font-size: 0.95rem;
                line-height: 1.4;
                color: inherit;
            }
            .message-image {
                max-width: 100%;
                height: auto;
                max-height: 250px;
                border-radius: 12px;
                margin-top: 8px;
            }
            .message-video {
                max-width: 100%;
                height: auto;
                max-height: 300px;
                border-radius: 12px;
                margin-top: 8px;
            }
            .message-audio {
                width: 100%;
                margin-top: 8px;
                height: 35px;
            }
            .footer { display: none; }
            /* --- کانتینر شناور موبایل --- */
            .mobile-floating-container {
                position: fixed;
                bottom: 0;
                left: 0;
                width: 100%;
                height: auto;
                min-height: 54px;
                background: var(--tg-surface);
                border-top: 1px solid var(--tg-divider);
                z-index: 100;
                padding: 8px 10px;
                padding-bottom: max(6px, env(safe-area-inset-bottom));
                display: flex;
                flex-direction: column;
                gap: 6px;
                box-shadow: none;
            }
            .mobile-input-row {
                display: flex;
                flex-direction: row;
                align-items: center;
                gap: 8px;
                background: var(--tg-input);
                border: 1px solid var(--tg-divider);
                border-radius: 24px;
                padding: 6px 8px;
            }
            .mobile-floating-input {
                flex: 1;
                padding: 10px 8px;
                border: none;
                border-radius: 20px;
                background: transparent;
                color: var(--tg-text);
                font-size: 0.95rem;
                outline: none;
                transition: background 0.15s ease;
                min-height: 42px;
            }
            .mobile-floating-input:focus {
                background: var(--tg-surface-2);
            }
            .mobile-icon-btn {
                width: 42px;
                height: 42px;
                flex: none;
                border-radius: 50%;
                border: none;
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
                transition: all 0.15s ease;
                font-size: 0.85rem;
                gap: 6px;
                color: #fff;
                position: relative;
                overflow: hidden;
            }
            .mobile-icon-btn svg {
                width: 22px;
                height: 22px;
                fill: currentColor;
            }
            .mobile-icon-btn:active {
                transform: scale(0.96);
                opacity: 0.9;
            }
            .mobile-icon-btn::after {
                display: none;
            }
            .btn-voice {
                background: rgba(112,117,121,0.12);
                color: var(--tg-muted);
                box-shadow: none;
            }
            .btn-voice svg {
                fill: var(--tg-muted);
            }
            .btn-send {
                background: var(--tg-accent);
                width: 56px;
                height: 56px;
                font-weight: 500;
                box-shadow: 0 8px 18px rgba(42,171,238,0.35);
            }
            .btn-send:hover {
                background: var(--tg-accent-2);
            }
            .btn-send svg {
                fill: #ffffff;
            }
            .btn-image {
                background: rgba(42,171,238,0.12);
                color: var(--tg-accent);
                box-shadow: none;
            }
            .btn-image svg {
                stroke: var(--tg-accent);
                fill: none;
            }
            .mobile-reply-indicator {
                background: var(--tg-hover);
                padding: 6px 10px;
                border-radius: 8px;
                font-size: 0.8rem;
                color: var(--tg-accent);
                display: none;
                border-right: 2px solid var(--tg-accent);
                animation: slideUp 0.15s ease;
                flex-direction: row;
                align-items: center;
                justify-content: space-between;
            }
            .mobile-reply-indicator.visible {
                display: flex;
            }
            @keyframes slideUp {
                from { opacity: 0; transform: translateY(10px); }
                to { opacity: 1; transform: translateY(0); }
            }
            .message-context-menu {
                position: fixed;
                bottom: 90px;
                left: 50%;
                transform: translateX(-50%);
                width: 90%;
                max-width: 320px;
                border-radius: 20px;
                box-shadow: 0 10px 40px rgba(0,0,0,0.6);
            }
            .swipe-reply-overlay {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(42, 171, 238, 0.15);
                display: flex;
                align-items: center;
                justify-content: flex-start;
                padding-left: 20px;
                opacity: 0;
                pointer-events: none;
                transition: opacity 0.2s;
                border-radius: inherit;
            }
            .swipe-reply-overlay i {
                color: var(--primary);
                font-size: 1.5rem;
                transform: translateX(-20px);
                transition: transform 0.2s;
            }
            .message.swiping .swipe-reply-overlay {
                opacity: 1;
            }
            .message.swiping .swipe-reply-overlay i {
                transform: translateX(0);
            }
            #edit-modal .modal-content {
                width: 95%;
                padding: 1.5rem;
            }
            #edit-textarea {
                width: 100%;
                min-height: 150px;
                font-size: 1.1rem;
            }
        }
        @media (max-width: 480px) {
            .header h1 { font-size: 1rem; }
            .message { max-width: 90%; }
        }
        /* --- استایل مودال پیش‌نمایش آپلود (Preview Modal) --- */
        #upload-preview-modal .modal-content {
            max-width: 500px;
            padding: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            background: var(--bg-chat);
            border: 1px solid var(--border-color);
        }
        .preview-header {
            padding: 15px;
            background: var(--bg-header);
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .preview-header h3 {
            font-size: 1rem;
            color: var(--text-primary);
        }
        .preview-close-btn {
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 1.5rem;
            cursor: pointer;
        }
        .preview-body {
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: var(--bg-chat);
            min-height: 200px;
        }
        .preview-media-container {
            width: 100%;
            max-height: 50vh;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 12px;
            overflow: hidden;
            background: rgba(0,0,0,0.1);
        }
        #preview-image {
            max-width: 100%;
            max-height: 50vh;
            object-fit: contain;
        }
        #preview-video {
            max-width: 100%;
            max-height: 50vh;
        }
        #preview-audio {
            width: 100%;
            margin-top: 10px;
        }
        .preview-caption-input {
            width: 100%;
            margin-top: 15px;
            padding: 12px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            background: var(--bg-input);
            color: var(--text-primary);
            resize: none;
            font-family: inherit;
        }
        .preview-footer {
            padding: 15px;
            background: var(--bg-header);
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: center;
            gap: 10px;
        }
        .preview-send-btn {
            background: var(--tg-accent);
            color: white;
            border: none;
            padding: 12px 28px;
            border-radius: 12px;
            font-weight: 600;
            cursor: pointer;
            box-shadow: none;
            transition: background 0.15s ease;
        }
        .preview-send-btn:hover {
            background: var(--tg-accent-2);
        }
        /* --- استایل مودال ارسال با لینک --- */
        #link-modal .modal-content {
            max-width: 520px;
            padding: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            background: var(--bg-chat);
            border: 1px solid var(--border-color);
        }
        .link-modal-body {
            padding: 18px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        .link-choice-row {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .link-choice-btn {
            border: 1px solid var(--border-color);
            background: rgba(255,255,255,0.05);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 700;
        }
        .link-choice-btn.secondary {
            background: transparent;
            color: var(--text-secondary);
        }
        .link-input-row {
            display: flex;
            gap: 8px;
            align-items: center;
        }
        .link-input {
            flex: 1;
            padding: 12px 14px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            background: var(--bg-input);
            color: var(--text-primary);
            font-size: 0.95rem;
        }
        .link-preview-btn {
            border: none;
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: #fff;
            padding: 10px 14px;
            border-radius: 12px;
            font-weight: 700;
            cursor: pointer;
            flex-shrink: 0;
        }
        .link-preview-area {
            width: 100%;
            min-height: 160px;
            border-radius: 14px;
            background: rgba(0,0,0,0.1);
            border: 1px dashed var(--border-color);
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            padding: 8px;
        }
        .link-preview-hint {
            font-size: 0.85rem;
            color: var(--text-secondary);
            text-align: center;
        }
        #link-preview-image,
        #link-preview-video {
            max-width: 100%;
            max-height: 50vh;
            border-radius: 12px;
        }
        #link-preview-audio {
            width: 100%;
        }
        .link-preview-file {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            background: rgba(255,255,255,0.05);
            color: var(--text-secondary);
            width: 100%;
        }
        .link-preview-stream {
            width: 100%;
            min-height: 112px;
            border-radius: 16px;
            padding: 14px;
            display: flex;
            align-items: center;
            gap: 12px;
            background: linear-gradient(135deg, rgba(42, 171, 238, 0.18), rgba(120, 210, 99, 0.1));
            border: 1px solid rgba(42, 171, 238, 0.24);
            color: var(--text-primary);
        }
        .link-stream-icon {
            width: 52px;
            height: 52px;
            border-radius: 18px;
            display: grid;
            place-items: center;
            background: rgba(42, 171, 238, 0.16);
            color: var(--primary);
            flex: 0 0 auto;
        }
        .link-stream-icon svg {
            width: 27px;
            height: 27px;
        }
        .link-preview-stream strong,
        .link-preview-stream span {
            display: block;
        }
        .link-preview-stream strong {
            font-size: 0.98rem;
            font-weight: 800;
        }
        .link-preview-stream span {
            margin-top: 4px;
            color: var(--text-secondary);
            font-size: 0.8rem;
            line-height: 1.7;
        }
        @media (max-width: 480px) {
            .link-input-row {
                flex-direction: column;
                align-items: stretch;
            }
            .link-preview-btn {
                width: 100%;
            }
        }
        /* --- استایل مودال آپلود (Upload Progress) --- */
        #upload-progress-modal .modal-content {
            max-width: 400px;
            padding: 2rem;
            text-align: center;
            background: var(--bg-header);
            border: 1px solid var(--border-color);
        }
        .upload-icon-wrapper {
            font-size: 3rem;
            margin-bottom: 1rem;
            color: var(--primary);
            animation: bounce 2s infinite;
        }
        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
            40% {transform: translateY(-10px);}
            60% {transform: translateY(-5px);}
        }
        .progress-container {
            width: 100%;
            background-color: rgba(128,128,128,0.2);
            border-radius: 10px;
            margin: 20px 0;
            overflow: hidden;
            height: 10px;
            position: relative;
        }
        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, var(--primary), var(--primary-dark), #4facfe);
            background-size: 200% 100%;
            width: 0%;
            border-radius: 10px;
            transition: width 0.2s ease;
            animation: progressShine 1.5s infinite linear;
        }
        .upload-status-text {
            font-size: 1.1rem;
            font-weight: bold;
            color: var(--text-primary);
            margin-bottom: 5px;
        }
        .upload-percentage {
            font-size: 2rem;
            font-weight: 800;
            color: var(--primary);
            text-shadow: 0 0 10px rgba(42, 171, 238, 0.3);
        }
        .upload-error-text {
            color: var(--danger);
            font-weight: bold;
            margin-top: 10px;
            display: none;
        }
        /* --- Web Inspired Layer --- */
        :root {
            --mobile-header-height: 56px;
            --mobile-input-height: 100px;
        }
        body {
            min-height: 100dvh;
            padding: 0;
            justify-content: stretch;
            align-items: stretch;
        }
        #main-container {
            width: 100%;
            max-width: 100%;
            height: 100dvh;
            background: var(--bg-chat);
            background-image: none;
            border-radius: 0;
            border: none;
            box-shadow: none;
        }
        #main-container::before {
            content: '';
            position: absolute;
            inset: 0;
            background: radial-gradient(800px 360px at 15% -10%, rgba(42, 171, 238, 0.16), transparent 62%),
                        radial-gradient(650px 340px at 95% 10%, rgba(122, 216, 255, 0.09), transparent 62%);
            opacity: 0.35;
            pointer-events: none;
            z-index: 0;
        }
        #main-container > * {
            position: relative;
            z-index: 1;
        }
        .header {
            padding: 0.75rem 1.4rem;
            background: var(--bg-header);
            border-bottom: 1px solid var(--border-color);
        }
        .header-content {
            position: relative;
            padding-right: 56px;
            gap: 2px;
        }
        .header-content::before {
            content: 'A';
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 44px;
            height: 44px;
            border-radius: 50%;
            background: radial-gradient(circle at 30% 30%, #7ad8ff, #2aabee 60%, #1d6ea5 100%);
            box-shadow: 0 10px 24px rgba(0,0,0,0.35);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 0.95rem;
            color: #ffffff;
            letter-spacing: 0.5px;
        }
        .header-content::after {
            content: '';
            position: absolute;
            right: 2px;
            bottom: 6px;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: var(--status-online);
            box-shadow: 0 0 8px var(--status-online);
            border: 2px solid var(--bg-header);
        }
        .header-content h1 {
            font-size: 1.2rem;
            font-weight: 700;
            letter-spacing: 0;
            background: none;
            -webkit-text-fill-color: unset;
            color: var(--text-primary);
        }
        .header-content .byline {
            font-size: 0.72rem;
            color: var(--text-secondary);
        }
        .neon-text {
            font-family: inherit;
            font-weight: 600;
            font-size: 0.75rem;
            margin-right: 6px;
            animation: none;
            text-shadow: none;
        }
        .header-actions {
            gap: 10px;
        }
        .action-btn {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            background: rgba(255,255,255,0.06);
            border: 1px solid var(--border-color);
            transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
        }
        .action-btn:hover {
            transform: translateY(-1px);
            color: var(--primary);
            box-shadow: 0 8px 20px rgba(42, 171, 238, 0.2);
        }
        .action-btn:active {
            transform: translateY(0) scale(0.98);
        }
        .action-btn::before {
            display: none;
        }
        .chat-container {
            background: transparent;
        }
        #chat-messages {
            padding: 1.3rem 1.6rem 2.6rem;
            background: var(--bg-chat);
            background-image: var(--chat-wallpaper);
            scroll-padding-bottom: 180px;
            gap: 0.7rem;
        }
        .message {
            max-width: 72%;
            border-radius: 18px;
            border: 1px solid rgba(255,255,255,0.06);
            box-shadow: var(--shadow-msg);
            padding: 8px 12px;
        }
        body.light-mode .message {
            border-color: rgba(15,23,42,0.06);
            box-shadow: 0 2px 8px rgba(15,23,42,0.08);
        }
        .message::after {
            display: none;
        }
        .user-message {
            color: #ffffff;
            background: var(--tg-bubble-out);
        }
        body.light-mode .user-message {
            color: #000000;
            background: var(--tg-bubble-out);
        }
        .user-message::after {
            display: none;
        }
        .other-message::after {
            display: none;
        }
        .message-header {
            font-size: 0.7rem;
            opacity: 0.82;
        }
        .username {
            color: var(--tg-accent);
            font-weight: 600;
        }
        .user-message .username {
            color: rgba(255,255,255,0.9);
        }
        body.light-mode .user-message .username {
            color: #2a7a45;
            opacity: 1;
        }
        body.light-mode .user-message .timestamp {
            color: rgba(0,0,0,0.5);
        }
        .timestamp {
            color: var(--text-secondary);
            opacity: 0.75;
        }
        .input-area-wrapper {
            padding: 0.9rem 1.2rem 1.1rem;
            background: var(--bg-header);
            border-top: 1px solid var(--border-color);
            box-shadow: 0 -8px 18px rgba(0,0,0,0.25);
        }
        .desktop-input-row {
            background: rgba(255,255,255,0.05);
            border: 1px solid var(--border-color);
            border-radius: 999px;
            padding: 6px 8px;
        }
        .desktop-input {
            background: transparent;
            border: none;
            height: 44px;
            padding: 0 14px;
        }
        .desktop-input:focus {
            box-shadow: none;
        }
        .send-btn {
            height: 40px;
            padding: 0 20px;
            border-radius: 20px;
            font-size: 0.88rem;
            font-weight: 500;
            box-shadow: none;
        }
        .emoji-picker {
            border-radius: 18px;
            background: var(--bg-header);
            border: 1px solid var(--border-color);
        }
        .mobile-floating-container {
            background: rgba(23, 33, 43, 0.92);
            border-top: 1px solid var(--border-color);
            border-radius: 18px 18px 0 0;
            min-height: var(--mobile-input-height);
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
            backdrop-filter: blur(16px);
        }
        .mobile-floating-input {
            background: rgba(255,255,255,0.06);
            border-radius: 999px;
            border: 1px solid var(--border-color);
        }
        .mobile-icon-btn {
            border-radius: 14px;
        }
        .btn-voice {
            background: linear-gradient(135deg, #2c3e50, #1f2a36);
        }
        .btn-send {
            background: linear-gradient(135deg, #2aabee, #1d8dbd);
        }
        .btn-image {
            background: linear-gradient(135deg, #3271ff, #1f4db4);
        }
        body.light-mode .header {
            background: #ffffff;
            border-bottom: 1px solid rgba(17,24,39,0.08);
            box-shadow: 0 6px 18px rgba(16,24,40,0.08);
        }
        body.light-mode .mobile-floating-container {
            background: rgba(255,255,255,0.95);
            border-top: 1px solid rgba(17,24,39,0.08);
            box-shadow: 0 -6px 18px rgba(16,24,40,0.06);
        }
        body.light-mode .desktop-input-row {
            background: rgba(17,24,39,0.03);
        }
        body.light-mode .mobile-floating-input {
            background: #f8fafc;
            border-color: rgba(17,24,39,0.1);
            color: var(--text-primary);
        }
        body.light-mode .btn-voice {
            background: linear-gradient(135deg, #9ca3af, #6b7280);
        }
        #voice-recording-modal .modal-content {
            background: linear-gradient(135deg, rgba(23,33,43,0.96), rgba(16,24,35,0.96));
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: 0 30px 80px rgba(0,0,0,0.45);
        }
        #voice-recording-modal .login-btn {
            width: auto;
            min-width: 180px;
            border-radius: 999px;
        }
        .action-btn.recording,
        .mobile-icon-btn.recording {
            background: var(--danger);
            color: #ffffff;
            box-shadow: 0 0 0 6px rgba(255, 71, 87, 0.2), 0 8px 20px rgba(0,0,0,0.3);
        }
        @media (max-width: 1024px) {
            body {
                height: 100dvh;
            }
            #main-container {
                height: 100dvh;
                border-radius: 0;
                box-shadow: none;
            }
            #main-container::before {
                display: none;
            }
            .header {
                min-height: var(--mobile-header-height);
                padding: max(10px, env(safe-area-inset-top)) 12px 10px;
                position: sticky;
                top: 0;
                z-index: 20;
                background: var(--bg-header);
                box-shadow: none;
                border-bottom: 1px solid var(--border-color);
                gap: 8px;
            }
            .header-content {
                padding-right: 0;
                flex-direction: column;
                align-items: flex-start;
                text-align: right;
            }
            .header-content::before,
            .header-content::after {
                display: none;
            }
            .header-content h1 {
                font-size: 1.05rem;
                font-weight: 700;
                letter-spacing: 0;
            }
            .header-content .byline {
                font-size: 0.62rem;
                opacity: 0.8;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                max-width: 65vw;
            }
            .header-actions {
                gap: 6px;
            }
            .header-actions .action-btn {
                width: 36px;
                height: 36px;
                border-radius: 10px;
            }
            .chat-container {
                height: calc(100dvh - var(--mobile-header-height));
            }
            #chat-messages {
                height: auto;
                min-height: 0;
                flex: 1;
                padding: 1rem 1rem calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 24px);
                scroll-padding-bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 24px);
                background: var(--bg-chat);
                background-image: var(--chat-wallpaper);
            }
            .message {
                max-width: 86%;
            }
            .desktop-input-row {
                padding: 4px;
            }
        }
        .voice-preview-bar {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 12px;
            background: rgba(18, 28, 40, 0.85);
            border: 1px solid var(--border-color);
            border-radius: 18px;
            margin-bottom: 10px;
        }
        body.light-mode .voice-preview-bar {
            background: rgba(255, 255, 255, 0.9);
        }
        .voice-preview-bar.mobile {
            margin-bottom: 8px;
            border-radius: 20px;
            border: 1px solid var(--tg-divider);
            background: var(--tg-surface);
            box-shadow: 0 10px 24px rgba(0,0,0,0.22);
        }
        .voice-recording-bar {
            display: none;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: rgba(18, 28, 40, 0.95);
            border: 1px solid var(--border-color);
            border-radius: 18px;
            box-shadow: 0 10px 24px rgba(0,0,0,0.25);
            position: relative;
            overflow: hidden;
            width: 100%;
        }
        body.light-mode .voice-recording-bar {
            background: #ffffff;
            box-shadow: 0 8px 18px rgba(16,24,40,0.08);
        }
        .voice-recording-bar.is-locked .voice-recording-hint {
            display: none;
        }
        .voice-recording-bar.is-cancel {
            background: rgba(239, 68, 68, 0.15);
            border-color: rgba(239, 68, 68, 0.4);
        }
        .voice-recording-lock {
            width: 34px;
            height: 34px;
            border-radius: 12px;
            background: rgba(255,255,255,0.08);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            font-size: 0.65rem;
            color: var(--text-secondary);
            flex-shrink: 0;
            position: relative;
        }
        .voice-recording-bar:not(.is-locked) .voice-recording-lock::after {
            content: '↑';
            position: absolute;
            top: -12px;
            left: 50%;
            transform: translate(-50%, 4px);
            font-size: 0.85rem;
            color: var(--primary);
            animation: lockHint 1s ease-in-out infinite;
            opacity: 0.9;
        }
        @keyframes lockHint {
            0%, 100% { transform: translate(-50%, 4px); opacity: 0.7; }
            50% { transform: translate(-50%, -2px); opacity: 1; }
        }
        .voice-recording-lock .lock-icon {
            font-size: 0.9rem;
            line-height: 1;
        }
        .voice-recording-bar.is-locked .voice-recording-lock {
            color: var(--primary);
            background: rgba(42, 171, 238, 0.18);
        }
        .voice-recording-core {
            display: flex;
            align-items: center;
            gap: 8px;
            flex: 1;
            min-width: 0;
        }
        .voice-recording-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #ef4444;
            box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
            animation: recPulse 1s ease-in-out infinite;
            flex-shrink: 0;
        }
        @keyframes recPulse {
            0%, 100% { transform: scale(1); opacity: 1; }
            50% { transform: scale(1.2); opacity: 0.7; }
        }
        .voice-recording-timer {
            font-variant-numeric: tabular-nums;
            font-weight: 700;
            color: var(--text-primary);
            min-width: 48px;
            text-align: center;
        }
        .voice-recording-wave {
            display: flex;
            align-items: center;
            gap: 3px;
            flex: 1;
            height: 24px;
            overflow: hidden;
        }
        .voice-recording-wave span {
            width: 3px;
            height: 10px;
            background: rgba(255,255,255,0.35);
            border-radius: 6px;
        }
        body.light-mode .voice-recording-wave span {
            background: rgba(17,24,39,0.2);
        }
        .voice-recording-wave span:nth-child(3n) { height: 18px; }
        .voice-recording-wave span:nth-child(4n) { height: 14px; }
        .voice-recording-wave span:nth-child(5n) { height: 20px; }
        .voice-recording-hint {
            font-size: 0.72rem;
            color: var(--text-secondary);
            white-space: nowrap;
        }
        .voice-recording-stop,
        .voice-recording-cancel {
            display: none;
            border: none;
            border-radius: 12px;
            padding: 6px 12px;
            font-weight: 700;
            cursor: pointer;
            flex-shrink: 0;
        }
        .voice-recording-stop {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: #ffffff;
            box-shadow: 0 6px 14px rgba(42, 171, 238, 0.3);
        }
        .voice-recording-cancel {
            background: rgba(239, 68, 68, 0.15);
            color: #ef4444;
        }
        .voice-recording-bar.is-locked .voice-recording-stop,
        .voice-recording-bar.is-locked .voice-recording-cancel {
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .voice-recording-bar.mobile {
            margin-bottom: 8px;
            padding: 12px 14px;
            border-radius: 22px;
            background: var(--tg-surface);
            border: 1px solid var(--tg-divider);
            box-shadow: 0 12px 24px rgba(0,0,0,0.25);
        }
        .voice-recording-bar.desktop {
            margin-bottom: 10px;
        }
        body.light-mode .voice-recording-bar.mobile {
            background: #ffffff;
            box-shadow: 0 8px 18px rgba(16,24,40,0.08);
        }
        .voice-recording-bar.mobile .voice-recording-lock {
            width: 40px;
            height: 40px;
            border-radius: 14px;
        }
        .voice-recording-bar.mobile .voice-recording-timer {
            font-size: 0.9rem;
            min-width: 54px;
        }
        .voice-recording-bar.mobile .voice-recording-wave {
            height: 28px;
        }
        .voice-recording-bar.mobile .voice-recording-hint {
            font-size: 0.7rem;
        }
        .voice-recording-bar.mobile .voice-recording-stop,
        .voice-recording-bar.mobile .voice-recording-cancel {
            border-radius: 14px;
            padding: 8px 14px;
        }
        .voice-circle-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: none;
            background: linear-gradient(135deg, #2aabee, #1d8dbd);
            color: #ffffff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            box-shadow: 0 8px 18px rgba(42, 171, 238, 0.35);
        }
        .voice-circle-btn svg {
            width: 20px;
            height: 20px;
        }
        .voice-preview-bar .icon-pause {
            display: none;
        }
        .voice-preview-bar.is-playing .icon-play {
            display: none;
        }
        .voice-preview-bar.is-playing .icon-pause {
            display: block;
        }
        .voice-wave {
            position: relative;
            flex: 1;
            height: 30px;
            border-radius: 12px;
            background: rgba(255,255,255,0.05);
            display: flex;
            align-items: center;
            overflow: hidden;
            cursor: pointer;
            touch-action: none;
        }
        .voice-wave-bars {
            display: flex;
            align-items: center;
            gap: 3px;
            width: 100%;
            padding: 0 8px;
            z-index: 1;
        }
        .voice-wave-bars span {
            width: 3px;
            height: 10px;
            background: rgba(255,255,255,0.35);
            border-radius: 6px;
            transition: transform 0.2s ease;
        }
        .voice-wave-bars span:nth-child(3n) { height: 18px; }
        .voice-wave-bars span:nth-child(4n) { height: 14px; }
        .voice-wave-bars span:nth-child(5n) { height: 20px; }
        .voice-wave-progress {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            width: 0%;
            background: linear-gradient(90deg, rgba(42, 171, 238, 0.2), rgba(42, 171, 238, 0.7));
            border-radius: 12px;
            pointer-events: none;
            z-index: 0;
        }
        .voice-preview-time {
            font-size: 0.8rem;
            color: var(--text-secondary);
            min-width: 48px;
            text-align: center;
        }
        .voice-ghost-btn {
            border: none;
            background: rgba(255,255,255,0.08);
            color: var(--text-secondary);
            padding: 6px 10px;
            border-radius: 12px;
            cursor: pointer;
        }
        .voice-send-btn {
            border: none;
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: #fff;
            padding: 6px 12px;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 700;
        }
        .voice-preview-bar.is-playing .voice-wave-bars span {
            animation: voicePulse 0.9s ease-in-out infinite;
        }
        .voice-preview-bar.is-playing .voice-wave-bars span:nth-child(2n) {
            animation-delay: 0.1s;
        }
        .voice-preview-bar.is-playing .voice-wave-bars span:nth-child(3n) {
            animation-delay: 0.2s;
        }
        @keyframes voicePulse {
            0% { transform: scaleY(1); }
            50% { transform: scaleY(1.4); }
            100% { transform: scaleY(1); }
        }
        .voice-preview-bar audio {
            display: none;
        }
        .voice-message {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 10px;
            border-radius: 16px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.08);
            flex-wrap: wrap;
        }
        .user-message .voice-message {
            background: rgba(0,0,0,0.12);
        }
        body.light-mode .voice-message {
            background: rgba(17, 24, 39, 0.05);
            border-color: rgba(17, 24, 39, 0.08);
        }
        body.light-mode .user-message .voice-message {
            background: rgba(11, 29, 46, 0.08);
        }
        .voice-play-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border: none;
            background: linear-gradient(135deg, #2aabee, #1d8dbd);
            color: #ffffff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            box-shadow: 0 8px 18px rgba(42, 171, 238, 0.35);
        }
        .voice-play-btn svg {
            width: 18px;
            height: 18px;
        }
        .voice-message .icon-pause {
            display: none;
        }
        .voice-message.is-playing .icon-play {
            display: none;
        }
        .voice-message.is-playing .icon-pause {
            display: block;
        }
        .voice-bars {
            position: relative;
            flex: 1;
            height: 26px;
            border-radius: 12px;
            background: rgba(255,255,255,0.08);
            display: flex;
            align-items: center;
            overflow: hidden;
            cursor: pointer;
            touch-action: none;
        }
        .voice-bars-track {
            display: flex;
            align-items: center;
            gap: 3px;
            width: 100%;
            padding: 0 8px;
            z-index: 1;
        }
        .voice-bars-track span {
            width: 3px;
            height: 10px;
            background: rgba(255,255,255,0.5);
            border-radius: 6px;
        }
        .voice-bars-track span:nth-child(3n) { height: 18px; }
        .voice-bars-track span:nth-child(4n) { height: 14px; }
        .voice-bars-track span:nth-child(5n) { height: 20px; }
        .voice-progress {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            width: 0%;
            background: linear-gradient(90deg, rgba(42, 171, 238, 0.2), rgba(42, 171, 238, 0.85));
            border-radius: 12px;
            z-index: 0;
            pointer-events: none;
        }
        .voice-duration {
            font-size: 0.75rem;
            color: var(--text-secondary);
            min-width: 48px;
            text-align: center;
            margin-inline-start: auto;
            white-space: nowrap;
        }
        .voice-controls {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-inline-start: 6px;
        }
        .voice-skip-btn,
        .voice-speed-btn {
            border: 1px solid var(--border-color);
            background: rgba(255,255,255,0.08);
            color: var(--text-primary);
            border-radius: 10px;
            padding: 3px 8px;
            font-size: 0.7rem;
            font-weight: 700;
            cursor: pointer;
            min-width: 38px;
            text-align: center;
        }
        body.light-mode .voice-skip-btn,
        body.light-mode .voice-speed-btn {
            background: rgba(17,24,39,0.04);
        }
        .voice-skip-btn:active,
        .voice-speed-btn:active {
            transform: scale(0.96);
        }
        .voice-message.is-playing .voice-bars-track span {
            animation: voicePulse 0.9s ease-in-out infinite;
        }
        .voice-message.is-playing .voice-bars-track span:nth-child(2n) {
            animation-delay: 0.1s;
        }
        .voice-message.is-playing .voice-bars-track span:nth-child(3n) {
            animation-delay: 0.2s;
        }
        .voice-audio {
            display: none;
        }
        .scroll-to-bottom {
            position: absolute;
            left: 18px;
            bottom: 110px;
            width: 44px;
            height: 44px;
            border-radius: 14px;
            border: 1px solid var(--border-color);
            background: rgba(23, 33, 43, 0.9);
            color: var(--text-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 10px 24px rgba(0,0,0,0.35);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease, transform 0.2s ease;
            transform: translateY(8px);
            z-index: 30;
        }
        .scroll-to-bottom.visible {
            opacity: 1;
            pointer-events: auto;
            transform: translateY(0);
        }
        .scroll-to-bottom svg {
            width: 20px;
            height: 20px;
            stroke: currentColor;
            stroke-width: 2.2;
            fill: none;
        }
        body.light-mode .scroll-to-bottom {
            background: #ffffff;
            box-shadow: 0 10px 18px rgba(16,24,40,0.12);
        }
        @media (max-width: 1024px) {
            .scroll-to-bottom {
                left: 14px;
                bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 18px);
            }
        }

        /* --- Professional UI overrides (original design) --- */
        :root {
            --tg-bg: #0e1621;
            --tg-surface: #17212b;
            --tg-surface-2: #1e2933;
            --tg-panel: #17212b;
            --tg-border: rgba(255,255,255,0.08);
            --tg-accent: #2aabee;
            --tg-accent-2: #229ed9;
            --tg-muted: #707579;
            --tg-bubble-in: #182533;
            --tg-bubble-out: #2b5278;
            --tg-input: #0d1418;
            --tg-hover: rgba(42,171,238,0.08);
            --tg-shadow: 0 1px 2px rgba(0,0,0,0.1);
            --tg-text: #e9edef;
            --tg-text-secondary: #aaaaaa;
            --tg-divider: rgba(255,255,255,0.06);
            --tg-unread-bg: #2aabee;
            --tg-unread-text: #ffffff;
        }
        body.light-mode {
            --tg-bg: #e7ebef;
            --tg-surface: #ffffff;
            --tg-surface-2: #f0f2f5;
            --tg-panel: #ffffff;
            --tg-border: rgba(0,0,0,0.08);
            --tg-accent: #3390ec;
            --tg-accent-2: #229ed9;
            --tg-muted: #707579;
            --tg-bubble-in: #ffffff;
            --tg-bubble-out: #eeffde;
            --tg-input: #f0f2f5;
            --tg-hover: rgba(0,0,0,0.04);
            --tg-shadow: 0 1px 2px rgba(0,0,0,0.07);
            --tg-text: #000000;
            --tg-text-secondary: #707579;
            --tg-divider: rgba(0,0,0,0.08);
            --tg-unread-bg: #3390ec;
            --tg-unread-text: #ffffff;
        }
        body {
            background: var(--tg-bg);
            background-image: none;
            padding: 0;
            align-items: stretch;
        }
        #main-container.tg-app {
            width: 100%;
            max-width: none;
            height: 100vh;
            border-radius: 0;
            background: var(--tg-surface);
            box-shadow: none;
            border: 0;
            display: none;
            flex-direction: row;
        }
        .tg-sidebar {
            width: 340px;
            background: var(--tg-panel);
            border-inline-end: 1px solid var(--tg-border);
            display: flex;
            flex-direction: column;
            min-width: 260px;
            transition: width 0.2s ease, min-width 0.2s ease;
        }
        body.tg-sidebar-collapsed .tg-sidebar {
            width: 0;
            min-width: 0;
            border-inline-end: 0;
            overflow: hidden;
            box-shadow: none;
        }
        body.tg-sidebar-collapsed .tg-sidebar > * {
            opacity: 0;
            pointer-events: none;
        }
        .tg-sidebar-header {
            height: 56px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 12px 0 20px;
            border-bottom: none;
            color: var(--tg-text);
            background: var(--tg-panel);
            flex-shrink: 0;
        }
        .tg-app-title {
            display: flex;
            align-items: center;
            gap: 12px;
            font-weight: 600;
            font-size: 1rem;
            color: var(--tg-text);
        }
        .tg-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--tg-accent), var(--tg-accent-2));
            color: #fff;
            display: grid;
            place-items: center;
            font-weight: 600;
            font-size: 1rem;
            letter-spacing: 0;
        }
        .tg-avatar.has-image {
            background-size: cover;
            background-position: center;
            color: transparent;
        }
        .tg-icon-btn {
            width: 36px;
            height: 36px;
            border-radius: 12px;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            display: grid;
            place-items: center;
            cursor: pointer;
        }
        .tg-icon-btn:hover {
            background: var(--tg-hover);
            color: var(--text-primary);
        }
        #tg-sidebar-close {
            display: none;
        }
        .tg-search {
            padding: 12px 14px 14px;
            border-bottom: 1px solid var(--tg-border);
            background: var(--tg-panel);
        }
        .tg-search input {
            width: 100%;
            padding: 8px 12px;
            border-radius: 20px;
            border: none;
            background: var(--tg-input);
            color: var(--tg-text);
            font-size: 0.88rem;
            transition: background 0.15s ease;
        }
        .tg-search input:focus {
            background: var(--tg-surface-2);
            box-shadow: none;
        }
        .tg-chat-list {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            padding: 4px 0;
            gap: 0;
        }
        .tg-create-group {
            padding: 12px;
            border-bottom: 1px solid var(--tg-border);
            background: var(--tg-panel);
            display: flex;
            justify-content: center;
        }
        .tg-create-btn {
            width: min(260px, 90%);
            padding: 12px 16px;
            border-radius: 12px;
            border: none;
            background: rgba(42, 171, 238, 0.12);
            color: var(--tg-accent);
            font-weight: 600;
            font-size: 0.95rem;
            cursor: pointer;
            transition: background 0.15s ease;
        }
        .tg-create-btn:hover {
            background: rgba(42, 171, 238, 0.18);
        }
        .tg-chat-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 0;
            border: none;
            background: transparent;
            color: var(--tg-text);
            cursor: pointer;
            text-align: right;
            transition: background 0.15s ease;
            position: relative;
        }
        .tg-chat-item:hover {
            background: var(--tg-hover);
        }
        .tg-chat-item.active {
            background: rgba(42, 171, 238, 0.12);
            border-left: 3px solid var(--tg-accent);
            padding-left: 9px;
        }
        .tg-chat-meta {
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 0;
            flex: 1;
        }
        .tg-chat-title {
            font-weight: 500;
            font-size: 0.94rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--tg-text);
        }
        .tg-chat-snippet {
            font-size: 0.8rem;
            color: var(--tg-text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .tg-chat-time {
            font-size: 0.7rem;
            color: var(--tg-muted);
        }
        .tg-unread-badge {
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: 10px;
            background: var(--tg-unread-bg);
            color: var(--tg-unread-text);
            font-size: 0.7rem;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-left: auto;
        }
        .tg-chat-item.active .tg-unread-badge {
            background: var(--tg-accent);
        }
        .tg-chat-panel {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            background: var(--tg-surface);
        }
        body.tg-sidebar-collapsed .tg-chat-panel {
            width: 100%;
        }
        .tg-backdrop {
            display: none;
        }
        .header.tg-topbar {
            height: 56px;
            padding: 0 18px 0 12px;
            background: var(--tg-surface);
            border-bottom: 1px solid var(--tg-divider);
            display: flex;
            align-items: center;
            gap: 12px;
            position: sticky;
            top: 0;
            z-index: 40;
            box-shadow: none;
        }
        .tg-chat-info {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
            min-width: 0;
            cursor: pointer;
            padding: 6px 8px;
            border-radius: 12px;
        }
        .tg-chat-info:hover {
            background: var(--tg-hover);
        }
        .tg-title-wrap {
            display: flex;
            flex-direction: column;
            gap: 2px;
            min-width: 0;
        }
        .tg-title {
            font-weight: 700;
            font-size: 1rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .tg-subtitle {
            font-size: 0.76rem;
            color: var(--tg-muted);
        }
        .tg-back-btn {
            display: none;
            width: 36px;
            height: 36px;
            border-radius: 12px;
            border: none;
            background: transparent;
            color: var(--text-primary);
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }
        .tg-back-btn:hover {
            background: var(--tg-hover);
        }
        .header-actions.tg-actions .action-btn {
            width: 40px;
            height: 40px;
            background: transparent;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease;
        }
        .header-actions.tg-actions .action-btn:hover {
            background: var(--tg-hover);
            box-shadow: none;
            transform: none;
        }
        .header-actions.tg-actions .action-btn svg {
            width: 22px;
            height: 22px;
        }
        .chat-container {
            background: var(--tg-bg);
        }
        #chat-messages {
            padding: 16px 18px;
            gap: 10px;
        }
        .message {
            border-radius: 12px;
            padding: 6px 10px 8px;
            font-size: 0.94rem;
            box-shadow: 0 1px 2px rgba(0,0,0,0.08);
            line-height: 1.42;
            max-width: 68%;
        }
        .user-message {
            background: var(--tg-bubble-out);
            color: #ffffff;
            border-bottom-left-radius: 4px;
        }
        .other-message {
            background: var(--tg-bubble-in);
            border-bottom-right-radius: 4px;
        }
        .message-header .username {
            color: var(--tg-accent);
            font-weight: 500;
            font-size: 0.85rem;
        }
        .user-message .username {
            color: rgba(255,255,255,0.95);
            font-weight: 500;
        }
        .input-area-wrapper {
            background: var(--tg-surface);
            border-top: 1px solid var(--tg-divider);
            padding: 10px 14px 12px;
        }
        .desktop-input-row {
            background: var(--tg-input);
            border: 1px solid var(--tg-divider);
            border-radius: 22px;
            padding: 4px 6px;
            gap: 6px;
            align-items: center;
            box-shadow: none;
        }
        .desktop-input {
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 0.95rem;
        }
        .send-btn {
            background: var(--tg-accent);
            border-radius: 50%;
            width: 56px;
            height: 56px;
            padding: 0;
            font-weight: 500;
            font-size: 0.88rem;
            box-shadow: none;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease, transform 0.15s ease;
        }
        .send-btn:hover {
            background: var(--tg-accent-2);
            transform: scale(1.05);
        }
        .send-btn svg {
            width: 20px;
            height: 20px;
        }
        .login-container {
            background: var(--tg-surface);
        }
        .login-input {
            width: min(360px, 90%);
            border-radius: 14px;
            border: 1px solid var(--tg-border);
            background: var(--tg-input);
            color: var(--text-primary);
            padding: 12px 14px;
            margin-bottom: 12px;
        }
        .login-btn {
            background: var(--tg-accent);
            border-radius: 14px;
            padding: 10px 20px;
            font-weight: 700;
        }
        @media (max-width: 1024px) {
            body {
                position: relative;
                overflow: hidden;
            }
            #main-container.tg-app {
                flex-direction: column;
                height: 100dvh;
                display: flex;
            }
            .tg-chat-panel {
                width: 100%;
                min-width: 0;
                flex: 1;
                min-height: 0;
            }
            .tg-back-btn {
                display: inline-flex;
            }
            .tg-sidebar {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                width: 100%;
                height: 100%;
                transform: translateX(100%);
                opacity: 0;
                visibility: hidden;
                transition: transform 0.35s cubic-bezier(0.33, 1, 0.68, 1), opacity 0.3s ease, visibility 0.3s ease;
                z-index: 9999; /* Ensure it is on top of everything */
                display: flex;
                box-shadow: -10px 0 30px rgba(0,0,0,0.5);
                border-radius: 0;
                pointer-events: none;
                background: var(--tg-surface); /* Ensure background is solid */
            }
            body.tg-sidebar-open .tg-sidebar {
                transform: translateX(0);
                opacity: 1;
                visibility: visible;
                pointer-events: auto;
            }
            body.tg-sidebar-open .tg-chat-panel {
                display: none;
            }
            body.tg-sidebar-open .mobile-floating-container {
                display: none;
            }
            .tg-backdrop {
                display: block;
                position: fixed;
                inset: 0;
                background: rgba(0,0,0,0.45);
                opacity: 0;
                pointer-events: none;
                transition: opacity 0.2s ease;
                z-index: 1100;
            }
            body.tg-sidebar-open .tg-backdrop {
                opacity: 1;
                pointer-events: auto;
            }
            .header-actions.tg-actions {
                display: flex;
                position: absolute;
                right: 10px;
                top: 50%;
                transform: translateY(-50%);
            }
            .header-actions.tg-actions .action-btn {
                display: none;
            }
            #tg-menu-top {
                display: flex;
            }
            .mobile-floating-container {
                z-index: 90;
            }
            #tg-sidebar-close {
                display: grid;
            }
            #tg-menu {
                display: none;
            }
        }
        @media (max-width: 768px) {
            #main-container.tg-app {
                display: flex !important;
                flex-direction: column !important;
                height: 100dvh !important;
                width: 100% !important;
                position: fixed !important; /* Ensure it stays full screen */
                inset: 0 !important;
                margin: 0 !important;
                padding: 0 !important;
            }
            .tg-chat-panel {
                position: absolute !important;
                inset: 0 !important;
                width: 100% !important;
                height: 100% !important;
                display: flex !important;
                flex-direction: column !important;
                z-index: 10 !important;
                background: var(--tg-bg) !important;
            }
            .chat-container {
                flex: 1 !important;
                display: flex !important;
                flex-direction: column !important;
                height: auto !important;
                overflow: hidden !important;
            }
            #chat-container {
                flex: 1;
                min-height: 0;
            }
            #chat-messages {
                height: auto;
                min-height: 0;
                flex: 1;
                padding: 12px 10px 16px;
                padding-bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 28px);
                scroll-padding-bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 28px);
                overscroll-behavior: contain;
                -webkit-overflow-scrolling: touch;
                gap: 12px;
            }
            .message {
                font-size: 0.92rem;
                border-radius: 12px;
                max-width: 85%;
                padding: 6px 10px 7px;
            }
            .message-image,
            .message-video {
                max-height: 220px;
                object-fit: cover;
                border-radius: 12px;
            }
            .desktop-input-row {
                border-radius: 16px;
            }
            .header.tg-topbar {
                height: var(--mobile-header-height);
                padding: 0 10px;
                position: sticky;
                top: 0;
                z-index: 40;
            }
            .header-actions.tg-actions {
                display: flex;
                position: absolute;
                right: 8px;
                top: 50%;
                transform: translateY(-50%);
            }
            .header-actions.tg-actions .action-btn {
                display: none;
            }
            #tg-menu-top {
                display: flex;
            }
            .tg-title {
                font-size: 0.95rem;
            }
            .tg-subtitle {
                font-size: 0.68rem;
            }
            .mobile-floating-container {
                min-height: var(--mobile-input-height);
                padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
            }
            .mobile-floating-input {
                height: 44px;
                font-size: 0.95rem;
            }
            .mobile-icon-btn {
                width: 44px;
                height: 44px;
            }
        }
        @media (min-width: 1200px) {
            #main-container.tg-app {
                width: 100%;
                height: 100vh;
            }
        }
        /* --- UI polish (buttons) --- */
        :root {
            --btn-surface: rgba(255,255,255,0.08);
            --btn-border-strong: rgba(255,255,255,0.18);
            --accent-1: #2ab4ff;
            --accent-2: #1c7dff;
            --accent-3: #7cc3ff;
            --btn-shadow-strong: 0 12px 26px rgba(28,125,255,0.35), 0 6px 14px rgba(0,0,0,0.25);
            --btn-shadow-soft: 0 6px 16px rgba(0,0,0,0.25);
        }
        body.light-mode {
            --btn-surface: rgba(2,6,23,0.04);
            --btn-border-strong: rgba(15,23,42,0.12);
            --btn-shadow-strong: 0 10px 22px rgba(37,99,235,0.25), 0 4px 10px rgba(2,6,23,0.1);
            --btn-shadow-soft: 0 6px 14px rgba(2,6,23,0.1);
        }
        .send-btn {
            height: 44px;
            padding: 0 22px;
            border-radius: 999px;
            font-weight: 700;
            font-size: 0.9rem;
            border: 1px solid rgba(255,255,255,0.2);
            background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
            color: #ffffff;
            box-shadow: var(--btn-shadow-strong);
            transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
        }
        .send-btn:hover {
            transform: translateY(-1px);
            filter: brightness(1.05);
        }
        .send-btn:active {
            transform: translateY(0) scale(0.98);
            box-shadow: 0 6px 16px rgba(0,0,0,0.25);
        }
        .preview-send-btn,
        .voice-send-btn {
            background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
            border: 1px solid rgba(255,255,255,0.18);
            box-shadow: var(--btn-shadow-soft);
        }
        .mobile-input-row {
            background: rgba(12, 18, 26, 0.65);
            border: 1px solid var(--btn-border-strong);
            border-radius: 24px;
            box-shadow: 0 12px 28px rgba(0,0,0,0.28);
        }
        body.light-mode .mobile-input-row {
            background: rgba(255,255,255,0.95);
            border-color: rgba(15,23,42,0.08);
            box-shadow: 0 10px 22px rgba(2,6,23,0.08);
        }
        .mobile-icon-btn {
            border-radius: 16px;
            border: 1px solid var(--btn-border-strong);
            background: var(--btn-surface);
            color: var(--tg-text);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), var(--btn-shadow-soft);
        }
        body.light-mode .mobile-icon-btn {
            color: #1f2937;
        }
        .mobile-icon-btn svg {
            width: 20px;
            height: 20px;
        }
        .btn-image {
            background: linear-gradient(135deg, rgba(42,171,238,0.18), rgba(28,125,255,0.25));
            color: var(--accent-3);
        }
        .btn-voice {
            background: linear-gradient(135deg, rgba(148,163,184,0.18), rgba(30,41,59,0.35));
            color: #cbd5f5;
        }
        body.light-mode .btn-voice {
            background: linear-gradient(135deg, rgba(148,163,184,0.22), rgba(71,85,105,0.2));
            color: #334155;
        }
        .btn-send {
            width: 52px;
            height: 52px;
            border-radius: 18px;
            border: none;
            background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
            color: #ffffff;
            box-shadow: var(--btn-shadow-strong);
        }
        .btn-send:hover {
            filter: brightness(1.05);
        }
        .btn-send:active {
            transform: translateY(0) scale(0.96);
            box-shadow: 0 6px 16px rgba(0,0,0,0.25);
        }
        @media (max-width: 480px) {
            .mobile-icon-btn {
                width: 42px;
                height: 42px;
            }
            .btn-send {
                width: 50px;
                height: 50px;
            }
        }
        /* --- 2026 iOS / Android visual refresh --- */
        :root {
            --ui-bg-start: #0a1522;
            --ui-bg-end: #07111b;
            --ui-shell: rgba(11, 26, 40, 0.8);
            --ui-shell-border: rgba(181, 217, 255, 0.16);
            --ui-panel: rgba(16, 33, 50, 0.88);
            --ui-panel-soft: rgba(255, 255, 255, 0.05);
            --ui-panel-soft-2: rgba(255, 255, 255, 0.09);
            --ui-text: #eaf5ff;
            --ui-text-soft: #9cb6cb;
            --ui-accent: #33a8ff;
            --ui-accent-strong: #1f8ff3;
            --ui-chat-in: #172b40;
            --ui-chat-out: linear-gradient(145deg, #2390ff, #2db8ff);
            --mobile-header-height: 70px;
            --mobile-input-height: 90px;
        }
        body.light-mode {
            --ui-bg-start: #dceaf7;
            --ui-bg-end: #eff6fd;
            --ui-shell: rgba(255, 255, 255, 0.84);
            --ui-shell-border: rgba(40, 93, 145, 0.12);
            --ui-panel: rgba(255, 255, 255, 0.86);
            --ui-panel-soft: rgba(10, 36, 62, 0.04);
            --ui-panel-soft-2: rgba(10, 36, 62, 0.08);
            --ui-text: #0f2438;
            --ui-text-soft: #607b95;
            --ui-accent: #2c98f5;
            --ui-accent-strong: #1f83df;
            --ui-chat-in: #ffffff;
            --ui-chat-out: linear-gradient(145deg, #2f9bff, #56b8ff);
        }
        body {
            background:
                radial-gradient(1100px 600px at 8% -10%, rgba(61, 175, 255, 0.33), transparent 58%),
                radial-gradient(1000px 560px at 95% 5%, rgba(28, 123, 230, 0.26), transparent 60%),
                linear-gradient(150deg, var(--ui-bg-start), var(--ui-bg-end)) !important;
            color: var(--ui-text);
            padding: clamp(10px, 2vw, 20px) !important;
            align-items: center !important;
            justify-content: center !important;
            position: relative;
        }
        #main-container.tg-app {
            position: relative;
            z-index: 1;
            width: min(1540px, 100%);
            height: min(980px, calc(100dvh - 2 * clamp(10px, 2vw, 20px)));
            min-height: 660px;
            margin: 0 auto;
            background: linear-gradient(170deg, var(--ui-shell), rgba(8, 18, 28, 0.58));
            border: 1px solid var(--ui-shell-border);
            border-radius: 30px;
            box-shadow: 0 32px 80px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            overflow: hidden;
        }
        .tg-sidebar {
            width: 360px;
            min-width: 320px;
            background: linear-gradient(185deg, rgba(14, 31, 46, 0.95), rgba(9, 21, 34, 0.9));
            border-inline-end: 1px solid rgba(150, 205, 255, 0.14);
        }
        body.light-mode .tg-sidebar {
            background: linear-gradient(185deg, rgba(255, 255, 255, 0.96), rgba(242, 248, 255, 0.96));
            border-inline-end-color: rgba(12, 67, 121, 0.1);
        }
        .tg-sidebar-header {
            height: 74px;
            padding: 0 16px 0 18px;
            border-bottom: 1px solid rgba(150, 205, 255, 0.08);
            background: rgba(7, 21, 33, 0.45);
            backdrop-filter: blur(14px);
        }
        body.light-mode .tg-sidebar-header {
            border-bottom-color: rgba(12, 67, 121, 0.08);
            background: rgba(255, 255, 255, 0.62);
        }
        .tg-app-title span:last-child {
            font-size: 1.02rem;
            font-weight: 780;
            color: var(--ui-text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .tg-avatar {
            width: 44px;
            height: 44px;
            border-radius: 15px;
            background: linear-gradient(145deg, #2daeff, #157de0);
            box-shadow: 0 12px 22px rgba(18, 128, 235, 0.4);
            border: 1px solid rgba(255, 255, 255, 0.22);
            font-weight: 800;
        }
        .tg-icon-btn,
        .action-btn {
            width: 40px;
            height: 40px;
            border-radius: 14px;
            background: var(--ui-panel-soft);
            border: 1px solid rgba(184, 218, 255, 0.14);
            color: var(--ui-text-soft);
            transition: all 0.18s ease;
        }
        .tg-icon-btn:hover,
        .action-btn:hover {
            background: var(--ui-panel-soft-2);
            color: var(--ui-text);
            transform: translateY(-1px);
            box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
        }
        .tg-search {
            padding: 14px 14px 12px;
            border-bottom: none;
            background: transparent;
        }
        .tg-search input {
            height: 44px;
            border-radius: 15px;
            border: 1px solid rgba(187, 220, 255, 0.15);
            background: rgba(10, 25, 39, 0.72);
            color: var(--ui-text);
            font-size: 0.92rem;
            padding: 0 14px;
        }
        .tg-search input:focus {
            border-color: rgba(61, 167, 255, 0.44);
            box-shadow: 0 0 0 3px rgba(61, 167, 255, 0.16);
            background: rgba(13, 29, 45, 0.9);
        }
        body.light-mode .tg-search input {
            background: rgba(243, 249, 255, 0.9);
            border-color: rgba(21, 86, 145, 0.12);
        }
        .tg-sidebar-tabs {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 7px;
            padding: 6px 14px 10px;
        }
        .tg-folder-tab {
            flex: 1 1 calc(50% - 4px);
            height: 34px;
            border-radius: 12px;
            border: 1px solid rgba(152, 209, 255, 0.24);
            background: rgba(12, 30, 48, 0.42);
            color: var(--ui-text-soft);
            font-size: 0.78rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.16s ease;
        }
        .tg-folder-tab:hover {
            background: rgba(33, 97, 150, 0.34);
            color: var(--ui-text);
        }
        .tg-folder-tab.is-active {
            border-color: rgba(89, 183, 255, 0.48);
            background: linear-gradient(145deg, rgba(48, 165, 255, 0.3), rgba(48, 165, 255, 0.12));
            color: #d9f0ff;
            box-shadow: 0 8px 16px rgba(19, 106, 178, 0.24);
        }
        body.light-mode .tg-folder-tab {
            border-color: rgba(17, 92, 158, 0.14);
            background: rgba(255, 255, 255, 0.82);
            color: #53779b;
        }
        body.light-mode .tg-folder-tab:hover {
            background: rgba(232, 244, 255, 0.95);
            color: #194d77;
        }
        body.light-mode .tg-folder-tab.is-active {
            border-color: rgba(22, 126, 215, 0.34);
            background: linear-gradient(145deg, rgba(37, 143, 231, 0.2), rgba(37, 143, 231, 0.08));
            color: #0f5f9f;
        }
        .tg-sidebar-sections {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            padding: 2px 10px 14px;
        }
        .tg-sidebar-sections::-webkit-scrollbar {
            width: 6px;
        }
        .tg-sidebar-sections::-webkit-scrollbar-thumb {
            background: rgba(167, 211, 251, 0.24);
            border-radius: 99px;
        }
        .tg-sidebar-section {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 10px;
        }
        .tg-sidebar-section:last-child {
            margin-bottom: 0;
        }
        .tg-section-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 2px 4px 0;
        }
        .tg-section-title {
            font-size: 0.8rem;
            font-weight: 760;
            color: var(--ui-text-soft);
        }
        body.light-mode .tg-section-title {
            color: #587c9f;
        }
        .section-create-btn {
            width: auto;
            min-width: 118px;
            height: 36px;
            border-radius: 11px;
            font-size: 0.78rem;
            padding: 0 10px;
            white-space: nowrap;
        }
        body.tg-sidebar-view-groups .tg-section-private {
            display: none;
        }
        body.tg-sidebar-view-private .tg-section-groups {
            display: none;
        }
        .tg-section-channels {
            display: none;
        }
        body.tg-sidebar-view-groups .tg-section-channels,
        body.tg-sidebar-view-private .tg-section-channels {
            display: none;
        }
        body.tg-sidebar-view-channels .tg-section-groups,
        body.tg-sidebar-view-channels .tg-section-private {
            display: none;
        }
        body.tg-sidebar-view-channels .tg-section-channels {
            display: flex;
        }
        .tg-create-btn {
            width: 100%;
            border-radius: 15px;
            border: 1px solid rgba(98, 180, 255, 0.45);
            background: linear-gradient(145deg, rgba(41, 158, 252, 0.18), rgba(64, 190, 255, 0.08));
            color: #6bc6ff;
            font-size: 0.9rem;
            font-weight: 720;
            height: 44px;
        }
        .tg-section-head .section-create-btn {
            width: auto;
        }
        .tg-chat-list {
            flex: 0 1 auto;
            max-height: min(35vh, 340px);
            overflow-y: auto;
            padding: 6px 10px 10px;
            gap: 6px;
        }
        body.tg-sidebar-view-groups .tg-section-groups .tg-chat-list,
        body.tg-sidebar-view-private .tg-section-private .tg-chat-list {
            max-height: min(62vh, 640px);
        }
        body.tg-sidebar-view-channels .tg-section-channels .tg-chat-list {
            max-height: min(62vh, 640px);
        }
        .tg-chat-list::-webkit-scrollbar {
            width: 6px;
        }
        .tg-chat-list::-webkit-scrollbar-thumb {
            background: rgba(167, 211, 251, 0.2);
            border-radius: 99px;
        }
        .tg-chat-item {
            border-radius: 16px;
            padding: 12px;
            border: 1px solid transparent;
            transition: all 0.18s ease;
            min-height: 72px;
            gap: 10px;
        }
        .tg-chat-item:hover {
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(177, 216, 255, 0.14);
        }
        .tg-chat-item.active {
            background: linear-gradient(145deg, rgba(42, 164, 255, 0.22), rgba(42, 164, 255, 0.07));
            border-color: rgba(97, 187, 255, 0.35);
            border-left: 0;
            padding-left: 12px;
            box-shadow: 0 12px 24px rgba(20, 122, 216, 0.22);
        }
        .tg-chat-title {
            font-size: 0.92rem;
            font-weight: 690;
            color: var(--ui-text);
        }
        .tg-chat-snippet,
        .tg-chat-time {
            color: var(--ui-text-soft);
        }
        .tg-unread-badge {
            background: linear-gradient(145deg, #29a4ff, #1680df);
            box-shadow: 0 8px 18px rgba(19, 123, 214, 0.35);
        }
        .header.tg-topbar {
            height: 74px;
            padding: 0 14px 0 12px;
            background: rgba(9, 22, 34, 0.56);
            border-bottom: 1px solid rgba(163, 208, 252, 0.12);
            backdrop-filter: blur(15px);
        }
        body.light-mode .header.tg-topbar {
            background: rgba(255, 255, 255, 0.78);
            border-bottom-color: rgba(12, 67, 121, 0.1);
        }
        .tg-chat-info {
            border-radius: 16px;
            padding: 8px 10px;
        }
        .tg-chat-info:hover {
            background: rgba(255, 255, 255, 0.06);
        }
        body.light-mode .tg-chat-info:hover {
            background: rgba(6, 52, 94, 0.06);
        }
        .tg-title {
            font-size: 1rem;
            font-weight: 760;
            color: var(--ui-text);
        }
        .tg-subtitle {
            font-size: 0.72rem;
            color: var(--ui-text-soft);
        }
        .header-actions.tg-actions {
            gap: 8px;
        }
        .header-actions.tg-actions .action-btn {
            border-radius: 14px;
            width: 40px;
            height: 40px;
        }
        .chat-container {
            background: transparent !important;
        }
        #chat-messages {
            position: relative;
            padding: 22px 22px 18px;
            background:
                radial-gradient(460px 220px at 0% 0%, rgba(56, 173, 255, 0.12), transparent 68%),
                radial-gradient(500px 260px at 100% 100%, rgba(27, 123, 221, 0.1), transparent 66%),
                repeating-linear-gradient(145deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 24px);
        }
        body.light-mode #chat-messages {
            background:
                radial-gradient(500px 250px at 10% 0%, rgba(42, 148, 240, 0.09), transparent 72%),
                radial-gradient(420px 220px at 100% 100%, rgba(41, 126, 213, 0.08), transparent 68%),
                repeating-linear-gradient(145deg, rgba(7, 43, 78, 0.03) 0 1px, transparent 1px 24px);
        }
        #chat-messages::-webkit-scrollbar {
            width: 7px;
        }
        #chat-messages::-webkit-scrollbar-thumb {
            background: rgba(177, 214, 248, 0.24);
        }
        .message {
            max-width: min(74%, 600px);
            border-radius: 18px;
            padding: 10px 12px 9px;
            border: 1px solid rgba(197, 221, 245, 0.08);
            box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
            position: relative;
        }
        .other-message {
            background: var(--ui-chat-in);
            color: var(--ui-text);
            border-bottom-right-radius: 6px;
        }
        .user-message {
            background: var(--ui-chat-out);
            color: #f6fbff;
            border-color: rgba(150, 218, 255, 0.32);
            border-bottom-left-radius: 6px;
        }
        .message-header {
            margin-bottom: 6px;
            font-size: 0.72rem;
            gap: 8px;
            opacity: 0.96;
        }
        .username {
            color: #79ccff;
            font-size: 0.78rem;
            font-weight: 700;
        }
        body.light-mode .username {
            color: #0f79d7;
        }
        .user-message .username {
            color: rgba(245, 251, 255, 0.94);
        }
        .timestamp {
            color: rgba(227, 242, 255, 0.78);
            font-size: 0.64rem;
            margin-right: 0;
        }
        .other-message .timestamp {
            color: var(--ui-text-soft);
        }
        .message-text {
            font-size: 0.93rem;
            line-height: 1.62;
        }
        .message-image,
        .message-video {
            border-radius: 14px;
            margin-top: 6px;
            border: 1px solid rgba(183, 220, 255, 0.2);
        }
        .message-file {
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.09);
            border: 1px solid rgba(176, 220, 255, 0.16);
        }
        .user-message .message-file {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.2);
        }
        .reply-indicator {
            border-right: 3px solid rgba(123, 206, 255, 0.95);
            border-radius: 10px;
            padding: 8px 10px;
            margin-bottom: 8px;
            background: rgba(14, 36, 55, 0.45);
        }
        .reaction-bar {
            margin-top: 8px;
            gap: 6px;
        }
        .reaction-item {
            border-radius: 999px;
            padding: 3px 8px;
            background: rgba(255, 255, 255, 0.09);
            border: 1px solid rgba(189, 220, 248, 0.14);
        }
        .reaction-item.is-active {
            background: rgba(44, 156, 242, 0.35);
            border-color: rgba(113, 197, 255, 0.55);
        }
        .input-area-wrapper {
            border-top: 1px solid rgba(168, 212, 255, 0.14);
            background: rgba(8, 22, 35, 0.68);
            backdrop-filter: blur(15px);
            padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
            gap: 10px;
        }
        body.light-mode .input-area-wrapper {
            background: rgba(255, 255, 255, 0.75);
            border-top-color: rgba(10, 63, 114, 0.1);
        }
        .desktop-input-row {
            border: 1px solid rgba(171, 216, 255, 0.17);
            border-radius: 22px;
            background: rgba(15, 31, 47, 0.86);
            padding: 5px 6px 5px 10px;
        }
        body.light-mode .desktop-input-row {
            background: rgba(244, 249, 255, 0.95);
            border-color: rgba(10, 63, 114, 0.12);
        }
        .desktop-input {
            background: transparent;
            border: 0;
            box-shadow: none;
            height: 46px;
            padding: 0 12px;
            font-size: 0.96rem;
            color: var(--ui-text);
        }
        .desktop-input:focus {
            box-shadow: none;
            border: 0;
            background: transparent;
        }
        .desktop-input-row .action-btn {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            background: transparent;
            border: 0;
            box-shadow: none;
        }
        .desktop-input-row .action-btn:hover {
            background: rgba(255, 255, 255, 0.08);
            transform: none;
        }
        .send-btn {
            min-width: 96px;
            height: 44px;
            border-radius: 14px;
            background: linear-gradient(145deg, #2ca6ff, #1b82e0);
            border: 1px solid rgba(171, 227, 255, 0.48);
            box-shadow: 0 14px 24px rgba(17, 122, 216, 0.35);
            color: #ffffff;
            font-size: 0.86rem;
            font-weight: 760;
            padding: 0 20px;
        }
        .emoji-picker {
            width: min(420px, calc(100vw - 40px));
            height: 150px;
            border-radius: 18px;
            background: rgba(8, 24, 38, 0.94);
            border: 1px solid rgba(175, 217, 255, 0.2);
            box-shadow: 0 24px 44px rgba(0, 0, 0, 0.35);
            bottom: 70px;
            right: 0;
        }
        .footer {
            background: rgba(7, 20, 32, 0.5);
            border-top: 1px solid rgba(164, 211, 255, 0.11);
            padding: 9px 16px;
            min-height: 46px;
        }
        .connection-status {
            background: rgba(255, 255, 255, 0.07);
            border: 1px solid rgba(176, 219, 255, 0.2);
            color: var(--ui-text-soft);
            font-size: 0.78rem;
            font-weight: 650;
            padding: 5px 10px;
        }
        .reaction-picker {
            background: rgba(8, 22, 36, 0.96);
            border-radius: 16px;
            border: 1px solid rgba(167, 214, 255, 0.2);
            box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
            padding: 10px;
        }
        .message-context-menu {
            background: rgba(8, 23, 36, 0.96);
            border: 1px solid rgba(172, 217, 255, 0.2);
            border-radius: 16px;
            box-shadow: 0 24px 46px rgba(0, 0, 0, 0.42);
            min-width: 190px;
            padding: 8px;
        }
        .menu-item {
            border-radius: 10px;
            padding: 11px 12px;
        }
        .menu-item:hover {
            background: rgba(66, 169, 255, 0.14);
        }
        .modal-overlay {
            backdrop-filter: blur(8px);
            background: rgba(3, 10, 18, 0.56);
        }
        .modal-content {
            border-radius: 22px;
            border: 1px solid rgba(175, 219, 255, 0.2);
            background: linear-gradient(170deg, rgba(13, 29, 45, 0.96), rgba(8, 20, 32, 0.94));
            box-shadow: 0 30px 58px rgba(0, 0, 0, 0.43);
            padding: 18px;
            color: var(--ui-text);
        }
        body.light-mode .modal-content {
            background: linear-gradient(170deg, rgba(255, 255, 255, 0.96), rgba(242, 248, 255, 0.96));
            border-color: rgba(10, 63, 114, 0.12);
            color: #14324b;
        }
        .login-input,
        .link-input,
        .preview-caption-input {
            border-radius: 14px;
            border: 1px solid rgba(173, 217, 255, 0.18);
            background: rgba(11, 27, 42, 0.8);
            color: var(--ui-text);
        }
        body.light-mode .login-input,
        body.light-mode .link-input,
        body.light-mode .preview-caption-input {
            background: rgba(246, 251, 255, 0.96);
            border-color: rgba(10, 63, 114, 0.14);
            color: #10273d;
        }
        .login-btn,
        .preview-send-btn,
        .voice-send-btn,
        .link-preview-btn,
        .link-choice-btn {
            border-radius: 14px;
            border: 1px solid rgba(170, 224, 255, 0.34);
            background: linear-gradient(145deg, #2ca6ff, #1d86e3);
            color: #ffffff;
            font-weight: 730;
            box-shadow: 0 12px 24px rgba(24, 124, 216, 0.3);
        }
        #login-container {
            background: linear-gradient(165deg, rgba(8, 24, 39, 0.76), rgba(7, 19, 31, 0.58));
            border-radius: 0;
            padding: 28px 20px;
        }
        .mobile-floating-container {
            z-index: 120;
            padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
            background: linear-gradient(to top, rgba(7, 19, 31, 0.95), rgba(7, 19, 31, 0.62) 60%, transparent);
            min-height: var(--mobile-input-height);
        }
        body.light-mode .mobile-floating-container {
            background: linear-gradient(to top, rgba(245, 251, 255, 0.96), rgba(245, 251, 255, 0.66) 62%, transparent);
        }
        .mobile-reply-indicator {
            border-radius: 14px;
            border: 1px solid rgba(173, 217, 255, 0.18);
            background: rgba(11, 29, 46, 0.82);
            margin-bottom: 8px;
            color: var(--ui-text-soft);
        }
        .mobile-input-row {
            border-radius: 22px;
            border: 1px solid rgba(173, 217, 255, 0.18);
            background: rgba(10, 27, 42, 0.9);
            padding: 6px;
            gap: 6px;
            box-shadow: 0 16px 30px rgba(0, 0, 0, 0.3);
        }
        .mobile-floating-input {
            height: 46px;
            border-radius: 14px;
            background: transparent;
            border: 0;
            color: var(--ui-text);
            font-size: 0.95rem;
            padding: 0 10px;
        }
        .mobile-icon-btn {
            width: 44px;
            height: 44px;
            border-radius: 14px;
            border: 1px solid rgba(172, 218, 255, 0.16);
            background: rgba(255, 255, 255, 0.06);
            color: var(--ui-text-soft);
            box-shadow: none;
        }
        .mobile-icon-btn.btn-send {
            width: 48px;
            height: 48px;
            border: 1px solid rgba(185, 230, 255, 0.42);
            background: linear-gradient(145deg, #2ca6ff, #1d84e1);
            color: #fff;
            box-shadow: 0 12px 24px rgba(20, 122, 216, 0.34);
        }
        .scroll-to-bottom {
            width: 42px;
            height: 42px;
            border-radius: 14px;
            border: 1px solid rgba(174, 218, 255, 0.2);
            background: rgba(8, 23, 36, 0.84);
            color: #d5ecff;
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
        }
        body.light-mode .footer {
            background: rgba(255, 255, 255, 0.62);
            border-top-color: rgba(10, 63, 114, 0.1);
        }
        body.light-mode .reaction-picker,
        body.light-mode .message-context-menu {
            background: rgba(255, 255, 255, 0.98);
            border-color: rgba(10, 63, 114, 0.15);
        }
        body.light-mode .mobile-input-row {
            background: rgba(255, 255, 255, 0.96);
            border-color: rgba(10, 63, 114, 0.12);
            box-shadow: 0 14px 24px rgba(10, 63, 114, 0.12);
        }
        body.light-mode .mobile-icon-btn {
            border-color: rgba(10, 63, 114, 0.1);
            background: rgba(8, 63, 114, 0.05);
            color: #1f4d74;
        }
        body.light-mode .scroll-to-bottom {
            background: rgba(255, 255, 255, 0.94);
            color: #1f4d74;
            border-color: rgba(10, 63, 114, 0.15);
        }
        @media (max-width: 1200px) {
            #main-container.tg-app {
                width: 100%;
                height: calc(100dvh - 2 * clamp(8px, 1.8vw, 16px));
                min-height: auto;
            }
            .tg-sidebar {
                width: 330px;
                min-width: 290px;
            }
            #chat-messages {
                padding: 18px 16px 14px;
            }
            .message {
                max-width: min(80%, 560px);
            }
        }
        @media (max-width: 1024px) {
            body {
                padding: 0 !important;
            }
            #main-container.tg-app {
                width: 100% !important;
                height: 100dvh !important;
                border-radius: 0 !important;
                border: 0 !important;
                box-shadow: none !important;
                background: linear-gradient(165deg, rgba(8, 21, 33, 0.98), rgba(5, 15, 24, 0.99));
            }
            body.light-mode #main-container.tg-app {
                background: linear-gradient(165deg, rgba(239, 247, 255, 0.98), rgba(249, 252, 255, 0.99));
            }
            .tg-sidebar {
                width: 100%;
                min-width: 0;
                border-inline-end: 0;
                border-radius: 0;
            }
            .tg-sidebar-header {
                height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
                padding-top: env(safe-area-inset-top);
            }
            .header.tg-topbar {
                height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
                padding-top: env(safe-area-inset-top);
            }
            #chat-messages {
                padding: 14px 10px 16px;
                padding-bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 26px);
            }
            .message {
                max-width: 88%;
                border-radius: 16px;
                padding: 8px 10px;
                box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
            }
            .header-actions.tg-actions .action-btn {
                width: 36px;
                height: 36px;
                border-radius: 12px;
            }
            .tg-title {
                font-size: 0.94rem;
            }
            .tg-subtitle {
                font-size: 0.67rem;
            }
            .message-context-menu {
                width: min(340px, calc(100vw - 18px));
                max-width: calc(100vw - 18px);
            }
        }
        @media (max-width: 768px) {
            .tg-chat-info {
                padding: 6px 8px;
                gap: 8px;
            }
            .tg-avatar {
                width: 40px;
                height: 40px;
                border-radius: 13px;
            }
            .tg-chat-info .tg-avatar {
                width: 36px;
                height: 36px;
                border-radius: 12px;
            }
            .tg-subtitle {
                max-width: 44vw;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            .mobile-floating-container {
                padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
            }
            .mobile-input-row {
                border-radius: 20px;
            }
            .mobile-icon-btn {
                width: 42px;
                height: 42px;
            }
            .mobile-icon-btn.btn-send {
                width: 46px;
                height: 46px;
            }
            .scroll-to-bottom {
                bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 12px);
                left: 10px;
            }
        }
        @media (max-width: 480px) {
            .tg-search {
                padding: 12px 10px 10px;
            }
            .tg-create-group {
                padding: 8px 10px;
            }
            .tg-chat-item {
                padding: 10px;
                min-height: 66px;
            }
            #chat-messages {
                padding: 12px 8px;
                padding-bottom: calc(var(--mobile-input-height) + env(safe-area-inset-bottom) + 24px);
            }
            .message {
                max-width: 91%;
                font-size: 0.9rem;
                line-height: 1.55;
            }
            .mobile-floating-input {
                font-size: 0.92rem;
            }
        }
        /* --- Sidebar + Topbar rebuild (stable mobile drawer) --- */
        body.tg-no-scroll {
            overflow: hidden !important;
        }
        .header-actions.tg-actions {
            position: relative;
        }
        .topbar-overflow {
            position: relative;
        }
        .topbar-more-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .topbar-menu {
            position: absolute;
            top: calc(100% + 10px);
            left: 0;
            min-width: 200px;
            background: rgba(10, 25, 40, 0.98);
            border: 1px solid rgba(162, 213, 255, 0.24);
            border-radius: 14px;
            box-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
            padding: 6px;
            display: none;
            z-index: 90;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }
        body.light-mode .topbar-menu {
            background: rgba(255, 255, 255, 0.98);
            border-color: rgba(13, 71, 126, 0.16);
        }
        .topbar-overflow.is-open .topbar-menu {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .topbar-menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            border: 0;
            background: transparent;
            color: var(--ui-text);
            border-radius: 10px;
            padding: 10px 10px;
            cursor: pointer;
            font-size: 0.86rem;
            text-align: right;
        }
        .topbar-menu-item svg {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
        }
        .topbar-menu-item:hover {
            background: rgba(58, 164, 252, 0.16);
        }
        .topbar-menu-item.danger {
            color: #ff8d9a;
        }
        .topbar-menu-item.danger:hover {
            background: rgba(255, 99, 132, 0.15);
        }
        .header.tg-topbar {
            grid-template-columns: auto 1fr auto;
            display: grid;
        }
        .tg-back-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 38px;
            height: 38px;
            border: 0;
            background: transparent;
            border-radius: 12px;
            color: var(--ui-text-soft);
        }
        .tg-back-btn:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--ui-text);
        }
        .tg-sidebar {
            transition: transform 0.28s ease, opacity 0.2s ease;
        }
        .tg-backdrop {
            z-index: 1200;
            background: rgba(0, 0, 0, 0.44);
            backdrop-filter: blur(2px);
        }
        @media (max-width: 1024px) {
            .header-actions.tg-actions {
                gap: 8px;
                display: flex !important;
                position: static !important;
                transform: none !important;
            }
            .header-actions.tg-actions .action-btn {
                display: inline-flex !important;
            }
            #group-info-btn {
                display: none !important;
            }
            .topbar-menu {
                left: 0;
                right: auto;
                min-width: 190px;
            }
            .tg-sidebar {
                position: fixed !important;
                top: 0 !important;
                right: 0 !important;
                left: auto !important;
                bottom: 0 !important;
                height: 100dvh !important;
                width: min(88vw, 360px) !important;
                min-width: min(88vw, 360px) !important;
                transform: translateX(108%) !important;
                opacity: 0 !important;
                visibility: hidden !important;
                pointer-events: none !important;
                z-index: 1300 !important;
                border-inline-end: 0 !important;
                border-inline-start: 1px solid rgba(165, 216, 255, 0.2) !important;
                box-shadow: -24px 0 48px rgba(0, 0, 0, 0.42) !important;
                border-radius: 20px 0 0 20px !important;
                overflow: hidden;
            }
            body.light-mode .tg-sidebar {
                border-inline-start-color: rgba(12, 67, 121, 0.14) !important;
            }
            body.tg-sidebar-open .tg-sidebar {
                transform: translateX(0) !important;
                opacity: 1 !important;
                visibility: visible !important;
                pointer-events: auto !important;
            }
            body.tg-sidebar-open .tg-backdrop {
                display: block !important;
                opacity: 1 !important;
                pointer-events: auto !important;
            }
            .tg-chat-panel {
                display: flex !important;
            }
            .tg-sidebar-header {
                align-items: center;
                justify-content: space-between;
            }
            #tg-menu {
                display: none !important;
            }
            #tg-sidebar-close {
                display: inline-flex !important;
            }
        }
        @media (max-width: 768px) {
            .header.tg-topbar {
                gap: 8px;
                grid-template-columns: auto minmax(0, 1fr) auto;
            }
            .tg-chat-info {
                min-width: 0;
            }
            .header-actions.tg-actions {
                gap: 6px;
            }
            .header-actions.tg-actions .action-btn {
                width: 34px;
                height: 34px;
                border-radius: 10px;
            }
            .topbar-menu {
                min-width: 176px;
            }
        }
        /* --- Final UX fixes: desktop toggle, mobile voice-lock, light theme polish --- */
        .input-area-reply {
            background: rgba(28, 127, 211, 0.14);
            border: 1px solid rgba(103, 188, 255, 0.5);
            border-radius: 12px;
            color: #8bd0ff;
            font-size: 0.88rem;
            padding: 9px 12px;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }
        .input-area-reply strong {
            color: #c2e9ff;
        }
        .mobile-reply-indicator {
            display: none;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 8px 10px;
        }
        .header.tg-topbar {
            position: relative;
            display: flex !important;
            direction: ltr;
            align-items: center;
        }
        .header-actions.tg-actions {
            order: 1;
            justify-content: flex-start;
        }
        .tg-chat-info {
            order: 2;
            flex: 1;
            min-width: 0;
            direction: rtl;
            text-align: right;
        }
        .tg-back-btn {
            order: 3;
            margin-left: 0;
            margin-right: 6px;
        }
        #tg-menu-top {
            display: none;
        }
        .tg-back-btn {
            display: none;
        }
        @media (min-width: 1025px) {
            body.tg-sidebar-collapsed .tg-back-btn {
                display: inline-flex;
                position: absolute;
                right: 14px;
                top: 50%;
                transform: translateY(-50%);
                z-index: 3;
            }
            body.tg-sidebar-collapsed .tg-chat-info {
                margin-right: 42px;
            }
            body:not(.tg-sidebar-collapsed) .tg-back-btn {
                display: none;
            }
            #tg-menu-top {
                display: none !important;
            }
        }
        @media (max-width: 1024px) {
            #tg-menu-top {
                display: none !important;
            }
            .tg-back-btn {
                display: inline-flex !important;
            }
            .voice-recording-bar.mobile {
                direction: ltr;
                border-radius: 20px;
                background: rgba(10, 27, 41, 0.96);
                border: 1px solid rgba(171, 219, 255, 0.2);
                box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
                padding: 10px 12px;
            }
            .voice-recording-bar.mobile .voice-recording-core {
                direction: rtl;
                order: 1;
            }
            .voice-recording-bar.mobile .voice-recording-lock {
                order: 0;
                width: 42px;
                height: 42px;
                border-radius: 14px;
                background: rgba(255, 255, 255, 0.1);
                margin-left: 4px;
            }
            .voice-recording-bar.mobile .voice-recording-hint {
                font-size: 0.72rem;
            }
            .voice-recording-bar.mobile .voice-recording-stop {
                order: 2;
            }
            .voice-recording-bar.mobile .voice-recording-cancel {
                order: 3;
            }
            body.voice-recording-active .header.tg-topbar,
            body.voice-recording-active .topbar-overflow,
            body.voice-recording-active .tg-back-btn {
                pointer-events: none !important;
            }
            body.voice-recording-active .topbar-menu {
                display: none !important;
            }
        }
        body.light-mode {
            --ui-shell: rgba(255, 255, 255, 0.92);
            --ui-shell-border: rgba(40, 93, 145, 0.15);
            --ui-chat-in: #ffffff;
        }
        body.light-mode .voice-recording-bar.mobile {
            background: #ffffff;
            border-color: rgba(16, 82, 140, 0.14);
            box-shadow: 0 10px 20px rgba(15, 74, 129, 0.12);
        }
        body.light-mode #main-container.tg-app {
            background: linear-gradient(168deg, rgba(255, 255, 255, 0.94), rgba(245, 251, 255, 0.96));
            box-shadow: 0 20px 50px rgba(10, 60, 110, 0.16);
        }
        body.light-mode .tg-sidebar {
            background: linear-gradient(180deg, #ffffff, #f4f9ff);
        }
        body.light-mode .tg-sidebar-header {
            background: rgba(255, 255, 255, 0.9);
        }
        body.light-mode .tg-chat-item {
            border-color: rgba(20, 80, 130, 0.08);
        }
        body.light-mode .tg-chat-item:hover {
            background: rgba(26, 126, 214, 0.08);
            border-color: rgba(26, 126, 214, 0.18);
        }
        body.light-mode .tg-chat-item.active {
            background: linear-gradient(145deg, rgba(47, 153, 238, 0.18), rgba(47, 153, 238, 0.09));
            border-color: rgba(26, 126, 214, 0.26);
        }
        body.light-mode .header.tg-topbar {
            background: rgba(255, 255, 255, 0.92);
        }
        body.light-mode #chat-messages {
            background:
                radial-gradient(500px 260px at 12% 0%, rgba(88, 170, 244, 0.13), transparent 70%),
                radial-gradient(440px 240px at 100% 100%, rgba(76, 154, 226, 0.1), transparent 68%),
                linear-gradient(180deg, #f7fbff, #f2f8ff);
        }
        body.light-mode .message {
            border-color: rgba(17, 82, 139, 0.12);
            box-shadow: 0 6px 16px rgba(15, 74, 129, 0.1);
        }
        body.light-mode .other-message {
            background: #ffffff;
            color: #14324b;
        }
        body.light-mode .user-message {
            background: linear-gradient(145deg, #3ea7ff, #2291f0);
            color: #ffffff;
        }
        body.light-mode .message-file {
            background: rgba(10, 65, 120, 0.06);
            border-color: rgba(10, 65, 120, 0.14);
        }
        body.light-mode .reply-indicator,
        body.light-mode .input-area-reply {
            background: rgba(46, 146, 232, 0.14);
            border-color: rgba(46, 146, 232, 0.36);
            color: #1b76c5;
        }
        body.light-mode .reply-indicator strong,
        body.light-mode .input-area-reply strong {
            color: #0f5ca4;
        }
        body.light-mode .mobile-reply-indicator {
            background: rgba(255, 255, 255, 0.96);
            border-color: rgba(25, 108, 178, 0.2);
            color: #14508a;
        }
        body.light-mode .input-area-wrapper {
            background: rgba(252, 254, 255, 0.96);
            border-top-color: rgba(21, 88, 146, 0.12);
        }
        body.light-mode .desktop-input-row {
            background: #ffffff;
            border-color: rgba(17, 82, 139, 0.14);
        }
        body.light-mode .desktop-input {
            color: #0f2f48;
        }
        body.light-mode .topbar-menu-item {
            color: #123759;
        }
        body.light-mode .topbar-menu-item:hover {
            background: rgba(34, 132, 215, 0.12);
        }
        body.light-mode .topbar-menu-item.danger {
            color: #cf3248;
        }
        body.light-mode .topbar-menu-item.danger:hover {
            background: rgba(207, 50, 72, 0.12);
        }
        /* --- Popup + Login redesign polish --- */
        .modal-overlay {
            background:
                radial-gradient(480px 240px at 10% 0%, rgba(58, 165, 247, 0.2), transparent 70%),
                rgba(3, 10, 18, 0.64);
            backdrop-filter: blur(10px);
        }
        .modal-content {
            width: min(460px, calc(100vw - 24px));
            max-height: min(86vh, 720px);
            overflow: auto;
            border-radius: 24px;
            border: 1px solid rgba(182, 224, 255, 0.24);
            background: linear-gradient(175deg, rgba(14, 31, 47, 0.98), rgba(8, 20, 32, 0.97));
            padding: 20px;
            text-align: right;
            box-shadow: 0 30px 64px rgba(0, 0, 0, 0.42);
        }
        .modal-content::-webkit-scrollbar {
            width: 6px;
        }
        .modal-content::-webkit-scrollbar-thumb {
            background: rgba(158, 209, 252, 0.35);
            border-radius: 8px;
        }
        body.light-mode .modal-content {
            border-color: rgba(17, 83, 141, 0.14);
            background: linear-gradient(175deg, rgba(255, 255, 255, 0.99), rgba(244, 250, 255, 0.98));
            box-shadow: 0 24px 52px rgba(15, 72, 130, 0.18);
        }
        .modal-content h2,
        .modal-content h3 {
            font-weight: 800;
            letter-spacing: -0.1px;
            margin-bottom: 12px !important;
            color: #8bd0ff;
            text-align: right;
        }
        body.light-mode .modal-content h2,
        body.light-mode .modal-content h3 {
            color: #156ebf;
        }
        .preview-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 14px;
            padding-bottom: 12px;
            border-bottom: 1px solid rgba(172, 221, 255, 0.16);
        }
        body.light-mode .preview-header {
            border-bottom-color: rgba(22, 106, 176, 0.12);
        }
        .preview-header h3 {
            margin: 0 !important;
            font-size: 1.04rem;
            font-weight: 780;
        }
        .preview-close-btn {
            width: 36px;
            height: 36px;
            border: 1px solid rgba(170, 224, 255, 0.24);
            border-radius: 11px;
            background: rgba(255, 255, 255, 0.06);
            color: var(--ui-text-soft);
            font-size: 1.4rem;
            line-height: 1;
            cursor: pointer;
        }
        .preview-close-btn:hover {
            background: rgba(84, 177, 249, 0.16);
            color: var(--ui-text);
        }
        body.light-mode .preview-close-btn {
            background: rgba(10, 64, 116, 0.04);
            border-color: rgba(10, 64, 116, 0.14);
            color: #2a5f8d;
        }
        .preview-footer {
            display: flex;
            justify-content: stretch;
            gap: 10px;
            padding-top: 12px;
        }
        .preview-footer .preview-send-btn,
        .preview-footer .login-btn,
        .preview-footer .link-choice-btn {
            width: 100%;
        }
        .login-input,
        .link-input,
        .preview-caption-input {
            min-height: 50px;
            border-radius: 14px;
            border: 1px solid rgba(173, 217, 255, 0.22);
            background: rgba(10, 27, 41, 0.84);
            color: var(--ui-text);
            font-size: 0.95rem;
            padding: 0 14px;
            margin-bottom: 12px;
            text-align: right;
        }
        .preview-caption-input {
            min-height: 108px;
            padding: 12px 14px;
            resize: vertical;
        }
        .login-input:focus,
        .link-input:focus,
        .preview-caption-input:focus {
            border-color: rgba(75, 179, 255, 0.52);
            box-shadow: 0 0 0 4px rgba(75, 179, 255, 0.15);
        }
        body.light-mode .login-input,
        body.light-mode .link-input,
        body.light-mode .preview-caption-input {
            background: #ffffff;
            color: #12334f;
            border-color: rgba(17, 83, 141, 0.16);
        }
        .login-btn,
        .preview-send-btn,
        .voice-send-btn,
        .link-preview-btn,
        .link-choice-btn {
            min-height: 50px;
            border-radius: 14px;
            border: 1px solid rgba(173, 225, 255, 0.42);
            background: linear-gradient(145deg, #33acff, #1d84e3);
            color: #ffffff;
            font-size: 0.94rem;
            font-weight: 760;
            padding: 0 16px;
            cursor: pointer;
            transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.2s ease;
            box-shadow: 0 14px 28px rgba(22, 119, 208, 0.32);
        }
        .login-btn:hover,
        .preview-send-btn:hover,
        .voice-send-btn:hover,
        .link-preview-btn:hover,
        .link-choice-btn:hover {
            transform: translateY(-1px);
            filter: brightness(1.05);
        }
        .login-btn:active,
        .preview-send-btn:active,
        .voice-send-btn:active,
        .link-preview-btn:active,
        .link-choice-btn:active {
            transform: translateY(0) scale(0.985);
        }
        #login-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 10px;
            text-align: center;
            background: linear-gradient(168deg, rgba(10, 29, 45, 0.8), rgba(7, 20, 32, 0.72));
            padding: 28px 20px;
        }
        #login-container .login-input {
            width: min(390px, 100%);
            height: 54px;
            font-size: 1rem;
            border-radius: 16px;
            margin-bottom: 0;
        }
        #login-container #login-btn {
            width: min(390px, 100%);
            height: 54px;
            font-size: 1rem;
            border-radius: 16px;
        }
        .modal-overlay .modal-content {
            border-radius: 24px;
            border: 1px solid rgba(146, 197, 245, 0.28);
            background: linear-gradient(170deg, rgba(16, 40, 63, 0.95) 0%, rgba(11, 28, 46, 0.95) 100%);
            box-shadow: 0 26px 55px rgba(4, 11, 23, 0.45);
        }
        body.light-mode .modal-overlay .modal-content {
            border-color: rgba(34, 125, 209, 0.22);
            background: linear-gradient(170deg, #f6fbff 0%, #eaf4ff 100%);
            box-shadow: 0 22px 48px rgba(24, 104, 178, 0.17);
        }
        #password-modal .modal-content {
            width: min(410px, calc(100vw - 22px));
            padding: 22px;
        }
        #password-modal .login-input {
            height: 52px;
            font-size: 0.98rem;
            margin-bottom: 10px;
        }
        #password-modal #password-submit {
            height: 52px;
            font-size: 0.98rem;
        }
        #phone-modal .modal-content {
            width: min(430px, calc(100vw - 20px));
            padding: 24px 22px;
            border-radius: 24px;
            border: 1px solid rgba(146, 197, 245, 0.28);
            background: linear-gradient(170deg, rgba(16, 40, 63, 0.95) 0%, rgba(11, 28, 46, 0.95) 100%);
            box-shadow: 0 26px 55px rgba(4, 11, 23, 0.45);
        }
        body.light-mode #phone-modal .modal-content {
            border-color: rgba(34, 125, 209, 0.22);
            background: linear-gradient(170deg, #f6fbff 0%, #eaf4ff 100%);
            box-shadow: 0 22px 48px rgba(24, 104, 178, 0.17);
        }
        #phone-modal .phone-auth-step {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 14px;
        }
        #phone-modal .login-input {
            width: min(338px, 100%);
            height: 54px;
            font-size: 1rem;
            margin-bottom: 0;
            border-radius: 15px;
            text-align: center;
            direction: ltr;
            letter-spacing: 0.2px;
        }
        #phone-modal .login-btn {
            width: min(338px, 100%);
            height: 52px;
            font-size: 0.99rem;
            border-radius: 15px;
        }
        #phone-step-send .login-btn {
            margin-top: 8px;
        }
        #phone-step-verify .login-btn {
            margin-top: 4px;
        }
        #phone-modal #phone-modal-subtitle,
        #phone-modal #otp-phone-label,
        #phone-modal .auth-helper-text {
            text-align: center;
        }
        #otp-phone-label span[dir="ltr"] {
            direction: ltr;
            unicode-bidi: isolate;
            letter-spacing: 0.4px;
        }
        .auth-modal-card {
            text-align: center;
        }
        .auth-helper-text {
            min-height: 18px;
            margin: 0;
            font-size: 0.84rem;
            color: var(--text-secondary);
            text-align: center;
        }
        .auth-inline-actions {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 4px;
            flex-wrap: wrap;
        }
        .auth-link-btn {
            border: 0;
            background: rgba(34, 145, 240, 0.12);
            color: #8fd0ff;
            cursor: pointer;
            font-size: 0.84rem;
            font-weight: 650;
            padding: 6px 12px;
            border-radius: 999px;
            transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
        }
        .auth-link-btn:hover {
            transform: translateY(-1px);
            background: rgba(34, 145, 240, 0.2);
        }
        body.light-mode .auth-link-btn {
            background: rgba(22, 119, 208, 0.1);
            color: #1677d0;
        }
        body.light-mode .auth-link-btn:hover {
            background: rgba(22, 119, 208, 0.18);
        }
        .readonly-field {
            background: rgba(120, 168, 212, 0.12);
            color: var(--text-secondary);
            cursor: not-allowed;
            border-color: rgba(112, 174, 226, 0.26);
        }
        body.light-mode .readonly-field {
            background: rgba(22, 119, 208, 0.08);
            border-color: rgba(22, 119, 208, 0.18);
            color: #315a7e;
        }
        .group-invite-box {
            border: 1px solid rgba(114, 180, 236, 0.28);
            border-radius: 16px;
            background: rgba(12, 30, 48, 0.42);
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        body.light-mode .group-invite-box {
            border-color: rgba(24, 112, 192, 0.2);
            background: rgba(255, 255, 255, 0.7);
        }
        .group-invite-title {
            font-size: 0.82rem;
            color: var(--text-secondary);
        }
        .group-invite-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 8px;
            align-items: center;
        }
        #group-invite-link {
            margin-bottom: 0;
            text-align: left;
            direction: ltr;
            font-size: 0.85rem;
            height: 44px;
        }
        #group-invite-copy {
            min-width: 92px;
            min-height: 44px;
            border-radius: 12px;
            white-space: nowrap;
        }
        .invite-join-card {
            width: min(430px, calc(100vw - 20px));
            padding: 24px 20px;
            text-align: center;
        }
        .invite-join-avatar {
            width: 68px;
            height: 68px;
            border-radius: 50%;
            margin: 0 auto 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 1.3rem;
            color: #fff;
            background: linear-gradient(140deg, #2290f0, #1a6bbb);
            background-size: cover;
            background-position: center;
            box-shadow: 0 10px 22px rgba(9, 84, 148, 0.34);
        }
        #invite-join-title {
            margin: 0;
        }
        #invite-join-subtitle {
            margin: 8px 0 0;
            color: var(--text-secondary);
            font-size: 0.9rem;
        }
        #invite-join-bio {
            margin: 8px 0 0;
            color: var(--text-primary);
            font-size: 0.9rem;
            min-height: 1.4em;
        }
        .invite-join-actions {
            margin-top: 14px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }
        .invite-join-actions .login-btn {
            width: min(300px, 100%);
        }
        #group-info-modal .modal-content,
        #create-group-modal .modal-content,
        #profile-modal .modal-content,
        #private-chat-modal .modal-content,
        #password-modal .modal-content {
            width: min(440px, calc(100vw - 18px));
            padding: 14px;
        }
        .tg-modal-card {
            padding: 0 !important;
            overflow: hidden;
        }
        .tg-modal-card .preview-header {
            margin-bottom: 0;
            padding: 14px 16px 12px;
            background: linear-gradient(180deg, rgba(58, 163, 245, 0.12), rgba(58, 163, 245, 0.02));
        }
        body.light-mode .tg-modal-card .preview-header {
            background: linear-gradient(180deg, rgba(32, 129, 210, 0.1), rgba(32, 129, 210, 0.03));
        }
        .tg-modal-body {
            padding: 16px;
        }
        .tg-modal-stack {
            display: flex;
            flex-direction: column;
            gap: 13px;
        }
        .tg-modal-avatar-row {
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }
        .tg-modal-avatar-controls {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 10px;
            padding-top: 2px;
        }
        .tg-photo-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-top: 4px;
        }
        .tg-modal-avatar-controls .login-input {
            margin-bottom: 0;
        }
        #group-photo-pick,
        #profile-photo-pick {
            margin-top: 0;
        }
        #private-chat-modal .preview-header {
            direction: rtl;
        }
        #private-chat-modal .preview-close-btn {
            margin-right: auto;
            margin-left: 0;
        }
        .private-toast-stack {
            position: fixed;
            left: 14px;
            bottom: 16px;
            z-index: 14000;
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
            width: min(340px, calc(100vw - 20px));
        }
        .private-toast {
            pointer-events: auto;
            border-radius: 16px;
            border: 1px solid rgba(137, 203, 255, 0.36);
            background: linear-gradient(150deg, rgba(18, 48, 76, 0.96), rgba(11, 27, 43, 0.94));
            box-shadow: 0 18px 34px rgba(6, 20, 34, 0.42);
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 11px 12px;
            transform: translateY(8px);
            opacity: 0;
            transition: transform 0.2s ease, opacity 0.2s ease;
            cursor: pointer;
        }
        .private-toast.show {
            transform: translateY(0);
            opacity: 1;
        }
        .private-toast-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            flex: 0 0 40px;
            display: grid;
            place-items: center;
            font-weight: 700;
            color: #fff;
            background: linear-gradient(140deg, #30aaf6, #1578d7);
            background-size: cover;
            background-position: center;
        }
        .private-toast-main {
            min-width: 0;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
        .private-toast-title {
            font-size: 0.87rem;
            font-weight: 720;
            color: #e9f4ff;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .private-toast-text {
            font-size: 0.78rem;
            color: #bcd3e6;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .private-toast-close {
            width: 30px;
            height: 30px;
            border-radius: 10px;
            border: 1px solid rgba(154, 208, 255, 0.26);
            background: rgba(148, 191, 231, 0.14);
            color: #dff1ff;
            cursor: pointer;
            font-size: 1rem;
            line-height: 1;
        }
        body.light-mode .private-toast {
            border-color: rgba(23, 110, 185, 0.25);
            background: linear-gradient(150deg, rgba(255, 255, 255, 0.97), rgba(243, 250, 255, 0.96));
            box-shadow: 0 14px 30px rgba(22, 95, 162, 0.22);
        }
        body.light-mode .private-toast-title {
            color: #175f98;
        }
        body.light-mode .private-toast-text {
            color: #4f7394;
        }
        body.light-mode .private-toast-close {
            border-color: rgba(22, 110, 188, 0.2);
            background: rgba(22, 110, 188, 0.08);
            color: #1b6eae;
        }
        .tg-private-modal-body {
            padding-top: 12px;
        }
        #group-info-modal .modal-content > div:last-child,
        #create-group-modal .modal-content > div:last-child,
        #profile-modal .modal-content > div:last-child,
        #private-chat-modal .modal-content > div:last-child {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        #group-info-modal .login-input,
        #create-group-modal .login-input,
        #profile-modal .login-input,
        #private-chat-modal .login-input,
        #password-modal .login-input,
        #phone-modal .login-input {
            margin: 0;
            min-height: 50px;
            border-radius: 14px;
        }
        #group-info-modal .preview-caption-input,
        #profile-modal .preview-caption-input {
            margin: 0;
            border-radius: 14px;
        }
        #group-info-modal .preview-footer,
        #create-group-modal .preview-footer,
        #profile-modal .preview-footer {
            margin: 0;
            padding: 4px 0 0;
        }
        #group-info-modal .preview-send-btn,
        #create-group-modal .preview-send-btn,
        #profile-modal .preview-send-btn {
            width: 100%;
            min-height: 50px;
            border-radius: 14px;
        }
        .private-user-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: min(52vh, 420px);
            overflow: auto;
            padding: 4px 2px;
        }
        .private-user-item {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            border: 1px solid rgba(122, 186, 238, 0.25);
            background: rgba(17, 40, 63, 0.4);
            border-radius: 14px;
            padding: 10px;
            color: var(--text-primary);
            text-align: right;
            cursor: pointer;
            transition: transform 0.18s ease, background 0.18s ease;
        }
        .private-user-item:hover {
            transform: translateY(-1px);
            background: rgba(31, 86, 132, 0.5);
        }
        body.light-mode .private-user-item {
            background: rgba(255, 255, 255, 0.78);
            border-color: rgba(27, 119, 195, 0.2);
        }
        body.light-mode .private-user-item:hover {
            background: rgba(236, 247, 255, 0.95);
        }
        .private-user-meta {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            gap: 2px;
        }
        .private-user-name {
            font-size: 0.93rem;
            font-weight: 620;
        }
        .private-user-username {
            font-size: 0.78rem;
            color: var(--text-secondary);
            direction: ltr;
        }
        .private-online-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: auto;
            background: #5ccf78;
            box-shadow: 0 0 8px rgba(92, 207, 120, 0.65);
        }
        .private-online-dot.offline {
            background: #9da8b3;
            box-shadow: none;
        }
        #edit-modal .modal-content {
            width: min(470px, calc(100vw - 24px));
        }
        #edit-modal .modal-content > div:last-child {
            display: flex;
            gap: 10px;
        }
        #edit-modal .modal-content > div:last-child .login-btn {
            width: 100%;
        }
        @media (max-width: 768px) {
            .modal-content {
                width: calc(100vw - 16px);
                border-radius: 18px;
                padding: 14px;
                max-height: min(88vh, 780px);
            }
            .login-btn,
            .preview-send-btn,
            .voice-send-btn,
            .link-preview-btn,
            .link-choice-btn {
                min-height: 48px;
                font-size: 0.91rem;
            }
            #login-container {
                padding: 22px 14px;
            }
            #login-container .login-input,
            #login-container #login-btn {
                width: 100%;
                max-width: 100%;
                height: 50px;
            }
            #phone-modal .modal-content {
                border-radius: 20px;
                padding: 20px 14px;
            }
            #phone-modal .login-input,
            #phone-modal .login-btn {
                width: 100%;
                max-width: 100%;
            }
            .group-invite-row {
                grid-template-columns: 1fr;
            }
            #group-invite-copy {
                width: 100%;
            }
            .invite-join-card {
                width: calc(100vw - 16px);
                border-radius: 20px;
                padding: 18px 14px;
            }
            #group-info-modal .modal-content,
            #create-group-modal .modal-content,
            #profile-modal .modal-content,
            #private-chat-modal .modal-content,
            #password-modal .modal-content {
                width: calc(100vw - 14px);
            }
            .tg-modal-card .preview-header {
                padding: 12px 12px 10px;
            }
            .tg-modal-body {
                padding: 12px;
            }
            .tg-modal-avatar-row {
                gap: 10px;
            }
            .tg-modal-avatar-controls {
                gap: 8px;
            }
            .tg-photo-actions {
                grid-template-columns: 1fr;
            }
            .private-toast-stack {
                left: 8px;
                right: 8px;
                width: auto;
                bottom: 10px;
            }
            .private-toast {
                border-radius: 14px;
            }
            .tg-sidebar-tabs {
                padding: 6px 10px 8px;
                gap: 6px;
            }
            .tg-folder-tab {
                height: 32px;
                font-size: 0.74rem;
            }
            .tg-sidebar-sections {
                padding: 2px 8px 12px;
            }
            .tg-section-head {
                padding: 2px 2px 0;
                gap: 8px;
            }
            .section-create-btn {
                min-width: 104px;
                height: 34px;
                font-size: 0.74rem;
            }
            .tg-chat-list {
                max-height: min(30vh, 300px);
                padding: 4px 8px 8px;
            }
            body.tg-sidebar-view-groups .tg-section-groups .tg-chat-list,
            body.tg-sidebar-view-private .tg-section-private .tg-chat-list {
                max-height: min(50vh, 540px);
            }
            body.tg-sidebar-view-channels .tg-section-channels .tg-chat-list {
                max-height: min(50vh, 540px);
            }
        }
        /* --- iOS-style mobile composer redesign --- */
        .tg-ios-composer {
            display: grid !important;
            grid-template-columns: 46px minmax(0, 1fr) 52px;
            align-items: center;
            gap: 8px;
            background: transparent !important;
            border: 0 !important;
            box-shadow: none !important;
            padding: 0 !important;
            min-height: 56px;
        }
        .tg-ios-composer .ios-upload-btn {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            border: 1px solid rgba(169, 216, 255, 0.2);
            background: rgba(9, 30, 46, 0.8);
            color: #87ceff;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
        }
        .tg-ios-composer .ios-upload-btn:hover,
        .tg-ios-composer .ios-upload-btn:active {
            background: rgba(32, 131, 211, 0.2);
            color: #d8f1ff;
            transform: none;
        }
        .tg-ios-composer .mobile-input-pill {
            display: flex;
            align-items: center;
            min-width: 0;
            height: 48px;
            border-radius: 24px;
            border: 1px solid rgba(166, 215, 255, 0.2);
            background: rgba(8, 24, 37, 0.88);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 20px rgba(0,0,0,0.22);
            padding: 0 14px;
        }
        .tg-ios-composer .mobile-floating-input {
            width: 100%;
            height: 100%;
            border: 0;
            background: transparent;
            border-radius: 0;
            padding: 0;
            margin: 0;
            color: #e9f4ff;
            font-size: 0.96rem;
            line-height: 1;
            text-align: right;
        }
        .tg-ios-composer .mobile-floating-input::placeholder {
            color: rgba(185, 213, 236, 0.72);
        }
        .tg-ios-composer .mobile-floating-input:focus {
            background: transparent;
            box-shadow: none;
        }
        .tg-ios-composer .mobile-action-stack {
            position: relative;
            width: 50px;
            height: 50px;
        }
        .tg-ios-composer .mobile-action-stack .mobile-icon-btn {
            position: absolute;
            inset: 0;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            border: 0;
            transition: opacity 0.18s ease, transform 0.18s ease, filter 0.18s ease;
        }
        .tg-ios-composer .ios-voice-btn {
            background: linear-gradient(145deg, #228fe9, #1f7fd1);
            color: #ffffff;
            box-shadow: 0 12px 24px rgba(19, 109, 187, 0.36);
            opacity: 1;
            transform: scale(1);
            pointer-events: auto;
        }
        .tg-ios-composer .ios-send-btn {
            background: linear-gradient(145deg, #31adff, #1d88e6);
            color: #ffffff;
            box-shadow: 0 12px 24px rgba(21, 126, 216, 0.38);
            opacity: 0;
            transform: scale(0.74);
            pointer-events: none;
        }
        .tg-ios-composer.has-text .ios-voice-btn {
            opacity: 0;
            transform: scale(0.74);
            pointer-events: none;
        }
        .tg-ios-composer.has-text .ios-send-btn {
            opacity: 1;
            transform: scale(1);
            pointer-events: auto;
        }
        .tg-ios-composer .mobile-action-stack .mobile-icon-btn:active {
            transform: scale(0.96);
        }
        .tg-ios-composer .mobile-action-stack .mobile-icon-btn svg {
            width: 21px;
            height: 21px;
        }
        .tg-ios-composer .ios-send-btn svg {
            transform: translateX(-1px) rotate(-8deg);
        }
        body.light-mode .tg-ios-composer .ios-upload-btn {
            background: rgba(255, 255, 255, 0.96);
            border-color: rgba(18, 94, 157, 0.16);
            color: #2c7dc4;
            box-shadow: 0 6px 14px rgba(17, 83, 141, 0.1);
        }
        body.light-mode .tg-ios-composer .mobile-input-pill {
            background: #ffffff;
            border-color: rgba(16, 82, 140, 0.15);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 8px 16px rgba(16,82,140,0.1);
        }
        body.light-mode .tg-ios-composer .mobile-floating-input {
            color: #12324b;
        }
        body.light-mode .tg-ios-composer .mobile-floating-input::placeholder {
            color: rgba(37, 89, 129, 0.62);
        }
        body.light-mode .tg-ios-composer .ios-voice-btn {
            background: linear-gradient(145deg, #2f9ff8, #217fd4);
        }
        body.light-mode .tg-ios-composer .ios-send-btn {
            background: linear-gradient(145deg, #2fb0ff, #1f8be4);
        }
        @media (max-width: 480px) {
            .tg-ios-composer {
                grid-template-columns: 42px minmax(0, 1fr) 48px;
                gap: 6px;
            }
            .tg-ios-composer .ios-upload-btn {
                width: 40px;
                height: 40px;
            }
            .tg-ios-composer .mobile-input-pill {
                height: 44px;
                padding: 0 12px;
            }
            .tg-ios-composer .mobile-action-stack {
                width: 46px;
                height: 46px;
            }
            .tg-ios-composer .mobile-action-stack .mobile-icon-btn {
                width: 46px;
                height: 46px;
            }
        }
        /* --- Final button palette harmonization + stable mobile voice bar --- */
        :root {
            --btn-primary-a: #37abff;
            --btn-primary-b: #248fe8;
            --btn-primary-border: rgba(180, 227, 255, 0.44);
            --btn-neutral-bg: rgba(10, 30, 46, 0.76);
            --btn-neutral-border: rgba(166, 215, 255, 0.24);
            --btn-neutral-text: #9ad9ff;
            --btn-voice-icon: #1f87db;
        }
        body.light-mode {
            --btn-neutral-bg: #ffffff;
            --btn-neutral-border: rgba(19, 88, 149, 0.17);
            --btn-neutral-text: #2f7fc4;
            --btn-voice-icon: #227fcf;
        }
        .login-btn,
        .preview-send-btn,
        .voice-send-btn,
        .link-preview-btn,
        .link-choice-btn,
        .send-btn,
        .btn-send,
        .tg-ios-composer .ios-send-btn {
            background: linear-gradient(145deg, var(--btn-primary-a), var(--btn-primary-b)) !important;
            border: 1px solid var(--btn-primary-border) !important;
            color: #ffffff !important;
            box-shadow: 0 12px 24px rgba(18, 115, 194, 0.28) !important;
        }
        .mobile-icon-btn:not(.btn-send):not(.ios-send-btn):not(.ios-voice-btn):not(.recording),
        .action-btn,
        .tg-icon-btn {
            background: var(--btn-neutral-bg) !important;
            border: 1px solid var(--btn-neutral-border) !important;
            color: var(--btn-neutral-text) !important;
        }
        .mobile-icon-btn:not(.btn-send):not(.ios-send-btn):not(.ios-voice-btn):not(.recording):hover,
        .action-btn:hover,
        .tg-icon-btn:hover {
            background: rgba(58, 165, 247, 0.18) !important;
            color: #d8efff !important;
        }
        body.light-mode .mobile-icon-btn:not(.btn-send):not(.ios-send-btn):not(.ios-voice-btn):not(.recording):hover,
        body.light-mode .action-btn:hover,
        body.light-mode .tg-icon-btn:hover {
            color: #1b6eb6 !important;
        }
        /* iOS mobile mic button: always white and clear on both themes */
        .tg-ios-composer .ios-voice-btn {
            background: #ffffff !important;
            border: 1px solid rgba(125, 196, 245, 0.48) !important;
            color: var(--btn-voice-icon) !important;
            box-shadow: 0 10px 22px rgba(20, 111, 188, 0.22), inset 0 1px 0 rgba(255,255,255,0.95) !important;
        }
        .tg-ios-composer .ios-voice-btn:hover {
            filter: brightness(1.02);
            transform: translateY(-1px);
        }
        .tg-ios-composer .ios-voice-btn.recording,
        .mobile-icon-btn.ios-voice-btn.recording {
            background: #ffffff !important;
            border: 1px solid rgba(255, 122, 122, 0.62) !important;
            color: #ff4f4f !important;
            box-shadow: 0 0 0 5px rgba(255, 82, 82, 0.18), 0 10px 22px rgba(214, 63, 63, 0.2) !important;
        }
        body.light-mode .tg-ios-composer .ios-voice-btn {
            border-color: rgba(24, 103, 171, 0.24) !important;
            box-shadow: 0 8px 16px rgba(17, 83, 141, 0.14), inset 0 1px 0 rgba(255,255,255,0.96) !important;
        }
        .mobile-floating-container {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .voice-recording-bar.mobile,
        .voice-preview-bar.mobile {
            margin: 0 !important;
            width: 100%;
        }
        .voice-recording-bar.mobile {
            align-items: center;
            min-height: 58px;
        }
        .voice-recording-bar.mobile .voice-recording-core {
            min-width: 0;
        }
        .story-strip {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-bottom: 1px solid var(--border-color);
            background: linear-gradient(180deg, rgba(30, 113, 182, 0.14), rgba(20, 82, 134, 0.04));
        }
        .story-create-btn {
            border: 1px solid rgba(108, 184, 242, 0.34);
            background: rgba(20, 93, 154, 0.26);
            color: #d9efff;
            border-radius: 999px;
            min-height: 38px;
            padding: 0 14px;
            font-weight: 700;
            cursor: pointer;
        }
        .story-items {
            display: flex;
            align-items: center;
            gap: 8px;
            overflow-x: auto;
            padding-bottom: 2px;
        }
        .story-items::-webkit-scrollbar {
            height: 4px;
        }
        .story-items::-webkit-scrollbar-thumb {
            background: rgba(137, 196, 240, 0.45);
            border-radius: 999px;
        }
        .story-item {
            border: 0;
            background: transparent;
            display: inline-flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            cursor: pointer;
            min-width: 58px;
            color: var(--text-secondary);
            font-size: 0.72rem;
        }
        .story-item .story-ring {
            width: 46px;
            height: 46px;
            border-radius: 50%;
            padding: 2px;
            background: linear-gradient(135deg, #2aabee, #3d67ff);
            display: grid;
            place-items: center;
        }
        .story-item.is-seen .story-ring {
            background: #7f9ab1;
        }
        .story-item .story-avatar {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: #153753;
            color: #fff;
            display: grid;
            place-items: center;
            font-weight: 700;
            background-size: cover;
            background-position: center;
            border: 2px solid rgba(7, 20, 33, 0.9);
        }
        .advanced-send-wrap {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 2px;
        }
        .advanced-send-toggle {
            border: 1px solid rgba(118, 186, 241, 0.28);
            background: rgba(17, 55, 84, 0.42);
            color: #bfe4ff;
            border-radius: 12px;
            min-height: 38px;
            padding: 0 12px;
            cursor: pointer;
            font-weight: 650;
            align-self: flex-start;
        }
        .advanced-send-panel {
            border: 1px solid rgba(117, 185, 241, 0.24);
            border-radius: 14px;
            background: rgba(13, 34, 53, 0.48);
            padding: 10px;
            display: grid;
            gap: 8px;
        }
        .advanced-send-panel .advanced-field {
            display: grid;
            gap: 5px;
        }
        .advanced-send-panel label {
            font-size: 0.78rem;
            color: var(--text-secondary);
            text-align: right;
        }
        .advanced-send-panel .login-input {
            margin: 0;
            min-height: 44px;
            border-radius: 10px;
        }
        .public-msg-avatar {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 0.72rem;
            font-weight: 700;
            color: #fff;
            background: linear-gradient(145deg, #35acef, #2870c7);
            background-size: cover;
            background-position: center;
            flex: 0 0 24px;
        }
        .group-members-box {
            border: 1px solid rgba(124, 192, 244, 0.25);
            border-radius: 14px;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            background: rgba(12, 31, 48, 0.42);
        }
        .group-members-head {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
        }
        .group-member-count {
            font-size: 0.78rem;
            color: var(--text-secondary);
        }
        .group-admin-prompt {
            display: grid;
            grid-template-columns: minmax(0,1fr) auto;
            gap: 8px;
            align-items: center;
        }
        .group-admin-prompt .login-input {
            margin: 0;
            min-height: 42px;
            border-radius: 10px;
        }
        .group-members-list {
            display: flex;
            flex-direction: column;
            max-height: 200px;
            overflow: auto;
            gap: 7px;
        }
        .group-member-row {
            display: flex;
            align-items: center;
            gap: 8px;
            border: 1px solid rgba(117, 186, 240, 0.22);
            border-radius: 12px;
            padding: 8px;
            background: rgba(17, 46, 69, 0.44);
        }
        .group-member-meta {
            min-width: 0;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            flex: 1;
            gap: 2px;
        }
        .group-member-name {
            font-size: 0.86rem;
            font-weight: 700;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .group-member-user {
            font-size: 0.75rem;
            color: var(--text-secondary);
            direction: ltr;
        }
        .group-member-role {
            font-size: 0.67rem;
            padding: 3px 7px;
            border-radius: 999px;
            color: #dff2ff;
            background: rgba(30, 139, 220, 0.34);
        }
        .group-member-action {
            min-height: 34px;
            border-radius: 10px;
            border: 1px solid rgba(141, 199, 244, 0.32);
            background: rgba(27, 95, 151, 0.32);
            color: #daefff;
            padding: 0 10px;
            font-size: 0.74rem;
            cursor: pointer;
        }
        .story-create-preview {
            border: 1px dashed rgba(132, 197, 245, 0.34);
            min-height: 120px;
            border-radius: 14px;
            padding: 8px;
            display: grid;
            place-items: center;
            overflow: hidden;
            background: rgba(15, 37, 56, 0.42);
        }
        .story-create-preview img,
        .story-create-preview video {
            max-width: 100%;
            max-height: 240px;
            border-radius: 12px;
        }
        .story-preview-empty {
            color: var(--text-secondary);
            font-size: 0.8rem;
        }
        .story-view-card {
            width: min(460px, calc(100vw - 14px));
            padding: 0 !important;
            overflow: hidden;
        }
        .story-view-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .story-view-user {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .story-view-meta {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            gap: 2px;
        }
        #story-view-time {
            font-size: 0.78rem;
            color: var(--text-secondary);
        }
        .story-view-body {
            padding: 12px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        #story-view-image,
        #story-view-video {
            width: 100%;
            max-height: min(52vh, 420px);
            border-radius: 12px;
            background: #06111c;
            object-fit: contain;
        }
        .story-view-text {
            min-height: 140px;
            border-radius: 14px;
            padding: 12px;
            background: rgba(12, 36, 56, 0.46);
            color: var(--text-primary);
            white-space: pre-wrap;
            font-size: 0.95rem;
            text-align: right;
        }
        .story-view-caption {
            color: var(--text-primary);
            text-align: right;
            white-space: pre-wrap;
            font-size: 0.86rem;
            min-height: 1.2em;
        }
        .story-view-viewers {
            border: 1px solid rgba(123, 189, 242, 0.24);
            border-radius: 12px;
            padding: 8px;
            max-height: 160px;
            overflow: auto;
            display: none;
            flex-direction: column;
            gap: 6px;
            background: rgba(12, 36, 56, 0.34);
        }
        .story-view-viewer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            font-size: 0.8rem;
            color: var(--text-secondary);
            direction: ltr;
        }
        .story-view-actions {
            padding: 0 12px 12px;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }
        .user-message .seen-indicator {
            color: #d4e7ff;
            opacity: 1;
        }
        .user-message .seen-indicator[data-empty="false"] .seen-checks {
            color: #53d1ff;
        }
        body.light-mode .user-message .seen-indicator {
            color: #365776;
        }
        body.light-mode .user-message .seen-indicator[data-empty="false"] .seen-checks {
            color: #008ce9;
        }
        .modal-overlay {
            padding: 12px;
            overflow-y: auto;
        }
        .modal-content {
            margin: auto;
        }
        #password-modal .login-btn,
        #password-modal #password-submit,
        #phone-modal .login-btn,
        #phone-send-btn,
        #otp-verify-btn {
            width: 100%;
            max-width: 340px;
            min-height: 52px;
            border-radius: 14px;
            font-size: 0.96rem;
        }
        @media (max-width: 768px) {
            .modal-overlay {
                align-items: flex-start;
                padding: 8px;
            }
            .modal-content {
                width: calc(100vw - 10px) !important;
                max-width: calc(100vw - 10px) !important;
                max-height: calc(100vh - 18px);
                overflow-y: auto;
                margin: 0 auto;
            }
            .story-strip {
                padding: 8px;
                gap: 8px;
            }
            .story-create-btn {
                min-height: 34px;
                padding: 0 10px;
                font-size: 0.8rem;
            }
            .story-item {
                min-width: 50px;
                font-size: 0.68rem;
            }
            .story-item .story-ring {
                width: 40px;
                height: 40px;
            }
            .advanced-send-wrap {
                margin-bottom: 0;
            }
            .advanced-send-toggle {
                width: 100%;
            }
            .group-admin-prompt {
                grid-template-columns: 1fr;
            }
            .story-view-card {
                width: calc(100vw - 8px);
            }
        }
        body.light-mode .story-strip {
            background: linear-gradient(180deg, rgba(37, 139, 223, 0.11), rgba(37, 139, 223, 0.03));
        }
        body.light-mode .story-create-btn {
            color: #1a6ca9;
            background: rgba(39, 136, 218, 0.12);
            border-color: rgba(39, 136, 218, 0.28);
        }
        body.light-mode .advanced-send-panel {
            background: rgba(255,255,255,0.82);
            border-color: rgba(39, 136, 218, 0.2);
        }
        body.light-mode .advanced-send-toggle {
            color: #1f6da9;
            background: rgba(39, 136, 218, 0.1);
            border-color: rgba(39, 136, 218, 0.2);
        }
        body.light-mode .group-members-box,
        body.light-mode .story-create-preview,
        body.light-mode .story-view-viewers,
        body.light-mode .group-member-row {
            background: rgba(255,255,255,0.78);
            border-color: rgba(39, 136, 218, 0.2);
        }
        body.light-mode .group-member-role {
            color: #1970ae;
            background: rgba(39, 136, 218, 0.12);
        }
        /* --- Final override: Instagram-like story + premium modals --- */
        .advanced-send-wrap {
            display: none !important;
        }
        .modal-overlay {
            align-items: center !important;
            justify-content: center !important;
            overflow: hidden !important;
            padding: 10px !important;
        }
        .modal-content {
            overflow: hidden !important;
            max-height: none !important;
            transform-origin: center center !important;
            --fit-scale: 1;
            transform: none !important;
        }
        .tg-modal-card {
            border-radius: 20px !important;
            border: 1px solid rgba(113, 188, 246, 0.28) !important;
            background: linear-gradient(178deg, rgba(14, 38, 61, 0.98), rgba(10, 27, 44, 0.98)) !important;
            box-shadow: 0 24px 46px rgba(2, 10, 21, 0.52) !important;
        }
        body.light-mode .tg-modal-card {
            border-color: rgba(28, 121, 198, 0.2) !important;
            background: linear-gradient(178deg, #f8fbff, #eef6ff) !important;
            box-shadow: 0 20px 38px rgba(18, 96, 165, 0.2) !important;
        }
        .tg-modal-card .preview-header {
            padding: 12px 14px !important;
            border-bottom: 1px solid rgba(120, 184, 233, 0.18);
            background: rgba(30, 109, 176, 0.16) !important;
        }
        body.light-mode .tg-modal-card .preview-header {
            background: rgba(39, 136, 218, 0.09) !important;
        }
        .tg-modal-body {
            padding: 12px !important;
            gap: 10px !important;
        }
        #group-info-modal .tg-modal-body,
        #create-group-modal .tg-modal-body,
        #profile-modal .tg-modal-body,
        #private-chat-modal .tg-modal-body {
            gap: 9px !important;
        }
        #group-info-modal .login-input,
        #create-group-modal .login-input,
        #profile-modal .login-input,
        #private-chat-modal .login-input,
        .message-timing-card .login-input {
            min-height: 44px !important;
            border-radius: 12px !important;
            font-size: 0.9rem !important;
        }
        #group-info-modal .preview-caption-input,
        #profile-modal .preview-caption-input,
        #story-text-input {
            min-height: 74px !important;
            border-radius: 12px !important;
            font-size: 0.88rem !important;
        }
        .group-members-list {
            display: grid !important;
            grid-template-columns: 1fr 1fr !important;
            gap: 6px !important;
            max-height: none !important;
            overflow: hidden !important;
        }
        .private-user-list,
        #notif-history-list,
        .story-view-viewers {
            max-height: none !important;
            overflow: hidden !important;
        }
        .group-member-row {
            padding: 7px !important;
            border-radius: 10px !important;
        }
        .group-member-name {
            font-size: 0.8rem !important;
        }
        .group-member-user {
            font-size: 0.7rem !important;
        }
        .group-member-action {
            min-height: 30px !important;
            padding: 0 7px !important;
            font-size: 0.68rem !important;
        }
        .story-strip {
            padding: 10px 12px !important;
            background: #0a1824 !important;
            border-bottom: 1px solid rgba(102, 177, 238, 0.2) !important;
        }
        body.light-mode .story-strip {
            background: #ffffff !important;
            border-bottom-color: rgba(24, 105, 177, 0.16) !important;
        }
        .story-create-btn {
            border-radius: 14px !important;
            min-height: 36px !important;
            padding: 0 12px !important;
            font-size: 0.82rem !important;
        }
        .story-item {
            min-width: 62px !important;
            gap: 5px !important;
        }
        .story-item .story-ring {
            width: 54px !important;
            height: 54px !important;
            padding: 2px !important;
            background: linear-gradient(45deg, #f9ce34 0%, #ee2a7b 45%, #6228d7 95%) !important;
        }
        .story-item.is-seen .story-ring {
            background: linear-gradient(45deg, #8ca2b2, #7f97a7) !important;
        }
        .story-item .story-avatar {
            border: 2px solid #0a1824 !important;
            font-size: 0.85rem !important;
        }
        body.light-mode .story-item .story-avatar {
            border-color: #ffffff !important;
        }
        .story-view-card {
            width: min(430px, calc(100vw - 14px)) !important;
            border-radius: 24px !important;
            border: 0 !important;
            background: #000000 !important;
            box-shadow: 0 30px 56px rgba(0, 0, 0, 0.6) !important;
            position: relative;
        }
        .story-progress-track {
            position: absolute;
            top: 10px;
            left: 10px;
            right: 10px;
            display: flex;
            gap: 4px;
            z-index: 6;
        }
        .story-progress-seg {
            flex: 1;
            height: 2.6px;
            background: rgba(255, 255, 255, 0.25);
            border-radius: 999px;
            overflow: hidden;
        }
        .story-progress-fill {
            display: block;
            width: 0%;
            height: 100%;
            background: #ffffff;
            transition: width 0.08s linear;
        }
        .story-view-header {
            position: absolute !important;
            top: 16px;
            left: 12px;
            right: 12px;
            z-index: 7;
            padding: 0 !important;
            background: transparent !important;
            border: 0 !important;
        }
        .story-view-user {
            gap: 8px !important;
        }
        .story-view-user .tg-avatar {
            width: 34px !important;
            height: 34px !important;
            border: 2px solid rgba(255, 255, 255, 0.8);
            color: #fff !important;
        }
        .story-view-meta strong,
        #story-view-time {
            color: #ffffff !important;
        }
        .story-view-body {
            padding: 0 !important;
            min-height: 560px;
            background: #000;
        }
        #story-view-image,
        #story-view-video,
        .story-view-text {
            width: 100% !important;
            height: 100% !important;
            max-height: none !important;
            min-height: 560px !important;
            border-radius: 0 !important;
            object-fit: cover !important;
            background: #000;
        }
        .story-view-text {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 60px 18px 70px !important;
            text-align: center !important;
            font-size: 1.08rem !important;
            line-height: 1.8;
            color: #ffffff;
            background: linear-gradient(145deg, #111 0%, #000 100%) !important;
        }
        .story-view-caption {
            position: absolute;
            bottom: 18px;
            left: 14px;
            right: 14px;
            color: #fff !important;
            text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
            text-align: right !important;
            z-index: 6;
            font-size: 0.85rem !important;
        }
        .story-view-viewers {
            position: absolute;
            bottom: 44px;
            left: 14px;
            right: 14px;
            background: rgba(0, 0, 0, 0.55) !important;
            border: 1px solid rgba(255, 255, 255, 0.22) !important;
            backdrop-filter: blur(6px);
            z-index: 6;
            display: none;
        }
        .story-view-viewer {
            color: #f4f8ff !important;
        }
        .story-nav-zone {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 36%;
            border: 0;
            background: transparent;
            z-index: 5;
            cursor: pointer;
        }
        .story-nav-prev {
            left: 0;
        }
        .story-nav-next {
            right: 0;
        }
        .message-timing-card {
            width: min(420px, calc(100vw - 16px)) !important;
        }
        .timing-quick-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }
        .timing-chip {
            min-height: 38px;
            border-radius: 12px;
            border: 1px solid rgba(132, 198, 245, 0.26);
            background: rgba(24, 76, 116, 0.34);
            color: #d9eeff;
            font-size: 0.82rem;
            font-weight: 700;
            cursor: pointer;
        }
        .timing-chip.is-active {
            background: linear-gradient(135deg, #2aabee, #2088e0);
            color: #fff;
            border-color: rgba(194, 230, 255, 0.45);
        }
        body.light-mode .timing-chip {
            color: #1f6ea9;
            background: rgba(39, 136, 218, 0.1);
            border-color: rgba(39, 136, 218, 0.22);
        }
        .timing-preview {
            border: 1px solid rgba(119, 187, 241, 0.24);
            background: rgba(16, 48, 74, 0.34);
            color: #cce8ff;
            border-radius: 11px;
            padding: 8px 10px;
            font-size: 0.8rem;
            line-height: 1.7;
            min-height: 46px;
            text-align: right;
        }
        body.light-mode .timing-preview {
            background: rgba(39, 136, 218, 0.07);
            color: #216ea7;
            border-color: rgba(39, 136, 218, 0.2);
        }
        .send-btn.has-schedule,
        .mobile-icon-btn.has-schedule {
            box-shadow: 0 0 0 2px rgba(67, 186, 106, 0.35);
            border-color: rgba(72, 201, 116, 0.48) !important;
        }
        .message.is-pending {
            opacity: 0.72;
            filter: saturate(0.86);
        }
        .message.is-pending .timestamp::after {
            content: ' \25CF';
            color: #f2c94c;
            font-size: 0.72rem;
        }
        #ctx-reply-private {
            color: var(--primary);
        }
        .send-hold-card {
            width: min(320px, calc(100vw - 24px));
        }
        .scheduled-list-card {
            width: min(430px, calc(100vw - 20px));
        }
        .scheduled-list-container {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .scheduled-item {
            border: 1px solid rgba(125, 187, 236, 0.24);
            border-radius: 12px;
            padding: 10px;
            background: rgba(18, 55, 86, 0.28);
            display: grid;
            gap: 8px;
        }
        .scheduled-item-head {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            color: var(--text-primary);
            font-size: 0.84rem;
        }
        .scheduled-item-text {
            color: var(--text-secondary);
            font-size: 0.78rem;
            line-height: 1.5;
        }
        .scheduled-item-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }
        .scheduled-action-btn {
            border: 1px solid rgba(125, 187, 236, 0.24);
            border-radius: 9px;
            min-height: 32px;
            padding: 0 9px;
            background: rgba(21, 71, 111, 0.35);
            color: var(--text-primary);
            cursor: pointer;
            font-size: 0.74rem;
            font-weight: 600;
        }
        .scheduled-action-btn.danger {
            color: #ff8080;
            border-color: rgba(255, 128, 128, 0.24);
        }
        #story-create-modal .modal-content.story-compose-card {
            width: min(500px, calc(100vw - 24px));
            max-width: 500px;
            height: min(92vh, 760px);
            background: #101921 !important;
            border-radius: 24px !important;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }
        #story-create-modal .story-compose-header {
            background: rgba(0, 0, 0, 0.24) !important;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        }
        .story-compose-body {
            gap: 10px !important;
            padding: 12px !important;
            display: grid !important;
            grid-template-rows: auto auto minmax(0, 1fr) auto auto;
            min-height: 0 !important;
            flex: 1 1 auto;
            overflow: hidden;
        }
        .story-create-modes {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }
        .story-mode-btn {
            min-height: 38px;
            border-radius: 11px;
            border: 1px solid rgba(120, 178, 230, 0.24);
            background: rgba(16, 48, 77, 0.4);
            color: #d7ebff;
            font-weight: 700;
            font-size: 0.8rem;
            cursor: pointer;
        }
        .story-mode-btn.is-active {
            background: linear-gradient(135deg, #fa7e1e, #d62976 55%, #4f5bd5);
            border-color: rgba(255,255,255,0.36);
            color: #fff;
        }
        .tg-chat-item.ai-chat-item {
            border: 1px solid rgba(130, 165, 255, 0.42) !important;
            background: linear-gradient(130deg, rgba(54, 111, 214, 0.2), rgba(126, 66, 214, 0.18)) !important;
            box-shadow: 0 10px 22px rgba(34, 78, 166, 0.2);
        }
        .tg-chat-item.ai-chat-item .tg-chat-title {
            color: #d6e8ff !important;
            font-weight: 800;
        }
        .tg-chat-item.ai-chat-item .tg-chat-time {
            color: #aeddff !important;
            font-weight: 800;
        }
        body.ai-chat-active #chat-messages {
            background:
                radial-gradient(800px 320px at 100% 0%, rgba(83, 122, 255, 0.14), transparent 62%),
                radial-gradient(700px 280px at 0% 100%, rgba(151, 87, 255, 0.1), transparent 60%),
                var(--chat-wallpaper);
        }
        body.ai-chat-active #tg-status {
            color: #a9d7ff !important;
        }
        body.ai-chat-active .tg-chat-info {
            border-color: rgba(138, 177, 255, 0.36) !important;
            background: linear-gradient(145deg, rgba(41, 67, 118, 0.36), rgba(33, 47, 87, 0.28)) !important;
            cursor: default;
            pointer-events: none;
        }
        .message.ai-bot-message {
            border: 1px solid rgba(126, 171, 252, 0.42) !important;
            background: linear-gradient(145deg, rgba(37, 58, 99, 0.74), rgba(66, 39, 112, 0.72)) !important;
            box-shadow: 0 10px 20px rgba(19, 35, 70, 0.24);
        }
        .message.ai-bot-message .username {
            color: #ccf0ff !important;
            font-weight: 800;
        }
        .public-msg-avatar.ai-bot-avatar {
            border: 1px solid rgba(173, 221, 255, 0.55);
            box-shadow: 0 0 0 3px rgba(93, 153, 255, 0.24);
        }
        body.light-mode .tg-chat-item.ai-chat-item {
            border-color: rgba(77, 132, 228, 0.33) !important;
            background: linear-gradient(130deg, rgba(102, 154, 244, 0.16), rgba(147, 112, 244, 0.15)) !important;
            box-shadow: 0 10px 20px rgba(66, 109, 186, 0.12);
        }
        body.light-mode .tg-chat-item.ai-chat-item .tg-chat-title {
            color: #225a91 !important;
        }
        body.light-mode .tg-chat-item.ai-chat-item .tg-chat-time {
            color: #2d6fb1 !important;
        }
        body.light-mode.ai-chat-active #chat-messages {
            background:
                radial-gradient(800px 320px at 100% 0%, rgba(76, 126, 229, 0.11), transparent 62%),
                radial-gradient(700px 280px at 0% 100%, rgba(149, 109, 230, 0.09), transparent 60%),
                var(--chat-wallpaper);
        }
        body.light-mode .message.ai-bot-message {
            border-color: rgba(84, 142, 236, 0.32) !important;
            background: linear-gradient(145deg, rgba(227, 238, 255, 0.92), rgba(238, 231, 255, 0.92)) !important;
            box-shadow: 0 8px 16px rgba(57, 103, 182, 0.12);
        }
        body.light-mode .message.ai-bot-message .username {
            color: #245d94 !important;
        }
        #story-create-modal .story-compose-body {
            display: flex !important;
            flex-direction: column;
            gap: 8px !important;
            overflow-y: auto;
            overscroll-behavior: contain;
            padding: 10px !important;
        }
        #story-create-modal .story-create-modes {
            display: flex;
            gap: 6px;
            overflow-x: auto;
            padding-bottom: 2px;
            scrollbar-width: none;
        }
        #story-create-modal .story-create-modes::-webkit-scrollbar {
            display: none;
        }
        #story-create-modal .story-create-modes .story-mode-btn {
            flex: 0 0 auto;
            min-width: 82px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.24);
            background: rgba(12, 16, 22, 0.64);
            color: #dce8f6;
            font-weight: 700;
            font-size: 0.74rem;
            min-height: 32px;
            padding: 0 12px;
            gap: 6px;
        }
        #story-create-modal .story-create-modes .story-mode-btn.is-active {
            border-color: rgba(255, 255, 255, 0.88);
            color: #fff;
            background: linear-gradient(130deg, #f9ce34 0%, #ee2a7b 48%, #6228d7 100%);
            box-shadow: 0 4px 14px rgba(238, 42, 123, 0.28);
        }
        #story-create-modal .story-mode-note {
            font-size: 0.73rem;
            color: #d8e9ff;
            border: 1px solid rgba(255, 255, 255, 0.15);
            background: rgba(0, 0, 0, 0.38);
            border-radius: 999px;
            padding: 5px 10px;
            width: fit-content;
            max-width: 100%;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        #story-create-modal .story-compose-top-actions {
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            gap: 6px;
        }
        #story-create-modal .story-compose-top-actions .link-choice-btn {
            min-height: 34px;
            border-radius: 999px;
            font-size: 0.72rem;
            padding: 0 8px;
        }
        #story-create-modal .story-slide-strip {
            display: flex;
            gap: 8px;
            overflow-x: auto;
            padding: 2px 1px 4px;
        }
        #story-create-modal .story-slide-chip {
            border: 1px solid rgba(136, 198, 247, 0.24);
            border-radius: 10px;
            background: rgba(15, 49, 78, 0.36);
            color: #d6edff;
            min-height: 34px;
            min-width: 90px;
            padding: 0 8px;
            font-size: 0.74rem;
            font-weight: 700;
            cursor: pointer;
            white-space: nowrap;
        }
        #story-create-modal .story-slide-chip.is-active {
            border-color: rgba(255, 255, 255, 0.44);
            background: linear-gradient(135deg, #fa7e1e, #d62976 55%, #4f5bd5);
            color: #fff;
        }
        #story-create-modal .story-create-preview {
            width: min(100%, 360px);
            align-self: center;
            aspect-ratio: 9 / 16;
            min-height: 0 !important;
            height: auto !important;
            border-radius: 16px !important;
            background: #080d12 !important;
            border: 1px solid rgba(255,255,255,0.08) !important;
            position: relative;
            overflow: hidden;
        }
        #story-create-modal .story-preview-stage {
            width: 100%;
            height: 100%;
            position: relative;
            overflow: hidden;
            background: #000;
        }
        #story-create-modal #story-preview-image,
        #story-create-modal #story-preview-video,
        #story-create-modal #story-layout-grid,
        #story-create-modal #story-text-card,
        #story-create-modal #story-overlay-layer,
        #story-create-modal #story-preview-empty {
            position: absolute;
            inset: 0;
        }
        #story-create-modal #story-preview-image,
        #story-create-modal #story-preview-video {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        #story-create-modal #story-layout-grid {
            display: grid;
            gap: 2px;
            background: #060a11;
        }
        #story-create-modal #story-layout-grid img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        #story-create-modal .story-text-card {
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding: 24px;
            color: #fff;
            font-weight: 800;
            font-size: 1.2rem;
            line-height: 1.75;
            background: linear-gradient(145deg, #833ab4, #fd1d1d 45%, #fcb045);
            white-space: pre-wrap;
            word-break: break-word;
        }
        #story-create-modal .story-preview-empty {
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            color: #9fc6ea;
            font-size: 0.82rem;
            padding: 16px;
            background: linear-gradient(180deg, rgba(4, 11, 20, 0.28), rgba(4, 11, 20, 0.72));
        }
        #story-create-modal #story-overlay-layer {
            pointer-events: auto;
            z-index: 5;
        }
        #story-create-modal .story-sticker-chip {
            position: absolute;
            max-width: 76%;
            border-radius: 11px;
            border: 1px solid rgba(255, 255, 255, 0.4);
            background: rgba(0, 0, 0, 0.42);
            color: #fff;
            padding: 6px 10px;
            font-size: 0.78rem;
            font-weight: 700;
            white-space: pre-wrap;
            pointer-events: auto;
            cursor: move;
            user-select: none;
            touch-action: none;
        }
        #story-create-modal .story-sticker-chip.is-selected {
            box-shadow: 0 0 0 2px rgba(137, 204, 255, 0.9);
        }
        #story-create-modal .story-sticker-chip.photo {
            padding: 2px;
            background: rgba(9, 15, 23, 0.9);
        }
        #story-create-modal .story-sticker-chip.photo img {
            width: 84px;
            height: 84px;
            object-fit: cover;
            display: block;
            border-radius: 9px;
        }
        #story-create-modal .story-compose-input {
            min-height: 64px !important;
            max-height: 96px !important;
            background: rgba(8, 11, 17, 0.78) !important;
            margin: 0 !important;
            border-radius: 14px !important;
        }
        #story-create-modal .story-tools-toggle {
            border: 1px solid rgba(255, 255, 255, 0.18);
            background: rgba(0, 0, 0, 0.38);
            color: #e6f1ff;
            min-height: 34px;
            border-radius: 999px;
            font-size: 0.74rem;
            font-weight: 700;
            cursor: pointer;
            padding: 0 12px;
            width: fit-content;
            align-self: center;
        }
        #story-create-modal .story-tools-toggle.is-open {
            border-color: rgba(255, 255, 255, 0.36);
            background: rgba(255, 255, 255, 0.16);
        }
        #story-create-modal .story-editor-panel {
            display: grid;
            gap: 8px;
            border: 1px solid rgba(132, 196, 243, 0.18);
            border-radius: 12px;
            padding: 8px;
            background: rgba(8, 22, 34, 0.46);
            max-height: 520px;
            overflow: hidden;
            transition: max-height 220ms ease, opacity 220ms ease, padding 220ms ease, border-width 220ms ease;
            opacity: 1;
        }
        #story-create-modal .story-editor-panel.is-collapsed {
            max-height: 0;
            opacity: 0;
            padding-top: 0;
            padding-bottom: 0;
            border-width: 0;
        }
        #story-create-modal .story-editor-row {
            display: grid;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: 6px;
            align-items: center;
        }
        #story-create-modal .story-editor-row label {
            font-size: 0.72rem;
            color: #c7e5ff;
            justify-self: start;
        }
        #story-create-modal .story-editor-row .login-input,
        #story-create-modal .story-editor-row select,
        #story-create-modal .story-editor-row input[type="text"] {
            min-height: 34px;
            font-size: 0.75rem;
            padding: 0 8px;
        }
        #story-create-modal .story-editor-row input[type="range"] {
            width: 100%;
        }
        #story-create-modal .story-inline-toggle {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 0.72rem;
            color: #d5edff;
            white-space: nowrap;
        }
        #story-create-modal .story-compose-actions {
            display: grid !important;
            grid-template-columns: 1fr 1fr;
            gap: 8px !important;
            align-items: stretch;
        }
        #story-create-modal .story-compose-actions .preview-send-btn {
            grid-column: 1 / -1;
            min-height: 48px;
        }
        #story-view-modal #story-view-overlay-layer {
            position: absolute;
            inset: 0;
            z-index: 5;
            pointer-events: none;
        }
        #story-view-modal .story-view-overlay-chip {
            position: absolute;
            max-width: 76%;
            border-radius: 11px;
            border: 1px solid rgba(255, 255, 255, 0.4);
            background: rgba(0, 0, 0, 0.44);
            color: #fff;
            padding: 6px 10px;
            font-size: 0.78rem;
            font-weight: 700;
            white-space: pre-wrap;
            transform: translate(-50%, -50%);
        }
        #story-view-modal .story-view-overlay-chip.photo {
            padding: 2px;
            background: rgba(8, 11, 17, 0.94);
        }
        #story-view-modal .story-view-overlay-chip.photo img {
            width: 78px;
            height: 78px;
            object-fit: cover;
            border-radius: 9px;
            display: block;
        }
        #story-view-modal .story-view-music-tag {
            position: absolute;
            bottom: 64px;
            right: 14px;
            z-index: 6;
            border: 1px solid rgba(255, 255, 255, 0.33);
            background: rgba(0, 0, 0, 0.46);
            color: #f2f8ff;
            border-radius: 999px;
            padding: 5px 10px;
            font-size: 0.72rem;
            font-weight: 700;
        }
        body.light-mode .scheduled-item {
            background: rgba(39, 136, 218, 0.08);
            border-color: rgba(39, 136, 218, 0.2);
        }
        body.light-mode .scheduled-action-btn {
            background: rgba(39, 136, 218, 0.1);
            border-color: rgba(39, 136, 218, 0.2);
            color: #1d5e90;
        }
        body.light-mode .story-mode-btn {
            background: rgba(39, 136, 218, 0.08);
            border-color: rgba(39, 136, 218, 0.22);
            color: #2369a0;
        }
        body.light-mode #story-create-modal .story-mode-note {
            color: #1f5f91;
            border-color: rgba(39, 136, 218, 0.22);
            background: rgba(39, 136, 218, 0.11);
        }
        body.light-mode #story-create-modal .story-tools-toggle {
            color: #225f92;
            border-color: rgba(39, 136, 218, 0.25);
            background: rgba(39, 136, 218, 0.1);
        }
        body.light-mode #story-create-modal .story-slide-chip {
            border-color: rgba(39, 136, 218, 0.22);
            background: rgba(39, 136, 218, 0.08);
            color: #2f6c9f;
        }
        body.light-mode #story-create-modal .story-editor-panel {
            background: rgba(39, 136, 218, 0.06);
            border-color: rgba(39, 136, 218, 0.2);
        }
        @media (max-width: 768px) {
            .group-members-list {
                grid-template-columns: 1fr !important;
            }
            .story-view-card {
                width: calc(100vw - 6px) !important;
                border-radius: 16px !important;
            }
            .story-view-body,
            #story-view-image,
            #story-view-video,
            .story-view-text {
                min-height: min(74vh, 560px) !important;
            }
            .timing-quick-grid {
                grid-template-columns: 1fr 1fr;
            }
            .timing-chip {
                min-height: 36px;
                font-size: 0.78rem;
            }
            #story-create-modal .modal-content.story-compose-card {
                width: calc(100vw - 12px);
                max-width: none;
                height: calc(100dvh - 20px);
                border-radius: 16px !important;
            }
            .story-create-preview {
                min-height: 0 !important;
                height: 100% !important;
            }
            .story-compose-body {
                padding: 10px !important;
            }
            #story-create-modal .story-create-modes {
                gap: 5px;
            }
            #story-create-modal .story-create-modes .story-mode-btn {
                min-width: 74px;
                font-size: 0.71rem;
            }
            #story-create-modal .story-compose-top-actions {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }
            #story-create-modal .story-editor-row {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
            .story-compose-input {
                min-height: 56px !important;
                max-height: 74px !important;
                font-size: 0.9rem !important;
            }
            .story-compose-actions .preview-send-btn {
                min-height: 46px;
            }
            .scheduled-item-actions {
                display: grid;
                grid-template-columns: 1fr 1fr;
            }
            .scheduled-action-btn {
                width: 100%;
            }
        }
        .tg-auth-card {
            width: min(408px, calc(100vw - 18px));
            padding: 22px 18px;
            border-radius: 24px;
            background: #ffffff !important;
            color: #1f2d3d;
            border: 1px solid rgba(24, 119, 204, 0.16) !important;
            box-shadow: 0 24px 48px rgba(17, 76, 128, 0.2) !important;
            max-height: min(560px, calc(100vh - 20px));
            overflow: hidden;
        }
        body.light-mode .tg-auth-card {
            background: #ffffff !important;
            color: #1f2d3d;
        }
        .tg-auth-brand {
            text-align: center;
            margin-bottom: 12px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .tg-auth-logo {
            width: 54px;
            height: 54px;
            border-radius: 50%;
            margin: 0 auto 10px;
            background: linear-gradient(145deg, #37aee2, #1d86dc);
            color: #fff;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 1.1rem;
            font-weight: 700;
            box-shadow: 0 12px 22px rgba(29, 134, 220, 0.28);
        }
        .tg-auth-title {
            margin: 0;
            font-size: 1.24rem;
            color: #1b2a3a;
            font-weight: 760;
            text-align: center;
        }
        .tg-auth-title.brand-glow {
            color: #0c7fd3;
            text-shadow: 0 0 8px rgba(28, 151, 235, 0.35), 0 0 22px rgba(28, 151, 235, 0.24);
            letter-spacing: 0.2px;
            animation: brandPulse 2.3s ease-in-out infinite;
        }
        @keyframes brandPulse {
            0%, 100% { text-shadow: 0 0 8px rgba(28, 151, 235, 0.35), 0 0 22px rgba(28, 151, 235, 0.24); }
            50% { text-shadow: 0 0 12px rgba(28, 151, 235, 0.55), 0 0 30px rgba(28, 151, 235, 0.36); }
        }
        .tg-auth-subtitle {
            margin: 6px 0 0;
            color: #6c7f92;
            font-size: 0.9rem;
            line-height: 1.55;
        }
        .tg-auth-step {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-top: 8px;
        }
        .auth-label {
            font-size: 0.82rem;
            color: #7f8fa2;
            text-align: right;
            font-weight: 600;
        }
        .auth-row {
            display: grid;
            grid-template-columns: 1fr;
            gap: 8px;
        }
        .auth-country-select {
            direction: rtl;
            text-align: right;
        }
        #phone-modal .login-input,
        #password-modal .login-input,
        .setup-card .login-input {
            height: 48px;
            border-radius: 14px;
            border: 1px solid #d6e2ee;
            background: #f7fbff;
            color: #1f2d3d;
            text-align: right;
            box-shadow: none;
        }
        #phone-modal .login-input:focus,
        #password-modal .login-input:focus,
        .setup-card .login-input:focus {
            border-color: #2a9ee8;
            box-shadow: 0 0 0 3px rgba(42, 158, 232, 0.16);
        }
        .tg-auth-card .login-btn,
        .setup-card .login-btn {
            height: 48px;
            min-height: 48px;
            border-radius: 14px;
            border: 0;
            background: linear-gradient(145deg, #2ba6f7, #1f8fe0);
            box-shadow: 0 12px 24px rgba(32, 136, 217, 0.26);
            color: #fff;
            font-weight: 760;
            width: min(320px, 100%);
            align-self: center;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .auth-helper-text {
            min-height: 18px;
            font-size: 0.82rem;
            color: #7c8da1;
            margin: 0;
            text-align: center;
        }
        .auth-helper-text.error-text {
            color: #cf3c4a;
        }
        .auth-helper-text.success-text {
            color: #1e9661;
        }
        .auth-confirm-text {
            margin: 0;
            text-align: center;
            color: #3f5164;
            line-height: 1.7;
            font-size: 0.9rem;
            padding: 6px 2px 2px;
        }
        .auth-confirm-actions {
            display: grid;
            grid-template-columns: 1fr;
            gap: 10px;
            justify-items: center;
        }
        .auth-inline-actions {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            flex-wrap: wrap;
        }
        .tg-auth-card .auth-link-btn,
        .setup-card .auth-link-btn {
            border: 0;
            background: rgba(42, 158, 232, 0.1);
            color: #1f90df;
            font-size: 0.82rem;
            font-weight: 700;
            border-radius: 999px;
            padding: 7px 12px;
            cursor: pointer;
            transition: background 0.16s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .tg-auth-card .auth-link-btn.secondary,
        .setup-card .auth-link-btn.secondary {
            background: rgba(134, 149, 168, 0.16);
            color: #46586c;
        }
        .tg-auth-card .auth-link-btn:disabled,
        .setup-card .auth-link-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }
        .otp-grid {
            display: grid;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: 8px;
            direction: ltr;
        }
        .otp-digit {
            height: 48px;
            border-radius: 12px;
            border: 1px solid #d6e2ee;
            background: #f7fbff;
            text-align: center;
            font-size: 1.05rem;
            font-weight: 700;
            color: #1b2d3e;
            outline: none;
        }
        .otp-digit:focus {
            border-color: #2a9ee8;
            box-shadow: 0 0 0 3px rgba(42, 158, 232, 0.16);
        }
        .auth-password-wrap {
            position: relative;
            display: flex;
            align-items: center;
        }
        .auth-password-wrap .login-input {
            padding-left: 40px;
            margin-bottom: 0;
        }
        .auth-eye-btn {
            position: absolute;
            left: 10px;
            border: 0;
            background: transparent;
            color: #6f8195;
            width: 28px;
            height: 28px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9rem;
        }
        #password-submit.is-loading {
            opacity: 0.85;
            pointer-events: none;
        }
        #login-container {
            display: none;
            align-items: center;
            justify-content: center;
            padding: 18px;
            background: radial-gradient(circle at top right, rgba(43, 166, 247, 0.2), transparent 48%), #edf5fc;
        }
        body.light-mode #login-container {
            background: radial-gradient(circle at top right, rgba(43, 166, 247, 0.24), transparent 46%), #edf5fc;
        }
        .setup-card {
            width: min(430px, calc(100vw - 24px));
            border-radius: 24px;
            border: 1px solid rgba(24, 119, 204, 0.18);
            background: #ffffff;
            box-shadow: 0 24px 44px rgba(18, 83, 136, 0.19);
            padding: 22px 18px;
            text-align: right;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .setup-avatar-row {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .setup-avatar {
            width: 56px;
            height: 56px;
            border-radius: 50%;
            background: linear-gradient(145deg, #40b2f6, #2490df);
            color: #fff;
            font-size: 1.25rem;
            font-weight: 700;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background-size: cover;
            background-position: center;
        }
        .setup-avatar.has-image {
            color: transparent;
        }
        .setup-avatar-meta {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
        .setup-avatar-meta strong {
            font-size: 0.98rem;
            color: #243547;
        }
        .setup-avatar-meta span {
            font-size: 0.8rem;
            color: #7d8ea1;
        }
        .setup-photo-actions {
            display: flex;
            gap: 8px;
        }
        .setup-photo-actions .auth-link-btn {
            flex: 1;
        }
        .setup-id-preview {
            text-align: right;
            font-size: 0.82rem;
            color: #61758c;
            margin-top: -2px;
        }
        .setup-id-preview strong {
            color: #1f90df;
            direction: ltr;
            unicode-bidi: isolate;
            display: inline-block;
        }
        .readonly-field {
            background: #eef3f8 !important;
            color: #6a7f95 !important;
            cursor: not-allowed;
            border-color: #d9e4ef !important;
        }
        #profile-public-id-input {
            direction: ltr;
            text-align: left;
        }
        #phone-modal .tg-auth-step button,
        #password-modal .tg-auth-step button {
            margin-inline: auto;
        }
        #story-create-modal .modal-content.story-compose-card {
            width: min(500px, calc(100vw - 24px)) !important;
            max-width: 500px !important;
            height: min(92vh, 760px) !important;
        }
        #group-info-modal .modal-content,
        #create-group-modal .modal-content,
        #profile-modal .modal-content {
            width: min(440px, calc(100vw - 24px)) !important;
            max-width: 440px !important;
        }
        @media (max-width: 768px) {
            .tg-auth-card {
                width: calc(100vw - 12px);
                border-radius: 18px;
                padding: 16px 12px;
                max-height: min(560px, calc(100vh - 10px));
            }
            .setup-card {
                width: calc(100vw - 12px);
                border-radius: 18px;
                padding: 16px 12px;
            }
            #story-create-modal .modal-content.story-compose-card {
                width: calc(100vw - 12px) !important;
                max-width: none !important;
                height: calc(100dvh - 20px) !important;
            }
            #group-info-modal .modal-content,
            #create-group-modal .modal-content,
            #profile-modal .modal-content {
                width: calc(100vw - 12px) !important;
                max-width: none !important;
            }
            .otp-digit {
                height: 42px;
            }
        }
        :root {
            --ig-story-pink: #E1306C;
            --ig-story-purple: #833AB4;
            --ig-story-orange: #F77737;
            --ig-story-yellow: #FCAF45;
            --ig-story-blue: #405DE6;
            --story-shell-bg: #090c12;
            --story-surface-bg: rgba(17, 23, 34, 0.88);
            --story-border: rgba(255, 255, 255, 0.14);
        }
        body.light-mode {
            --story-shell-bg: #f7f9fc;
            --story-surface-bg: rgba(255, 255, 255, 0.94);
            --story-border: rgba(15, 23, 42, 0.14);
        }
        .story-strip {
            display: flex !important;
            align-items: center;
            gap: 12px;
            padding: 10px 12px !important;
            background:
                linear-gradient(180deg, rgba(7, 11, 18, 0.9), rgba(7, 11, 18, 0.72)) !important;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
            backdrop-filter: blur(12px);
        }
        body.light-mode .story-strip {
            background: linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(244, 248, 255, 0.9)) !important;
            border-bottom-color: rgba(15, 23, 42, 0.08) !important;
        }
        .story-create-btn {
            min-height: 38px !important;
            border-radius: 999px !important;
            border: 1px solid rgba(255, 255, 255, 0.32) !important;
            background: linear-gradient(138deg, var(--ig-story-orange), var(--ig-story-pink) 58%, var(--ig-story-purple)) !important;
            color: #fff !important;
            font-size: 0.8rem !important;
            font-weight: 800 !important;
            letter-spacing: 0.2px;
            padding: 0 14px !important;
            box-shadow: 0 8px 20px rgba(225, 48, 108, 0.28);
        }
        body.light-mode .story-create-btn {
            border-color: rgba(255, 255, 255, 0.65) !important;
        }
        .story-items {
            display: flex;
            gap: 12px;
            overflow-x: auto;
            padding: 2px 2px 4px;
            scrollbar-width: none;
        }
        .story-items::-webkit-scrollbar {
            display: none;
        }
        .story-item {
            min-width: 64px !important;
            display: grid;
            gap: 6px !important;
            justify-items: center;
            color: var(--text-primary) !important;
            font-size: 0.72rem !important;
            font-weight: 600;
        }
        .story-item .story-ring {
            width: 56px !important;
            height: 56px !important;
            padding: 2.5px !important;
            border-radius: 999px;
            background: conic-gradient(from 0deg, var(--ig-story-orange), var(--ig-story-yellow), var(--ig-story-orange), var(--ig-story-pink), var(--ig-story-purple), var(--ig-story-blue), var(--ig-story-purple), var(--ig-story-pink), var(--ig-story-orange)) !important;
            box-shadow: 0 4px 12px rgba(225, 48, 108, 0.26);
        }
        .story-item.is-seen .story-ring {
            background: linear-gradient(140deg, #9aa8b4, #7c8c99) !important;
            box-shadow: none;
        }
        .story-item .story-avatar {
            border-radius: 999px !important;
            border: 2px solid #0b1119 !important;
            background-size: cover;
            background-position: center;
            font-weight: 800;
        }
        body.light-mode .story-item .story-avatar {
            border-color: #ffffff !important;
        }
        #story-create-modal .modal-content.story-compose-card {
            width: min(1020px, calc(100vw - 20px)) !important;
            max-width: 1020px !important;
            height: min(94vh, 860px) !important;
            border-radius: 26px !important;
            border: 1px solid var(--story-border) !important;
            background: var(--story-shell-bg) !important;
            box-shadow: 0 24px 56px rgba(0, 0, 0, 0.52) !important;
        }
        #story-create-modal .story-compose-header {
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)) !important;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
            padding: 12px 14px !important;
        }
        #story-create-modal .story-compose-header h3 {
            font-family: 'Vazirmatn', "Segoe UI", Arial, sans-serif;
            font-size: 0.92rem;
            font-weight: 700;
            color: #fff;
            letter-spacing: 0.2px;
        }
        body.light-mode #story-create-modal .story-compose-header h3 {
            color: #111827;
        }
        #story-create-modal .story-compose-body {
            display: grid !important;
            grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
            grid-auto-rows: min-content;
            gap: 10px 14px !important;
            padding: 12px !important;
            overflow-y: auto;
            overscroll-behavior: contain;
        }
        #story-create-modal .story-create-preview {
            grid-column: 1;
            grid-row: 1 / span 8;
            width: 100%;
            align-self: start;
            position: sticky;
            top: 0;
            border-radius: 24px !important;
            border: 1px solid rgba(255, 255, 255, 0.2) !important;
            background: #000 !important;
            box-shadow: 0 20px 36px rgba(0, 0, 0, 0.45);
            overflow: hidden;
        }
        #story-create-modal .story-create-preview::before {
            content: '';
            position: absolute;
            top: 10px;
            left: 10px;
            right: 10px;
            height: 3px;
            border-radius: 999px;
            background: linear-gradient(90deg, rgba(255, 255, 255, 0.95) 0 24%, rgba(255, 255, 255, 0.35) 24% 48%, rgba(255, 255, 255, 0.2) 48% 72%, rgba(255, 255, 255, 0.12) 72%);
            z-index: 7;
            pointer-events: none;
        }
        #story-create-modal .story-preview-stage::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 120px;
            z-index: 6;
            background: linear-gradient(180deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
            pointer-events: none;
        }
        #story-create-modal .story-preview-stage::after {
            content: '';
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 120px;
            z-index: 6;
            background: linear-gradient(0deg, rgba(0, 0, 0, 0.56), rgba(0, 0, 0, 0));
            pointer-events: none;
        }
        #story-create-modal .story-preview-stage {
            background:
                linear-gradient(45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.06) 75%, transparent 75%, transparent) center/24px 24px,
                #050912;
        }
        #story-create-modal #story-preview-image,
        #story-create-modal #story-preview-video,
        #story-create-modal #story-layout-grid,
        #story-create-modal #story-text-card {
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
        }
        body.light-mode #story-create-modal .story-preview-stage {
            background:
                linear-gradient(45deg, rgba(15, 23, 42, 0.06) 25%, transparent 25%, transparent 50%, rgba(15, 23, 42, 0.06) 50%, rgba(15, 23, 42, 0.06) 75%, transparent 75%, transparent) center/24px 24px,
                #eef3fa;
        }
        #story-create-modal .story-create-modes,
        #story-create-modal .story-mode-note,
        #story-create-modal .story-compose-top-actions,
        #story-create-modal .story-slide-strip,
        #story-create-modal .story-compose-input,
        #story-create-modal .story-tools-toggle,
        #story-create-modal .story-editor-panel,
        #story-create-modal .story-compose-actions {
            grid-column: 2;
        }
        #story-create-modal .story-create-modes {
            display: flex;
            flex-wrap: nowrap;
            gap: 8px;
            padding-bottom: 4px;
            overflow-x: auto;
            scrollbar-width: thin;
        }
        #story-create-modal .story-create-modes .story-mode-btn {
            flex: 0 0 auto;
            min-width: 88px;
            min-height: 34px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.24);
            background: rgba(11, 15, 22, 0.76);
            color: #e4edf8;
            font-family: "Helvetica Neue", "Segoe UI", Arial, sans-serif;
            font-size: 0.74rem;
            font-weight: 700;
            letter-spacing: 0.2px;
        }
        #story-create-modal .story-create-modes .story-mode-btn.is-active {
            background: linear-gradient(140deg, var(--ig-story-orange), var(--ig-story-pink) 52%, var(--ig-story-purple));
            border-color: rgba(255, 255, 255, 0.82);
            color: #fff;
            box-shadow: 0 6px 16px rgba(225, 48, 108, 0.34);
        }
        #story-create-modal .story-mode-note {
            font-size: 0.72rem;
            border-radius: 999px;
            padding: 6px 12px;
            color: #f2f6fb;
            border: 1px solid rgba(255, 255, 255, 0.18);
            background: rgba(255, 255, 255, 0.08);
            width: fit-content;
        }
        #story-create-modal .story-compose-top-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        #story-create-modal .story-compose-top-actions .link-choice-btn {
            flex: 1 1 140px;
            min-height: 35px;
            border-radius: 999px;
            font-size: 0.7rem;
            font-weight: 700;
        }
        #story-create-modal .story-slide-strip {
            display: flex;
            flex-wrap: nowrap;
            gap: 8px;
            overflow-x: auto;
            scrollbar-width: thin;
            padding-bottom: 2px;
        }
        #story-create-modal .story-slide-chip {
            border-radius: 999px;
            min-height: 32px;
            min-width: 96px;
            padding: 0 10px;
            font-size: 0.72rem;
        }
        #story-create-modal .story-compose-input {
            min-height: 68px !important;
            border-radius: 16px !important;
            border: 1px solid rgba(255, 255, 255, 0.18) !important;
            background: rgba(5, 9, 16, 0.76) !important;
            color: #eef3fb !important;
        }
        #story-create-modal .story-tools-toggle {
            justify-self: start;
            min-height: 35px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: #e8f1fc;
            font-weight: 700;
        }
        #story-create-modal .story-editor-panel {
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: var(--story-surface-bg);
            padding: 10px;
            gap: 9px;
            max-height: 360px;
            overflow: auto;
        }
        #story-create-modal .story-editor-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            align-items: center;
            padding: 8px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.03);
        }
        #story-create-modal .story-editor-row label {
            font-size: 0.7rem;
            color: #d4e5f8;
            min-width: 74px;
            font-weight: 700;
        }
        #story-create-modal .story-editor-row .login-input,
        #story-create-modal .story-editor-row select,
        #story-create-modal .story-editor-row input[type="text"] {
            min-height: 34px;
            border-radius: 10px;
            flex: 1 1 130px;
            background: rgba(5, 10, 16, 0.72);
            border: 1px solid rgba(255, 255, 255, 0.16);
            color: #edf3fb;
        }
        #story-create-modal .story-editor-row input[type="range"] {
            flex: 1 1 130px;
        }
        #story-create-modal .story-editor-row input[type="color"] {
            width: 48px;
            min-height: 34px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: transparent;
        }
        #story-create-modal .story-inline-toggle {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-radius: 999px;
            padding: 4px 10px;
            color: #e5effb;
        }
        #story-create-modal .story-compose-actions {
            position: sticky;
            bottom: -2px;
            grid-template-columns: 1fr 1fr;
            gap: 8px !important;
            padding: 8px;
            border-radius: 14px;
            background: linear-gradient(180deg, rgba(10, 14, 22, 0.4), rgba(10, 14, 22, 0.78));
            border: 1px solid rgba(255, 255, 255, 0.08);
        }
        #story-create-modal .story-compose-actions .preview-send-btn {
            grid-column: 1 / -1;
            min-height: 50px;
            border-radius: 15px;
            background: linear-gradient(140deg, #42a5ff, #2f7bff) !important;
            border: 1px solid rgba(255, 255, 255, 0.36) !important;
            font-size: 0.9rem;
        }
        #story-view-modal .story-view-card {
            width: min(460px, calc(100vw - 10px)) !important;
            min-height: min(94vh, 820px);
            border-radius: 24px !important;
            border: 1px solid rgba(255, 255, 255, 0.16) !important;
            background: #06090f !important;
            overflow: hidden;
            box-shadow: 0 28px 56px rgba(0, 0, 0, 0.6) !important;
        }
        #story-view-modal .story-progress-track {
            top: 12px;
            left: 12px;
            right: 12px;
            gap: 5px;
            z-index: 12;
        }
        #story-view-modal .story-progress-seg {
            height: 4px;
            background: rgba(255, 255, 255, 0.26);
        }
        #story-view-modal .story-progress-fill {
            display: block;
            background: linear-gradient(90deg, var(--ig-story-orange), var(--ig-story-pink) 45%, var(--ig-story-purple) 78%, var(--ig-story-blue));
            box-shadow: 0 0 10px rgba(225, 48, 108, 0.45);
            transition: width 0.05s linear;
            will-change: width;
        }
        #story-view-modal .story-view-header {
            top: 20px !important;
            left: 12px !important;
            right: 12px !important;
            z-index: 13;
        }
        #story-view-modal .story-view-head-actions {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        #story-view-modal .story-head-icon-btn {
            width: 30px;
            height: 30px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.24);
            background: rgba(0, 0, 0, 0.34);
            color: #fff;
            font-size: 1.1rem;
            line-height: 1;
            cursor: pointer;
        }
        #story-view-modal .story-head-icon-btn:hover {
            background: rgba(255, 255, 255, 0.14);
        }
        #story-view-modal .story-view-overflow {
            position: relative;
        }
        #story-view-modal .story-view-menu {
            position: absolute;
            top: 36px;
            right: 0;
            min-width: 170px;
            padding: 6px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.18);
            background: rgba(8, 12, 20, 0.92);
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
            display: none;
            flex-direction: column;
            gap: 4px;
            z-index: 20;
        }
        #story-view-modal .story-view-overflow.is-open .story-view-menu {
            display: flex;
        }
        #story-view-modal .story-view-menu-btn {
            border: 0;
            background: transparent;
            color: #fff;
            text-align: right;
            font-size: 0.86rem;
            border-radius: 8px;
            padding: 8px 10px;
            cursor: pointer;
        }
        #story-view-modal .story-view-menu-btn:hover {
            background: rgba(255, 255, 255, 0.12);
        }
        #story-view-modal .story-view-body {
            position: relative;
            min-height: min(94vh, 820px);
            padding-bottom: 126px;
            overflow: hidden;
            background:
                radial-gradient(120% 70% at 50% 100%, rgba(19, 32, 51, 0.5), rgba(6, 9, 15, 0.98)),
                #06090f;
        }
        #story-view-modal .story-view-body::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 130px;
            z-index: 9;
            pointer-events: none;
            background: linear-gradient(180deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
        }
        #story-view-modal .story-view-body::after {
            content: '';
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 164px;
            z-index: 9;
            pointer-events: none;
            background: linear-gradient(0deg, rgba(3, 7, 12, 0.94), rgba(3, 7, 12, 0));
        }
        #story-view-modal #story-view-image,
        #story-view-modal #story-view-video,
        #story-view-modal .story-view-text {
            min-height: min(94vh, 820px) !important;
            width: 100% !important;
            height: 100% !important;
            object-fit: contain !important;
            background:
                linear-gradient(45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.06) 75%, transparent 75%, transparent) center/24px 24px,
                #04070d;
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
        }
        #story-view-modal .story-view-caption {
            bottom: 88px;
            right: 14px;
            left: 14px;
            z-index: 11;
            text-align: right;
            line-height: 1.75;
            font-size: 0.84rem;
            display: inline-flex;
            flex-wrap: wrap;
            gap: 4px;
            align-items: center;
        }
        #story-view-modal .story-view-caption-stats {
            color: #f5ddff;
            font-size: 0.76rem;
            font-weight: 700;
        }
        #story-view-modal .story-view-viewers {
            bottom: 136px;
            z-index: 11;
            max-height: min(34%, 210px);
            overflow-y: auto;
            background: rgba(5, 10, 17, 0.62) !important;
            border-color: rgba(255, 255, 255, 0.2) !important;
            border-radius: 14px;
            gap: 4px;
            padding: 10px;
        }
        #story-view-modal .story-view-viewer {
            border-bottom: 1px dashed rgba(255, 255, 255, 0.14);
            padding-bottom: 5px;
            margin-bottom: 5px;
            gap: 8px;
            align-items: flex-start;
        }
        #story-view-modal .story-view-viewer:last-child {
            border-bottom: 0;
            margin-bottom: 0;
            padding-bottom: 0;
        }
        #story-view-modal .story-view-viewer-title {
            color: #ffd9ea !important;
            font-weight: 800;
            border-bottom: 0;
            margin: 2px 0 0;
            padding-bottom: 0;
        }
        #story-view-modal .story-view-replybar {
            position: absolute;
            left: 12px;
            right: 12px;
            bottom: 14px;
            z-index: 14;
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto auto auto;
            align-items: center;
            gap: 8px;
            margin: 0;
        }
        #story-view-modal .story-view-reply-input {
            width: 100%;
            min-height: 38px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.26);
            background: rgba(0, 0, 0, 0.48);
            color: rgba(255, 255, 255, 0.92);
            padding: 0 14px !important;
            font-size: 0.74rem;
            backdrop-filter: blur(6px);
            outline: none;
        }
        #story-view-modal .story-view-reply-input::placeholder {
            color: rgba(255, 255, 255, 0.72);
        }
        #story-view-modal .story-view-reply-input:disabled,
        #story-view-modal .story-view-reply-send:disabled,
        #story-view-modal .story-view-reply-icon:disabled {
            opacity: 0.58;
            cursor: not-allowed;
        }
        #story-view-modal .story-view-reply-send {
            min-height: 38px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.34);
            background: linear-gradient(140deg, var(--ig-story-orange), var(--ig-story-pink) 52%, var(--ig-story-purple));
            color: #fff;
            font-size: 0.74rem;
            font-weight: 800;
            padding: 0 14px;
            cursor: pointer;
            white-space: nowrap;
        }
        #story-view-modal .story-view-reply-icon {
            width: auto;
            height: 38px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.26);
            background: rgba(0, 0, 0, 0.48);
            color: #fff;
            font-size: 0.96rem;
            cursor: pointer;
            white-space: nowrap;
            padding: 0 10px;
            min-width: 38px;
        }
        #story-view-modal .story-view-reply-icon.is-active {
            border-color: rgba(255, 255, 255, 0.78);
            background: linear-gradient(145deg, rgba(245, 62, 119, 0.95), rgba(179, 53, 241, 0.95));
            box-shadow: 0 8px 20px rgba(225, 48, 108, 0.35);
        }
        #story-view-modal .story-view-feedback {
            position: absolute;
            left: 14px;
            right: 14px;
            bottom: 60px;
            z-index: 14;
            text-align: center;
            font-size: 0.72rem;
            color: rgba(255, 255, 255, 0.85);
            min-height: 18px;
            pointer-events: none;
        }
        #story-view-modal .story-view-feedback.is-success {
            color: #9df0bd;
        }
        #story-view-modal .story-view-feedback.is-error {
            color: #ffb7b7;
            text-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
        }
        #story-view-modal .story-nav-zone {
            top: 64px;
            bottom: 128px;
            width: 30%;
            z-index: 10;
        }
        #story-view-modal .story-nav-prev {
            left: 0;
        }
        #story-view-modal .story-nav-next {
            right: 0;
        }
        body.light-mode #story-view-modal .story-view-card {
            background: #f5f8fc !important;
            border-color: rgba(20, 45, 72, 0.14) !important;
        }
        body.light-mode #story-view-modal .story-view-reply-input {
            color: #12395b;
            background: rgba(255, 255, 255, 0.9);
            border-color: rgba(30, 72, 110, 0.2);
        }
        body.light-mode #story-view-modal .story-view-reply-input::placeholder {
            color: rgba(18, 57, 91, 0.62);
        }
        body.light-mode #story-view-modal .story-view-viewers {
            background: rgba(255, 255, 255, 0.88) !important;
            border-color: rgba(30, 72, 110, 0.16) !important;
        }
        body.light-mode #story-view-modal .story-view-feedback {
            color: #355f85;
        }
        body.light-mode #story-create-modal .story-create-modes .story-mode-btn {
            color: #25476b;
            border-color: rgba(40, 69, 102, 0.18);
            background: rgba(255, 255, 255, 0.84);
        }
        body.light-mode #story-create-modal .story-mode-note {
            color: #244667;
            border-color: rgba(38, 67, 100, 0.18);
            background: rgba(255, 255, 255, 0.84);
        }
        body.light-mode #story-create-modal .story-compose-input {
            color: #17324e !important;
            background: rgba(255, 255, 255, 0.92) !important;
            border-color: rgba(38, 67, 100, 0.16) !important;
        }
        body.light-mode #story-create-modal .story-editor-row {
            background: rgba(255, 255, 255, 0.78);
            border-color: rgba(38, 67, 100, 0.14);
        }
        body.light-mode #story-create-modal .story-editor-row label,
        body.light-mode #story-create-modal .story-inline-toggle {
            color: #26496d;
        }
        body.light-mode #story-create-modal .story-editor-row .login-input,
        body.light-mode #story-create-modal .story-editor-row select,
        body.light-mode #story-create-modal .story-editor-row input[type="text"] {
            color: #17324e;
            background: rgba(255, 255, 255, 0.94);
            border-color: rgba(38, 67, 100, 0.16);
        }
        @media (max-width: 980px) {
            #story-create-modal .modal-content.story-compose-card {
                width: calc(100vw - 12px) !important;
                max-width: none !important;
                height: calc(100dvh - 16px) !important;
                border-radius: 16px !important;
            }
            #story-create-modal .story-compose-body {
                grid-template-columns: minmax(0, 1fr);
            }
            #story-create-modal .story-create-preview {
                grid-column: 1;
                grid-row: auto;
                position: relative;
                top: 0;
                width: min(100%, 360px);
                justify-self: center;
            }
            #story-create-modal .story-create-modes,
            #story-create-modal .story-mode-note,
            #story-create-modal .story-compose-top-actions,
            #story-create-modal .story-slide-strip,
            #story-create-modal .story-compose-input,
            #story-create-modal .story-tools-toggle,
            #story-create-modal .story-editor-panel,
            #story-create-modal .story-compose-actions {
                grid-column: 1;
            }
            #story-create-modal .story-compose-top-actions {
                display: flex;
                flex-wrap: wrap;
            }
            #story-create-modal .story-compose-top-actions .link-choice-btn {
                flex: 1 1 calc(50% - 6px);
                min-width: 120px;
            }
            #story-view-modal .story-view-card {
                border-radius: 16px !important;
            }
            #story-view-modal .story-view-body,
            #story-view-modal #story-view-image,
            #story-view-modal #story-view-video,
            #story-view-modal .story-view-text {
                min-height: min(82vh, 700px) !important;
            }
            #story-view-modal .story-view-replybar {
                left: 10px;
                right: 10px;
                bottom: 10px;
                gap: 6px;
                grid-template-columns: minmax(0, 1fr) auto auto auto;
            }
            #story-view-modal .story-view-reply-send {
                min-width: 64px;
                padding: 0 12px;
            }
            #story-view-modal .story-view-reply-icon {
                width: auto;
                height: 36px;
                min-width: 36px;
            }
            #story-view-modal .story-view-feedback {
                bottom: 54px;
            }
            #story-view-modal .story-view-caption {
                bottom: 82px;
            }
            #story-view-modal .story-view-viewers {
                bottom: 130px;
                max-height: min(30%, 180px);
            }
            #story-view-modal .story-nav-zone {
                top: 62px;
                bottom: 122px;
                width: 32%;
            }
        }
        @media (max-width: 768px) {
            #story-create-modal {
                padding: 6px !important;
            }
            #story-create-modal .modal-content.story-compose-card {
                width: calc(100vw - 8px) !important;
                max-width: none !important;
                height: calc(100dvh - 10px) !important;
                border-radius: 14px !important;
                overflow: hidden !important;
            }
            #story-create-modal .story-compose-header {
                position: sticky;
                top: 0;
                z-index: 18;
                padding: 10px !important;
            }
            #story-create-modal .story-compose-body {
                display: flex !important;
                flex-direction: column !important;
                gap: 8px !important;
                padding: 8px !important;
                overflow-y: auto !important;
                min-height: 0;
            }
            #story-create-modal .story-create-modes,
            #story-create-modal .story-mode-note,
            #story-create-modal .story-compose-top-actions,
            #story-create-modal .story-slide-strip,
            #story-create-modal .story-create-preview,
            #story-create-modal .story-compose-input,
            #story-create-modal .story-tools-toggle,
            #story-create-modal .story-editor-panel,
            #story-create-modal .story-compose-actions {
                width: 100% !important;
                max-width: 100% !important;
                grid-column: auto !important;
                grid-row: auto !important;
            }
            #story-create-modal .story-mode-note {
                width: 100% !important;
                border-radius: 12px !important;
                text-align: right;
            }
            #story-create-modal .story-compose-top-actions {
                display: grid !important;
                grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
                gap: 6px !important;
            }
            #story-create-modal .story-compose-top-actions .link-choice-btn {
                min-width: 0 !important;
                width: 100% !important;
                flex: 0 0 auto !important;
            }
            #story-create-modal .story-create-preview {
                position: relative !important;
                top: auto !important;
                min-height: 0 !important;
                height: auto !important;
                aspect-ratio: 9 / 16;
                max-height: 52vh;
                border-radius: 16px !important;
            }
            #story-create-modal .story-preview-stage {
                min-height: 0 !important;
            }
            #story-create-modal .story-compose-input {
                min-height: 72px !important;
                max-height: 130px !important;
            }
            #story-create-modal .story-tools-toggle {
                width: 100% !important;
                justify-content: center !important;
            }
            #story-create-modal .story-editor-panel {
                max-height: none !important;
                overflow: visible !important;
                padding: 8px !important;
            }
            #story-create-modal .story-editor-row {
                display: flex !important;
                flex-direction: column !important;
                align-items: stretch !important;
                gap: 6px !important;
                padding: 8px !important;
            }
            #story-create-modal .story-editor-row label {
                min-width: 0 !important;
                width: 100% !important;
            }
            #story-create-modal .story-editor-row .login-input,
            #story-create-modal .story-editor-row select,
            #story-create-modal .story-editor-row input[type="text"],
            #story-create-modal .story-editor-row input[type="range"],
            #story-create-modal .story-editor-row .link-choice-btn,
            #story-create-modal .story-inline-toggle {
                width: 100% !important;
                flex: 0 0 auto !important;
            }
            #story-create-modal .story-editor-row input[type="color"] {
                width: 100% !important;
                min-height: 40px !important;
            }
            #story-create-modal .story-compose-actions {
                position: static !important;
                bottom: auto !important;
                padding: 0 !important;
                border: 0 !important;
                background: transparent !important;
                grid-template-columns: 1fr !important;
                gap: 8px !important;
            }
            #story-create-modal .story-compose-actions .link-choice-btn,
            #story-create-modal .story-compose-actions .preview-send-btn {
                width: 100% !important;
                min-height: 44px !important;
            }
        }
        @media (max-width: 420px) {
            #story-create-modal .story-compose-top-actions {
                grid-template-columns: 1fr !important;
            }
            #story-create-modal .story-create-modes .story-mode-btn {
                min-width: 82px !important;
            }
        }
        .message .story-reply-preview {
            margin-top: 8px;
            border: 1px solid rgba(137, 187, 238, 0.3);
            border-radius: 12px;
            background: rgba(9, 25, 40, 0.55);
            overflow: hidden;
        }
        .message .story-reply-preview-head {
            font-size: 0.72rem;
            color: #cfe8ff;
            padding: 6px 8px;
            border-bottom: 1px solid rgba(137, 187, 238, 0.2);
        }
        .message .story-reply-preview-media {
            width: 100%;
            max-height: 180px;
            display: block;
            object-fit: cover;
            background: #081524;
        }
        .message .story-reply-preview-text {
            padding: 9px 10px;
            font-size: 0.84rem;
            color: var(--text-primary);
            line-height: 1.55;
            white-space: pre-wrap;
            text-align: right;
        }
        .message .story-reply-preview-caption {
            padding: 8px 10px;
            font-size: 0.76rem;
            color: var(--text-secondary);
            border-top: 1px solid rgba(137, 187, 238, 0.16);
            text-align: right;
            white-space: pre-wrap;
        }
        body.light-mode .message .story-reply-preview {
            background: rgba(255, 255, 255, 0.9);
            border-color: rgba(39, 136, 218, 0.24);
        }
        body.light-mode .message .story-reply-preview-head {
            color: #1f6ea9;
            border-bottom-color: rgba(39, 136, 218, 0.2);
        }
        body.light-mode .message .story-reply-preview-caption {
            border-top-color: rgba(39, 136, 218, 0.16);
        }
        .story-view-viewer.story-reply-open-dm {
            cursor: pointer;
            border-radius: 9px;
            transition: background 0.14s ease;
        }
        .story-view-viewer.story-reply-open-dm:hover {
            background: rgba(79, 143, 223, 0.2);
        }
        .chat-container.dm-enter-anim {
            animation: dmEnterPulse 0.42s cubic-bezier(0.2, 0.72, 0.22, 1);
        }
        .live-stream-card {
            width: min(100%, 420px);
            border: 1px solid rgba(42, 171, 238, 0.24);
            border-radius: 18px;
            overflow: hidden;
            background: linear-gradient(145deg, rgba(10, 24, 37, 0.92), rgba(18, 37, 55, 0.9));
            box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
            margin-top: 4px;
        }
        .live-stream-hero {
            position: relative;
            min-height: 148px;
            background:
                radial-gradient(circle at 18% 22%, rgba(42, 171, 238, 0.34), transparent 28%),
                radial-gradient(circle at 82% 12%, rgba(122, 92, 255, 0.24), transparent 26%),
                linear-gradient(135deg, #07131f, #132c42);
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .live-stream-hero video,
        .live-stream-hero audio {
            width: 100%;
            max-height: 260px;
            display: block;
            background: #06111b;
        }
        .live-stream-hero audio {
            padding: 0 14px;
            background: transparent;
        }
        .tg-live-message-player {
            gap: 16px;
            padding: 18px;
            justify-content: flex-start;
        }
        .live-msg-play {
            width: 58px;
            height: 58px;
            border: none;
            border-radius: 50%;
            display: grid;
            place-items: center;
            background: #2aabee;
            color: #fff;
            cursor: pointer;
            box-shadow: 0 10px 26px rgba(42, 171, 238, 0.36);
            flex: 0 0 auto;
        }
        .live-msg-play svg {
            width: 27px;
            height: 27px;
        }
        .live-msg-visual {
            flex: 1;
            min-width: 0;
            display: grid;
            gap: 10px;
            text-align: right;
        }
        .live-msg-broadcast {
            width: max-content;
            border-radius: 999px;
            padding: 3px 9px;
            background: rgba(255, 61, 90, 0.14);
            color: #ff91a6;
            font-size: 0.7rem;
            font-weight: 950;
            direction: ltr;
        }
        .live-msg-bars {
            height: 44px;
            display: flex;
            align-items: center;
            gap: 5px;
            overflow: hidden;
        }
        .live-msg-bars span {
            width: 6px;
            height: 18px;
            border-radius: 999px;
            background: rgba(157, 229, 255, 0.86);
            animation: liveWave 1.08s ease-in-out infinite;
        }
        .live-msg-bars span:nth-child(2n) { height: 30px; animation-delay: 0.12s; }
        .live-msg-bars span:nth-child(3n) { height: 38px; animation-delay: 0.24s; }
        .live-msg-bars.is-paused span {
            animation-play-state: paused;
            opacity: 0.36;
        }
        .live-msg-media {
            display: none;
        }
        .live-stream-pulse {
            width: 82px;
            height: 82px;
            border-radius: 50%;
            display: grid;
            place-items: center;
            color: #fff;
            font-weight: 900;
            background: linear-gradient(135deg, var(--primary), #7567ff);
            box-shadow: 0 0 0 10px rgba(42, 171, 238, 0.12), 0 0 38px rgba(42, 171, 238, 0.45);
        }
        .live-stream-meta {
            padding: 12px 14px 14px;
            display: grid;
            gap: 8px;
        }
        .live-stream-title {
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 900;
            color: #f4fbff;
        }
        .live-badge {
            direction: ltr;
            font-size: 0.68rem;
            padding: 2px 7px;
            border-radius: 999px;
            background: #ff3d5a;
            color: #fff;
            box-shadow: 0 0 14px rgba(255, 61, 90, 0.45);
        }
        .live-stream-url {
            direction: ltr;
            text-align: left;
            color: rgba(231, 243, 255, 0.7);
            font-size: 0.73rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .live-stream-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }
        .stream-mini-btn {
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
            border-radius: 10px;
            padding: 7px 10px;
            cursor: pointer;
            font-weight: 800;
            text-decoration: none;
            font-size: 0.78rem;
        }
        .stream-mini-btn.primary {
            background: var(--primary);
            border-color: transparent;
        }
        .stream-status-note {
            font-size: 0.75rem;
            color: rgba(231, 243, 255, 0.72);
            line-height: 1.7;
        }
        .live-stream-card.stream-error .stream-status-note {
            color: #ff8a8a;
        }
        .message-sticker {
            font-size: clamp(3.4rem, 10vw, 5.8rem);
            line-height: 1;
            text-align: center;
            padding: 8px 10px 12px;
            filter: drop-shadow(0 12px 18px rgba(0,0,0,0.22));
        }
        .sticker-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
            gap: 10px;
        }
        .sticker-btn {
            border: 1px solid var(--border-color);
            border-radius: 14px;
            min-height: 58px;
            background: rgba(255,255,255,0.06);
            color: var(--text-primary);
            font-size: 2rem;
            cursor: pointer;
            transition: transform 0.15s ease, background 0.15s ease;
        }
        .sticker-btn:hover {
            transform: translateY(-2px);
            background: rgba(42, 171, 238, 0.16);
        }
        .stream-center-card {
            width: min(96vw, 860px);
            max-height: min(90vh, 780px);
            overflow: hidden;
            padding: 0;
            background: #0b141b;
        }
        .live-room-shell {
            display: grid;
            grid-template-rows: auto minmax(0, 1fr);
            min-height: min(82vh, 720px);
            background:
                radial-gradient(700px 360px at 15% -10%, rgba(42, 171, 238, 0.18), transparent 62%),
                radial-gradient(560px 300px at 92% 8%, rgba(122, 92, 255, 0.12), transparent 58%),
                #0b141b;
        }
        .live-room-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 14px 16px;
            border-bottom: 1px solid rgba(255,255,255,0.07);
            background: rgba(19, 31, 43, 0.92);
            backdrop-filter: blur(16px);
        }
        .live-room-title {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
        }
        .live-room-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            display: grid;
            place-items: center;
            background: linear-gradient(135deg, #2aabee, #6d5dfc);
            box-shadow: 0 0 0 5px rgba(42, 171, 238, 0.11);
            color: #fff;
        }
        .live-room-title strong {
            color: #f4fbff;
            font-size: 1rem;
        }
        .live-room-title span {
            display: block;
            color: rgba(231, 243, 255, 0.62);
            font-size: 0.76rem;
            margin-top: 2px;
        }
        .live-room-close {
            border: none;
            background: rgba(255,255,255,0.08);
            color: #d9ecff;
            border-radius: 999px;
            padding: 9px 13px;
            font-weight: 900;
            cursor: pointer;
        }
        .live-room-body {
            display: grid;
            grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
            min-height: 0;
        }
        .live-room-stage {
            min-height: 0;
            padding: 20px;
            display: grid;
            align-content: center;
            gap: 18px;
            border-left: 1px solid rgba(255,255,255,0.06);
        }
        .live-stage-card {
            border-radius: 28px;
            border: 1px solid rgba(255,255,255,0.09);
            background:
                radial-gradient(circle at 50% 0%, rgba(42, 171, 238, 0.22), transparent 36%),
                linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.035));
            padding: 22px;
            min-height: 360px;
            display: grid;
            place-items: center;
            text-align: center;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 24px 70px rgba(0,0,0,0.26);
        }
        .live-orb {
            width: 136px;
            height: 136px;
            border-radius: 50%;
            display: grid;
            place-items: center;
            margin: 0 auto 18px;
            background: linear-gradient(135deg, #2aabee, #7667ff);
            box-shadow: 0 0 0 14px rgba(42, 171, 238, 0.08), 0 0 70px rgba(42, 171, 238, 0.38);
            color: #fff;
        }
        .live-orb svg {
            width: 58px;
            height: 58px;
        }
        .live-room-status {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            border-radius: 999px;
            padding: 5px 10px;
            background: rgba(255, 61, 90, 0.12);
            color: #ff9aad;
            font-size: 0.74rem;
            font-weight: 900;
            margin-bottom: 10px;
        }
        .live-room-status::before {
            content: '';
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: #ff3d5a;
            box-shadow: 0 0 12px rgba(255, 61, 90, 0.8);
        }
        .live-room-current {
            color: #f5fbff;
            font-size: 1.36rem;
            font-weight: 950;
            margin-bottom: 6px;
        }
        .live-room-url {
            direction: ltr;
            color: rgba(231, 243, 255, 0.54);
            font-size: 0.76rem;
            max-width: 420px;
            margin: 0 auto;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .live-waveform {
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            margin: 18px 0 2px;
        }
        .live-waveform span {
            width: 5px;
            height: 16px;
            border-radius: 99px;
            background: rgba(149, 223, 255, 0.85);
            animation: liveWave 1.15s ease-in-out infinite;
        }
        .live-waveform span:nth-child(2n) { animation-delay: 0.12s; height: 24px; }
        .live-waveform span:nth-child(3n) { animation-delay: 0.22s; height: 34px; }
        .live-waveform.is-paused span {
            animation-play-state: paused;
            opacity: 0.38;
        }
        @keyframes liveWave {
            0%, 100% { transform: scaleY(0.45); }
            50% { transform: scaleY(1.22); }
        }
        .live-room-controls {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 16px;
        }
        .live-control-btn {
            border: none;
            min-width: 52px;
            height: 52px;
            border-radius: 50%;
            background: #2aabee;
            color: #fff;
            display: inline-grid;
            place-items: center;
            cursor: pointer;
            box-shadow: 0 10px 24px rgba(42, 171, 238, 0.28);
        }
        .live-control-btn.secondary {
            width: auto;
            min-width: 0;
            height: 42px;
            padding: 0 14px;
            border-radius: 999px;
            background: rgba(255,255,255,0.09);
            box-shadow: none;
            font-weight: 900;
        }
        .live-control-btn svg {
            width: 24px;
            height: 24px;
        }
        .live-volume {
            width: 126px;
            accent-color: #2aabee;
        }
        .live-room-side {
            min-height: 0;
            padding: 16px;
            display: grid;
            grid-template-rows: auto auto minmax(0, 1fr);
            gap: 12px;
            background: rgba(9, 20, 31, 0.5);
        }
        .live-custom-row {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 8px;
        }
        .stream-list {
            display: grid;
            gap: 8px;
            overflow: auto;
            min-height: 0;
            padding: 2px 2px 8px;
        }
        .stream-item {
            border: 1px solid rgba(255,255,255,0.07);
            background: rgba(255,255,255,0.045);
            color: var(--text-primary);
            border-radius: 16px;
            padding: 11px;
            text-align: right;
            display: grid;
            gap: 6px;
            cursor: pointer;
            transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
        }
        .stream-item:hover,
        .stream-item.is-active {
            transform: translateY(-1px);
            border-color: rgba(42, 171, 238, 0.4);
            background: rgba(42, 171, 238, 0.12);
        }
        .stream-item-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }
        .stream-item strong {
            font-size: 0.9rem;
            min-width: 0;
        }
        .stream-item span {
            direction: ltr;
            text-align: left;
            color: var(--text-secondary);
            font-size: 0.68rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .stream-format-pill {
            direction: ltr;
            flex: 0 0 auto;
            border-radius: 999px;
            padding: 2px 7px;
            background: rgba(42, 171, 238, 0.14);
            color: #9de5ff;
            font-size: 0.64rem;
            font-weight: 900;
            letter-spacing: 0;
        }
        .stream-result-count {
            color: var(--text-secondary);
            font-size: 0.75rem;
            padding: 0 2px;
        }
        .sticker-modal-note {
            color: var(--text-secondary);
            font-size: 0.8rem;
            line-height: 1.8;
            margin-top: -4px;
        }
        body.light-mode .live-stream-card {
            background: linear-gradient(145deg, #ffffff, #eef7ff);
        }
        body.light-mode .live-stream-title,
        body.light-mode .stream-mini-btn {
            color: #102033;
        }
        body.light-mode .live-stream-url,
        body.light-mode .stream-status-note {
            color: #607083;
        }
        body.light-mode .stream-format-pill {
            color: #146995;
            background: rgba(42, 171, 238, 0.16);
        }
        @media (max-width: 560px) {
            .stream-center-card {
                width: 96vw;
                max-height: 88vh;
            }
            .live-room-shell {
                min-height: 88vh;
            }
            .live-room-header {
                padding: 12px;
            }
            .live-room-body {
                grid-template-columns: 1fr;
                grid-template-rows: auto minmax(0, 1fr);
            }
            .live-room-stage {
                border-left: none;
                border-bottom: 1px solid rgba(255,255,255,0.06);
                padding: 12px;
            }
            .live-stage-card {
                min-height: 280px;
                border-radius: 22px;
                padding: 16px;
            }
            .live-orb {
                width: 104px;
                height: 104px;
                margin-bottom: 12px;
            }
            .live-room-current {
                font-size: 1.08rem;
            }
            .live-room-side {
                padding: 12px;
                max-height: 43vh;
            }
            .stream-list {
                grid-template-columns: 1fr;
            }
        }
        @keyframes dmEnterPulse {
            0% {
                transform: translateY(16px) scale(0.985);
                filter: saturate(0.9);
                opacity: 0.78;
            }
            100% {
                transform: translateY(0) scale(1);
                filter: saturate(1);
                opacity: 1;
            }
        }

        /* TWeb-inspired polish layer */
        :root {
            --tweb-accent: #3390ec;
            --tweb-accent-hover: #2b82d9;
            --tweb-green: #78d263;
            --tweb-danger: #df3f40;
            --tweb-radius: 12px;
            --tweb-radius-lg: 18px;
            --tweb-shadow-popup: 0 16px 42px rgba(0, 0, 0, 0.32);
            --tweb-chat-pattern: rgba(255, 255, 255, 0.035);
            --tweb-wallpaper: #0e1621;
            --tweb-panel: #17212b;
            --tweb-panel-2: #202b36;
            --tweb-panel-3: #24313e;
            --tweb-border: rgba(255, 255, 255, 0.08);
            --tweb-text: #f5f7fa;
            --tweb-muted: #8b9baa;
            --tweb-incoming: #182533;
            --tweb-outgoing: #2b5278;
            --tweb-outgoing-text: #ffffff;
        }

        body.light-mode {
            --tweb-chat-pattern: rgba(60, 85, 105, 0.055);
            --tweb-wallpaper: #dbe9f2;
            --tweb-panel: #ffffff;
            --tweb-panel-2: #f4f4f5;
            --tweb-panel-3: #edf1f5;
            --tweb-border: rgba(17, 32, 46, 0.1);
            --tweb-text: #111827;
            --tweb-muted: #707b87;
            --tweb-incoming: #ffffff;
            --tweb-outgoing: #eeffde;
            --tweb-outgoing-text: #111827;
        }

        body {
            background:
                radial-gradient(circle at 20% 0%, rgba(51, 144, 236, 0.12), transparent 32%),
                linear-gradient(180deg, #0b141b, #0e1621) !important;
        }

        body.light-mode {
            background: linear-gradient(180deg, #eef3f7, #dfeaf2) !important;
        }

        #main-container.tg-app {
            width: min(1440px, calc(100vw - 28px)) !important;
            height: min(940px, calc(100dvh - 28px)) !important;
            min-height: 640px !important;
            border-radius: var(--tweb-radius-lg) !important;
            border: 1px solid var(--tweb-border) !important;
            background: var(--tweb-panel) !important;
            box-shadow: 0 18px 54px rgba(0, 0, 0, 0.28) !important;
            backdrop-filter: none !important;
        }

        .tg-sidebar {
            width: 368px !important;
            min-width: 320px !important;
            background: var(--tweb-panel) !important;
            border-inline-end: 1px solid var(--tweb-border) !important;
        }

        .tg-sidebar-header,
        .header.tg-topbar {
            height: 58px !important;
            background: var(--tweb-panel) !important;
            border-bottom: 1px solid var(--tweb-border) !important;
            backdrop-filter: none !important;
        }

        .tg-sidebar-header {
            padding: 0 12px !important;
        }

        .header.tg-topbar {
            padding: 0 12px !important;
        }

        .tg-app-title span:last-child,
        .tg-title,
        .tg-chat-title {
            color: var(--tweb-text) !important;
            font-weight: 650 !important;
            letter-spacing: 0 !important;
        }

        .tg-avatar,
        .live-room-avatar {
            border-radius: 50% !important;
            border: 0 !important;
            background: linear-gradient(135deg, #6ab2f2, #3390ec) !important;
            box-shadow: none !important;
            color: #fff !important;
        }

        .tg-icon-btn,
        .action-btn,
        .mobile-icon-btn {
            border: 0 !important;
            border-radius: 50% !important;
            background: transparent !important;
            color: var(--tweb-muted) !important;
            box-shadow: none !important;
            transform: none !important;
        }

        .tg-icon-btn:hover,
        .action-btn:hover,
        .mobile-icon-btn:hover {
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-accent) !important;
        }

        .tg-search {
            padding: 8px 12px 7px !important;
        }

        .tg-search input,
        .login-input,
        .link-input,
        .preview-caption-input {
            height: 40px !important;
            border-radius: 999px !important;
            border: 1px solid transparent !important;
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-text) !important;
            box-shadow: none !important;
        }

        .tg-search input:focus,
        .login-input:focus,
        .link-input:focus,
        .preview-caption-input:focus {
            border-color: rgba(51, 144, 236, 0.5) !important;
            box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.14) !important;
        }

        .tg-sidebar-tabs {
            gap: 6px !important;
            padding: 5px 10px 8px !important;
            overflow-x: auto !important;
            flex-wrap: nowrap !important;
        }

        .tg-folder-tab {
            flex: 0 0 auto !important;
            min-width: max-content !important;
            height: 32px !important;
            padding: 0 14px !important;
            border-radius: 999px !important;
            border: 0 !important;
            background: transparent !important;
            color: var(--tweb-muted) !important;
            font-weight: 650 !important;
            box-shadow: none !important;
        }

        .tg-folder-tab:hover {
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-text) !important;
        }

        .tg-folder-tab.is-active {
            background: rgba(51, 144, 236, 0.16) !important;
            color: var(--tweb-accent) !important;
            box-shadow: none !important;
        }

        .tg-sidebar-sections {
            padding: 0 8px 10px !important;
        }

        .tg-section-head {
            min-height: 34px !important;
            padding: 0 8px !important;
        }

        .tg-section-title,
        .tg-chat-snippet,
        .tg-chat-time,
        .tg-subtitle,
        .stream-result-count,
        .sticker-modal-note {
            color: var(--tweb-muted) !important;
        }

        .tg-create-btn,
        .section-create-btn {
            height: 32px !important;
            width: auto !important;
            min-width: 0 !important;
            border: 0 !important;
            border-radius: 999px !important;
            padding: 0 12px !important;
            background: rgba(51, 144, 236, 0.12) !important;
            color: var(--tweb-accent) !important;
            box-shadow: none !important;
            font-weight: 650 !important;
        }

        .tg-chat-list {
            padding: 1px 0 8px !important;
            gap: 1px !important;
        }

        .tg-chat-item {
            min-height: 64px !important;
            border: 0 !important;
            border-radius: var(--tweb-radius) !important;
            padding: 9px 10px !important;
            gap: 10px !important;
            background: transparent !important;
            box-shadow: none !important;
        }

        .tg-chat-item:hover {
            background: var(--tweb-panel-2) !important;
            border-color: transparent !important;
        }

        .tg-chat-item.active {
            background: var(--tweb-accent) !important;
            color: #fff !important;
            box-shadow: none !important;
            border-color: transparent !important;
        }

        .tg-chat-item.active .tg-chat-title,
        .tg-chat-item.active .tg-chat-snippet,
        .tg-chat-item.active .tg-chat-time {
            color: #fff !important;
        }

        .tg-unread-badge {
            background: var(--tweb-green) !important;
            box-shadow: none !important;
        }

        .tg-chat-info {
            border-radius: var(--tweb-radius) !important;
            padding: 6px 8px !important;
        }

        .tg-chat-info:hover {
            background: var(--tweb-panel-2) !important;
        }

        .chat-container {
            background: var(--tweb-wallpaper) !important;
        }

        #chat-messages {
            background:
                radial-gradient(circle at 14px 14px, var(--tweb-chat-pattern) 0 1.4px, transparent 1.5px 100%),
                radial-gradient(circle at 42px 38px, var(--tweb-chat-pattern) 0 1px, transparent 1.2px 100%),
                var(--tweb-wallpaper) !important;
            background-size: 58px 58px, 72px 72px, auto !important;
            padding: 18px 20px 14px !important;
        }

        .message {
            max-width: min(72%, 620px) !important;
            border: 0 !important;
            border-radius: 13px !important;
            padding: 8px 10px 7px !important;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14) !important;
        }

        .other-message {
            background: var(--tweb-incoming) !important;
            color: var(--tweb-text) !important;
            border-bottom-right-radius: 4px !important;
        }

        .user-message {
            background: var(--tweb-outgoing) !important;
            color: var(--tweb-outgoing-text) !important;
            border-bottom-left-radius: 4px !important;
        }

        .message::after {
            content: '';
            position: absolute;
            bottom: 0;
            width: 9px;
            height: 13px;
            background: inherit;
        }

        .other-message::after {
            right: -5px;
            clip-path: polygon(0 0, 100% 100%, 0 100%);
        }

        .user-message::after {
            left: -5px;
            clip-path: polygon(100% 0, 100% 100%, 0 100%);
        }

        .message-text {
            font-size: 0.94rem !important;
            line-height: 1.55 !important;
        }

        .username {
            color: var(--tweb-accent) !important;
            font-weight: 650 !important;
        }

        .timestamp,
        .other-message .timestamp {
            color: var(--tweb-muted) !important;
        }

        .user-message .timestamp,
        .user-message .username {
            color: rgba(255, 255, 255, 0.82) !important;
        }

        body.light-mode .user-message .timestamp,
        body.light-mode .user-message .username {
            color: rgba(27, 55, 42, 0.68) !important;
        }

        .reply-indicator,
        .input-area-reply,
        .mobile-reply-indicator {
            border-radius: 10px !important;
            border: 0 !important;
            border-right: 3px solid var(--tweb-accent) !important;
            background: rgba(51, 144, 236, 0.1) !important;
        }

        .reaction-item {
            border: 0 !important;
            background: rgba(51, 144, 236, 0.12) !important;
            color: var(--tweb-accent) !important;
        }

        .reaction-item.is-active {
            background: var(--tweb-accent) !important;
            color: #fff !important;
        }

        .input-area-wrapper {
            border-top: 1px solid var(--tweb-border) !important;
            background: var(--tweb-panel) !important;
            backdrop-filter: none !important;
            padding: 10px 14px calc(10px + env(safe-area-inset-bottom)) !important;
        }

        .desktop-input-row,
        .mobile-input-row {
            min-height: 48px !important;
            border: 0 !important;
            border-radius: 24px !important;
            background: var(--tweb-panel-2) !important;
            box-shadow: none !important;
            padding: 4px 5px !important;
        }

        .desktop-input {
            height: 40px !important;
            color: var(--tweb-text) !important;
        }

        .desktop-input-row .action-btn,
        .mobile-input-row .mobile-icon-btn {
            width: 40px !important;
            height: 40px !important;
        }

        .send-btn,
        .mobile-icon-btn.btn-send,
        .login-btn,
        .preview-send-btn,
        .voice-send-btn,
        .link-preview-btn,
        .link-choice-btn {
            border: 0 !important;
            border-radius: 999px !important;
            background: var(--tweb-accent) !important;
            color: #fff !important;
            box-shadow: none !important;
            font-weight: 650 !important;
        }

        .send-btn:hover,
        .mobile-icon-btn.btn-send:hover,
        .login-btn:hover,
        .preview-send-btn:hover,
        .voice-send-btn:hover,
        .link-preview-btn:hover,
        .link-choice-btn:hover {
            background: var(--tweb-accent-hover) !important;
        }

        .emoji-picker,
        .message-context-menu,
        .reaction-picker,
        .modal-content {
            border: 1px solid var(--tweb-border) !important;
            border-radius: var(--tweb-radius-lg) !important;
            background: var(--tweb-panel) !important;
            color: var(--tweb-text) !important;
            box-shadow: var(--tweb-shadow-popup) !important;
        }

        .menu-item,
        .topbar-menu-item {
            border-radius: var(--tweb-radius) !important;
        }

        .menu-item:hover,
        .topbar-menu-item:hover {
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-accent) !important;
        }

        .topbar-menu {
            border: 1px solid var(--tweb-border) !important;
            border-radius: var(--tweb-radius-lg) !important;
            background: var(--tweb-panel) !important;
            box-shadow: var(--tweb-shadow-popup) !important;
            padding: 6px !important;
        }

        .story-strip {
            background: var(--tweb-panel) !important;
            border-bottom: 1px solid var(--tweb-border) !important;
        }

        .story-create-btn {
            border-radius: 999px !important;
            border: 0 !important;
            background: rgba(51, 144, 236, 0.12) !important;
            color: var(--tweb-accent) !important;
        }

        .message-sticker {
            padding: 4px 6px 8px !important;
            filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.18)) !important;
        }

        .sticker-grid {
            grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)) !important;
            gap: 6px !important;
        }

        .sticker-btn {
            min-height: 64px !important;
            border: 0 !important;
            border-radius: var(--tweb-radius) !important;
            background: transparent !important;
            box-shadow: none !important;
        }

        .sticker-btn:hover {
            background: var(--tweb-panel-2) !important;
            transform: scale(1.06) !important;
        }

        .stream-center-card {
            width: min(94vw, 920px) !important;
            max-width: min(94vw, 920px) !important;
            background: var(--tweb-panel) !important;
            color: var(--tweb-text) !important;
            padding: 0 !important;
        }

        #stream-center-modal.active {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            opacity: 1 !important;
            visibility: visible !important;
        }

        #stream-center-modal.active .stream-center-card {
            display: grid !important;
            opacity: 1 !important;
            visibility: visible !important;
            transform: none !important;
            position: relative !important;
            z-index: 1 !important;
            overflow: hidden !important;
        }

        .live-room-shell {
            min-height: min(82vh, 720px) !important;
            background: var(--tweb-panel) !important;
        }

        .live-room-header {
            height: 60px !important;
            padding: 0 14px !important;
            background: var(--tweb-panel) !important;
            border-bottom: 1px solid var(--tweb-border) !important;
            backdrop-filter: none !important;
        }

        .live-room-title strong {
            color: var(--tweb-text) !important;
            font-weight: 650 !important;
        }

        .live-room-title span {
            color: var(--tweb-muted) !important;
        }

        .live-room-close {
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-muted) !important;
            border-radius: 999px !important;
            border: 0 !important;
            box-shadow: none !important;
        }

        .live-room-close:hover {
            color: var(--tweb-danger) !important;
        }

        .live-room-body {
            grid-template-columns: minmax(0, 1fr) 340px !important;
            direction: ltr !important;
        }

        .live-room-stage,
        .live-room-side {
            direction: rtl !important;
        }

        .live-room-stage {
            border-left: 1px solid var(--tweb-border) !important;
            background:
                radial-gradient(circle at 20px 20px, var(--tweb-chat-pattern) 0 1.3px, transparent 1.4px 100%),
                var(--tweb-wallpaper) !important;
            background-size: 62px 62px, auto !important;
            padding: 18px !important;
            display: grid !important;
            place-items: center !important;
            align-content: center !important;
            justify-content: stretch !important;
            position: relative !important;
            overflow: hidden !important;
        }

        .live-stage-card {
            width: min(100%, 520px) !important;
            min-height: 340px !important;
            border: 0 !important;
            border-radius: 20px !important;
            background: rgba(23, 33, 43, 0.9) !important;
            color: var(--tweb-text) !important;
            display: grid !important;
            place-items: center !important;
            opacity: 1 !important;
            visibility: visible !important;
            position: absolute !important;
            top: 50% !important;
            left: 50% !important;
            right: auto !important;
            bottom: auto !important;
            margin: 0 !important;
            align-self: center !important;
            justify-self: center !important;
            transform: translate(-50%, -50%) !important;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18) !important;
        }

        .live-stage-card > div {
            display: block !important;
            opacity: 1 !important;
            visibility: visible !important;
        }

        #stream-center-modal .live-room-stage {
            position: relative !important;
            display: grid !important;
            place-items: center !important;
            overflow: hidden !important;
        }

        #stream-center-modal .live-stage-card {
            position: absolute !important;
            top: 50% !important;
            left: 50% !important;
            right: auto !important;
            bottom: auto !important;
            transform: translate(-50%, -50%) !important;
            width: min(100%, 520px) !important;
            margin: 0 !important;
        }

        body.light-mode .live-stage-card {
            background: rgba(255, 255, 255, 0.88) !important;
        }

        .live-orb {
            width: 112px !important;
            height: 112px !important;
            background: var(--tweb-accent) !important;
            box-shadow: 0 0 0 10px rgba(51, 144, 236, 0.12) !important;
        }

        .live-room-status,
        .live-msg-broadcast,
        .live-badge {
            background: rgba(223, 63, 64, 0.12) !important;
            color: #ff7b7c !important;
            box-shadow: none !important;
        }

        .live-room-current {
            color: var(--tweb-text) !important;
            font-weight: 700 !important;
        }

        .live-room-url,
        .live-stream-url,
        .stream-status-note {
            color: var(--tweb-muted) !important;
        }

        .live-waveform span,
        .live-msg-bars span {
            background: var(--tweb-accent) !important;
        }

        .live-control-btn,
        .live-msg-play {
            background: var(--tweb-accent) !important;
            box-shadow: none !important;
        }

        .live-control-btn.secondary {
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-text) !important;
        }

        .live-room-side {
            background: var(--tweb-panel) !important;
            padding: 12px !important;
            gap: 9px !important;
        }

        .stream-item {
            border: 0 !important;
            border-radius: var(--tweb-radius) !important;
            background: transparent !important;
            padding: 10px !important;
        }

        .stream-item:hover,
        .stream-item.is-active {
            transform: none !important;
            background: var(--tweb-panel-2) !important;
        }

        .stream-item.is-active {
            outline: 2px solid rgba(51, 144, 236, 0.28) !important;
        }

        .stream-format-pill {
            background: rgba(51, 144, 236, 0.12) !important;
            color: var(--tweb-accent) !important;
        }

        .tg-live-message-player,
        .live-stream-card {
            border: 0 !important;
            border-radius: 14px !important;
            background: rgba(51, 144, 236, 0.12) !important;
            box-shadow: none !important;
        }

        .footer {
            background: var(--tweb-panel) !important;
            border-top: 1px solid var(--tweb-border) !important;
        }

        .connection-status {
            border: 0 !important;
            border-radius: 999px !important;
            background: var(--tweb-panel-2) !important;
            color: var(--tweb-muted) !important;
        }

        @media (max-width: 1024px) {
            #main-container.tg-app {
                width: 100% !important;
                height: 100dvh !important;
                min-height: 0 !important;
                border-radius: 0 !important;
                border: 0 !important;
                box-shadow: none !important;
            }

            .tg-sidebar {
                width: 100% !important;
            }

            .tg-sidebar-header,
            .header.tg-topbar {
                height: calc(56px + env(safe-area-inset-top)) !important;
            }

            #chat-messages {
                padding: 12px 9px calc(var(--mobile-input-height) + 28px) !important;
            }

            .message {
                max-width: 86% !important;
                box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16) !important;
            }

            .mobile-floating-container {
                background: linear-gradient(to top, var(--tweb-panel), rgba(23, 33, 43, 0.82) 72%, transparent) !important;
                padding: 7px 8px calc(8px + env(safe-area-inset-bottom)) !important;
            }

            body.light-mode .mobile-floating-container {
                background: linear-gradient(to top, #fff, rgba(255, 255, 255, 0.84) 72%, transparent) !important;
            }
        }

        @media (max-width: 640px) {
            .live-room-body {
                grid-template-columns: 1fr !important;
                grid-template-rows: auto minmax(0, 1fr) !important;
            }

            .live-room-stage {
                border-left: 0 !important;
                border-bottom: 1px solid var(--tweb-border) !important;
                padding: 12px !important;
            }

            .live-stage-card {
                min-height: 260px !important;
            }

            .live-room-side {
                max-height: 42vh !important;
            }

            .live-custom-row {
                grid-template-columns: 1fr !important;
            }

            .send-btn {
                min-width: 72px !important;
                padding: 0 14px !important;
            }
        }

        /* Final Telegram-like sidebar and live stream polish */
        .tg-sidebar-sections {
            padding: 8px 8px 14px !important;
            background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent 140px), var(--tweb-panel) !important;
            scrollbar-width: thin !important;
        }

        .tg-sidebar-section {
            gap: 6px !important;
            margin: 0 0 10px !important;
            padding: 8px 0 10px !important;
            border-bottom: 1px solid var(--tweb-border) !important;
        }

        .tg-sidebar-section:last-child {
            border-bottom: 0 !important;
        }

        .tg-section-head {
            position: sticky !important;
            top: 0 !important;
            z-index: 2 !important;
            padding: 5px 8px 7px !important;
            background: color-mix(in srgb, var(--tweb-panel) 92%, transparent) !important;
            backdrop-filter: blur(10px) !important;
        }

        .tg-section-title {
            color: var(--tweb-muted) !important;
            font-size: 0.72rem !important;
            font-weight: 800 !important;
            letter-spacing: 0 !important;
        }

        .tg-section-head .section-create-btn {
            min-width: 0 !important;
            height: 30px !important;
            padding: 0 10px !important;
            border-radius: 999px !important;
            font-size: 0.72rem !important;
            background: rgba(51, 144, 236, 0.12) !important;
            border: 0 !important;
            color: var(--tweb-accent) !important;
        }

        .tg-chat-list {
            padding: 0 2px !important;
            gap: 2px !important;
            max-height: none !important;
        }

        body:not(.tg-sidebar-view-all) .tg-chat-list {
            max-height: none !important;
        }

        .tg-chat-item {
            min-height: 64px !important;
            border-radius: 12px !important;
            padding: 9px 10px !important;
            border: 0 !important;
        }

        .tg-chat-item:hover {
            background: var(--tweb-panel-2) !important;
        }

        .tg-chat-item.active {
            background: rgba(51, 144, 236, 0.16) !important;
            color: var(--tweb-text) !important;
            box-shadow: inset 3px 0 0 var(--tweb-accent) !important;
        }

        .live-stream-card {
            width: min(100%, 390px) !important;
            border-radius: 16px !important;
            overflow: hidden !important;
            background: var(--tweb-panel-2) !important;
            border: 1px solid var(--tweb-border) !important;
        }

        .tg-live-message-player {
            min-height: 112px !important;
            padding: 14px !important;
            background:
                linear-gradient(135deg, rgba(51, 144, 236, 0.16), rgba(37, 55, 71, 0.42)),
                var(--tweb-panel-2) !important;
            border-radius: 0 !important;
        }

        .live-msg-play,
        .live-control-btn {
            width: 48px !important;
            height: 48px !important;
            border-radius: 50% !important;
            background: var(--tweb-accent) !important;
            color: #fff !important;
            transition: transform 0.14s ease, filter 0.14s ease !important;
        }

        .live-msg-play:active,
        .live-control-btn:active {
            transform: scale(0.94) !important;
        }

        .live-msg-visual {
            gap: 8px !important;
        }

        .live-msg-bars,
        .live-waveform {
            border: 0 !important;
            background: transparent !important;
        }

        .live-stream-meta {
            gap: 6px !important;
            padding: 10px 12px 12px !important;
        }

        .live-stream-url,
        .live-room-url {
            display: none !important;
        }

        .stream-mini-btn.primary {
            display: none !important;
        }

        .stream-mini-btn {
            border: 0 !important;
            border-radius: 999px !important;
            background: rgba(51, 144, 236, 0.13) !important;
            color: var(--tweb-accent) !important;
            padding: 7px 12px !important;
        }

        #stream-center-modal .stream-center-card {
            width: min(94vw, 980px) !important;
            max-height: min(90dvh, 760px) !important;
            border-radius: 18px !important;
            box-shadow: 0 24px 70px rgba(0,0,0,0.34) !important;
        }

        .live-room-body {
            grid-template-columns: minmax(0, 1fr) 320px !important;
        }

        .live-stage-card {
            width: min(100%, 480px) !important;
            min-height: 324px !important;
            border-radius: 18px !important;
            background: color-mix(in srgb, var(--tweb-panel) 92%, transparent) !important;
            overflow: visible !important;
        }

        .live-orb {
            width: 104px !important;
            height: 104px !important;
            margin-bottom: 14px !important;
            border-radius: 28px !important;
            background: linear-gradient(135deg, var(--tweb-accent), #42b883) !important;
            box-shadow: 0 14px 34px rgba(51,144,236,0.24) !important;
        }

        .live-room-current {
            max-width: 360px !important;
            margin-inline: auto !important;
            font-size: 1.18rem !important;
            line-height: 1.45 !important;
        }

        .live-waveform {
            width: min(100%, 320px) !important;
            height: 58px !important;
            margin: 18px auto 0 !important;
            padding: 0 12px !important;
            border-radius: 18px !important;
            cursor: pointer !important;
            display: inline-flex !important;
        }

        .live-waveform:hover {
            background: rgba(51,144,236,0.08) !important;
        }

        .live-room-controls {
            width: min(100%, 330px) !important;
            margin: 12px auto 0 !important;
            gap: 10px !important;
            padding: 10px !important;
            border: 1px solid var(--tweb-border) !important;
            border-radius: 18px !important;
            background: var(--tweb-panel-2) !important;
            opacity: 0 !important;
            transform: translateY(10px) scale(0.98) !important;
            pointer-events: none !important;
            transition: opacity 0.18s ease, transform 0.18s ease !important;
        }

        .live-stage-card.volume-open .live-room-controls,
        .live-room-controls:focus-within {
            opacity: 1 !important;
            transform: translateY(0) scale(1) !important;
            pointer-events: auto !important;
        }

        .live-volume-wrap {
            min-width: 0 !important;
            flex: 1 1 180px !important;
            height: 42px !important;
            display: flex !important;
            align-items: center !important;
            gap: 9px !important;
            padding: 0 12px !important;
            border-radius: 999px !important;
            background: color-mix(in srgb, var(--tweb-panel) 78%, transparent) !important;
        }

        .live-volume-icon {
            width: 19px !important;
            height: 19px !important;
            color: var(--tweb-muted) !important;
            flex: 0 0 auto !important;
        }

        .live-volume {
            width: 100% !important;
            min-width: 120px !important;
        }

        .live-room-side {
            border-right: 1px solid var(--tweb-border) !important;
        }

        .stream-item {
            min-height: 56px !important;
            border-radius: 12px !important;
            padding: 9px 10px !important;
        }

        .stream-item span {
            direction: rtl !important;
            text-align: right !important;
            font-size: 0.72rem !important;
        }

        .stream-item.is-active {
            outline: 0 !important;
            box-shadow: inset 3px 0 0 var(--tweb-accent) !important;
        }

        #stream-btn svg,
        #sticker-btn svg,
        #mobile-stream-btn svg,
        #mobile-sticker-btn svg,
        #stream-center-btn svg {
            stroke-linecap: round !important;
            stroke-linejoin: round !important;
        }

        @media (max-width: 640px) {
            #stream-center-modal.active {
                align-items: flex-end !important;
                padding: 0 !important;
            }

            #stream-center-modal .stream-center-card {
                width: 100vw !important;
                max-width: 100vw !important;
                max-height: 92dvh !important;
                border-radius: 22px 22px 0 0 !important;
            }

            .live-room-shell {
                min-height: 92dvh !important;
            }

            .live-room-header {
                height: 58px !important;
                padding-inline: 12px !important;
            }

            .live-room-title strong {
                font-size: 0.92rem !important;
            }

            .live-room-body {
                grid-template-rows: auto minmax(0, 1fr) !important;
            }

            .live-room-stage {
                min-height: 350px !important;
                padding: 12px !important;
            }

            .live-stage-card {
                position: relative !important;
                inset: auto !important;
                transform: none !important;
                width: 100% !important;
                min-height: 300px !important;
            }

            #stream-center-modal .live-stage-card {
                position: relative !important;
                top: auto !important;
                left: auto !important;
                transform: none !important;
            }

            .live-room-side {
                max-height: none !important;
                min-height: 0 !important;
                overflow: hidden !important;
                border-right: 0 !important;
            }

            .stream-list {
                max-height: 32dvh !important;
            }

            .live-room-controls {
                opacity: 1 !important;
                transform: none !important;
                pointer-events: auto !important;
                flex-wrap: nowrap !important;
            }

            .live-control-btn {
                width: 46px !important;
                height: 46px !important;
                flex: 0 0 46px !important;
            }

            .live-volume-wrap {
                flex-basis: auto !important;
            }

            .live-stream-card {
                width: min(100%, 340px) !important;
            }

            .tg-live-message-player {
                min-height: 104px !important;
            }
        }

        /* Final fixes requested after visual QA */
        body.tg-sidebar-collapsed .tg-sidebar {
            width: 0 !important;
            min-width: 0 !important;
            flex: 0 0 0 !important;
            border-inline-end: 0 !important;
            overflow: hidden !important;
            opacity: 0 !important;
            pointer-events: none !important;
        }

        body.tg-sidebar-collapsed .tg-chat-panel {
            flex: 1 1 100% !important;
            width: 100% !important;
            max-width: none !important;
        }

        @media (max-width: 1024px) {
            body.tg-sidebar-collapsed .tg-sidebar {
                width: 0 !important;
                min-width: 0 !important;
                transform: translateX(100%) !important;
            }
        }

        body.light-mode .topbar-menu,
        body.light-mode .message-context-menu,
        body.light-mode .reaction-picker {
            background: #ffffff !important;
            color: #111827 !important;
            border-color: rgba(17, 32, 46, 0.12) !important;
        }

        body.light-mode .topbar-menu-item,
        body.light-mode .topbar-menu-item span,
        body.light-mode .preview-header h3,
        body.light-mode .modal-content h2,
        body.light-mode .modal-content h3,
        body.light-mode .tg-section-title,
        body.light-mode .stream-item strong,
        body.light-mode .live-room-title strong {
            color: #111827 !important;
        }

        body.light-mode .topbar-menu-item svg,
        body.light-mode .preview-close-btn,
        body.light-mode .stream-item span,
        body.light-mode .live-room-title span,
        body.light-mode .link-preview-stream span {
            color: #64748b !important;
        }

        body.light-mode .topbar-menu-item:hover {
            background: #eef6ff !important;
            color: #0f5f9f !important;
        }

        body.light-mode .preview-header,
        body.light-mode .tg-modal-card .preview-header {
            background: #ffffff !important;
            border-bottom-color: rgba(17, 32, 46, 0.1) !important;
        }

        .live-room-title > div {
            min-width: 0 !important;
        }

        .live-room-title span {
            white-space: normal !important;
            overflow: visible !important;
            text-overflow: clip !important;
            line-height: 1.55 !important;
        }

        .stream-item {
            grid-template-rows: auto auto !important;
            align-content: center !important;
            min-height: 68px !important;
            gap: 3px !important;
            overflow: visible !important;
        }

        .stream-item-top {
            min-width: 0 !important;
        }

        .stream-item strong {
            min-width: 0 !important;
            overflow: hidden !important;
            text-overflow: ellipsis !important;
            white-space: nowrap !important;
            line-height: 1.55 !important;
        }

        .stream-item span {
            display: block !important;
            min-height: 1.45em !important;
            line-height: 1.55 !important;
            white-space: normal !important;
            overflow: visible !important;
            text-overflow: clip !important;
        }

        .live-room-controls {
            width: min(100%, 390px) !important;
        }

        .live-send-stream {
            width: auto !important;
            min-width: 92px !important;
            height: 42px !important;
            padding: 0 13px !important;
            border-radius: 999px !important;
            white-space: nowrap !important;
            font-size: 0.78rem !important;
            font-weight: 850 !important;
            color: var(--tweb-accent) !important;
        }

        .link-preview-area.is-stream {
            align-items: stretch !important;
            justify-content: stretch !important;
            border-style: solid !important;
            border-color: rgba(51, 144, 236, 0.28) !important;
            background: rgba(51, 144, 236, 0.08) !important;
        }

        .link-preview-stream {
            background: linear-gradient(135deg, rgba(51, 144, 236, 0.18), rgba(66, 184, 131, 0.1)) !important;
            border-color: rgba(51, 144, 236, 0.24) !important;
            color: var(--tweb-text) !important;
        }

        .link-stream-icon {
            background: rgba(51, 144, 236, 0.14) !important;
            color: var(--tweb-accent) !important;
        }

        .live-stream-card.stream-kind-audio .live-msg-broadcast::after {
            content: ' AUDIO';
        }

        .live-stream-card.stream-kind-video .live-msg-broadcast::after,
        .live-stream-card.stream-kind-hls .live-msg-broadcast::after {
            content: ' VIDEO';
        }

        .live-stream-subtitle {
            display: block;
            color: var(--tweb-muted);
            font-size: 0.76rem;
            line-height: 1.65;
        }

        .live-stream-card {
            position: relative !important;
            isolation: isolate !important;
        }

        .live-stream-card::before {
            content: '';
            position: absolute;
            inset-block: 0;
            inset-inline-start: 0;
            width: 3px;
            background: linear-gradient(180deg, var(--tweb-accent), var(--tweb-green));
            z-index: 2;
        }

        .live-stream-title {
            flex-wrap: wrap !important;
            line-height: 1.55 !important;
        }

        @media (max-width: 640px) {
            .live-room-controls {
                width: 100% !important;
                gap: 8px !important;
            }

            .live-send-stream {
                min-width: 78px !important;
                padding: 0 10px !important;
            }

            .link-preview-stream {
                min-height: 104px !important;
            }
        }

        /* Final click/live-card/mobile-stream refinements */
        .live-stream-card .live-msg-media {
            display: none !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .tg-live-message-player,
        .live-stream-card.stream-kind-hls.has-video-frame .tg-live-message-player {
            min-height: 0 !important;
            padding: 0 !important;
            display: block !important;
            aspect-ratio: 16 / 9 !important;
            background: #07131f !important;
            overflow: hidden !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-media,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-media {
            display: block !important;
            width: 100% !important;
            height: 100% !important;
            max-height: none !important;
            object-fit: cover !important;
            background: #07131f !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-play,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-play {
            position: absolute !important;
            inset-inline-start: 50% !important;
            top: 50% !important;
            transform: translate(-50%, -50%) !important;
            z-index: 4 !important;
            width: 56px !important;
            height: 56px !important;
            background: rgba(51, 144, 236, 0.96) !important;
            box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28) !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-play:active,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-play:active {
            transform: translate(-50%, -50%) scale(0.94) !important;
        }

        .live-msg-mute {
            display: none;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-mute,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-mute {
            position: absolute !important;
            inset-inline-start: 12px !important;
            bottom: 12px !important;
            z-index: 4 !important;
            width: 40px !important;
            height: 40px !important;
            border: 0 !important;
            border-radius: 50% !important;
            display: grid !important;
            place-items: center !important;
            color: #fff !important;
            background: rgba(9, 20, 31, 0.72) !important;
            cursor: pointer !important;
            backdrop-filter: blur(8px) !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-mute svg,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-mute svg {
            width: 20px !important;
            height: 20px !important;
        }

        html[dir="rtl"] .live-stream-card.stream-kind-video.has-video-frame .live-msg-play,
        html[dir="rtl"] .live-stream-card.stream-kind-hls.has-video-frame .live-msg-play {
            transform: translate(50%, -50%) !important;
        }

        html[dir="rtl"] .live-stream-card.stream-kind-video.has-video-frame .live-msg-play:active,
        html[dir="rtl"] .live-stream-card.stream-kind-hls.has-video-frame .live-msg-play:active {
            transform: translate(50%, -50%) scale(0.94) !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-visual,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-visual {
            position: absolute !important;
            top: 10px !important;
            inset-inline-end: 10px !important;
            z-index: 3 !important;
            width: auto !important;
            display: block !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-bars,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-bars {
            display: none !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-broadcast,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-broadcast {
            background: rgba(223, 63, 64, 0.88) !important;
            color: #fff !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame.is-playing:not(.controls-visible) .live-msg-play,
        .live-stream-card.stream-kind-hls.has-video-frame.is-playing:not(.controls-visible) .live-msg-play,
        .live-stream-card.stream-kind-video.has-video-frame.is-playing:not(.controls-visible) .live-msg-mute,
        .live-stream-card.stream-kind-hls.has-video-frame.is-playing:not(.controls-visible) .live-msg-mute {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-msg-play,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-play,
        .live-stream-card.stream-kind-video.has-video-frame .live-msg-mute,
        .live-stream-card.stream-kind-hls.has-video-frame .live-msg-mute {
            transition: opacity 0.22s ease, transform 0.14s ease !important;
        }

        .live-stream-card.stream-kind-audio .tg-live-message-player {
            display: flex !important;
            align-items: center !important;
            min-height: 106px !important;
        }

        .live-stream-card.stream-kind-audio .live-msg-play {
            order: 2 !important;
        }

        .live-stream-card.stream-kind-audio .live-msg-visual {
            order: 1 !important;
        }

        .live-stream-card.stream-kind-audio .live-stream-meta {
            background: color-mix(in srgb, var(--tweb-panel-2) 88%, #000 12%) !important;
        }

        .live-stream-card.stream-kind-video.has-video-frame .live-stream-meta,
        .live-stream-card.stream-kind-hls.has-video-frame .live-stream-meta {
            background: var(--tweb-panel-2) !important;
        }

        .live-room-mute {
            width: 42px !important;
            min-width: 42px !important;
            padding: 0 !important;
        }

        .live-room-mute svg {
            width: 20px !important;
            height: 20px !important;
        }

        .live-room-mute:disabled {
            opacity: 0.48 !important;
            cursor: default !important;
        }

        @media (max-width: 640px) {
            #stream-center-modal .stream-center-card {
                max-height: 90dvh !important;
                border-radius: 20px 20px 0 0 !important;
            }

            .live-room-shell {
                min-height: 0 !important;
                height: 90dvh !important;
            }

            .live-room-body {
                height: calc(90dvh - 58px) !important;
                min-height: 0 !important;
                grid-template-rows: auto minmax(0, 1fr) !important;
            }

            .live-room-stage {
                min-height: 0 !important;
                padding: 10px !important;
                align-content: stretch !important;
                place-items: stretch !important;
            }

            #stream-center-modal .live-stage-card,
            .live-stage-card {
                min-height: 0 !important;
                height: auto !important;
                width: 100% !important;
                padding: 14px !important;
                border-radius: 16px !important;
                display: grid !important;
                place-items: center !important;
            }

            .live-stage-card > div {
                width: 100% !important;
            }

            .live-orb {
                width: 62px !important;
                height: 62px !important;
                border-radius: 18px !important;
                margin-bottom: 8px !important;
            }

            .live-orb svg {
                width: 30px !important;
                height: 30px !important;
            }

            .live-room-status {
                margin-bottom: 6px !important;
                padding: 3px 8px !important;
                font-size: 0.68rem !important;
            }

            .live-room-current {
                font-size: 1rem !important;
                margin-bottom: 2px !important;
                line-height: 1.45 !important;
            }

            .live-waveform {
                width: min(100%, 260px) !important;
                height: 40px !important;
                margin: 8px auto 0 !important;
            }

            .live-waveform span {
                width: 4px !important;
            }

            .live-room-controls {
                margin-top: 8px !important;
                padding: 8px !important;
                border-radius: 16px !important;
                display: grid !important;
                grid-template-columns: 46px 46px minmax(74px, auto) minmax(0, 1fr) !important;
                align-items: center !important;
            }

            .live-volume-wrap {
                min-width: 0 !important;
                height: 40px !important;
                padding: 0 10px !important;
            }

            .live-room-side {
                min-height: 0 !important;
                padding: 10px !important;
                gap: 8px !important;
                grid-template-rows: 40px 40px auto minmax(0, 1fr) !important;
                overflow: hidden !important;
            }

            .live-custom-row {
                grid-template-columns: minmax(0, 1fr) 68px !important;
            }

            .stream-list {
                max-height: none !important;
                min-height: 0 !important;
                overflow: auto !important;
                padding-bottom: 10px !important;
            }

            .stream-item {
                min-height: 58px !important;
                padding: 8px 10px !important;
            }
        }

        @media (max-width: 380px) {
            .live-room-controls {
                grid-template-columns: 46px 46px minmax(0, 1fr) !important;
            }

            .live-volume-wrap {
                grid-column: 1 / -1 !important;
            }
        }

        /* Mobile-only live room redesign */
        @media (max-width: 640px) {
            #stream-center-modal.active {
                align-items: flex-end !important;
                justify-content: center !important;
                padding: 0 !important;
            }

            #stream-center-modal .stream-center-card {
                width: 100vw !important;
                max-width: none !important;
                height: min(92dvh, 760px) !important;
                max-height: 92dvh !important;
                border-radius: 24px 24px 0 0 !important;
                overflow: hidden !important;
            }

            #stream-center-modal .live-room-shell {
                height: min(92dvh, 760px) !important;
                min-height: 0 !important;
                grid-template-rows: 56px minmax(0, 1fr) !important;
                background: var(--tweb-panel) !important;
            }

            #stream-center-modal .live-room-header {
                height: 56px !important;
                padding: 8px 12px !important;
                background: var(--tweb-panel) !important;
            }

            #stream-center-modal .live-room-avatar {
                width: 38px !important;
                height: 38px !important;
                box-shadow: none !important;
            }

            #stream-center-modal .live-room-title {
                gap: 9px !important;
            }

            #stream-center-modal .live-room-title strong {
                font-size: 0.94rem !important;
            }

            #stream-center-modal .live-room-title span {
                font-size: 0.72rem !important;
                line-height: 1.45 !important;
                white-space: nowrap !important;
                overflow: hidden !important;
                text-overflow: ellipsis !important;
                max-width: 52vw !important;
            }

            #stream-center-modal .live-room-close {
                height: 36px !important;
                min-width: 64px !important;
                padding: 0 12px !important;
                border-radius: 999px !important;
                background: var(--tweb-panel-2) !important;
                color: var(--tweb-text) !important;
            }

            #stream-center-modal .live-room-body {
                height: auto !important;
                min-height: 0 !important;
                display: grid !important;
                grid-template-columns: 1fr !important;
                grid-template-rows: auto minmax(0, 1fr) !important;
                overflow: hidden !important;
            }

            #stream-center-modal .live-room-stage {
                padding: 10px 12px 8px !important;
                border: 0 !important;
                background:
                    linear-gradient(180deg, rgba(51, 144, 236, 0.12), rgba(66, 184, 131, 0.06)),
                    var(--tweb-panel) !important;
            }

            #stream-center-modal .live-stage-card {
                width: 100% !important;
                min-height: 0 !important;
                height: auto !important;
                padding: 12px !important;
                border-radius: 18px !important;
                display: block !important;
                background: var(--tweb-panel-2) !important;
                border-color: var(--tweb-border) !important;
                box-shadow: none !important;
            }

            #stream-center-modal .live-stage-card > div {
                width: 100% !important;
                display: grid !important;
                grid-template-columns: 66px minmax(0, 1fr) !important;
                grid-template-areas:
                    "orb status"
                    "orb title"
                    "wave wave"
                    "controls controls" !important;
                column-gap: 12px !important;
                align-items: center !important;
                text-align: start !important;
            }

            #stream-center-modal .live-orb {
                grid-area: orb !important;
                width: 60px !important;
                height: 60px !important;
                margin: 0 !important;
                border-radius: 18px !important;
                background: linear-gradient(135deg, var(--tweb-accent), var(--tweb-green)) !important;
                box-shadow: 0 10px 24px rgba(51, 144, 236, 0.22) !important;
            }

            #stream-center-modal .live-orb svg {
                width: 28px !important;
                height: 28px !important;
            }

            #stream-center-modal .live-room-status {
                grid-area: status !important;
                justify-self: start !important;
                margin: 0 !important;
                padding: 3px 8px !important;
                font-size: 0.66rem !important;
                line-height: 1.4 !important;
            }

            #stream-center-modal .live-room-current {
                grid-area: title !important;
                width: 100% !important;
                max-width: none !important;
                margin: 3px 0 0 !important;
                font-size: 1rem !important;
                line-height: 1.45 !important;
                text-align: start !important;
                white-space: nowrap !important;
                overflow: hidden !important;
                text-overflow: ellipsis !important;
            }

            #stream-center-modal .live-waveform {
                grid-area: wave !important;
                width: 100% !important;
                height: 54px !important;
                margin: 12px 0 0 !important;
                padding: 0 10px !important;
                display: flex !important;
                border-radius: 16px !important;
                background: color-mix(in srgb, var(--tweb-panel) 78%, transparent) !important;
            }

            #stream-center-modal .live-waveform span {
                width: 4px !important;
                background: color-mix(in srgb, var(--tweb-accent) 74%, #ffffff 26%) !important;
            }

            #stream-center-modal .live-room-controls {
                grid-area: controls !important;
                width: 100% !important;
                margin: 10px 0 0 !important;
                padding: 8px !important;
                display: grid !important;
                grid-template-columns: 48px 44px minmax(0, 1fr) !important;
                gap: 8px !important;
                align-items: center !important;
                border-radius: 16px !important;
                background: color-mix(in srgb, var(--tweb-panel) 80%, transparent) !important;
                border: 1px solid var(--tweb-border) !important;
                opacity: 1 !important;
                transform: none !important;
                pointer-events: auto !important;
            }

            #stream-center-modal #live-room-play {
                width: 48px !important;
                min-width: 48px !important;
                height: 48px !important;
            }

            #stream-center-modal .live-room-mute {
                width: 44px !important;
                min-width: 44px !important;
                height: 44px !important;
                border-radius: 14px !important;
            }

            #stream-center-modal .live-send-stream {
                width: 100% !important;
                min-width: 0 !important;
                height: 44px !important;
                padding: 0 10px !important;
                border-radius: 14px !important;
                font-size: 0.78rem !important;
            }

            #stream-center-modal .live-volume-wrap {
                grid-column: 1 / -1 !important;
                min-width: 0 !important;
                width: 100% !important;
                height: 38px !important;
                padding: 0 10px !important;
                border-radius: 13px !important;
                background: var(--tweb-panel-2) !important;
            }

            #stream-center-modal .live-volume {
                width: 100% !important;
                min-width: 0 !important;
            }

            #stream-center-modal .live-room-side {
                min-height: 0 !important;
                padding: 8px 12px 12px !important;
                gap: 8px !important;
                display: grid !important;
                grid-template-rows: 38px 38px auto minmax(0, 1fr) !important;
                overflow: hidden !important;
                background: var(--tweb-panel) !important;
                border: 0 !important;
            }

            #stream-center-modal .live-room-side .login-input {
                height: 38px !important;
                min-height: 38px !important;
                border-radius: 12px !important;
            }

            #stream-center-modal .live-custom-row {
                grid-template-columns: minmax(0, 1fr) 64px !important;
                gap: 8px !important;
            }

            #stream-center-modal #stream-custom-btn {
                height: 38px !important;
                min-height: 38px !important;
                border-radius: 12px !important;
                padding: 0 10px !important;
            }

            #stream-center-modal .stream-result-count {
                min-height: 18px !important;
                padding: 0 2px !important;
                font-size: 0.72rem !important;
                line-height: 18px !important;
            }

            #stream-center-modal .stream-list {
                min-height: 0 !important;
                max-height: none !important;
                overflow: auto !important;
                overscroll-behavior: contain !important;
                gap: 7px !important;
                padding: 0 0 12px !important;
            }

            #stream-center-modal .stream-item {
                min-height: 54px !important;
                padding: 8px 10px !important;
                border-radius: 14px !important;
                gap: 2px !important;
                background: var(--tweb-panel-2) !important;
            }

            #stream-center-modal .stream-item-top {
                gap: 7px !important;
            }

            #stream-center-modal .stream-item strong {
                font-size: 0.84rem !important;
            }

            #stream-center-modal .stream-format-pill {
                padding: 2px 6px !important;
                font-size: 0.58rem !important;
            }

            #stream-center-modal .stream-item span {
                font-size: 0.68rem !important;
                line-height: 1.45 !important;
                white-space: nowrap !important;
                overflow: hidden !important;
                text-overflow: ellipsis !important;
            }
        }

        @media (min-width: 1025px) {
            button,
            .action-btn,
            .mobile-icon-btn,
            .link-choice-btn,
            .preview-send-btn,
            .send-btn,
            .stream-item,
            .tg-chat-item,
            .tg-folder-tab {
                touch-action: manipulation;
            }

            .action-btn,
            .tg-icon-btn,
            .mobile-icon-btn {
                transform: none !important;
                transition: background 0.14s ease, color 0.14s ease, opacity 0.14s ease !important;
            }

            .action-btn:hover,
            .tg-icon-btn:hover,
            .mobile-icon-btn:hover {
                transform: none !important;
                box-shadow: none !important;
            }

            .action-btn:active,
            .tg-icon-btn:active,
            .mobile-icon-btn:active,
            .send-btn:active,
            .link-choice-btn:active,
            .preview-send-btn:active {
                transform: scale(0.97) !important;
            }

            .message {
                cursor: default !important;
            }

            #chat-messages {
                overscroll-behavior: contain !important;
                scroll-behavior: auto !important;
            }
        }

        /* Kill-switch: inactive modals must not render at all. Children of the
           stream modal set visibility/display with !important, which punched
           through the overlay's visibility:hidden and left an invisible layer
           over the chat that swallowed clicks and wheel/touch scrolling. */
        .modal-overlay:not(.active) {
            display: none !important;
            pointer-events: none !important;
        }

        /* Keep sender name pinned to the start of the bubble. With the avatar
           prepended (public/AI chats) the header has 3 children and
           space-between used to push the name into the middle of wide bubbles. */
        .message-header {
            justify-content: flex-start !important;
        }
        .message-header .timestamp {
            margin-inline-start: auto !important;
        }

        /* Telegram-style circular paper-plane send button */
        .desktop-input-row .send-btn {
            min-width: 46px !important;
            width: 46px !important;
            height: 46px !important;
            padding: 0 !important;
            border-radius: 50% !important;
            display: inline-grid !important;
            place-items: center !important;
            flex: 0 0 46px !important;
        }
        .desktop-input-row .send-btn svg {
            width: 22px;
            height: 22px;
            transform: scaleX(-1) translateX(1px); /* mirror for RTL send direction */
        }

        /* Ghost style for secondary choice buttons (Telegram look) */
        .link-choice-btn.secondary {
            background: rgba(51, 144, 236, 0.12) !important;
            color: var(--tweb-accent) !important;
        }
        .link-choice-btn.secondary:hover {
            background: rgba(51, 144, 236, 0.2) !important;
        }

        /* Message arrival animation — only newly-received/sent messages */
        @keyframes msgPopIn {
            0%   { opacity: 0; transform: translateY(14px) scale(0.94); }
            60%  { opacity: 1; }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }
        @keyframes msgPopOut {
            0%   { opacity: 0; transform: translateY(14px) scale(0.94); }
            60%  { opacity: 1; }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }
        .message.msg-enter-in {
            animation: msgPopIn 0.34s cubic-bezier(0.22, 1, 0.36, 1);
            transform-origin: bottom right;
        }
        .message.msg-enter-out {
            animation: msgPopOut 0.3s cubic-bezier(0.22, 1, 0.36, 1);
            transform-origin: bottom left;
        }
        /* AI bot: gentle attention pulse as its reply lands */
        .message.ai-bot-message.msg-enter-in {
            animation: msgPopIn 0.42s cubic-bezier(0.22, 1, 0.36, 1);
        }
        @media (prefers-reduced-motion: reduce) {
            .message.msg-enter-in, .message.msg-enter-out { animation: none !important; }
        }

        /* AI thinking bubble */
        .ai-thinking-bubble {
            animation: msgPopIn 0.34s cubic-bezier(0.22, 1, 0.36, 1);
        }
        .ai-thinking-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 2px 2px;
        }
        .ai-thinking-text {
            font-size: 0.9rem;
            color: var(--tweb-text, #f5f7fa);
            transition: opacity 0.18s ease;
            opacity: 1;
        }
        .ai-thinking-bubble .typing-dots span {
            width: 6px; height: 6px; border-radius: 50%;
            background: var(--tweb-accent, #3390ec);
            display: inline-block;
            animation: typingBounce 1.4s infinite ease-in-out;
        }
        .ai-thinking-bubble .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
        .ai-thinking-bubble .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

        /* Inline card fullscreen button */
        .live-msg-fullscreen {
            position: absolute;
            inset-inline-start: 12px;
            bottom: 12px;
            z-index: 4;
            width: 40px; height: 40px;
            border: 0; border-radius: 50%;
            display: none; place-items: center;
            color: #fff;
            background: rgba(9, 20, 31, 0.72);
            cursor: pointer;
            backdrop-filter: blur(8px);
        }
        .live-stream-card.has-video-frame .live-msg-fullscreen { display: grid; }
        .live-stream-card.has-video-frame .live-msg-mute { inset-inline-start: 58px !important; }
        .live-msg-fullscreen svg { width: 20px; height: 20px; }
        .live-stream-card.has-video-frame.is-playing:not(.controls-visible) .live-msg-fullscreen {
            opacity: 0; pointer-events: none;
        }
        .live-msg-fullscreen { transition: opacity 0.22s ease; }

        /* ===== Stream theater (YouTube-like fullscreen) ===== */
        body.theater-open { overflow: hidden; }
        .stream-theater {
            position: fixed; inset: 0; z-index: 5000;
            display: none;
            background: #000;
            flex-direction: column;
        }
        .stream-theater.active { display: flex; }
        .theater-stage {
            position: absolute; inset: 0;
            display: grid; place-items: center;
            background: #000;
        }
        .theater-media, .stream-theater video.theater-media {
            width: 100% !important; height: 100% !important;
            max-height: 100% !important;
            object-fit: contain !important;
            background: #000 !important;
            display: block !important;
        }
        .theater-tap { position: absolute; inset: 0; z-index: 1; }
        .theater-reactions {
            position: absolute; inset: 0; z-index: 3;
            pointer-events: none; overflow: hidden;
        }
        .theater-float-emoji {
            position: absolute; bottom: 90px;
            animation: theaterFloat 3s ease-out forwards;
            will-change: transform, opacity;
        }
        @keyframes theaterFloat {
            0% { opacity: 0; transform: translateY(0) scale(0.6); }
            15% { opacity: 1; transform: translateY(-20px) scale(1.1); }
            100% { opacity: 0; transform: translateY(-70vh) translateX(var(--drift, 0)) scale(1); }
        }
        .theater-topbar {
            position: relative; z-index: 4;
            display: flex; align-items: center; gap: 12px;
            padding: 14px 16px calc(14px + env(safe-area-inset-top));
            background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
            transform: translateY(-100%);
            transition: transform 0.25s ease;
        }
        .stream-theater.controls-on .theater-topbar { transform: translateY(0); }
        .theater-live {
            display: inline-flex; align-items: center; gap: 6px;
            background: #ff3d5a; color: #fff; font-weight: 800;
            font-size: 0.72rem; padding: 4px 9px; border-radius: 999px;
            direction: ltr; letter-spacing: 0.5px;
        }
        .theater-live .dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: livePulse 1.4s infinite; }
        @keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
        .theater-title { flex: 1; color: #fff; font-weight: 700; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .theater-close {
            width: 40px; height: 40px; border: 0; border-radius: 50%;
            background: rgba(255,255,255,0.14); color: #fff; cursor: pointer;
            display: grid; place-items: center; flex: 0 0 auto;
        }
        .theater-close svg { width: 22px; height: 22px; }
        .theater-comments {
            position: absolute; z-index: 3;
            inset-inline-start: 12px; bottom: 150px;
            width: min(360px, 74vw); max-height: 40vh;
            overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
            padding: 6px; pointer-events: none;
            -webkit-mask-image: linear-gradient(to top, #000 72%, transparent);
            mask-image: linear-gradient(to top, #000 72%, transparent);
        }
        .theater-comment {
            background: rgba(0,0,0,0.42); backdrop-filter: blur(4px);
            border-radius: 12px; padding: 6px 10px; color: #fff;
            font-size: 0.82rem; line-height: 1.5; max-width: 100%;
            animation: msgPopIn 0.3s ease;
        }
        .theater-comment b { color: #7cc4ff; margin-inline-end: 6px; font-weight: 700; }
        .theater-controls {
            position: absolute; z-index: 4; inset-inline: 0; bottom: 62px;
            display: flex; align-items: center; gap: 10px;
            padding: 10px 16px;
            background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
            transform: translateY(120%); transition: transform 0.25s ease;
        }
        .stream-theater.controls-on .theater-controls { transform: translateY(0); }
        .theater-ctrl {
            width: 44px; height: 44px; border: 0; border-radius: 50%;
            background: rgba(255,255,255,0.14); color: #fff; cursor: pointer;
            display: grid; place-items: center; flex: 0 0 auto;
        }
        .theater-ctrl svg { width: 22px; height: 22px; }
        .theater-volume { width: 108px; accent-color: #3390ec; cursor: pointer; }
        .theater-react-row { display: flex; gap: 4px; margin-inline-start: auto; }
        .theater-react-row button {
            width: 42px; height: 42px; border: 0; border-radius: 50%;
            background: rgba(255,255,255,0.1); cursor: pointer;
            font-size: 1.2rem; transition: transform 0.12s ease, background 0.12s ease;
        }
        .theater-react-row button:hover { background: rgba(255,255,255,0.2); }
        .theater-react-row button:active { transform: scale(1.3); }
        .theater-comment-bar {
            position: absolute; z-index: 4; inset-inline: 0; bottom: 0;
            display: flex; gap: 8px; align-items: center;
            padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
            background: rgba(10, 15, 22, 0.9); backdrop-filter: blur(10px);
        }
        .theater-comment-bar input {
            flex: 1; height: 42px; border-radius: 999px;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(255,255,255,0.08); color: #fff;
            padding: 0 16px; font-size: 0.9rem; outline: none;
        }
        .theater-comment-bar input:focus { border-color: rgba(51,144,236,0.6); }
        .theater-comment-bar button {
            width: 44px; height: 44px; border: 0; border-radius: 50%;
            background: #3390ec; color: #fff; cursor: pointer;
            display: grid; place-items: center; flex: 0 0 auto;
        }
        .theater-comment-bar button svg { width: 20px; height: 20px; transform: scaleX(-1); }
        @media (max-width: 640px) {
            /* Mobile theater: keep every desktop control, arranged cleanly in one row */
            .theater-controls {
                bottom: 64px;
                gap: 8px;
                padding: 10px 12px;
                flex-wrap: nowrap;
                overflow-x: auto;
                scrollbar-width: none;
            }
            .theater-controls::-webkit-scrollbar { display: none; }
            .theater-ctrl { width: 42px; height: 42px; flex: 0 0 auto; }
            .theater-volume { width: 84px; flex: 0 0 auto; }
            .theater-react-row { gap: 5px; margin-inline-start: auto; flex: 0 0 auto; }
            .theater-react-row button { width: 40px; height: 40px; font-size: 1.1rem; flex: 0 0 auto; }
            .theater-comments {
                width: min(78vw, 320px);
                bottom: 168px;
                max-height: 30vh;
            }
            .theater-topbar { padding: 12px 12px calc(12px + env(safe-area-inset-top)); }
            .theater-title { font-size: 0.92rem; }
            .theater-comment-bar { padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); }
            .theater-comment-bar input { height: 44px; }
            /* on phones the controls should always be visible (no hover) */
            .stream-theater .theater-topbar,
            .stream-theater .theater-controls { transform: translateY(0) !important; }
        }

        /* Tidy textareas — drop the ugly resize grip */
        .preview-caption-input, #link-caption, #edit-textarea {
            resize: none !important;
        }

        /* Mobile: turn content popups into polished bottom sheets */
        @media (max-width: 640px) {
            #link-modal.modal-overlay.active,
            #upload-preview-modal.modal-overlay.active,
            #sticker-modal.modal-overlay.active {
                align-items: flex-end !important;
                padding: 0 !important;
            }
            #link-modal .modal-content,
            #upload-preview-modal .modal-content,
            #sticker-modal .modal-content {
                width: 100% !important;
                max-width: 100% !important;
                margin: 0 !important;
                border-radius: 22px 22px 0 0 !important;
                max-height: 92dvh !important;
                overflow-y: auto !important;
                padding: 16px 16px calc(16px + env(safe-area-inset-bottom)) !important;
                animation: sheetUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
            }
            @keyframes sheetUp {
                from { transform: translateY(100%); }
                to { transform: translateY(0); }
            }
            /* grab handle */
            #link-modal .modal-content::before,
            #upload-preview-modal .modal-content::before,
            #sticker-modal .modal-content::before {
                content: '';
                display: block;
                width: 42px; height: 4px;
                border-radius: 99px;
                background: var(--tweb-border, rgba(255,255,255,0.2));
                margin: 0 auto 12px;
            }
            .link-choice-row {
                flex-wrap: wrap !important;
                gap: 8px !important;
            }
            .link-choice-btn {
                flex: 1 1 auto !important;
                min-width: 44% !important;
            }
        }

        /* Refined scroll-to-bottom button (Telegram-style circular) */
        .scroll-to-bottom {
            width: 46px !important;
            height: 46px !important;
            border-radius: 50% !important;
            border: 1px solid var(--tweb-border, rgba(255,255,255,0.08)) !important;
            background: var(--tweb-panel, #17212b) !important;
            color: var(--tweb-text, #f5f7fa) !important;
            box-shadow: 0 6px 20px rgba(0,0,0,0.32) !important;
            display: grid !important;
            place-items: center !important;
            opacity: 0;
            transform: translateY(8px) scale(0.9);
            transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease !important;
            pointer-events: none;
        }
        .scroll-to-bottom.visible {
            opacity: 1;
            transform: translateY(0) scale(1);
            pointer-events: auto;
        }
        .scroll-to-bottom:hover {
            background: var(--tweb-panel-2, #202b36) !important;
            color: var(--tweb-accent, #3390ec) !important;
        }
        .scroll-to-bottom svg { width: 22px !important; height: 22px !important; }
        body.light-mode .scroll-to-bottom {
            background: #fff !important;
            color: #1f4d74 !important;
            border-color: rgba(10,63,114,0.12) !important;
        }

        /* Site-wide custom scrollbars — slim, themed, unobtrusive */
        * {
            scrollbar-width: thin;
            scrollbar-color: rgba(140,160,180,0.4) transparent;
        }
        *::-webkit-scrollbar { width: 8px; height: 8px; }
        *::-webkit-scrollbar-track { background: transparent; }
        *::-webkit-scrollbar-thumb {
            background: rgba(140,160,180,0.34);
            border-radius: 999px;
            border: 2px solid transparent;
            background-clip: padding-box;
        }
        *::-webkit-scrollbar-thumb:hover {
            background: rgba(140,160,180,0.6);
            background-clip: padding-box;
        }
        body.light-mode * { scrollbar-color: rgba(60,90,120,0.35) transparent; }
        body.light-mode *::-webkit-scrollbar-thumb { background: rgba(60,90,120,0.3); background-clip: padding-box; }
        /* stream list / comment areas already scroll internally; keep them tidy */

        /* ===== فاز ۵: ساده‌سازی و شیک‌سازی استوری =====
           حالت‌های کمکی (Boomerang/Layout/Hands-free/Dual/Green Screen) و ابزارهای
           پیشرفته پشت دکمه «ابزار ادیت استوری» می‌مانند برای جلوگیری از شکستن منطق JS،
           ولی از UI پیش‌فرض حذف می‌شوند تا تجربه ساده و شیک بماند. */
        #story-create-modal .story-create-modes [data-mode="boomerang"],
        #story-create-modal .story-create-modes [data-mode="layout"],
        #story-create-modal .story-create-modes [data-mode="handsfree"],
        #story-create-modal .story-create-modes [data-mode="dual"],
        #story-create-modal .story-create-modes [data-mode="green"] {
            display: none !important;
        }
        #story-create-modal #story-dup-slide,
        #story-create-modal #story-mode-note {
            display: none !important;
        }
        #story-create-modal .modal-content.story-compose-card {
            border-radius: 20px !important;
            max-width: 460px !important;
        }
        #story-create-modal .story-create-modes {
            gap: 8px !important;
            padding: 4px 2px 10px !important;
        }
        #story-create-modal .story-create-modes .story-mode-btn {
            border-radius: 999px !important;
            padding: 9px 18px !important;
            font-size: 13px !important;
            font-weight: 600 !important;
            border: 1px solid var(--border-color) !important;
            background: var(--bg-input) !important;
            color: var(--text-secondary) !important;
            transition: all .18s ease !important;
        }
        #story-create-modal .story-create-modes .story-mode-btn.is-active {
            background: var(--primary) !important;
            border-color: var(--primary) !important;
            color: #fff !important;
            box-shadow: 0 4px 14px rgba(42,171,238,0.35) !important;
        }
        #story-create-modal .story-compose-top-actions {
            gap: 8px !important;
        }
        #story-create-modal .story-compose-top-actions .link-choice-btn {
            border-radius: 12px !important;
            font-size: 12.5px !important;
        }
        #story-create-modal .story-preview-stage {
            border-radius: 16px !important;
            overflow: hidden !important;
        }
        #story-create-modal .story-compose-input {
            border-radius: 14px !important;
        }
        #story-create-modal .story-tools-toggle {
            border-radius: 12px !important;
            font-size: 12.5px !important;
            opacity: .75 !important;
        }
        #story-create-modal #story-create-submit {
            border-radius: 14px !important;
            font-weight: 700 !important;
        }
        /* استوری‌های خالی/بدون‌عنوان با ظاهر تمیزتر */
        .story-strip {
            gap: 10px !important;
        }
        .story-create-btn {
            border-radius: 999px !important;
            font-weight: 600 !important;
        }

        /* ===== فاز ۶: بازطراحی پلیر پخش زنده/موزیک ===== */
        #stream-center-modal .modal-content.live-room-shell {
            border-radius: 22px !important;
            border: 1px solid var(--border-color) !important;
            background:
                radial-gradient(600px 300px at 15% -10%, rgba(42,171,238,0.14), transparent 60%),
                var(--bg-header) !important;
            overflow: hidden !important;
        }
        #stream-center-modal .live-room-header {
            border-bottom: 1px solid var(--border-color) !important;
            backdrop-filter: blur(6px);
        }
        #stream-center-modal .live-room-close {
            border-radius: 999px !important;
            padding: 7px 16px !important;
        }
        #stream-center-modal .live-stage-card {
            border-radius: 20px !important;
            background:
                radial-gradient(420px 260px at 50% 0%, rgba(42,171,238,0.16), transparent 65%),
                var(--bg-input) !important;
            border: 1px solid var(--border-color) !important;
            box-shadow: 0 18px 40px rgba(0,0,0,0.25) !important;
        }
        #stream-center-modal .live-orb {
            filter: drop-shadow(0 0 22px rgba(42,171,238,0.55));
        }
        #stream-center-modal .live-room-status {
            border-radius: 999px !important;
            font-weight: 800 !important;
            letter-spacing: .06em !important;
            background: linear-gradient(90deg, #ff4757, #ff6b81) !important;
            color: #fff !important;
            box-shadow: 0 0 16px rgba(255,71,87,0.5) !important;
        }
        #stream-center-modal .live-control-btn {
            border-radius: 999px !important;
            width: 52px !important;
            height: 52px !important;
            display: inline-flex !important;
            align-items: center !important;
            justify-content: center !important;
            background: var(--primary) !important;
            color: #fff !important;
            box-shadow: 0 8px 20px rgba(42,171,238,0.4) !important;
            transition: transform .15s ease !important;
        }
        #stream-center-modal .live-control-btn:hover {
            transform: scale(1.06) !important;
        }
        #stream-center-modal .live-control-btn.secondary {
            background: var(--bg-input) !important;
            color: var(--text-primary) !important;
            border: 1px solid var(--border-color) !important;
            box-shadow: none !important;
            width: auto !important;
            border-radius: 999px !important;
            padding: 0 18px !important;
        }
        #stream-center-modal .live-room-side {
            border-radius: 18px !important;
            background: var(--bg-input) !important;
            border: 1px solid var(--border-color) !important;
        }
        #stream-center-modal #stream-search,
        #stream-center-modal #live-custom-url {
            border-radius: 12px !important;
        }
        #stream-center-modal .stream-list {
            gap: 6px !important;
        }
        #stream-center-modal .stream-item {
            border-radius: 14px !important;
            border: 1px solid transparent !important;
            transition: all .15s ease !important;
        }
        #stream-center-modal .stream-item:hover {
            background: var(--bg-msg-other) !important;
            transform: translateX(-2px);
        }
        #stream-center-modal .stream-item.is-active {
            background: rgba(42,171,238,0.12) !important;
            border-color: var(--primary) !important;
        }
        /* کارت پخش زنده داخل چت */
        .live-stream-card {
            border-radius: 18px !important;
            overflow: hidden !important;
        }

        /* ===== فاز ۴: نوار کنترل هوشمند فیدشونده (پخش زنده/موزیک) ===== */
        #stream-center-modal .live-room-controls {
            opacity: 0 !important;
            transform: translateY(6px) !important;
            pointer-events: none !important;
            transition: opacity .35s ease, transform .35s ease !important;
        }
        #stream-center-modal .live-stage-card.controls-visible .live-room-controls {
            opacity: 1 !important;
            transform: translateY(0) !important;
            pointer-events: auto !important;
        }
        #stream-center-modal .live-stage-card {
            cursor: pointer;
        }
        @media (hover: hover) {
            #stream-center-modal .live-stage-card:hover .live-room-controls {
                opacity: 1 !important;
                transform: translateY(0) !important;
                pointer-events: auto !important;
            }
        }

        /* ===== بهبود باکس چت هوش مصنوعی (دستیار و استاد) ===== */
        /* حباب پاسخ AI شبیه تلگرام: گردتر، تمیزتر، با کمی گلو */
        .message.ai-bot-message {
            border-radius: 16px 16px 16px 6px !important;
            backdrop-filter: blur(2px);
        }
        .message.ai-bot-message .username::before {
            content: '';
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #6fe0a0;
            box-shadow: 0 0 8px #6fe0a0;
            margin-inline-end: 5px;
            vertical-align: middle;
        }
        /* ورودی پیام در حالت AI: قاب ظریف رنگی */
        body.ai-chat-active .desktop-input-row,
        body.ai-chat-active .mobile-input-pill {
            box-shadow: 0 0 0 1px rgba(126,171,252,0.28), 0 8px 22px rgba(19,35,70,0.18) !important;
        }
        body.ai-chat-active .tg-topbar {
            background: linear-gradient(180deg, rgba(45,70,125,0.20), transparent) !important;
        }
        /* نشانگر «در حال فکر» شیک‌تر */
        .ai-thinking-bubble {
            border-radius: 16px 16px 16px 6px !important;
        }

        /* ===== تم متمایز «استاد» (طلایی/گرم) در برابر دستیار (آبی/بنفش) ===== */
        body.ostad-chat-active #chat-messages {
            background:
                radial-gradient(800px 320px at 100% 0%, rgba(232,137,12,0.14), transparent 62%),
                radial-gradient(700px 280px at 0% 100%, rgba(181,83,10,0.10), transparent 60%),
                var(--chat-wallpaper) !important;
        }
        body.ostad-chat-active #tg-status {
            color: #ffd79a !important;
        }
        body.ostad-chat-active .tg-chat-info {
            border-color: rgba(246,183,60,0.36) !important;
            background: linear-gradient(145deg, rgba(118,80,20,0.34), rgba(90,60,18,0.26)) !important;
        }
        body.ostad-chat-active .message.ai-bot-message {
            border-color: rgba(246,183,60,0.46) !important;
            background: linear-gradient(145deg, rgba(84,58,20,0.78), rgba(66,44,16,0.74)) !important;
            box-shadow: 0 10px 20px rgba(70,45,10,0.24) !important;
        }
        body.ostad-chat-active .message.ai-bot-message .username {
            color: #ffe0ad !important;
        }
        body.ostad-chat-active .message.ai-bot-message .username::before {
            background: #ffcf7a;
            box-shadow: 0 0 8px #ffcf7a;
        }
        body.ostad-chat-active .public-msg-avatar.ai-bot-avatar {
            border-color: rgba(255,214,150,0.6);
            box-shadow: 0 0 0 3px rgba(232,137,12,0.24);
        }
        body.ostad-chat-active .desktop-input-row,
        body.ostad-chat-active .mobile-input-pill {
            box-shadow: 0 0 0 1px rgba(246,183,60,0.3), 0 8px 22px rgba(70,45,10,0.18) !important;
        }
        body.light-mode.ostad-chat-active #chat-messages {
            background:
                radial-gradient(800px 320px at 100% 0%, rgba(232,137,12,0.10), transparent 62%),
                radial-gradient(700px 280px at 0% 100%, rgba(181,83,10,0.07), transparent 60%),
                var(--chat-wallpaper) !important;
        }
        body.light-mode.ostad-chat-active .message.ai-bot-message {
            border-color: rgba(214,142,36,0.34) !important;
            background: linear-gradient(145deg, rgba(255,245,227,0.94), rgba(255,238,214,0.94)) !important;
        }
        body.light-mode.ostad-chat-active .message.ai-bot-message .username {
            color: #9a5a12 !important;
        }
        body.light-mode.ostad-chat-active #tg-status {
            color: #9a5a12 !important;
        }
        /* آیتم استاد در سایدبار — تم طلایی */
        .tg-chat-item.ai-chat-item[data-group-id="ai_ostad"] {
            border-color: rgba(246,183,60,0.33) !important;
        }
