@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   RESET & BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --font: 'Manrope', -apple-system, sans-serif;

    /* Backgrounds — near-black, true dark */
    --bg-gradient:         #0f0f10;
    --glass-sidebar:       #141416;
    --glass-header:        #141416;
    --glass-input:         #1c1c1f;
    --glass-message-own:   #1a3a5c;
    --glass-message-other: #1c1c1f;
    --glass-card:          #17171a;
    --glass-hover:         rgba(255,255,255,0.04);
    --dropdown-bg:         #1c1c1f;

    /* Borders — very subtle */
    --border:        rgba(255,255,255,0.07);
    --border-strong: rgba(255,255,255,0.12);

    /* Accent — refined blue */
    --accent:      #4d7cc7;
    --accent-glow: rgba(77,124,199,0.18);
    --accent-dim:  rgba(77,124,199,0.12);

    /* Text — high contrast hierarchy */
    --text-primary:   #f0f0f2;
    --text-secondary: rgba(240,240,242,0.42);
    --text-muted:     rgba(240,240,242,0.24);

    --blur-sm: blur(0px);
    --blur-md: blur(0px);
    --blur-lg: blur(0px);

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  18px;
    --radius-msg: 16px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.55);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.65);
}

html, body {
    height: 100%;
    margin: 0;
}
body {
    font-family: var(--font);
    background: var(--bg-gradient);
    min-height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
    position: relative;
    display: flex;
    flex-direction: column;
}

 to { transform: translate(-60px, -80px) scale(1.15); } }

/* ============================================================
   AUTH
   ============================================================ */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-gradient);
    z-index: 100;
}

.auth-card {
    background: var(--glass-card);
    border: 1px solid var(--border-strong);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-xl);
    width: 340px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.auth-card p.auth-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.auth-card input {
    width: 100%;
    padding: 11px 16px;
    margin: 5px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--glass-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.auth-card input:focus {
    border-color: var(--accent);
    background: rgba(99,160,255,0.08);
}
.auth-card input::placeholder { color: var(--text-secondary); }

.auth-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 2px 0 6px 4px;
    text-align: left;
}

.auth-buttons {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}
.auth-buttons button {
    flex: 1;
    padding: 11px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.auth-buttons button:first-child {
    background: var(--glass-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.auth-buttons button:first-child:hover { background: var(--glass-hover); }
.auth-buttons button:last-child {
    background: var(--accent);
    color: #fff;
}
.auth-buttons button:last-child:hover { opacity: 0.88; }

.error {
    color: #ff7b7b;
    font-size: 12px;
    margin-top: 10px;
    min-height: 18px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.chat-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 300px;
    background: var(--glass-sidebar);
    border-right: 1px solid rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    position: relative;
}
.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: -1px;
    width: 1px; height: 100%;
    background: linear-gradient(180deg, var(--accent-glow, transparent) 0%, transparent 100%);
    pointer-events: none;
}

.user-info {
    padding: 16px 18px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    flex-shrink: 0;
    padding: 10px 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: color 0.18s, border-color 0.18s;
    margin-bottom: -1px;
    white-space: nowrap;
    letter-spacing: -0.1px;
}
.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}
.tab-btn:hover:not(.active) { color: rgba(255,255,255,0.75); }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 8px; }
.tab-content.active { display: block; }

/* Scrollbar */
.tab-content::-webkit-scrollbar { width: 3px; }
.tab-content::-webkit-scrollbar-track { background: transparent; }
.tab-content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.user-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    cursor: pointer;
    margin: 1px 4px;
    transition: background 0.15s;
    position: relative;
    gap: 10px;
}
.user-item .friend-request-btn {
    margin-left: auto;
}
.user-item:hover { background: rgba(255,255,255,0.05); }
.user-item:active { transform: scale(0.985); }
.user-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.user-item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.1px; }
.user-item-status { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-chat {
    background: rgba(255,255,255,0.07) !important;
}

.user-avatar {
    font-size: 20px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.user-info-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

.unread-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.empty-hint {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

/* Search input */
#searchUserInput, #joinCodeInput, #searchGroupInput {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--glass-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
#joinCodeInput {
    width: auto;
    flex: 1;
    margin-bottom: 0;
    border-radius: 20px;
}
#searchUserInput:focus, #joinCodeInput:focus, #searchGroupInput:focus {
    border-color: var(--accent);
}
#searchUserInput::placeholder, #joinCodeInput::placeholder, #searchGroupInput::placeholder {
    color: var(--text-secondary);
}

/* Friend request buttons */
.friend-request-btn {
    padding: 5px 12px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.friend-request-btn:hover { background: var(--accent); color: #fff; }

.accept-btn, .reject-btn {
    padding: 4px 11px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
}
.accept-btn { background: rgba(74,222,128,0.2); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.accept-btn:hover { background: rgba(74,222,128,0.35); }
.reject-btn { background: rgba(255,123,123,0.2); color: #ff7b7b; border: 1px solid rgba(255,123,123,0.3); margin-left: 4px; }
.reject-btn:hover { background: rgba(255,123,123,0.35); }

/* Groups toolbar */
.groups-toolbar {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.join-code-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.join-code-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}
.join-code-btn:hover { opacity: 0.85; }

.group-meta {
    font-size: 11px;
    color: var(--text-secondary);
}
.group-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
}
.group-badge.public { background: rgba(74,222,128,0.15); color: #4ade80; }
.group-badge.private { background: var(--accent-dim); color: var(--accent); }
.crown { font-size: 11px; }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-panel { padding: 12px; }
.settings-panel h4 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 14px;
    margin-top: 4px;
}

.avatar-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.avatar-selector label { font-size: 12px; color: var(--text-secondary); }
.avatar-preview {
    font-size: 28px;
    width: 44px;
    height: 44px;
    background: var(--glass-input);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}
.avatar-preview.large { font-size: 36px; width: 56px; height: 56px; }

.secondary-btn {
    padding: 11px 20px;
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
   min-width: 120px;
}
.secondary-btn:hover { background: var(--glass-hover); border-color: var(--border-strong); }

.avatar-emoji-panel {
    display: none;
    background: var(--glass-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-bottom: 12px;
}
.avatar-emoji-panel.open { display: block; }

.color-selector { margin-bottom: 14px; }
.color-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 10px;
    cursor: pointer;
}
.color-preview {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    flex-shrink: 0;
    transition: transform 0.2s;
}
.color-preview:hover { transform: scale(1.1); }
.color-picker-wrapper input[type="color"] {
    width: 0; height: 0; padding: 0; border: none; visibility: hidden; position: absolute;
}
.color-hex {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: monospace;
    letter-spacing: 1px;
}
.color-presets {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    padding: 4px 0;
}
.color-preset {
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.color-preset:hover { transform: scale(1.2); }
.color-preset.active { border-color: white; transform: scale(1.15); }

.primary-btn {
    width: 100%;
    padding: 11px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0;
    box-sizing: border-box;
}
.primary-btn:hover { opacity: 0.85; }
.primary-btn.small-btn { width: auto; padding: 8px 16px; font-size: 13px; margin-bottom: 0; }

.settings-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.logout-btn {
    width: 100%;
    padding: 11px;
    background: rgba(255,123,123,0.12);
    border: 1px solid rgba(255,123,123,0.25);
    border-radius: var(--radius-md);
    color: #ff7b7b;
    font-family: var(--font);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0;
}
.logout-btn:hover { background: rgba(255,123,123,0.22); }

/* Theme section in settings */
.theme-section { margin-bottom: 16px; }
.settings-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}
.theme-grid-inline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
}
.theme-card {
    border-radius: var(--radius-sm);
    padding: 7px 5px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: var(--glass-input);
}
.theme-card:hover { border-color: var(--border-strong); }
.theme-card.active { border-color: var(--accent); background: var(--accent-dim); }
.theme-preview {
    display: flex;
    gap: 2px;
    width: 100%;
    height: 28px;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}
.theme-preview-sidebar { width: 32%; flex-shrink: 0; }
.theme-preview-main { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 3px; gap: 2px; }
.theme-preview-msg { height: 4px; border-radius: 2px; opacity: 0.85; }
.theme-preview-msg.own { width: 55%; align-self: flex-end; }
.theme-preview-msg.other { width: 65%; align-self: flex-start; }
.theme-name { font-size: 9px; font-weight: 600; color: var(--text-secondary); text-align: center; letter-spacing: 0.3px; }
.theme-card.active .theme-name { color: var(--accent); }

/* ============================================================
   MAIN CHAT
   ============================================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.chat-header {
    padding: 11px 16px;
    background: var(--glass-header);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 8px;
    transition: color 0.2s;
}
.menu-toggle:hover { color: var(--text-primary); }

.chat-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-info-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
    margin-left: auto;
}
.group-info-btn:hover { background: var(--glass-hover); color: var(--text-primary); }

/* ============================================================
   MESSAGES
   ============================================================ */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    isolation: auto;
}
.messages.menu-open {
    overflow: visible;
}
.messages::-webkit-scrollbar { width: 3px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message {
    max-width: 68%;
    margin-bottom: 6px;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 6px;
    position: relative;
}
.message.own { align-self: flex-end; flex-direction: row-reverse; }
.message.other { align-self: flex-start; }

.message-bubble {
    background: var(--glass-message-other);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 18px 18px 18px 6px;
    padding: 9px 13px 7px;
    position: relative;
    word-break: break-word;
    z-index: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.message.own .message-bubble {
    background: var(--glass-message-own);
    border: none;
    border-radius: 18px 18px 6px 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.message.other .message-bubble {
    border: 1px solid rgba(255,255,255,0.05);
}

.msg-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.1px;
}
.message.own .msg-sender { display: none; }

.message-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}
.message.other .message-text { color: var(--text-primary); }
.message-text code {
    background: rgba(0,0,0,0.3);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}
.deleted-text { color: var(--text-secondary); font-size: 13px; font-style: italic; }

.msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    justify-content: flex-end;
}
.msg-time { font-size: 10px; color: var(--text-muted); }
.edited-badge { font-size: 10px; color: var(--text-muted); }
.read-status { font-size: 10px; color: var(--text-muted); transition: color 0.3s; }
.read-status.read { color: var(--accent); }

/* Reply */
.reply-preview {
    background: rgba(255,255,255,0.06);
    border-left: 2px solid var(--accent);
    border-radius: 8px;
    padding: 5px 9px;
    margin-bottom: 7px;
    cursor: pointer;
    transition: background 0.15s;
}
.reply-preview:hover { background: rgba(255,255,255,0.1); }
.reply-author { font-size: 11px; font-weight: 600; color: var(--accent); display: block; margin-bottom: 1px; }
.reply-content { font-size: 11px; color: var(--text-secondary); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

.reply-bar {
    display: flex;
    align-items: center;
    background: var(--glass-header);
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    gap: 10px;
    flex-shrink: 0;
}
.reply-bar-content { flex: 1; min-width: 0; }
.reply-bar-label { font-size: 11px; color: var(--accent); display: block; font-weight: 500; }
.reply-bar-text { font-size: 12px; color: var(--text-secondary); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 14px; padding: 4px 7px; border-radius: 6px; transition: all 0.15s; }
.reply-bar-close:hover { background: var(--glass-hover); color: var(--text-primary); }

/* Message actions */
.message-actions {
    display: none;
    gap: 2px;
    position: absolute;
    top: 50%;
    background: rgba(15,17,30,0.9);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 3px;
    z-index: 10;
    box-shadow: var(--shadow-md);
}
.message.own .message-actions { left: -4px; transform: translateY(-50%) translateX(-100%); }
.message.other .message-actions { right: -4px; transform: translateY(-50%) translateX(100%); }
.message:hover .message-actions,
.message-actions:hover { display: flex; }

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 5px 7px;
    border-radius: 7px;
    color: var(--text-secondary);
    transition: all 0.15s;
    line-height: 1;
    font-family: var(--font);
}
.action-btn:hover { background: var(--glass-hover); color: var(--text-primary); }
.del-btn:hover { color: #ff7b7b; }

/* Reactions */
.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
    padding: 0 2px;
}
.reaction-btn {
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 3px;
}
.reaction-btn span { font-size: 11px; color: var(--text-secondary); }
.reaction-btn:hover { background: var(--glass-hover); border-color: var(--border-strong); }
.reaction-btn.reacted { background: var(--accent-dim); border-color: var(--accent); }
.reaction-btn.reacted span { color: var(--accent); }

.reaction-picker {
    position: fixed;
    background: var(--glass-card);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    padding: 6px;
    display: flex;
    gap: 3px;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
}
.reaction-pick-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 9px;
    transition: background 0.15s;
}
.reaction-pick-btn:hover { background: var(--glass-hover); }

/* Image */
.msg-image {
    max-width: 240px;
    max-height: 280px;
    border-radius: 12px;
    display: block;
    cursor: pointer;
    margin-bottom: 5px;
    object-fit: cover;
    transition: opacity 0.2s;
    border: 1px solid var(--border);
}
.msg-image:hover { opacity: 0.9; }
/* File attachment */
.msg-file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    background: none;
    border: none;
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 5px;
    max-width: 240px;
}
.msg-file-link:hover .msg-file-name { opacity: 0.8; }
.msg-file-icon {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent, #6ab0f3);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.msg-file-icon svg { width: 18px; height: 18px; }
.msg-file-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.msg-file-dl { display: none; }

/* Highlight */
.message.highlight .message-bubble {
    animation: highlightPulse 1.5s ease;
}
@keyframes highlightPulse {
    0%,100% { box-shadow: none; }
    30% { box-shadow: 0 0 0 3px rgba(99,160,255,0.4); }
}

/* ============================================================
   TYPING
   ============================================================ */
.typing-indicator {
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.25s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.typing-indicator.active {
    max-height: 28px;
    padding: 4px 16px;
    opacity: 1;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.typing-dots span {
    width: 4px; height: 4px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingDot 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%,60%,100% { opacity: 0.2; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.3); }
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--glass-header);
    border-top: 1px solid rgba(255,255,255,0.05);
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#messageInput, #postTextInput {
    flex: 1;
    min-width: 0;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 22px;
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    letter-spacing: -0.1px;
}
#messageInput:focus {
    border-color: rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
}
#messageInput::placeholder { color: var(--text-secondary); }

.send-btn {
    background: var(--accent);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.send-btn:hover { opacity: 0.85; transform: scale(1.05); }

.emoji-toggle-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
    line-height: 1;
}
.emoji-toggle-btn:hover { background: var(--glass-hover); }

.image-upload-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 10px;
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
}
.image-upload-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* Emoji picker */
/* ===== TG-style Emoji Picker ===== */
.emoji-picker-panel {
    display: none;
    position: absolute;
    bottom: 62px;
    left: 8px;
    background: var(--glass-card, #1e1e2a);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    z-index: 999;
    width: 320px;
    max-height: 340px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.emoji-picker-panel.open { display: flex; }

/* Category strip */
.ep-cats {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.ep-cats::-webkit-scrollbar { display: none; }
.ep-cat-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 10px;
    flex-shrink: 0;
    transition: background 0.12s;
    opacity: 0.5;
}
.ep-cat-btn:hover { background: rgba(255,255,255,0.08); opacity: 0.8; }
.ep-cat-btn.active { background: rgba(255,255,255,0.1); opacity: 1; }

/* Scrollable body */
.ep-body {
    overflow-y: auto;
    flex: 1;
    padding: 8px 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.ep-body::-webkit-scrollbar { width: 3px; }
.ep-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.ep-section-label {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 4px 4px;
}
.ep-empty { font-size: 12px; color: rgba(255,255,255,0.3); text-align: center; padding: 16px; }

.ep-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.ep-grid span {
    font-size: 22px;
    cursor: pointer;
    text-align: center;
    padding: 4px 2px;
    border-radius: 8px;
    transition: background 0.1s, transform 0.1s;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ep-grid span:hover { background: rgba(255,255,255,0.1); transform: scale(1.2); }
.ep-grid span:active { transform: scale(0.9); }

/* Old classes kept for compatibility */
.emoji-categories { display: none; }
.emoji-grid { display: none; }
.emoji-cat-btn { display: none; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.modal-overlay.open { display: flex; }

.modal-card {
    background: var(--glass-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}
.modal-card.narrow { max-width: 340px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.15s;
    line-height: 1;
}
.modal-close:hover { background: var(--glass-hover); color: var(--text-primary); }

.modal-body { padding: 16px 20px; flex: 1; display: flex; flex-direction: column; gap: 12px; }
#createGroupModal .modal-body { gap: 12px; }
#createGroupModal .modal-input { width: 100%; box-sizing: border-box; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}
.modal-footer .primary-btn { flex: 1; }
.modal-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--glass-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text-secondary); }

.modal-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* Group type selector */
.modal-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.type-option { cursor: pointer; }
.type-option input[type="radio"] { display: none; }
.type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    background: var(--glass-input);
}
.type-option input[type="radio"]:checked + .type-card {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.type-icon { font-size: 22px; margin-bottom: 4px; }
.type-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.type-desc { font-size: 11px; color: var(--text-secondary); text-align: center; margin-top: 2px; }

/* Members */
.members-section { border-top: 1px solid var(--border); padding-top: 12px; }
.members-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; letter-spacing: 0.3px; }
.member-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s;
}
.member-checkbox-label:hover { background: var(--glass-hover); }
.member-checkbox-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }

/* Invite code */
.invite-code-box {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--accent);
    background: var(--glass-input);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    border: 1px dashed var(--accent);
    font-family: 'Courier New', monospace;
}
.invite-code-small {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent);
    font-family: monospace;
}
.info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
}
.info-label { font-size: 12px; color: var(--text-secondary); min-width: 120px; }
.tiny-btn { padding: 4px 8px !important; font-size: 11px !important; }
.members-list { display: flex; flex-wrap: wrap; gap: 6px; }
.member-tag {
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text-primary);
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        z-index: 1000;
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: block; }
    .message { max-width: 85%; }
    .main { display: flex; flex-direction: column; height: 100dvh; }
    .messages { flex: 1; overflow-y: auto; margin-bottom: 0; padding-bottom: 8px; }
    .typing-indicator { position: static; background: transparent; }
    .input-area { position: static; border-radius: 0; }
    #messageInput { font-size: 16px; }
}

@media (max-width: 425px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 100% !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main {
        width: 100%;
        position: fixed;
        inset: 0;
    }
    .menu-toggle { display: flex !important; }
}

@media (max-width: 480px) {
    .sidebar { width: 280px; }
    .message { max-width: 90%; }
    .message-bubble { padding: 7px 10px 5px; }
    .message-text { font-size: 13px; }
}

/* ============================================================
   THEMES
   ============================================================ */
/* ========== THEMES ========== */

/* ── 1. MIDNIGHT (default dark) ── */
[data-theme="dark"] {
    --bg-gradient: #0d0d12;
    --glass-sidebar: #13131a;
    --glass-header: #13131a;
    --glass-input: #1c1c26;
    --glass-message-own: #1a2f5e;
    --glass-message-other: #1a1a24;
    --glass-card: #16161f;
    --glass-hover: rgba(255,255,255,0.05);
    --border: rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.11);
    --accent: #6c8fff;
    --accent-glow: rgba(108,143,255,0.25);
    --accent-dim: rgba(108,143,255,0.12);
    --text-primary: #e8eaf4;
    --text-secondary: rgba(232,234,244,0.42);
    --text-muted: rgba(232,234,244,0.24);
    --dropdown-bg: #16161f;
    --chat-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%236c8fff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
[data-theme="dark"] .messages {
    background: radial-gradient(ellipse 80% 60% at 50% 100%, rgba(108,143,255,0.07) 0%, transparent 70%), var(--bg-gradient);
    background-image: var(--chat-pattern), radial-gradient(ellipse 80% 60% at 50% 100%, rgba(108,143,255,0.07) 0%, transparent 70%);
}

/* ── 2. LIGHT ── */
[data-theme="light"] {
    --bg-gradient: #eef1f8;
    --glass-sidebar: #ffffff;
    --glass-header: rgba(255,255,255,0.95);
    --glass-input: #f2f4f8;
    --glass-message-own: #ccdeff;
    --glass-message-other: #ffffff;
    --glass-card: #ffffff;
    --glass-hover: rgba(0,0,0,0.04);
    --border: rgba(0,0,0,0.07);
    --border-strong: rgba(0,0,0,0.13);
    --accent: #3b72e8;
    --accent-glow: rgba(59,114,232,0.18);
    --accent-dim: rgba(59,114,232,0.10);
    --text-primary: #1a1d2e;
    --text-secondary: rgba(26,29,46,0.48);
    --text-muted: rgba(26,29,46,0.28);
    --dropdown-bg: #ffffff;
}
[data-theme="light"] .messages {
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%233b72e8' fill-opacity='0.04' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E"), #eef1f8;
}

/* ── 3. AURORA (purple-teal) ── */
[data-theme="aurora"] {
    --bg-gradient: #0a0c18;
    --glass-sidebar: #0f1020;
    --glass-header: #0f1020;
    --glass-input: #181a2e;
    --glass-message-own: #1e1060;
    --glass-message-other: #151726;
    --glass-card: #12142a;
    --glass-hover: rgba(255,255,255,0.05);
    --border: rgba(150,120,255,0.10);
    --border-strong: rgba(150,120,255,0.18);
    --accent: #a78bfa;
    --accent-glow: rgba(167,139,250,0.28);
    --accent-dim: rgba(167,139,250,0.13);
    --text-primary: #e8e2ff;
    --text-secondary: rgba(232,226,255,0.42);
    --text-muted: rgba(232,226,255,0.22);
    --dropdown-bg: #12142a;
}
[data-theme="aurora"] .messages {
    background:
        radial-gradient(ellipse 90% 60% at 50% 0%, rgba(167,139,250,0.13) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 100% 100%, rgba(34,211,238,0.09) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 0% 60%, rgba(167,139,250,0.07) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ccircle cx='20' cy='30' r='1' fill='white' fill-opacity='0.06'/%3E%3Ccircle cx='80' cy='10' r='0.8' fill='white' fill-opacity='0.08'/%3E%3Ccircle cx='140' cy='50' r='1.2' fill='white' fill-opacity='0.05'/%3E%3Ccircle cx='170' cy='20' r='0.7' fill='%23a78bfa' fill-opacity='0.12'/%3E%3Ccircle cx='50' cy='80' r='0.9' fill='%2322d3ee' fill-opacity='0.10'/%3E%3Ccircle cx='110' cy='120' r='1' fill='white' fill-opacity='0.06'/%3E%3Ccircle cx='190' cy='100' r='0.8' fill='white' fill-opacity='0.07'/%3E%3Ccircle cx='30' cy='160' r='1.1' fill='%23a78bfa' fill-opacity='0.09'/%3E%3Ccircle cx='160' cy='180' r='0.9' fill='%2322d3ee' fill-opacity='0.08'/%3E%3Ccircle cx='90' cy='170' r='0.7' fill='white' fill-opacity='0.05'/%3E%3C/svg%3E"),
        #0a0c18;
}

/* ── 4. EMBER (dark warm amber) ── */
[data-theme="ember"] {
    --bg-gradient: #100a04;
    --glass-sidebar: #18100a;
    --glass-header: #18100a;
    --glass-input: #221508;
    --glass-message-own: #3d1f05;
    --glass-message-other: #1c120a;
    --glass-card: #1c120a;
    --glass-hover: rgba(255,180,60,0.06);
    --border: rgba(255,150,30,0.10);
    --border-strong: rgba(255,150,30,0.18);
    --accent: #f59e0b;
    --accent-glow: rgba(245,158,11,0.25);
    --accent-dim: rgba(245,158,11,0.12);
    --text-primary: #fef3c7;
    --text-secondary: rgba(254,243,199,0.42);
    --text-muted: rgba(254,243,199,0.22);
    --dropdown-bg: #1c120a;
}
[data-theme="ember"] .messages {
    background:
        radial-gradient(ellipse 70% 50% at 50% 100%, rgba(245,158,11,0.10) 0%, transparent 65%),
        url("data:image/svg+xml,%3Csvg width='52' height='26' viewBox='0 0 52 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23f59e0b' fill-opacity='0.04'%3E%3Cpath d='M10 10c0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6h2c0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4v2c-3.314 0-6-2.686-6-6 0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6zm25.464-1.95l8.486 8.486-1.414 1.414-8.486-8.486 1.414-1.414z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
        #100a04;
}

/* ── 5. FOREST (deep green) ── */
[data-theme="forest"] {
    --bg-gradient: #050e08;
    --glass-sidebar: #091410;
    --glass-header: #091410;
    --glass-input: #0f1f18;
    --glass-message-own: #0d3320;
    --glass-message-other: #0d1a14;
    --glass-card: #0d1a14;
    --glass-hover: rgba(52,211,153,0.06);
    --border: rgba(52,211,153,0.09);
    --border-strong: rgba(52,211,153,0.16);
    --accent: #34d399;
    --accent-glow: rgba(52,211,153,0.25);
    --accent-dim: rgba(52,211,153,0.11);
    --text-primary: #d1fae5;
    --text-secondary: rgba(209,250,229,0.42);
    --text-muted: rgba(209,250,229,0.22);
    --dropdown-bg: #0d1a14;
}
[data-theme="forest"] .messages {
    background:
        radial-gradient(ellipse 80% 55% at 20% 80%, rgba(52,211,153,0.10) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 20%, rgba(52,211,153,0.07) 0%, transparent 55%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M10 60 Q30 20 50 60 Q70 100 90 60 Q110 20 130 60' stroke='%2334d399' stroke-width='0.5' fill='none' stroke-opacity='0.07'/%3E%3Cpath d='M0 90 Q20 50 40 90 Q60 130 80 90 Q100 50 120 90' stroke='%2334d399' stroke-width='0.5' fill='none' stroke-opacity='0.05'/%3E%3Cpath d='M0 30 Q20 0 40 30 Q60 60 80 30 Q100 0 120 30' stroke='%2334d399' stroke-width='0.4' fill='none' stroke-opacity='0.04'/%3E%3C/svg%3E"),
        #050e08;
}

/* ── 6. ROSE (dark pink) ── */
[data-theme="rose"] {
    --bg-gradient: #110810;
    --glass-sidebar: #1a0e18;
    --glass-header: #1a0e18;
    --glass-input: #241424;
    --glass-message-own: #3d1030;
    --glass-message-other: #1e1020;
    --glass-card: #1e1020;
    --glass-hover: rgba(244,114,182,0.06);
    --border: rgba(244,114,182,0.09);
    --border-strong: rgba(244,114,182,0.16);
    --accent: #f472b6;
    --accent-glow: rgba(244,114,182,0.25);
    --accent-dim: rgba(244,114,182,0.11);
    --text-primary: #fce7f3;
    --text-secondary: rgba(252,231,243,0.42);
    --text-muted: rgba(252,231,243,0.22);
    --dropdown-bg: #1e1020;
}
[data-theme="rose"] .messages {
    background:
        radial-gradient(ellipse 70% 45% at 70% 0%, rgba(244,114,182,0.10) 0%, transparent 65%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23f472b6' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
        #110810;
}

body { background: var(--bg-gradient); }

/* ===== АВАТАРКА РЯДОМ С СООБЩЕНИЕМ ===== */
.message {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}
.message.own { flex-direction: row-reverse; }

.msg-avatar-wrap {
    width: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    margin-right: 8px;
}
.message.own .msg-avatar-wrap { display: none; }
.msg-avatar {
    font-size: 20px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
}

.msg-body {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0;
}
.message.own .msg-body { align-items: flex-end; }
.message.other .msg-body { align-items: flex-start; }

/* ===== СПИСОК ДРУЗЕЙ — новый layout ===== */
.friend-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    margin-right: 10px;
}
.friend-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #4ade80;
    border: 2px solid var(--bg-sidebar, #1f1f1f);
    
}
.friend-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.friend-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    overflow: visible;
    position: relative;
}
.friend-last-msg {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.last-msg-text {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 70px);
}
.last-msg-time-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.last-msg-time {
    font-size: 11px;
    color: var(--text-muted, rgba(240,242,248,0.25));
}

/* ===== КОНТЕКСТНОЕ МЕНЮ СООБЩЕНИЯ (TG-стиль) ===== */
.msg-context-menu {
    position: fixed;
    background: var(--glass-sidebar);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px;
    z-index: 9999;
    min-width: 180px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    opacity: 0;
    transform: scale(0.92) translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
   color: var(--text-primary);
}
.msg-context-menu.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}
.msg-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary, #f0f2f8);
    text-align: left;
    transition: background 0.12s;
}
.msg-menu-btn:hover { background: rgba(255,255,255,0.08); }
.msg-menu-btn.danger { color: #ff7b7b; }
.msg-menu-btn.danger:hover { background: rgba(255,123,123,0.12); }
.msg-menu-icon { font-size: 16px; width: 20px; text-align: center; }

/* ===== МОДАЛКА РЕДАКТИРОВАНИЯ ===== */
.edit-msg-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 12px;
    background: var(--glass-input, rgba(255,255,255,0.06));
    color: var(--text-primary, #f0f2f8);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.edit-msg-textarea:focus { border-color: var(--accent, #63a0ff); }

/* Убираем старый hover на message — теперь меню по клику */
.message-actions { display: none !important; }

/* ===== ЗВОНОК ===== */
#callOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.call-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 48px 56px 40px;
    background: rgba(18,20,36,0.95);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 28px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    min-width: 300px;
}
.call-avatar {
    font-size: 80px;
    line-height: 1;
    margin-bottom: 8px;
}
.call-username {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}
.call-status {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    min-height: 18px;
}
.call-timer {
    font-size: 15px;
    color: rgba(255,255,255,0.7);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.call-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, filter 0.15s;
    flex-shrink: 0;
    margin-top: 8px;
}
.call-btn svg {
    width: 26px;
    height: 26px;
}
.call-btn:hover { transform: scale(1.08); filter: brightness(1.15); }
.call-btn:active { transform: scale(0.95); }
.call-btn-accept { background: #22c55e; color: #fff; }
.call-btn-end { background: #ef4444; color: #fff; }
.call-btn-mute { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.1); }
.call-btn-mute.muted { background: rgba(239,68,68,0.25); color: #ef4444; }
.call-btn-label {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    text-align: center;
    white-space: nowrap;
}
/* Кнопка звонка в хедере чата */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.chat-call-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.chat-call-btn:hover { color: var(--accent); background: var(--accent-dim); }

.creator-name {
    background: linear-gradient(90deg, #d4a847, #f5d77e, #b8860b, #f0c040, #d4a847);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2.5s linear infinite;
    font-weight: 600;
}
@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.creator-crown {
    font-size: 13px;
    margin-left: 4px;
    cursor: default;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
    position: relative;
    top: -1px;
    filter: drop-shadow(0 0 4px rgba(212,168,71,0.7));
    transition: filter 0.2s;
    -webkit-text-fill-color: initial;
}
.creator-crown:hover {
    filter: drop-shadow(0 0 10px rgba(212,168,71,1));
}
.creator-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: calc(100% + 10px);
    transform: translateY(-50%) translateX(-4px);
    background: linear-gradient(135deg, rgba(20,18,30,0.98), rgba(30,25,45,0.98));
    border: 1px solid rgba(212,168,71,0.35);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #d4a847;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 12px rgba(212,168,71,0.15);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    -webkit-text-fill-color: #d4a847;
}
.creator-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(212,168,71,0.35);
}
.creator-crown:hover .creator-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.creator-name {
    overflow: visible !important;
    white-space: nowrap;
    position: relative;
}

[data-theme="light"] .modal-card {
    background: rgba(255,255,255,0.97);
}
[data-theme="light"] .modal-input {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
    color: #1a1d2e;
}
[data-theme="light"] .modal-input::placeholder {
    color: rgba(26,29,46,0.4);
}
[data-theme="light"] .type-card {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .type-label {
    color: #1a1d2e;
}
[data-theme="light"] .member-checkbox-label {
    color: #1a1d2e;
}
[data-theme="light"] .modal-header h3 {
    color: #1a1d2e;
}
[data-theme="light"] .secondary-btn {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.12);
    color: #1a1d2e;
}
[data-theme="light"] .secondary-btn:hover {
    background: rgba(0,0,0,0.09);
}

/* ===== CHAT DROPDOWN MENU ===== */
.chat-dropdown {
    display: none;
    position: fixed;
    background: var(--dropdown-bg);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 6px;
    min-width: 190px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    z-index: 9999;
}
.chat-dropdown.open { display: flex; flex-direction: column; gap: 2px; }
.chat-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.chat-dropdown-item:hover { background: rgba(255,255,255,0.07); }
.chat-dropdown-item.danger { color: #ef4444; }
.chat-dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }
.chat-dropdown-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 4px 0;
}

@keyframes fadeInUp {
    from { opacity:0; transform:translateX(-50%) translateY(10px); }
    to   { opacity:1; transform:translateX(-50%) translateY(0); }
}

/* === Settings improvements === */
.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary, rgba(255,255,255,0.4));
  margin-bottom: 8px;
  padding: 0 2px;
}
.settings-full-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  justify-content: center;
}
.settings-tg-btn {
  background: linear-gradient(135deg, #2ca5e0, #1a85c2);
  color: #fff;
  border: none;
  text-decoration: none;
}
.settings-tg-btn:hover {
  background: linear-gradient(135deg, #1a85c2, #1570a8);
  color: #fff;
}

.no-chat-selected {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
    background: var(--bg-gradient);
}
.no-chat-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0.85;
}
.no-chat-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent, #6ab0f3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
    box-shadow: 0 4px 24px rgba(106,176,243,0.25);
}
.no-chat-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.no-chat-sub {
    font-size: 14px;
    color: var(--text-secondary);
}

.pinned-msg { border-left: 3px solid var(--accent, #6ab0f3) !important; }
.pin-badge { font-size: 11px; position: absolute; top: 4px; right: 4px; }

.forward-friend-btn {
    width: 100%; text-align: left; padding: 10px 12px;
    background: none; border: none; color: var(--text-primary);
    font-size: 14px; cursor: pointer; border-radius: 8px;
    display: flex; align-items: center;
}
.forward-friend-btn:hover { background: var(--hover-bg, rgba(255,255,255,0.06)); }

.selected-msg { background: rgba(106,176,243,0.15) !important; border-radius: 8px; }

.select-bar {
    position: absolute; bottom: 70px; left: 0; right: 0;
    background: var(--glass-header); border-top: 1px solid var(--border);
    padding: 10px 16px; display: flex; justify-content: space-between;
    align-items: center; z-index: 50; font-size: 14px;
}
.select-bar button {
    background: none; border: none; color: var(--text-primary);
    cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 6px;
}
.select-bar button:hover { background: var(--hover-bg, rgba(255,255,255,0.06)); }

/* ============================================================
   REDESIGN OVERRIDES - Telegram-style minimal
   ============================================================ */

body {
    background: var(--bg-gradient) !important;
}

/* Sidebar border */
.sidebar {
    border-right: 1px solid var(--border) !important;
}

/* Messages - no border, solid bg */
.message-bubble {
    border: none !important;
    box-shadow: none !important;
}

/* Input area */
.input-area {
    background: var(--glass-header) !important;
    border-top: 1px solid var(--border) !important;
    box-shadow: none !important;
}

#messageInput {
    background: var(--glass-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: 20px !important;
}

/* Send btn - no glow */
.send-btn {
    box-shadow: none !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Auth card */
.auth-card {
    background: var(--glass-sidebar) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-md) !important;
}

/* Settings tab button SVG align */
.tab-btn svg {
    display: inline-block;
    vertical-align: middle;
}

/* Emoji/attach buttons - SVG color */
.emoji-toggle-btn svg,
.image-upload-btn svg {
    stroke: var(--text-secondary);
}
.emoji-toggle-btn:hover svg,
.image-upload-btn:hover svg {
    stroke: var(--accent);
}

/* Menu toggle SVG */
.menu-toggle svg {
    stroke: var(--text-secondary);
}

/* User info header */
.user-info {
    background: var(--glass-header) !important;
}

/* Chat header */
.chat-header {
    background: var(--glass-header) !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: none !important;
}

/* Unread badge - no glow */
.unread-badge {
    box-shadow: none !important;
}

/* Primary btn - no glow */
.primary-btn {
    box-shadow: none !important;
}
.primary-btn:hover {
    transform: none !important;
    opacity: 0.9 !important;
}

/* Auth btn */
.auth-buttons button:last-child {
    box-shadow: none !important;
}
.auth-buttons button:last-child:hover {
    transform: none !important;
}

/* Modal */
.modal-card {
    background: var(--glass-sidebar) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* Settings sections */
.settings-section-title {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    margin-bottom: 8px;
    margin-top: 16px;
    padding: 0 2px;
}

/* Tg support btn */
.settings-tg-btn {
    background: #2b5278 !important;
    color: #fff !important;
    border: none !important;
}
.settings-tg-btn:hover {
    background: #3a6a9a !important;
}

/* No chat selected bg */
.no-chat-selected {
    background: var(--bg-gradient) !important;
}

/* Light theme overrides */
[data-theme="light"] .message-bubble {
    border: none !important;
}
[data-theme="light"] .chat-header {
    border-bottom: 1px solid rgba(0,0,0,0.08) !important;
}
[data-theme="light"] .sidebar {
    border-right: 1px solid rgba(0,0,0,0.08) !important;
}
[data-theme="light"] .emoji-toggle-btn svg,
[data-theme="light"] .image-upload-btn svg {
    stroke: rgba(34,34,34,0.5);
}
[data-theme="light"] .menu-toggle svg {
    stroke: rgba(34,34,34,0.5);
}
[data-theme="light"] .modal-card {
    background: #ffffff !important;
}
[data-theme="light"] .auth-card {
    background: #ffffff !important;
}
[data-theme="light"] .settings-tg-btn {
    background: #2b5278 !important;
}

/* ============================================================
   TELEGRAM-STYLE REDESIGN
   ============================================================ */

/* Убираем все остаточные glows и shadows */
* { text-shadow: none !important; }
.unread-badge { box-shadow: none !important; }
.primary-btn { box-shadow: none !important; }
.auth-card { box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important; }
.send-btn { box-shadow: none !important; }

/* Body — чистый фон без градиентного шума */
body { background: var(--bg-gradient) !important; }
body::before, body::after { display: none !important; }

/* Sidebar — чистый без размытия */
.sidebar {
    background: var(--glass-sidebar) !important;
    border-right: 1px solid var(--border) !important;
}

/* Header */
.chat-header {
    background: var(--glass-header) !important;
    border-bottom: 1px solid var(--border) !important;
}

/* Auth card — без лишних украшений */
.auth-card {
    background: var(--glass-sidebar) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
}
.auth-card::before { display: none !important; }

/* Сообщения */
.message-bubble {
    border: none !important;
    box-shadow: none !important;
}

/* Input area */
.input-area {
    background: var(--glass-header) !important;
    border-top: 1px solid var(--border) !important;
}
#messageInput {
    background: var(--glass-input) !important;
    border: 1px solid transparent !important;
    border-radius: 20px !important;
}
#messageInput:focus { border-color: var(--accent) !important; }

/* Send btn — круглый */
.send-btn {
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Emoji и attach кнопки — SVG стиль */
.emoji-toggle-btn {
    font-size: 0 !important;
    color: var(--text-secondary);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.emoji-toggle-btn:hover { color: var(--accent); }
.image-upload-btn {
    font-size: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Settings tab btn — SVG вместо ⚙️ */
.settings-tab-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 8px !important;
}
.settings-tab-btn svg { display: block; }

/* Context menu — без излишеств */
.msg-context-menu {
    background: var(--dropdown-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 4px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35) !important;
}
.msg-menu-btn {
    padding: 8px 12px !important;
    border-radius: 7px !important;
    font-size: 13px !important;
}
.msg-menu-icon { font-size: 0 !important; display: flex !important; align-items: center !important; }

/* Убираем separator между menu items */
.msg-menu-separator {
    height: 1px;
    background: var(--border);
    margin: 3px 8px;
}

/* Модалки — без лишних теней */
.modal-card {
    background: var(--glass-sidebar) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4) !important;
}

/* Кнопки — чистые */
.primary-btn:hover { opacity: 0.88 !important; transform: none !important; }
.secondary-btn:hover { transform: none !important; }

/* Settings section title — без эмодзи, чистый uppercase */
.settings-section-title {
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.08em !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase !important;
    margin-bottom: 8px !important;
}

/* Telegram btn */
.settings-tg-btn {
    background: #2ca5e0 !important;
    border: none !important;
}
.settings-tg-btn:hover { background: #1a8fc7 !important; }

/* Online dot — без glow */
.online-dot { box-shadow: none !important; }

/* User item active */
.active-chat {
    background: var(--accent-dim) !important;
    border-left: 2px solid var(--accent) !important;
    border-radius: 0 8px 8px 0 !important;
}

/* Reaction picker */
.reaction-picker {
    background: var(--dropdown-bg) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
}

/* No chat selected */
.no-chat-selected { background: var(--bg-gradient) !important; }

/* Chat dropdown */
.chat-dropdown {
    background: var(--dropdown-bg) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35) !important;
    border: 1px solid var(--border) !important;
}

/* ============================================================
   FORWARD PANEL (TG-style)
   ============================================================ */
.forward-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 280px;
    background: var(--glass-sidebar);
    border-left: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
.forward-panel.open { transform: translateX(0); }

.forward-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.forward-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}
.forward-panel-close:hover { color: var(--text-primary); background: var(--glass-hover); }

.forward-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.forward-friend-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    text-align: left;
    transition: background 0.12s;
}
.forward-friend-btn:hover { background: var(--glass-hover); }

.forward-friend-avatar {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.forward-overlay {
    position: absolute;
    inset: 0;
    z-index: 199;
}

/* Forwarded message header */
.forwarded-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 5px;
    opacity: 0.85;
}
.forwarded-header svg { flex-shrink: 0; }
.forwarded-header b { font-weight: 600; }

/* ===== Voice recording ===== */
.vwave {
    display: inline-block;
    width: 3px;
    background: var(--danger, #f36a6a);
    border-radius: 2px;
    animation: vwave-idle 1s ease-in-out infinite;
}
.vwave:nth-child(1) { animation-delay: 0s;    height: 8px; }
.vwave:nth-child(2) { animation-delay: 0.15s; height: 14px; }
.vwave:nth-child(3) { animation-delay: 0.3s;  height: 20px; }
.vwave:nth-child(4) { animation-delay: 0.15s; height: 14px; }
.vwave:nth-child(5) { animation-delay: 0s;    height: 8px; }
@keyframes vwave-idle {
    0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
    50%       { transform: scaleY(1);   opacity: 1; }
}
#voiceBtn.recording {
    background: var(--danger, #f36a6a) !important;
    animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
    0%, 100% { box-shadow: 0 0 0 0 rgba(243,106,106,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(243,106,106,0); }
}

/* ===== Voice Player ===== */
.voice-player {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 220px;
    padding: 0;
    background: none;
}
.vp-play {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent, #6ab0f3);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.vp-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.vp-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}
.vp-progress {
    height: 100%;
    width: 0%;
    background: var(--accent, #6ab0f3);
    border-radius: 2px;
    pointer-events: none;
}
.vp-time {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== Sidebar top bar ===== */
.sidebar-top-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 6px;
}
.burger-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.burger-btn:hover { background: var(--glass-card); }
#sidebarSearch {
    flex: 1;
    background: var(--glass-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}
.burger-dropdown {
    position: absolute;
    top: 52px;
    left: 8px;
    width: 240px;
    background: var(--glass-sidebar);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    z-index: 999;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.burger-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 8px;
}
.burger-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--glass-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.burger-profile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.burger-username {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}
.burger-status {
    font-size: 12px;
    color: var(--accent);
}
.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.burger-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 6px 0;
}
.burger-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.burger-item:hover { background: var(--glass-card); }
.burger-item.danger { color: var(--danger, #f36a6a); }


/* ===== Settings overlay (TG-стиль) ===== */
.settings-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 500;
    pointer-events: none;
}
.settings-overlay-inner {
    position: absolute;
    top: 0; left: 0;
    width: 320px;
    height: 100%;
    background: var(--bg-sidebar, var(--glass-sidebar));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    pointer-events: all;
    overflow-y: auto;
}
.settings-overlay.open { pointer-events: all; }
.settings-overlay.open .settings-overlay-inner {
    transform: translateX(0);
}
.settings-overlay-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}
.settings-back-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}
.settings-profile-block {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
}
.settings-profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--glass-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    flex-shrink: 0;
    overflow: hidden;
}
.settings-profile-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.settings-overlay-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

/* backBtn только на мобильном */
.mobile-only { display: none !important; }
@media (max-width: 768px) {
    .mobile-only { display: flex !important; }
}

/* ============================================================
   CHANNELS
   ============================================================ */
.channel-list-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.channel-create-btn {
    width: 100%;
    font-size: 13px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}
.channel-item:hover { background: var(--glass-hover); }

.channel-avatar {
    font-size: 22px;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(85,136,204,0.12);
    border: 1px solid rgba(85,136,204,0.2);
    border-radius: 12px;
    transition: background 0.15s;
}
.channel-item:hover .channel-avatar {
    background: rgba(85,136,204,0.18);
}
.channel-info { flex: 1; min-width: 0; }
.channel-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s;
}
.channel-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.channel-meta { flex-shrink: 0; }
.channel-subs {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 7px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Channel modal */
#channelViewModal {
    align-items: stretch !important;
    padding: 0 !important;
}
.channel-modal {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    margin: 0 !important;
}
.channel-view-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}
/* Post editor */
.post-editor {
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 16px;
}
.post-editor textarea {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    box-sizing: border-box;
}

/* Post card */
.channel-posts-list { display: flex; flex-direction: column; gap: 16px; }

.channel-post {
    margin-bottom: 12px;
    width: fit-content;
    max-width: 520px;
}
.post-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 520px;
}
.post-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: fit-content;
    max-width: 100%;
}
.post-bubble {
    background: var(--glass-message-other);
    border: 1px solid var(--border);
    border-radius: 4px 18px 0 0;
    padding: 10px 14px 8px;
    max-width: 520px;
    width: fit-content;
    min-width: 180px;
    box-sizing: border-box;
    word-break: break-word;
}
.post-bubble-image {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    display: block;
}
.post-bubble-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    margin-bottom: 4px;
}
.post-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.post-bubble-footer .post-reactions {
    padding: 0;
    flex: 1;
}
.post-bubble-views {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text-muted);
}
.post-bubble-time {
    font-size: 11px;
    color: var(--text-muted);
}
.post-comment-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 7px 14px;
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 14px 14px;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
.post-comment-bar:hover {
    background: rgba(255,255,255,0.09);
    color: var(--text-primary);
}
.post-comment-bar svg { flex-shrink: 0; }

.post-comment-bar svg { flex-shrink: 0; }
.post-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 4px 0 2px;
    max-width: 520px;
    margin: 0 auto;
}

/* Comments */
.comment-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }
.comment-avatar {
    font-size: 20px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-input);
    border-radius: 50%;
}
.comment-body { flex: 1; min-width: 0; }
.comment-author {
    font-size: 12px;
    font-weight: 600;
    margin-right: 6px;
}
.comment-text {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
}

/* ============================================================
   CHANNELS TG-STYLE SPLIT VIEW
   ============================================================ */
/* Channel tab - normal list in sidebar */
#channels-tab {
    overflow-y: auto;
}
.channel-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.channel-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.channel-view-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--glass-header);
    flex-shrink: 0;
}
.channel-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: var(--glass-input);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.channel-action-btn:hover { background: var(--glass-hover); color: var(--text-primary); }
.channel-action-btn.danger:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

.channel-posts-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

/* Active channel item */
.channel-item.active-channel {
    background: var(--accent-dim, rgba(106,176,243,0.12));
    border-left: 2px solid var(--accent);
}

/* Post reactions */
.post-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 4px 0 2px;
}
.post-reaction-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--glass-input);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background 0.12s;
}
.post-reaction-pill.mine {
    background: var(--accent-dim, rgba(106,176,243,0.15));
    border-color: var(--accent);
    color: var(--accent);
}
.post-reaction-pill span { font-size: 12px; }

.post-react-trigger {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.12s;
}

.post-react-trigger:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.post-like-btn:hover { background: rgba(248,113,113,0.12) !important; color: #f87171 !important; }
.post-comment-btn:hover { background: rgba(255,255,255,0.08) !important; color: var(--text-primary) !important; }
.post-delete-btn:hover { background: rgba(239,68,68,0.12) !important; color: #ef4444 !important; }

.post-reaction-picker {
    position: fixed;
    background: #1e1e2e;
    border: 1px solid var(--border-strong);
    border-radius: 28px;
    padding: 8px 12px;
    display: flex;
    gap: 2px;
    z-index: 9999;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.post-reaction-picker button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px;
    transition: background 0.1s, transform 0.1s;
}
.post-reaction-picker button:hover { background: var(--glass-hover); transform: scale(1.2); }

/* Post meta */
.post-delete-btn { display: none; } /* удаление через контекстное меню */

/* Stats modal */
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-primary);
}
.stats-row:last-child { border-bottom: none; }
.stats-row strong { font-size: 18px; font-weight: 700; }

/* Search improvements */
.search-box-wrap {
    display: flex;
    align-items: center;
    gap: 6px;

    border: none;
    border-radius: 10px;
    padding: 6px 10px;
    transition: background 0.15s;
}
.search-box-wrap:focus-within {
    background: rgba(255,255,255,0.09);
}
.search-box-wrap svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    width: 14px;
    height: 14px;
}
.search-box-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
}
.search-box-input::placeholder { color: var(--text-secondary); opacity: 0.7; }

.search-filter-btns {
    display: flex;
    gap: 6px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
    max-height: 0;
    overflow-y: hidden;
    opacity: 0;
    transition: max-height 0.22s ease, opacity 0.18s ease, padding 0.18s ease;
}
.search-filter-btns.visible {
    max-height: 48px;
    opacity: 1;
    padding: 6px 12px 10px;
}
.search-filter-btns::-webkit-scrollbar { display: none; }
.search-filter-btn {
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    text-align: center;
}
.search-filter-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}
.search-filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.search-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 8px 12px 4px;
}
.search-result-item { cursor: pointer; }

/* Responsive channels */
@media (min-width: 600px) {
    .channel-split-left { width: 220px; }
}
@media (max-width: 599px) {
    .channel-split-left { width: 100%; }
    .channel-split-right { display: none; }
    .channel-split-left.hidden { display: none; }
    .channel-split-right.mobile-open { display: flex; width: 100%; }
}

/* Channel view panel in .main */
#channelViewPanel {
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-gradient);
}
#channelViewPanel .channel-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#channelViewPanel .channel-view-header {
    flex-shrink: 0;
}
#channelViewPanel .channel-posts-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

/* ===== Post sender row ===== */
.post-sender-row {
    display: none;
}
.post-channel-avatar {
    font-size: 22px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(85,136,204,0.12);
    border: 1px solid rgba(85,136,204,0.2);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
}
.post-channel-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.channel-name-btn {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    max-width: 200px;
}
.channel-name-btn:hover { text-decoration: underline; }

/* ========== Discord-style Group Profile ========== */
.group-profile-card {
    background: var(--glass-sidebar);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 360px;
    max-width: 90vw;
    max-height: 88vh;
    overflow: visible;
    position: relative;
    display: flex;
    flex-direction: column;
    /* clip children except the avatar-wrap */
    isolation: isolate;
}
.group-profile-card > .gp-scroll {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.gp-scroll {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.gp-banner {
    height: 90px;
    background: linear-gradient(135deg, #5588cc 0%, #7c6eaf 100%);
    border-radius: 20px 20px 0 0;
    position: relative;
    flex-shrink: 0;
    overflow: visible;
}
.gp-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(0,0,0,0.35);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}
.gp-avatar-wrap {
    position: absolute;
    bottom: -40px;
    left: 20px;
    z-index: 2;
}
.gp-avatar {
    width: 80px;
    height: 80px;
    font-size: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary, #1a1a2e);
    border: 4px solid var(--bg-primary, #1a1a2e);
    border-radius: 50%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.gp-info {
    padding: 10px 20px 4px;
}
.gp-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.gp-type {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.gp-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.4;
}
.gp-actions {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    flex-shrink: 0;
}
.gp-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px 8px;
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.gp-action-btn:hover { background: rgba(255,255,255,0.1); }
.gp-action-icon { font-size: 18px; line-height: 1; }
.gp-members-section {
    border-top: 1px solid var(--border);
    padding: 14px 20px 0;
    flex: 1;
}
.gp-members-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.gp-members-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}
.gp-add-member-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}
.gp-add-member-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }
.gp-members-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}
.gp-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 10px;
    transition: background 0.12s;
}
.gp-member-item:hover { background: rgba(255,255,255,0.06); }
.gp-member-avatar {
    width: 36px;
    height: 36px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(85,136,204,0.12);
    border: 2px solid transparent;
    border-radius: 50%;
    flex-shrink: 0;
}
.gp-member-avatar.online { border-color: #3ba55d; }
.gp-member-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.gp-member-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gp-member-status {
    font-size: 11px;
    color: var(--text-secondary);
}
.gp-member-role {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    flex-shrink: 0;
}
.gp-member-role.owner {
    background: rgba(250,166,26,0.15);
    color: #faa61a;
    border: 1px solid rgba(250,166,26,0.3);
}

/* Group settings textarea */
#gsDescInput {
    min-height: 70px;
}

/* ========== Channel posts area themes ========== */
[data-theme="dark"] .channel-posts-area {
    background: radial-gradient(ellipse 80% 50% at 50% 100%, rgba(108,143,255,0.06) 0%, transparent 65%), #0d0d12;
}
[data-theme="aurora"] .channel-posts-area {
    background:
        radial-gradient(ellipse 80% 55% at 50% 0%, rgba(167,139,250,0.12) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(34,211,238,0.08) 0%, transparent 55%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ccircle cx='20' cy='30' r='1' fill='white' fill-opacity='0.06'/%3E%3Ccircle cx='80' cy='10' r='0.8' fill='white' fill-opacity='0.08'/%3E%3Ccircle cx='170' cy='20' r='0.7' fill='%23a78bfa' fill-opacity='0.12'/%3E%3Ccircle cx='50' cy='80' r='0.9' fill='%2322d3ee' fill-opacity='0.10'/%3E%3Ccircle cx='190' cy='100' r='0.8' fill='white' fill-opacity='0.07'/%3E%3Ccircle cx='30' cy='160' r='1.1' fill='%23a78bfa' fill-opacity='0.09'/%3E%3C/svg%3E"),
        #0a0c18;
}
[data-theme="ember"] .channel-posts-area {
    background:
        radial-gradient(ellipse 70% 50% at 50% 100%, rgba(245,158,11,0.09) 0%, transparent 65%),
        #100a04;
}
[data-theme="forest"] .channel-posts-area {
    background:
        radial-gradient(ellipse 80% 55% at 20% 80%, rgba(52,211,153,0.09) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 20%, rgba(52,211,153,0.06) 0%, transparent 55%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M10 60 Q30 20 50 60 Q70 100 90 60 Q110 20 130 60' stroke='%2334d399' stroke-width='0.5' fill='none' stroke-opacity='0.06'/%3E%3Cpath d='M0 90 Q20 50 40 90 Q60 130 80 90 Q100 50 120 90' stroke='%2334d399' stroke-width='0.5' fill='none' stroke-opacity='0.04'/%3E%3C/svg%3E"),
        #050e08;
}
[data-theme="rose"] .channel-posts-area {
    background:
        radial-gradient(ellipse 70% 45% at 70% 0%, rgba(244,114,182,0.09) 0%, transparent 60%),
        #110810;
}
[data-theme="light"] .channel-posts-area {
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%233b72e8' fill-opacity='0.04' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E"), #eef1f8;
}

/* ========== Slide-in анимации сообщений ========== */
@keyframes msgSlideInOther {
    from { opacity: 0; transform: translateX(-18px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes msgSlideInOwn {
    from { opacity: 0; transform: translateX(18px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
.message.other.animate-in {
    animation: msgSlideInOther 0.22s cubic-bezier(0.34,1.26,0.64,1) both;
}
.message.own.animate-in {
    animation: msgSlideInOwn 0.22s cubic-bezier(0.34,1.26,0.64,1) both;
}

/* ========== Chat header subtitle (online/lastSeen) ========== */
.chat-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.chat-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.chat-subtitle {
    font-size: 11.5px;
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    transition: color 0.2s;
}
.chat-subtitle.online {
    color: var(--accent);
    font-weight: 500;
}

/* ========== @Mention highlight ========== */
.mention {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-dim);
    border-radius: 4px;
    padding: 0 3px;
    cursor: pointer;
    transition: background 0.15s;
}
.mention:hover { background: var(--accent-glow); }
.mention-self {
    color: #fff;
    background: var(--accent);
    border-radius: 4px;
    padding: 0 3px;
    font-weight: 700;
}

/* ========== Плавные анимации модалов ========== */
.modal-overlay {
    transition: opacity 0.18s ease;
}
.modal-overlay:not(.open) { opacity: 0; pointer-events: none; }
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-card {
    transition: transform 0.22s cubic-bezier(0.34,1.1,0.64,1), opacity 0.18s ease;
    transform: scale(0.96) translateY(8px);
    opacity: 0;
}
.modal-overlay.open .modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Плавное открытие группового профиля */
.group-profile-card {
    transition: transform 0.22s cubic-bezier(0.34,1.1,0.64,1), opacity 0.18s ease;
}
.modal-overlay:not(.open) .group-profile-card {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
}
.modal-overlay.open .group-profile-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Плавная смена вкладок */
.tab-content {
    transition: opacity 0.15s ease;
}

/* Hover на user-item */
.user-item {
    transition: background 0.12s ease, transform 0.1s ease;
}
.user-item:active { transform: scale(0.98); }

/* Кнопки */
.gp-action-btn {
    transition: background 0.15s, transform 0.12s;
}
.gp-action-btn:active { transform: scale(0.94); }

.primary-btn, .secondary-btn {
    transition: opacity 0.15s, transform 0.12s, background 0.15s !important;
}
.primary-btn:active, .secondary-btn:active { transform: scale(0.97) !important; }

/* Typing indicator pulse */
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}
.typing-dots span {
    animation: typingBounce 1.2s infinite;
    display: inline-block;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    margin: 0 1.5px;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Mention уведомление — подсветка своего имени */
.message.mention-highlight .message-bubble {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent-dim);
}

/* ========== Mobile theme backgrounds (force apply on ALL screen sizes) ========== */
@media (max-width: 768px) {
    /* Apply theme bg to .main itself so fixed positioning doesn't break it */
    [data-theme="dark"] .main,
    [data-theme="dark"] .messages { background: #0d0d12 !important; }
    [data-theme="aurora"] .main,
    [data-theme="aurora"] .messages { background: #0a0c18 !important; }
    [data-theme="ember"] .main,
    [data-theme="ember"] .messages { background: #100a04 !important; }
    [data-theme="forest"] .main,
    [data-theme="forest"] .messages { background: #050e08 !important; }
    [data-theme="rose"] .main,
    [data-theme="rose"] .messages { background: #110810 !important; }
    [data-theme="light"] .main,
    [data-theme="light"] .messages { background: #eef1f8 !important; }

    /* Gradient overlays only on messages */
    [data-theme="dark"] .messages { background: radial-gradient(ellipse 100% 60% at 50% 100%, rgba(108,143,255,0.10) 0%, transparent 65%), #0d0d12 !important; }
    [data-theme="aurora"] .messages { background: radial-gradient(ellipse 100% 60% at 50% 0%, rgba(167,139,250,0.18) 0%, transparent 55%), radial-gradient(ellipse 80% 50% at 100% 100%, rgba(34,211,238,0.12) 0%, transparent 55%), #0a0c18 !important; }
    [data-theme="ember"] .messages { background: radial-gradient(ellipse 100% 60% at 50% 100%, rgba(245,158,11,0.15) 0%, transparent 60%), #100a04 !important; }
    [data-theme="forest"] .messages { background: radial-gradient(ellipse 100% 60% at 20% 80%, rgba(52,211,153,0.15) 0%, transparent 55%), radial-gradient(ellipse 80% 40% at 80% 20%, rgba(52,211,153,0.10) 0%, transparent 50%), #050e08 !important; }
    [data-theme="rose"] .messages { background: radial-gradient(ellipse 100% 60% at 70% 0%, rgba(244,114,182,0.16) 0%, transparent 55%), #110810 !important; }
    [data-theme="light"] .messages { background: #eef1f8 !important; }
    
    [data-theme="dark"] .channel-posts-area { background: radial-gradient(ellipse 80% 50% at 50% 100%, rgba(108,143,255,0.06) 0%, transparent 65%), #0d0d12 !important; }
    [data-theme="aurora"] .channel-posts-area { background: radial-gradient(ellipse 80% 55% at 50% 0%, rgba(167,139,250,0.12) 0%, transparent 55%), #0a0c18 !important; }
    [data-theme="ember"] .channel-posts-area { background: radial-gradient(ellipse 70% 50% at 50% 100%, rgba(245,158,11,0.09) 0%, transparent 65%), #100a04 !important; }
    [data-theme="forest"] .channel-posts-area { background: radial-gradient(ellipse 80% 55% at 20% 80%, rgba(52,211,153,0.09) 0%, transparent 60%), #050e08 !important; }
    [data-theme="rose"] .channel-posts-area { background: radial-gradient(ellipse 70% 45% at 70% 0%, rgba(244,114,182,0.09) 0%, transparent 60%), #110810 !important; }
    [data-theme="light"] .channel-posts-area { background: #eef1f8 !important; }
}

/* ========== Chat open animation ========== */
@keyframes chatSlideIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}
.main.chat-opening {
    animation: chatSlideIn 0.22s cubic-bezier(0.22,1,0.36,1) both;
}

/* ========== Channel posts area missing themes ========== */
.channel-posts-area {
    background: var(--bg-gradient);
}

/* ═══════════════════════════════════════════════════
   TYPOGRAPHY PREMIUM OVERHAUL
═══════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --font: 'Inter', 'DM Sans', -apple-system, sans-serif;
    --fs-xs:   11px;
    --fs-sm:   12px;
    --fs-base: 13.5px;
    --fs-md:   14px;
    --fs-lg:   16px;
    --fs-xl:   18px;
    --fs-2xl:  22px;
    --fw-regular: 400;
    --fw-medium:  500;
    --fw-semi:    600;
    --fw-bold:    700;
    --lh-tight:  1.3;
    --lh-normal: 1.5;
    --lh-loose:  1.65;
}

body { font-size: var(--fs-base); line-height: var(--lh-normal); letter-spacing: -0.01em; }

/* Message text */
.message-text { font-size: var(--fs-md); line-height: var(--lh-loose); }

/* Chat title */
.chat-title { font-size: var(--fs-lg); font-weight: var(--fw-semi); letter-spacing: -0.02em; }

/* Sidebar names */
.user-item-name, .group-name, .channel-name { font-weight: var(--fw-medium); font-size: var(--fs-base); }

/* Timestamps */
.msg-time, .post-meta-time, .post-bubble-time { font-size: var(--fs-xs); letter-spacing: 0.02em; }

/* Section headers */
.settings-section-title, .group-profile-section-title, .cp-section-title {
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Input fields */
input, textarea, .modal-input {
    font-size: var(--fs-md) !important;
    letter-spacing: -0.01em;
}

/* Buttons */
.primary-btn, .secondary-btn {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    letter-spacing: 0.01em;
}

/* ═══════════════════════════════════════════════════
   PREMIUM ANIMATIONS
═══════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

/* Chat open animation */
.chat-area-animate { animation: fadeSlideUp 0.22s ease forwards; }

/* Message appear */
.message { animation: fadeSlideUp 0.18s ease forwards; }

/* Modal cards */
.modal-card { animation: scaleIn 0.2s cubic-bezier(0.34,1.2,0.64,1) forwards; }

/* Sidebar items */
.friend-item, .group-item, .channel-item {
    transition: background 0.15s ease, transform 0.1s ease;
}
.friend-item:hover, .group-item:hover, .channel-item:hover {
    transform: translateX(2px);
}

/* Send button pulse on active */
.send-btn:active { transform: scale(0.9); }

/* Primary button */
.primary-btn {
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(85,136,204,0.35); }
.primary-btn:active { transform: translateY(0) scale(0.97); }

/* ═══════════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════════ */
.skeleton-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    animation: fadeIn 0.3s ease;
}
.skeleton-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s infinite linear;
}
.skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.skeleton-line {
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s infinite linear;
}
.skeleton-line.w70 { width: 70%; }
.skeleton-line.w45 { width: 45%; animation-delay: 0.15s; }
.skeleton-line.w55 { width: 55%; }
.skeleton-line.w30 { width: 30%; animation-delay: 0.1s; }

/* ═══════════════════════════════════════════════════
   ONBOARDING
═══════════════════════════════════════════════════ */
.onboarding-card {
    background: var(--glass-card);
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    width: 380px;
    max-width: 92vw;
    padding: 36px 32px 28px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    opacity: 0;
    transform: scale(0.92) translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.2,0.64,1);
}
.onboarding-steps { position: relative; min-height: 180px; }
.onboarding-step {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeSlideUp 0.25s ease forwards;
}
.onboarding-step.active { display: flex; }
.onboarding-icon {
    font-size: 56px;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}
.onboarding-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    margin: 0 0 10px;
    letter-spacing: -0.03em;
}
.onboarding-desc {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: var(--lh-loose);
    margin: 0;
}
.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 24px 0 20px;
}
.onboarding-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-strong);
    transition: all 0.2s ease;
}
.onboarding-dot.active {
    width: 20px;
    border-radius: 3px;
    background: var(--accent);
}
.onboarding-footer {
    display: flex;
    gap: 10px;
}
.onboarding-footer .secondary-btn { flex: 1; }
.onboarding-footer .primary-btn { flex: 2; }

/* ═══════════════════════════════════════════════════
   TOGGLE SWITCH
═══════════════════════════════════════════════════ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--glass-input);
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.2s cubic-bezier(0.34,1.5,0.64,1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ═══════════════════════════════════════════════════
   EMPTY STATES (убрать унылые надписи)
═══════════════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
}
.empty-state-icon { font-size: 42px; opacity: 0.6; }
.empty-state-text { font-size: var(--fs-sm); line-height: var(--lh-loose); max-width: 200px; }

/* ═══════════════════════════════════════════════════
   PREMIUM SCROLLBAR
═══════════════════════════════════════════════════ */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ═══════════════════════════════════════════════════
   PREMIUM DESIGN REFINEMENT
═══════════════════════════════════════════════════ */

/* Inter font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Tighter, crisper base */
body { font-family: var(--font); font-size: 13.5px; -webkit-font-smoothing: antialiased; }

/* Sidebar — thinner, more structured */
.sidebar {
    border-right: 1px solid var(--border) !important;
    background: var(--glass-sidebar) !important;
}

/* Tabs — cleaner underline style */
.tab-btn {
    font-size: 12.5px !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em !important;
    color: var(--text-secondary) !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    transition: color 0.15s, background 0.15s !important;
}
.tab-btn:hover { color: var(--text-primary) !important; background: rgba(255,255,255,0.04) !important; }
.tab-btn.active {
    color: var(--accent) !important;
    background: var(--accent-dim) !important;
    border-bottom: none !important;
}

/* Chat header */
.chat-header {
    background: var(--glass-header) !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 11px 18px !important;
}
.chat-title { font-size: 15px !important; font-weight: 600 !important; letter-spacing: -0.02em !important; }

/* Message bubbles — tighter radius, crisper */
.message-bubble {
    border-radius: 14px !important;
    padding: 8px 12px !important;
    font-size: 13.5px !important;
    line-height: 1.55 !important;
    box-shadow: none !important;
}
.message.own .message-bubble {
    background: var(--glass-message-own) !important;
    border-bottom-right-radius: 3px !important;
}
.message.other .message-bubble {
    background: var(--glass-message-other) !important;
    border-bottom-left-radius: 3px !important;
    border: 1px solid var(--border) !important;
}

/* Message timestamp */
.msg-time {
    font-size: 10.5px !important;
    letter-spacing: 0.02em !important;
    opacity: 0.55 !important;
}

/* Input area */
.input-area {
    background: var(--glass-header) !important;
    border-top: 1px solid var(--border) !important;
    padding: 10px 14px !important;
}
#messageInput {
    background: var(--glass-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    font-size: 13.5px !important;
    padding: 9px 14px !important;
    transition: border-color 0.15s !important;
}
#messageInput:focus { border-color: var(--accent) !important; }

/* Send button — subtle */
.send-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    background: var(--accent) !important;
    box-shadow: none !important;
    transition: background 0.15s, transform 0.1s !important;
}
.send-btn:hover { background: #5a8fd4 !important; }
.send-btn:active { transform: scale(0.93) !important; }

/* Primary button — no gradient, flat */
.primary-btn {
    background: var(--accent) !important;
    border-radius: 9px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    padding: 9px 18px !important;
    box-shadow: none !important;
    transition: background 0.15s, transform 0.1s !important;
}
.primary-btn:hover { background: #5a8fd4 !important; transform: none !important; box-shadow: none !important; }
.primary-btn:active { background: #3d6bb5 !important; transform: scale(0.97) !important; }

/* Secondary button */
.secondary-btn {
    background: var(--glass-input) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 9px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    padding: 9px 16px !important;
}
.secondary-btn:hover { background: rgba(255,255,255,0.08) !important; border-color: rgba(255,255,255,0.15) !important; }

/* Modal cards */
.modal-card {
    background: var(--glass-card) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow-lg) !important;
}
.modal-header {
    border-bottom: 1px solid var(--border) !important;
    padding: 14px 18px !important;
}
.modal-header h3 { font-size: 15px !important; font-weight: 600 !important; letter-spacing: -0.02em !important; }

/* Dropdowns */
.chat-dropdown {
    background: var(--dropdown-bg) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-md) !important;
    padding: 4px !important;
}
.chat-dropdown-item {
    font-size: 13px !important;
    font-weight: 500 !important;
    border-radius: 7px !important;
    padding: 8px 12px !important;
}

/* Context menus */
.msg-context-menu {
    background: var(--dropdown-bg) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-md) !important;
    padding: 4px !important;
}
.msg-menu-btn {
    font-size: 13px !important;
    font-weight: 500 !important;
    border-radius: 7px !important;
    padding: 8px 12px !important;
}

/* Sidebar items — tighter */
.friend-item, .group-item, .channel-item {
    padding: 9px 12px !important;
    margin: 1px 6px !important;
    border-radius: 8px !important;
    transition: background 0.12s !important;
}
.friend-item:hover, .group-item:hover, .channel-item:hover {
    background: rgba(255,255,255,0.04) !important;
    transform: none !important;
}
.friend-item.active-chat, .group-item.active-chat, .channel-item.active-channel {
    background: rgba(77,124,199,0.12) !important;
}
.user-item-name, .group-name, .channel-name {
    font-size: 13.5px !important;
    font-weight: 600 !important;
}
.user-item-status, .group-desc, .channel-subs {
    font-size: 11.5px !important;
    opacity: 0.5 !important;
}

/* Delivered / read status */
.read-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 3px;
    font-weight: 500;
    letter-spacing: -0.5px;
    transition: color 0.2s;
}
.read-status.delivered { color: rgba(240,240,242,0.35); }
.read-status.read { color: var(--accent); }

/* No-chat-selected screen */
.no-chat-selected {
    background: var(--bg-gradient) !important;
}
.no-chat-title { font-size: 22px !important; font-weight: 700 !important; letter-spacing: -0.03em !important; opacity: 0.9 !important; }
.no-chat-subtitle { font-size: 13px !important; opacity: 0.4 !important; }

/* Scrollbar premium */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* Remove childish gradients / glows */
.message-bubble { text-shadow: none !important; }
.primary-btn { text-shadow: none !important; }

/* ========== Polish & Refinements ========== */

/* Sidebar top user bar */
.sidebar-top-bar {
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Friend preview row - time stamp */
.last-msg-time {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
    letter-spacing: 0;
}

/* Better unread badge */
.unread-badge {
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font);
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    letter-spacing: -0.3px;
    line-height: 1.5;
}

/* Message meta - time + read status */
.msg-meta {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 3px;
    justify-content: flex-end;
}
.message-time {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0;
    font-weight: 400;
}
.message.own .message-time { color: rgba(255,255,255,0.45); }

/* Read status tick */
.read-status {
    font-size: 13px;
    color: rgba(255,255,255,0.35);
    line-height: 1;
}
.read-status.read { color: var(--accent); }

/* Group/channel item avatar */
.group-avatar, .channel-avatar {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    flex-shrink: 0;
}

/* Active item indicator - pill instead of border */
.active-chat .group-avatar,
.active-chat .channel-avatar,
.active-chat .user-avatar {
    background: var(--accent-dim);
}

/* Smoother hover for all interactive list items */
.channel-item, .group-item {
    border-radius: 14px;
    margin: 1px 4px;
    padding-left: 8px;
    padding-right: 8px;
}

/* Modal card refinement */
.modal-card {
    border-radius: 20px !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) !important;
}

/* Dropdown menu */
.dropdown-menu {
    border-radius: 16px !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
    overflow: hidden;
}

/* Search box - even cleaner */
.search-box-wrap {
    margin: 8px 12px 4px !important;
    border-radius: 12px !important;
}

/* No-chat screen */
.no-chat-title {
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Reaction buttons */
.reaction-btn {
    border-radius: 20px !important;
    font-size: 13px !important;
    padding: 3px 8px !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    backdrop-filter: blur(8px);
}

/* Send button */
.send-btn {
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

/* Primary button */
.primary-btn {
    border-radius: 12px !important;
    font-weight: 600 !important;
    letter-spacing: -0.1px !important;
}

/* Typing indicator */
.typing-indicator {
    border-radius: 20px !important;
    padding: 6px 14px !important;
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.05) !important;
    font-size: 12px !important;
}

/* ===== Date Separator ===== */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0 8px;
    position: relative;
}
.date-separator span {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.45);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.02em;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.06);
}
[data-theme="light"] .date-separator span {
    background: rgba(0,0,0,0.07);
    color: rgba(0,0,0,0.45);
    border-color: rgba(0,0,0,0.08);
}

/* ===== Mobile emoji panel slide-up ===== */
@media (max-width: 768px) {
    .emoji-picker-panel {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 50vh !important;
        transform: translateY(100%);
        transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
        display: flex !important;
        flex-direction: column;
        z-index: 2000;
    }
    .emoji-picker-panel.open {
        transform: translateY(0);
    }
    .ep-grid { grid-template-columns: repeat(9, 1fr); }
}

/* ===== Avatar Cropper animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Avatar emoji panel inside settings */
#avatarEmojiPanel {
    transition: max-height 0.2s ease, opacity 0.15s ease;
}
#avatarEmojiPanel .ep-body {
    max-height: 160px;
    overflow-y: auto;
}

/* ========== Settings fields ========== */
.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════
   COMMENTS PANEL (TG-style)
═══════════════════════════════════════════════════ */
.cmt-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    transition: background 0.12s;
}
.cmt-item:hover { background: rgba(255,255,255,0.03); }

.cmt-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
}

.cmt-body {
    flex: 1;
    min-width: 0;
    background: var(--glass-input);
    border: 1px solid var(--border);
    border-radius: 4px 14px 14px 14px;
    padding: 8px 12px;
}

.cmt-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.cmt-name {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.cmt-time {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-left: auto;
}

.cmt-text {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.5;
    word-break: break-word;
}

/* Comments emoji picker positioning */
#commentsEmojiPickerPanel {
    position: absolute;
    bottom: 62px;
    left: 12px;
    z-index: 100;
}