/* CHAT MODULE CSS */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-container {
    display: flex;
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
    background: var(--modal);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
}

.chat-folders-sidebar {
    width: 60px;
    background: var(--bg3);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.chat-folder-item {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--modal);
    color: var(--text2);
    transition: all 0.2s;
    border: 2px solid transparent;
}
.chat-folder-item:hover {
    background: var(--bg2);
    color: var(--text);
}
.chat-folder-item.active {
    background: var(--accent);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}

.chat-sidebar {
    width: 240px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.chat-sidebar-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.chat-sidebar-header h2 { margin: 0; font-size: 16px; font-weight: 700; }
.chat-search {
    padding: 8px 10px;
    position: relative;
}
.chat-search .search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text2);
    font-size: 16px;
}
.chat-search input {
    width: 100%;
    padding: 6px 8px 6px 30px;
    border-radius: 16px;
    background: var(--modal);
    border: 1px solid var(--border);
    color: var(--text);
    outline: none;
    font-size: 12px;
}
.chat-search input:focus { border-color: var(--accent); }

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}
.chat-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}
.chat-item:hover { background: rgba(255,255,255,0.03); }
.chat-item.active {
    background: var(--item-h);
    border-left-color: var(--accent);
}
.chat-item.pinned {
    background: rgba(255,255,255,0.01);
}
.chat-item.chat-item-group { background: rgba(0, 150, 255, 0.04); }
.chat-item.chat-item-group:hover { background: rgba(0, 150, 255, 0.08); }
.chat-item.chat-item-group.active { background: rgba(0, 150, 255, 0.15); border-left-color: #0096ff; }
.chat-item-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-right: 8px;
    flex-shrink: 0;
}
.chat-item-content { flex: 1; overflow: hidden; }
.chat-item-name {
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-item-lastmsg {
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.chat-item-meta { display: flex; align-items: center; gap: 5px; }
.chat-item-time { font-size: 10px; color: var(--text2); }
.chat-item-badge {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 2px 6px;
}
.chat-item-pin-icon { font-size: 14px; color: var(--text2); transform: rotate(45deg); }

/* Main Chat */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--modal);
    position: relative;
}
.chat-main-header {
    height: 64px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--modal);
}
.chat-active-info { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.chat-active-name { font-weight: 600; font-size: 16px; }

.chat-history-search {
    padding: 10px 20px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: relative;
    display: flex;
    align-items: center;
}
.chat-history-search input {
    flex: 1;
    padding: 8px 10px 8px 35px;
    border-radius: 20px;
    background: var(--modal);
    border: 1px solid var(--border);
    color: var(--text);
    outline: none;
}
.chat-history-search .search-icon {
    position: absolute;
    left: 30px;
    color: var(--text2);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: url('/assets/img/chat-bg.png') center/cover;
}
.chat-empty-state {
    margin: auto;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    background: var(--bg2);
    padding: 8px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
}
.msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}
.msg-wrapper.mine { align-self: flex-end; align-items: flex-end; }
.msg-wrapper.theirs { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    position: relative;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.msg-bubble ul, .msg-bubble ol,
.chat-content-editable ul, .chat-content-editable ol {
    padding-left: 24px;
    margin: 6px 0;
}
.msg-bubble ol, .chat-content-editable ol {
    font-weight: bold;
}
.msg-bubble li, .chat-content-editable li {
    margin-bottom: 2px;
    font-weight: normal;
}
.mine .msg-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.theirs .msg-bubble {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.msg-bubble.msg-bubble-video {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}
.msg-forwarded {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.theirs .msg-forwarded { color: var(--text2); }

.chat-mention, span[style*="color:var(--accent)"] {
    color: var(--accent);
    font-weight: 600;
    background: rgba(76,175,80,0.15);
    padding: 2px 4px;
    border-radius: 4px;
    text-decoration: none !important;
}
.mine .msg-bubble .chat-mention, .mine .msg-bubble span[style*="color:var(--accent)"] {
    color: #fff !important;
    background: rgba(0,0,0,0.2) !important;
}

.msg-read-info {
    font-size: 11px;
    color: var(--text2);
    margin-top: 4px;
    text-align: right;
    padding-right: 4px;
}

.msg-reply-to {
    border-left: 3px solid rgba(255,255,255,0.5);
    padding-left: 8px;
    margin-bottom: 6px;
    font-size: 12px;
    background: rgba(0,0,0,0.1);
    padding: 4px 8px;
    border-radius: 4px;
}
.theirs .msg-reply-to {
    border-left-color: var(--accent);
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    margin-top: 4px;
    color: rgba(255,255,255,0.7);
    justify-content: flex-end;
}
.theirs .msg-meta { color: var(--text2); }
.msg-read-icon { font-size: 14px; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); color: rgba(255,255,255,0.8); }
.msg-read-icon.read { color: #60a5fa; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4)); }
.msg-read-info {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    text-align: right;
}

.msg-media img, .msg-media video {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 5px;
    max-height: 300px;
    cursor: pointer;
}
.circular-video video {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    object-fit: cover;
}
.msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.1);
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    margin-bottom: 5px;
}
.msg-file .material-icons-round { font-size: 24px; }
.msg-audio audio { height: 36px; outline: none; }

.msg-sender-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}

/* Chat Input */
.chat-input-area {
    border-top: 1px solid var(--border);
    background: var(--modal);
    padding: 10px 20px;
    position: relative;
}
.chat-reply-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg2);
    border-left: 3px solid var(--accent);
    margin-bottom: 10px;
    border-radius: 4px;
}
.chat-reply-preview .reply-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--text2);
}
.chat-input-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}
.chat-format-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    border-left: 1px solid var(--border);
    padding-left: 10px;
}
.chat-format-tools .btn-icon.active {
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--accent);
}
.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}
.chat-content-editable {
    flex: 1;
    min-height: 20px;
    max-height: 150px;
    overflow-y: auto;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text);
    outline: none;
}
.chat-content-editable[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: var(--text2);
    pointer-events: none;
}
.btn-voice {
    background: var(--bg2);
    color: var(--text2);
    border-radius: 50%;
    width: 44px; height: 44px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}
.btn-voice:active {
    background: var(--danger);
    color: #fff;
    transform: scale(1.1);
}
.btn-send {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 44px; height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: var(--modal);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 300px;
    height: 200px;
    overflow-y: auto;
    padding: 10px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    z-index: 1000;
}
.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}
.emoji-btn:hover { background: rgba(255,255,255,0.1); }

/* Context Menu */
.chat-context-menu {
    position: fixed;
    background: var(--modal);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 9999;
    min-width: 150px;
    padding: 5px 0;
}
.chat-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background 0.2s;
}
.chat-context-item:hover { background: var(--bg2); }
.chat-context-item .material-icons-round { font-size: 16px; color: var(--text2); }

/* Message Read Info */
.msg-read-info {
    position: absolute;
    bottom: -20px;
    right: 0;
    font-size: 10px;
    color: var(--text2);
    background: var(--bg2);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    display: none;
    z-index: 10;
}
.msg-wrapper:hover .msg-read-info { display: block; }

/* Hide Fullscreen button on video messages to prevent control cutoff */
.chat-message-video::-webkit-media-controls-fullscreen-button,
video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* Adjust video controls spacing so they fit within the circle */
.chat-message-video::-webkit-media-controls-panel,
video::-webkit-media-controls-panel {
    padding: 0 25px !important;
}

/* Force time display to not collapse */
.chat-message-video::-webkit-media-controls-time-remaining-display,
video::-webkit-media-controls-time-remaining-display,
.chat-message-video::-webkit-media-controls-current-time-display,
video::-webkit-media-controls-current-time-display {
    min-width: 35px !important;
    text-align: center !important;
    font-size: 11px !important;
}

/* Shrink progress bar to prevent cutoff */
.chat-message-video::-webkit-media-controls-timeline,
video::-webkit-media-controls-timeline {
    margin: 0 auto !important;
    width: 60% !important;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE CHAT — Premium Full-Screen Messenger Layout
   iOS/Android native feel, touch-optimized
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Chat Container — Full screen takeover ── */
    .chat-container {
        flex-direction: column;
        width: 100vw !important; 
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important; 
        max-height: 100vh !important; 
        max-height: 100dvh !important;
        border-radius: 0 !important; 
        border: none !important;
        margin: 0 !important;
    }

    /* ── Show folders sidebar horizontally on mobile ── */
    .chat-folders-sidebar {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        height: auto !important;
        min-height: 56px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
        padding: 8px 12px !important;
        gap: 12px !important;
        justify-content: flex-start !important;
        flex-shrink: 0 !important;
    }
    .chat-folder-item {
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }

    /* ── Chat Sidebar — Horizontal contacts strip ── */
    .chat-sidebar {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        flex: none !important;
        flex-shrink: 0 !important;
        padding-top: max(8px, env(safe-area-inset-top));
        display: flex;
        flex-direction: column;
        background: var(--bg2);
    }

    /* ── Sidebar Header — Compact with close button ── */
    .chat-sidebar-header { 
        display: flex; 
        padding: 8px 14px !important; 
        height: 44px !important; 
        border-bottom: none !important;
        align-items: center;
    }
    .chat-sidebar-header h2 { font-size: 16px !important; font-weight: 800; }
    .chat-sidebar-header .btn-icon { 
        min-width: 40px; 
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ── Search — Compact ── */
    .chat-search { padding: 0 14px 8px 14px !important; }
    .chat-search input { 
        padding: 10px 14px 10px 38px !important; 
        height: 40px !important; 
        font-size: 14px !important; 
        border-radius: 20px !important;
        background: var(--modal) !important;
    }
    .chat-search .search-icon { 
        left: 26px !important; 
        top: 50% !important; 
        font-size: 18px !important; 
    }

    /* ── Chat List — Horizontal scroll strip ── */
    .chat-list {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 8px 10px !important;
        white-space: nowrap;
        height: auto !important;
        min-height: 88px;
        flex-shrink: 0;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .chat-list::-webkit-scrollbar { display: none; }

    /* ── Chat Item — Circle avatar with name ── */
    .chat-item {
        flex-direction: column !important;
        width: 68px !important;
        min-width: 68px !important;
        border-left: none !important;
        border-bottom: none !important;
        padding: 4px 2px !important;
        justify-content: flex-start !important;
        align-items: center !important;
        text-align: center;
        position: relative;
        border-radius: 12px !important;
        scroll-snap-align: start;
        transition: background 0.2s;
    }
    .chat-item:active { 
        background: rgba(255,255,255,0.06) !important; 
        transform: scale(0.95);
    }
    .chat-item.active { 
        border-bottom: none !important;
        background: rgba(76,175,80,0.12) !important; 
    }
    .chat-item.chat-item-group.active { background: rgba(0, 150, 255, 0.12) !important; }

    /* ── Avatar — Larger for touch ── */
    .chat-item-avatar { 
        margin-right: 0 !important; 
        margin-bottom: 4px !important; 
        width: 48px !important; 
        height: 48px !important; 
        font-size: 16px !important;
        position: relative;
    }

    /* ── Online dot — Properly visible on mobile ── */
    .chat-item-online-dot {
        width: 12px !important;
        height: 12px !important;
        border: 2px solid var(--bg2) !important;
        bottom: -1px !important;
        right: -1px !important;
    }

    /* ── Chat Item Content — Show short name ── */
    .chat-item-content { 
        display: block !important;
        max-width: 64px;
    }
    .chat-item-name { 
        font-size: 10px !important; 
        justify-content: center !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 64px;
    }
    .chat-item-name span { 
        max-width: 56px; 
        overflow: hidden; 
        text-overflow: ellipsis; 
        display: inline-block;
    }
    .chat-item-lastmsg { display: none !important; }
    .chat-item-pin-icon { display: none !important; }

    /* ── Unread badge ── */
    .chat-item-badge,
    .chat-item > div[style*="margin-left:auto"] {
        position: absolute !important; 
        top: 0 !important; 
        right: 2px !important;
        padding: 2px 5px !important; 
        font-size: 9px !important;
        border-radius: 8px !important;
        min-width: 16px;
        text-align: center;
        z-index: 2;
    }
    
    /* ── Main Chat Area ── */
    .chat-main { 
        flex: 1 !important; 
        overflow: hidden !important; 
        display: flex !important; 
        flex-direction: column !important; 
        min-height: 0;
    }

    /* ── Chat Header — Glassmorphism bar ── */
    .chat-main-header {
        height: 52px !important;
        padding: 0 12px !important;
        background: var(--modal) !important;
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--border) !important;
        flex-shrink: 0;
    }
    .chat-active-info { gap: 10px !important; }
    .chat-avatar { 
        width: 34px !important; 
        height: 34px !important; 
        font-size: 14px !important;
    }
    .chat-active-name { font-size: 15px !important; font-weight: 700 !important; }
    .chat-main-header .btn-icon {
        min-width: 38px;
        min-height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ── Messages area ── */
    .chat-messages {
        padding: 12px !important;
        gap: 10px !important;
        -webkit-overflow-scrolling: touch;
    }
    .msg-wrapper { max-width: 85% !important; }
    .msg-bubble { 
        font-size: 14px !important; 
        padding: 10px 14px !important; 
        border-radius: 16px !important;
        line-height: 1.5 !important;
    }
    .mine .msg-bubble { border-bottom-right-radius: 6px !important; }
    .theirs .msg-bubble { border-bottom-left-radius: 6px !important; }
    .msg-sender-name { font-size: 12px !important; }
    .msg-meta { font-size: 10px !important; }

    /* ── Media in messages ── */
    .msg-media img, .msg-media video {
        max-height: 250px !important;
        border-radius: 12px !important;
    }
    .circular-video video {
        width: 200px !important;
        height: 200px !important;
    }
    .msg-file {
        padding: 12px 14px !important;
        border-radius: 12px !important;
        font-size: 13px !important;
    }
    .msg-audio audio { 
        width: 100% !important; 
        height: 40px !important; 
    }

    /* ── Chat Input Area — Touch-optimized ── */
    .chat-input-area { 
        padding: 8px 12px !important;
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
        min-height: auto !important; 
        flex-shrink: 0 !important; 
        border-top: 1px solid var(--border) !important;
        background: var(--modal) !important;
    }
    .chat-input-toolbar {
        gap: 4px !important;
        margin-bottom: 8px !important;
        flex-wrap: wrap;
    }
    .chat-input-toolbar .btn-icon {
        min-width: 36px;
        min-height: 36px;
        padding: 6px !important;
    }
    .chat-format-tools { 
        display: none !important; /* Hide formatting on mobile for cleaner UI */
    }
    .chat-input-wrapper { gap: 8px !important; }
    .chat-content-editable { 
        min-height: 40px !important; 
        max-height: 120px !important; 
        font-size: 15px !important; 
        padding: 10px 16px !important; 
        overflow-y: auto !important;
        border-radius: 22px !important;
        -webkit-overflow-scrolling: touch;
    }
    .btn-voice, .btn-send { 
        width: 42px !important; 
        height: 42px !important; 
        min-width: 42px !important;
        flex-shrink: 0;
        border-radius: 50% !important;
    }
    .btn-send .material-icons-round { font-size: 20px !important; }

    /* ── Reply preview ── */
    .chat-reply-preview {
        padding: 8px 12px !important;
        border-radius: 12px !important;
        margin-bottom: 8px !important;
    }

    /* ── Emoji Picker ── */
    .emoji-picker {
        width: calc(100vw - 24px) !important;
        left: 12px !important;
        right: 12px !important;
        height: 240px !important;
        border-radius: 16px !important;
        grid-template-columns: repeat(8, 1fr) !important;
        gap: 4px !important;
    }
    .emoji-btn { 
        font-size: 22px !important; 
        padding: 8px !important;
        min-width: 40px;
        min-height: 40px;
    }

    /* ── Context menu ── */
    .chat-context-menu {
        border-radius: 14px !important;
        min-width: 200px !important;
    }
    .chat-context-item {
        padding: 14px 18px !important;
        font-size: 14px !important;
    }

    /* ── Pinned message bar ── */
    #chat-pinned-bar {
        padding: 8px 14px !important;
    }

    /* ── History search ── */
    .chat-history-search input {
        padding: 10px 14px 10px 38px !important;
        border-radius: 20px !important;
        font-size: 14px !important;
    }

    /* ── Reactions ── */
    .chat-reactions-bubble {
        border-radius: 24px !important;
        padding: 8px 14px !important;
        gap: 10px !important;
    }
    .chat-reaction-quick { font-size: 24px !important; }
    .chat-reactions-expanded {
        width: calc(100vw - 24px) !important;
        left: 12px !important;
        border-radius: 16px !important;
    }

    /* ── Video recording circle ── */
    .chat-video-recording-circle { 
        width: 160px !important; 
        height: 160px !important; 
        bottom: 80px !important; 
        right: 16px !important; 
    }

    /* ── Selection toolbar ── */
    #chat-selection-toolbar {
        padding: 12px 14px !important;
    }

    /* ── Incoming call UI ── */
    #incoming-call-ui {
        width: 100vw !important;
        max-width: 100vw !important;
    }

    /* ── Audio call panel ── */
    #audio-cc-live-panel {
        width: calc(100vw - 24px) !important;
        left: 12px !important;
        right: 12px !important;
        border-radius: 16px !important;
    }
}

/* Reactions */
.chat-reactions-bubble {
    position: absolute;
    bottom: calc(100% + 5px);
    left: 0;
    background: var(--modal);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.chat-reactions-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    width: 10px;
    height: 10px;
    background: var(--modal);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transform: rotate(45deg);
}
.chat-reaction-quick {
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
}
.chat-reaction-quick:hover {
    transform: scale(1.2);
}
.chat-reaction-more {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    color: var(--text2);
    transition: background 0.2s;
}
.chat-reaction-more:hover {
    background: var(--border);
}

.chat-reactions-expanded {
    position: absolute;
    bottom: calc(100% + 5px);
    left: 0;
    background: var(--modal);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 280px;
    height: 300px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
}
.chat-reactions-expanded-header {
    padding: 10px;
    background: var(--bg2);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}
.chat-reactions-expanded-header input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
    font-size: 13px;
}
.chat-reactions-expanded-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    align-content: flex-start;
}

.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.msg-reaction-badge {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    user-select: none;
}
.msg-reaction-badge small {
    font-size: 10px;
    font-weight: bold;
    opacity: 0.8;
}
.msg-reaction-badge.reacted {
    background: rgba(76,175,80,0.2);
    border-color: rgba(76,175,80,1);
}
.theirs .msg-reaction-badge {
    background: rgba(255,255,255,0.1);
}
.theirs .msg-reaction-badge.reacted {
    background: rgba(76,175,80,0.1);
    border-color: rgba(76,175,80,1);
}

.chat-spoiler {
    background: var(--text2);
    color: transparent;
    border-radius: 4px;
    padding: 0 4px;
    cursor: pointer;
    transition: all 0.3s;
}
.chat-spoiler:hover, .chat-spoiler:active {
    background: rgba(0,0,0,0.1);
    color: inherit;
}
.msg-bubble blockquote {
    border-left: 3px solid var(--accent);
    margin: 4px 0;
    padding-left: 8px;
    color: var(--text2);
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
    padding-top: 4px;
    padding-bottom: 4px;
}
.msg-bubble pre, .msg-bubble code {
    font-family: monospace;
    background: rgba(0,0,0,0.2);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.chat-input-context-menu {
    border-radius: 8px;
    padding: 6px 0;
}
.chat-input-context-menu .chat-context-item {
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
