:root {
    --accent-color: #bb86fc;
    --accent-rgb: 187, 134, 252;
    --teal-color: #03dac6;
    --teal-rgb: 3, 218, 198;
    --danger-color: #cf6679;
    --danger-rgb: 207, 102, 121;
    --bg-dark: #09090c;
    --surface-glass: rgba(20, 20, 26, 0.78);
    --surface-elevated: rgba(30, 30, 38, 0.9);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.18);
    --text-primary: #f4f4f6;
    --text-secondary: #a0a0ab;
    --text-muted: #6e6e77;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at 15% 15%, rgba(var(--accent-rgb), 0.07) 0%, transparent 45%),
                      radial-gradient(circle at 85% 85%, rgba(var(--teal-rgb), 0.05) 0%, transparent 45%);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    position: fixed;
    inset: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- PIXEL ART SVG ICONS --- */
.ui-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    filter: invert(1) opacity(0.9);
    transition: transform 0.18s ease, filter 0.18s ease;
}

.danger-icon {
    filter: invert(53%) sepia(43%) saturate(983%) hue-rotate(301deg) brightness(95%) contrast(92%);
}

/* --- SCROLLBARS --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

/* --- APP SHELL --- */
.app-shell {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- TOP NAVBAR --- */
#chatHeader {
    height: 62px;
    padding: 0 20px;
    background: var(--surface-glass);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    background: linear-gradient(90deg, #fff, var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.modern-pill-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.modern-pill-btn .ui-icon {
    width: 17px;
    height: 17px;
}

.modern-pill-btn:hover {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: rgba(var(--accent-rgb), 0.5);
    transform: translateY(-1px);
}

.modern-pill-btn.secondary {
    background: rgba(0, 0, 0, 0.28);
    color: var(--text-secondary);
}

.modern-pill-btn.secondary:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.modern-pill-btn.icon-only {
    padding: 8px;
    width: 38px;
    height: 38px;
    justify-content: center;
}

.header-mini-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#menuBtn { display: none; }

/* --- 3-COLUMN WORKSPACE SANDWICH --- */
#chatWorkspace {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* --- COLUMN 1 (LEFT): VOICE CHANNEL PANEL --- */
.voice-panel {
    width: 310px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    z-index: 25;
}

.voice-panel.minimized {
    width: 0;
    opacity: 0;
    border-right: none;
    pointer-events: none;
}

.voice-panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
    white-space: nowrap;
}

.voice-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.voice-active-container {
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    flex: 1;
    overflow-y: auto;
}

.voice-status-badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(var(--teal-rgb), 0.14);
    color: var(--teal-color);
    border: 1px solid rgba(var(--teal-rgb), 0.35);
}

.voice-status-badge.ringing {
    background: rgba(var(--danger-rgb), 0.18);
    color: #ff9aa8;
    border-color: var(--danger-color);
    animation: tabPulseRed 1.4s infinite;
}

.voice-target-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-align: center;
}

.voice-target-subtitle strong {
    color: var(--accent-color);
}

.voice-participants {
    display: flex;
    gap: 28px;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
}

.voice-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.voice-avatar-ring {
    padding: 4px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    transition: all 0.25s ease;
}

.voice-avatar-ring.active {
    border: 3px solid var(--teal-color);
    box-shadow: 0 0 20px rgba(var(--teal-rgb), 0.35);
}

.voice-avatar {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    object-fit: cover;
    opacity: 0.4;
    filter: grayscale(85%);
    transition: all 0.25s ease;
    display: block;
}

.voice-avatar.active {
    opacity: 1;
    filter: grayscale(0%);
}

.voice-name {
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--text-primary);
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: auto;
}

.voice-btn {
    width: 100%;
    padding: 11px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.voice-btn.join {
    background: var(--teal-color);
    color: #070709;
}
.voice-btn.join .ui-icon { filter: none; }
.voice-btn.join:hover { filter: brightness(1.08); transform: translateY(-1px); }

.voice-btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
.voice-btn.secondary.muted-mic {
    background: rgba(var(--danger-rgb), 0.18);
    border-color: var(--danger-color);
    color: #ffccd5;
}

.voice-btn.leave {
    background: var(--danger-color);
    color: #09090b;
}
.voice-btn.leave .ui-icon { filter: none; }

.voice-btn.close {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}
.voice-btn.close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Voice Suggestions & Live Channels View */
.live-voice-section {
    padding: 12px 16px 4px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(var(--teal-rgb), 0.04);
}

.voice-suggestions-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 16px;
}

.voice-empty-hero {
    text-align: center;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    margin-bottom: 16px;
}

.voice-hero-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.12);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px auto;
}

.voice-empty-hero h4 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
}

.voice-empty-hero p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.voice-suggestions-header {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 0 4px;
}

.voice-suggestions-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.voice-suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
}

.voice-suggest-item:hover {
    background: rgba(var(--accent-rgb), 0.1);
    border-color: rgba(var(--accent-rgb), 0.35);
}

.voice-call-trigger {
    margin-left: auto;
    background: rgba(var(--teal-rgb), 0.15);
    border: 1px solid rgba(var(--teal-rgb), 0.4);
    color: var(--teal-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-call-trigger:hover {
    background: var(--teal-color);
    transform: scale(1.06);
}
.voice-call-trigger:hover .ui-icon {
    filter: none;
}

/* --- COLUMN 2 (MIDDLE): MAIN CHAT AREA --- */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

/* --- TABS SYSTEM (Dynamic Ordering & Full-Tab Pulsating) --- */
.tabs-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(14, 14, 18, 0.85);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px 12px;
    flex-shrink: 0;
    scrollbar-width: none;
}
.tabs-container::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    min-width: 120px;
    max-width: 180px;
    height: 36px;
    flex-shrink: 0;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
    position: relative;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.tab.active {
    background: rgba(var(--accent-rgb), 0.16);
    color: var(--text-primary);
    border-color: rgba(var(--accent-rgb), 0.55);
    box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.15);
}

/* FULL-TAB PULSATING UNREAD HIGHLIGHT */
.tab.unread {
    color: #ffffff;
    font-weight: 700;
    animation: tabPulseUnread 1.8s infinite ease-in-out;
}

@keyframes tabPulseUnread {
    0%, 100% {
        background: rgba(var(--accent-rgb), 0.18);
        border-color: rgba(var(--accent-rgb), 0.45);
        box-shadow: 0 0 0 rgba(var(--accent-rgb), 0);
    }
    50% {
        background: rgba(var(--accent-rgb), 0.48);
        border-color: var(--accent-color);
        box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.45);
    }
}

/* FULL-TAB PULSATING INCOMING CALL HIGHLIGHT (RED) */
.tab.ringing {
    color: #ffffff;
    font-weight: 700;
    animation: tabPulseRed 1.2s infinite ease-in-out;
}

@keyframes tabPulseRed {
    0%, 100% {
        background: rgba(var(--danger-rgb), 0.22);
        border-color: rgba(var(--danger-rgb), 0.5);
        box-shadow: 0 0 0 rgba(var(--danger-rgb), 0);
    }
    50% {
        background: rgba(var(--danger-rgb), 0.6);
        border-color: var(--danger-color);
        box-shadow: 0 0 18px rgba(var(--danger-rgb), 0.55);
    }
}

.tab-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.tab-icon-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.65;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.tab-icon-btn .ui-icon {
    width: 13px;
    height: 13px;
}

.tab-icon-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.tab-icon-btn.muted .ui-icon {
    filter: invert(53%) sepia(43%) saturate(983%) hue-rotate(301deg) brightness(95%) contrast(92%);
}

/* --- MESSAGES STREAM --- */
#chat {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 18px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-line {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 3px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.message-line:hover {
    background: rgba(255, 255, 255, 0.03);
}

.msg-main-body {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: 8px;
}

.msg-content-block {
    flex: 1;
    min-width: 0;
    line-height: 1.42;
    display: block;
    padding-top: 2px;
}

.time {
    color: var(--text-muted);
    font-size: 0.7rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin-top: 4px;
}

.msg-avatar-wrapper {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    margin-top: 1px;
}

.avatar-img, .avatar-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.username {
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    cursor: pointer;
    margin-right: 6px;
}

.username:hover {
    text-decoration: underline;
}

.text {
    word-break: break-word;
    color: var(--text-primary);
    font-size: 0.88rem;
}

.chat-image {
    max-width: 260px;
    max-height: 280px;
    width: auto;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    margin-top: 6px;
    cursor: pointer;
    display: block;
    transition: transform 0.2s ease;
}

.chat-image:hover {
    transform: scale(1.02);
}

/* System Join/Leave/Voice Broadcast Messages (Centered Faint Inline Text) */
.system-msg {
    margin: 4px auto;
    padding: 3px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    gap: 6px;
    opacity: 0.75;
}
.system-msg .clickable-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.system-msg.join { color: rgba(var(--teal-rgb), 0.8); }
.system-msg.leave { color: rgba(var(--danger-rgb), 0.8); }
.system-msg .avatar-img, .system-msg .avatar-dot {
    width: 16px;
    height: 16px;
    display: inline-block;
    margin: 0;
}

/* Reply Context */
.reply-context {
    margin-bottom: 4px;
    padding-left: 44px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    opacity: 0.85;
}
.reply-context:hover { opacity: 1; }
.reply-line {
    width: 3px;
    height: 12px;
    background: var(--accent-color);
    border-radius: 2px;
}
.reply-label { font-weight: 700; color: var(--accent-color); }
.reply-snippet {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Message Options Menu */
.msg-options-btn {
    opacity: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.msg-options-btn .ui-icon { width: 16px; height: 16px; }
@media (hover: hover) { .message-line:hover .msg-options-btn { opacity: 0.75; } }
.msg-options-btn:hover { opacity: 1 !important; background: rgba(255, 255, 255, 0.08); }
.message-line.tapped .msg-options-btn { opacity: 1; }

.msg-options-menu {
    display: none;
    position: absolute;
    right: 28px;
    top: 24px;
    background: #1a1a22;
    border: 1px solid var(--border-hover);
    border-radius: 12px;
    z-index: 100;
    min-width: 140px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
    overflow: hidden;
}
.msg-options-menu div {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}
.msg-options-menu div:last-child { border-bottom: none; }
.msg-options-menu div:hover { background: rgba(var(--accent-rgb), 0.16); }

/* --- BOTTOM INPUT BAR (Rectangular Buttons) --- */
.input-area {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-glass);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--border-subtle);
    align-items: center;
    position: relative;
    z-index: 20;
}

.input-area input[type="text"] {
    flex: 1;
    height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: rgba(10, 10, 14, 0.65);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-area input[type="text"]:focus {
    border-color: var(--accent-color);
}

.icon-action-btn {
    width: 44px;
    height: 42px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.icon-action-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.voice-toggle-btn.active-voice {
    background: rgba(var(--teal-rgb), 0.2);
    border-color: var(--teal-color);
    box-shadow: 0 0 14px rgba(var(--teal-rgb), 0.35);
}

.voice-toggle-btn.ringing-voice {
    animation: tabPulseRed 1.2s infinite;
}

.send-arrow-btn {
    width: 48px;
    height: 42px;
    border-radius: 10px;
    background: var(--accent-color);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-arrow-btn .ui-icon {
    filter: none;
    width: 22px;
    height: 22px;
}

.send-arrow-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.4);
}

#replyBar {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: rgba(22, 22, 28, 0.96);
    border-top: 1px solid var(--border-subtle);
    padding: 8px 16px;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(12px);
}

#replyPreview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.close-reply {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
}

#newMsgBtn {
    display: none;
    position: absolute;
    bottom: 78px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-color);
    color: #09090b;
    border: none;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    z-index: 40;
}

.load-more-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    width: auto;
    margin: 4px auto 12px auto;
    cursor: pointer;
}
.load-more-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* --- COLUMN 3 (RIGHT): SIDEBAR --- */
.sidebar {
    width: 270px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 25;
}

.mobile-sidebar-top {
    display: none;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-bottom: 1px solid var(--border-subtle);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-header {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
}

.user-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-item {
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.u-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-ind {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #141418;
    position: absolute;
    bottom: 0;
    left: 22px;
}

.item-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.mini-icon-btn .ui-icon {
    width: 15px;
    height: 15px;
}

.mini-icon-btn:hover {
    background: rgba(var(--accent-rgb), 0.2);
    border-color: var(--accent-color);
}

/* --- USER DROPDOWN POPUP --- */
.user-dropdown {
    position: fixed;
    background: rgba(24, 24, 30, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-hover);
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65);
    width: 230px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.popup-top-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
}

.popup-avatar, .popup-avatar-placeholder {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-hover);
    margin-bottom: 8px;
}

.popup-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.dropdown-action {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 11px 16px;
    text-align: left;
    width: 100%;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 600;
    font-family: inherit;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 10px;
}
.dropdown-action .ui-icon { width: 16px; height: 16px; }
.dropdown-action:last-child { border-bottom: none; }
.dropdown-action:hover { background: rgba(255, 255, 255, 0.08); }
.dropdown-action.add { color: var(--teal-color); }
.dropdown-action.remove { color: var(--danger-color); }

/* --- MODALS & TOASTS --- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    z-index: 4000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: #16161c;
    border: 1px solid var(--border-hover);
    padding: 24px;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

.admin-modal-card {
    max-width: 620px;
}

.modal-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header-row h3 {
    margin: 0;
    font-size: 1.15rem;
}

.icon-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.settings-field {
    margin-bottom: 14px;
    text-align: left;
}

.settings-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.settings-field input[type="email"],
.settings-field input[type="text"],
.settings-field input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    background: #202028;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
}

.settings-field input[type="color"] {
    width: 100%;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: #202028;
    cursor: pointer;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #202028;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 10px;
    font-size: 0.86rem;
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #3a3a44;
    transition: 0.25s;
    border-radius: 999px;
}
.slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.25s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider::before { transform: translateX(20px); }

.modal-actions-row {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

.primary-btn {
    background: var(--accent-color);
    color: #09090b;
    border: none;
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.danger-outline-btn {
    background: rgba(var(--danger-rgb), 0.14);
    color: #ffccd5;
    border: 1px solid rgba(var(--danger-rgb), 0.4);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    margin-right: auto;
    font-family: inherit;
}

/* Admin Logs List */
.admin-log-subtext {
    margin: 0 0 12px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.admin-logs-list {
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    font-size: 0.82rem;
}

.log-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}
.log-badge.join { background: rgba(var(--teal-rgb), 0.16); color: var(--teal-color); }
.log-badge.silent_join { background: rgba(var(--accent-rgb), 0.2); color: var(--accent-color); }
.log-badge.leave, .log-badge.silent_leave { background: rgba(var(--danger-rgb), 0.16); color: var(--danger-color); }

/* Image Modal (Save Image Button Below Preview) */
#imageModal {
    flex-direction: column;
}
#fullImage {
    max-width: 90%;
    max-height: 78%;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}
#downloadBtn {
    margin-top: 16px;
    padding: 10px 24px;
    background: var(--accent-color);
    color: #09090b;
    text-decoration: none;
    font-weight: 700;
    border-radius: 10px;
}
.close-modal-btn {
    position: absolute;
    top: 24px;
    right: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-subtle);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast-msg {
    background: rgba(22, 22, 28, 0.95);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}

#sidebarOverlay { display: none; }

/* --- RESPONSIVE MOBILE BREAKPOINTS --- */
@media (max-width: 860px) {
    #menuBtn { display: inline-flex !important; }
    .btn-label { display: none; }
    .modern-pill-btn { padding: 8px 12px; }

    .voice-panel {
        position: fixed;
        top: 62px;
        bottom: 0;
        left: 0;
        width: 300px;
        z-index: 2100;
        box-shadow: 12px 0 36px rgba(0, 0, 0, 0.7);
    }
    .voice-panel.minimized {
        transform: translateX(-100%);
        width: 300px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100%;
        z-index: 2200;
        transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: -12px 0 36px rgba(0, 0, 0, 0.7);
    }
    .sidebar.active { right: 0; }
    .mobile-sidebar-top { display: flex; }

    #sidebarOverlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(3px);
        z-index: 2050;
    }
    #sidebarOverlay.active { display: block; }
}