/* ==================== СБРОС И БАЗОВЫЕ СТИЛИ ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Включаем GPU для всех элементов */
.message,
.bubble,
.msg-avatar,
.context-menu,
.dropdown-menu,
.modal,
.modal-content,
.reactions-list,
.reaction-item,
.emoji-animation,
.toast,
.scroll-down-btn,
.pinned-messages-bar,
.search-modal,
.search-modal-content,
.chat-item,
.chats-sidebar,
.profile-header,
.selection-bar,
.audio-message-enhanced,
.media-message,
.file-message,
.poll-message,
.game-message,
.reply-preview,
.date-separator,
.chat-header,
.header-avatar,
.header-info,
.input-area,
.attach-btn,
.emoji-btn,
.voice-btn,
.send-btn,
.header-btn {
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Для контейнеров с прокруткой */
.messages-container,
.chats-list,
.search-results,
.emoji-panel {
    will-change: scroll-position;
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}
body {
    background: #0a0a0c;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app {
    width: 100%;
    height: 100vh;
    max-width: 1920px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

/* ==================== СОХРАНЕННЫЕ СООБЩЕНИЯ ==================== */
.saved-badge {
    font-size: 12px;
    opacity: 0.8;
}

/* ==================== ТЕМЫ (10 цветов) ==================== */
.theme-dark {
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-tertiary: #3a3a3c;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --accent: #9333ea;
    --accent-hover: #a855f7;
    --danger: #ff6b6b;
    --success: #4cd964;
    --warning: #ff9f0a;
    --border: rgba(147, 51, 234, 0.2);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(44, 44, 46, 0.95);
}

.theme-light {
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e5ea;
    --text-primary: #000000;
    --text-secondary: #6c6c70;
    --accent: #9333ea;
    --accent-hover: #a855f7;
    --danger: #ff3b30;
    --success: #34c759;
    --warning: #ff9f0a;
    --border: rgba(147, 51, 234, 0.3);
    --menu-text: rgba(0, 0, 0, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(255, 255, 255, 0.95);
}

.theme-blue {
    --bg-primary: #0a1a2f;
    --bg-secondary: #1a2a3f;
    --bg-tertiary: #2a3a4f;
    --text-primary: #ffffff;
    --text-secondary: #a0b0c0;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(59, 130, 246, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(26, 42, 63, 0.95);
}

.theme-green {
    --bg-primary: #0f2f1f;
    --bg-secondary: #1f3f2f;
    --bg-tertiary: #2f4f3f;
    --text-primary: #ffffff;
    --text-secondary: #a0c0b0;
    --accent: #10b981;
    --accent-hover: #34d399;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(16, 185, 129, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(31, 63, 47, 0.95);
}

.theme-purple {
    --bg-primary: #1f0f2f;
    --bg-secondary: #2f1f3f;
    --bg-tertiary: #3f2f4f;
    --text-primary: #ffffff;
    --text-secondary: #c0a0d0;
    --accent: #a855f7;
    --accent-hover: #c084fc;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(168, 85, 247, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(47, 31, 63, 0.95);
}

.theme-orange {
    --bg-primary: #2f1a0f;
    --bg-secondary: #3f2a1f;
    --bg-tertiary: #4f3a2f;
    --text-primary: #ffffff;
    --text-secondary: #d0b0a0;
    --accent: #f97316;
    --accent-hover: #fb923c;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(249, 115, 22, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(63, 42, 31, 0.95);
}

.theme-pink {
    --bg-primary: #2f0f1f;
    --bg-secondary: #3f1f2f;
    --bg-tertiary: #4f2f3f;
    --text-primary: #ffffff;
    --text-secondary: #d0a0b0;
    --accent: #ec4899;
    --accent-hover: #f472b6;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(236, 72, 153, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(63, 31, 47, 0.95);
}

.theme-cyan {
    --bg-primary: #0f2f2f;
    --bg-secondary: #1f3f3f;
    --bg-tertiary: #2f4f4f;
    --text-primary: #ffffff;
    --text-secondary: #a0d0d0;
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(6, 182, 212, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(31, 63, 63, 0.95);
}

.theme-yellow {
    --bg-primary: #2f2f0f;
    --bg-secondary: #3f3f1f;
    --bg-tertiary: #4f4f2f;
    --text-primary: #ffffff;
    --text-secondary: #d0d0a0;
    --accent: #eab308;
    --accent-hover: #facc15;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(234, 179, 8, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(63, 63, 31, 0.95);
}

.theme-red {
    --bg-primary: #2f0f0f;
    --bg-secondary: #3f1f1f;
    --bg-tertiary: #4f2f2f;
    --text-primary: #ffffff;
    --text-secondary: #d0a0a0;
    --accent: #ef4444;
    --accent-hover: #f87171;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(239, 68, 68, 0.3);
    --menu-text: rgba(255, 255, 255, 0.9);
    --menu-text-hover: #ffffff;
    --menu-bg: rgba(63, 31, 31, 0.95);
}

/* ==================== АНИМИРОВАННЫЙ ФОН ==================== */
.app::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 30% 50%, rgba(147, 51, 234, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 70% 50%, rgba(79, 70, 229, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 30%, rgba(236, 72, 153, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 60% 70%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    animation: rotate 40s linear infinite;
    pointer-events: none;
}

.app::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, transparent 0%, rgba(10, 10, 12, 0.4) 100%);
    pointer-events: none;
}

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

/* ==================== ЭКРАН АВТОРИЗАЦИИ ==================== */
.auth-screen {
    max-width: 380px;
    width: 90%;
    margin: auto;
    padding: 32px 24px;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: fadeInUp 0.5s ease;
    position: relative;
    z-index: 10;
    border: 1px solid var(--border);
    text-align: center;
}

.auth-screen::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(135deg, #9333ea, #4f46e5, #ec4899, #3b82f6);
    border-radius: 25px;
    z-index: -1;
    opacity: 0.3;
    filter: blur(5px);
    animation: borderGlow 3s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% { opacity: 0.3; filter: blur(5px); }
    50% { opacity: 0.6; filter: blur(8px); }
}

.auth-logo {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, #9333ea, #4f46e5, #ec4899, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
    animation: gradientShift 4s ease infinite;
    background-size: 300% 300%;
}

.auth-welcome {
    color: var(--text-primary);
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

.auth-welcome span {
    background: linear-gradient(135deg, #9333ea, #4f46e5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.auth-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 15px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.2);
}

.auth-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    border-radius: 12px;
    padding: 14px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 16px;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(147, 51, 234, 0.3);
}

.auth-switch {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-switch span {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-switch span:hover {
    text-decoration: underline;
}

/* ==================== ОСНОВНОЙ ИНТЕРФЕЙС ==================== */
.main-screen {
    display: none;
    flex: 1;
    height: 100%;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.main-screen.active {
    display: flex;
}

/* Левая панель */
.chats-sidebar {
    width: 280px;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Профиль */
.profile-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s ease;
}

.profile-header:hover {
    background: rgba(147, 51, 234, 0.1);
}

.profile-avatar {
    width: 42px;
    height: 42px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    position: relative;
    border: 2px solid var(--border);
    flex-shrink: 0;
    animation: avatarGlow 3s ease-in-out infinite;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-radius: 50%;
}

.profile-avatar:hover {
    transform: scale(1.05);
}

.profile-avatar::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #9333ea, #4f46e5, #ec4899, #3b82f6);
    z-index: -1;
    opacity: 0.5;
    animation: rotate 4s linear infinite;
    border-radius: 50%;
}

@keyframes avatarGlow {
    0%, 100% { box-shadow: 0 0 10px var(--accent); }
    50% { box-shadow: 0 0 20px var(--accent), 0 0 30px #4f46e5; }
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-status {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    color: var(--danger);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 20px;
    background: rgba(255, 107, 107, 0.1);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.2);
}

/* Поиск */
.search-section {
    padding: 12px 16px;
    position: relative;
}

.search-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.2);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    position: absolute;
    top: 55px;
    left: 16px;
    right: 16px;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 30;
    border: 1px solid var(--border);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.search-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: rgba(147, 51, 234, 0.1);
}

.search-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.search-avatar {
    width: 36px;
    height: 36px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
}

.search-info {
    min-width: 0;
}

.search-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-username {
    color: var(--accent);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.add-btn:hover {
    transform: scale(1.05);
}

.friend-badge {
    color: var(--success);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    background: rgba(76, 217, 100, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(76, 217, 100, 0.2);
}

.blocked-badge {
    color: var(--danger);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 107, 107, 0.2);
}

/* Список чатов */
.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    position: relative;
}

.chat-item:hover {
    background: rgba(147, 51, 234, 0.1);
}

.chat-item.active {
    background: rgba(147, 51, 234, 0.15);
}

.chat-item.pinned {
    border-left: 3px solid var(--accent);
}

.chat-avatar {
    width: 45px;
    height: 45px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    position: relative;
    flex-shrink: 0;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s ease;
    border-radius: 50%;
}

.chat-avatar:hover {
    transform: scale(1.05);
}

/* ==================== УЛУЧШЕННЫЙ ИНДИКАТОР ОНЛАЙН ==================== */
.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4cd964;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    z-index: 5;
    box-shadow: 0 0 5px rgba(76, 217, 100, 0.5);
}

/* Для сообщений */
.msg-avatar .online-indicator {
    width: 8px;
    height: 8px;
    bottom: 0px;
    right: 0px;
    border-width: 1.5px;
}

/* Для списка чатов */
.chat-avatar .online-indicator {
    width: 10px;
    height: 10px;
    bottom: 2px;
    right: 2px;
}

/* Анимация как в Telegram (пульсирующая) */
.online-indicator.pulse {
    animation: tgPulse 2s ease infinite;
}

@keyframes tgPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(76, 217, 100, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0);
    }
}

/* Для сообщений - чуть меньше пульсация */
.msg-avatar .online-indicator.pulse {
    animation: tgPulseSmall 2s ease infinite;
}

@keyframes tgPulseSmall {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7);
    }
    70% {
        box-shadow: 0 0 0 4px rgba(76, 217, 100, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0);
    }
}

/* Для каналов - скрываем индикатор */
.chat-avatar.channel .online-indicator,
.header-avatar.channel .online-indicator {
    display: none;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    color: var(--text-secondary);
    font-size: 10px;
}

.chat-last-msg {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-badge {
    background: var(--accent);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    flex-shrink: 0;
    /* Убираем всё что связано с текстом/цифрами */
    padding: 0;
    min-width: 0;
    font-size: 0;
    color: transparent;
}

/* Правая панель */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    backdrop-filter: blur(10px);
    min-width: 0;
    position: relative; 
    overflow: hidden;   
}

/* Шапка чата */
.chat-header {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.header-avatar {
    width: 42px;
    height: 42px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 17px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
    border-radius: 50%;
}

.header-avatar:hover {
    transform: scale(1.05);
}

.header-info {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.header-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status.online {
    color: var(--success);
}

.header-actions {
    display: flex;
    gap: 8px;
    position: relative;
}

.header-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.header-btn:hover {
    background: rgba(147, 51, 234, 0.2);
    border-color: var(--accent);
}

/* Выпадающее меню */
.dropdown-menu {
    position: absolute;
    top: 45px;
    right: 0;
    background: var(--menu-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 6px 0;
    min-width: 200px;
    z-index: 50;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(147, 51, 234, 0.3);
}

.dropdown-menu.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.dropdown-item {
    padding: 10px 16px;
    color: var(--menu-text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 0 5px currentColor;
}

.dropdown-item:hover {
    background: var(--accent);
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: var(--danger);
    color: white;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* Контекстное меню (ПКМ) */
.context-menu {
    position: fixed;
    background: var(--menu-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 260px;
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent), 0 0 60px var(--accent);
    animation: fadeIn 0.15s ease;
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.context-menu-item {
    padding: 12px 18px;
    color: var(--menu-text);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    text-shadow: 0 0 8px var(--accent);
}

.context-menu-item:hover {
    background: var(--accent);
    color: white;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

.context-menu-item.danger {
    color: var(--danger);
    text-shadow: 0 0 8px var(--danger);
}

.context-menu-item.danger:hover {
    background: var(--danger);
    color: white;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.reactions-menu {
    display: flex;
    justify-content: space-around;
    padding: 10px 18px;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin: 4px 8px;
}

.reaction-option {
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 6px;
    border-radius: 50%;
    filter: drop-shadow(0 0 5px currentColor);
}

.reaction-option:hover {
    transform: scale(1.3);
    filter: drop-shadow(0 0 10px var(--accent));
    background: rgba(147, 51, 234, 0.2);
}

/* Контейнер сообщений */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-top: 70px !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-primary);
    background-image: var(--chat-wallpaper, none);
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: local;
    transition: opacity 0.1s ease;
    will-change: scroll-position;
    scroll-behavior: auto !important;
}
.messages-container.no-pinned {
    padding-top: 16px !important;  /* ← ДОБАВИТЬ ЭТО */
}
/* Сообщения */
.message {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 60%;
    animation: messageIn 0.2s ease;
    position: relative;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.pinned {
    position: relative;
    background: linear-gradient(90deg, transparent, rgba(147, 51, 234, 0.08), transparent);
    border-left: 3px solid var(--accent);
    transition: all 0.3s ease;
    border-radius: 12px;
    margin: 2px 0;
}

/* Анимация появления бейджа */
.pinned-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.8;
    animation: pinAppear 0.3s ease;
}

@keyframes pinAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 0.8;
        transform: scale(1);
    }
}

/* Плавное удаление закрепления */
.message.pinned.removing {
    animation: pinRemove 0.3s ease forwards;
}

@keyframes pinRemove {
    to {
        opacity: 0;
        transform: translateX(-10px);
    }
}

/* Для своих сообщений - чуть другой оттенок */
.message.own.pinned {
    background: linear-gradient(90deg, transparent, rgba(147, 51, 234, 0.15), transparent);
}

.message.edited::after {
    content: 'ред.';
    font-size: 9px;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* ==================== УЛУЧШЕННЫЙ ОТВЕТ - КАК В TELEGRAM ==================== */
.reply-to {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(147, 51, 234, 0.15); /* СВЕТЛО-ФИОЛЕТОВЫЙ для чужих */
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(2px);
}

.reply-to:hover {
    background: rgba(147, 51, 234, 0.25);
}

.reply-icon {
    font-size: 12px;
    color: var(--text-primary);
    opacity: 0.9;
}

.reply-sender {
    font-weight: 600;
    color: var(--text-primary);
    opacity: 0.9;
}

.reply-message {
    color: var(--text-primary);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ДЛЯ СВОИХ СООБЩЕНИЙ - ЕДИНЫЙ СТИЛЬ (как в Telegram) */
.message.own .reply-to {
    background: rgba(255, 255, 255, 0.15); /* Полупрозрачный белый */
    border-left-color: rgba(255, 255, 255, 0.8); /* Светлая граница */
    backdrop-filter: blur(4px); /* Чуть сильнее размытие для эффекта стекла */
}

.message.own .reply-to:hover {
    background: rgba(255, 255, 255, 0.25); /* Чуть ярче при наведении */
}

.message.own .reply-icon,
.message.own .reply-sender,
.message.own .reply-message {
    color: #ffffff; /* Чисто белый текст */
    opacity: 1;
}

.message.own .reply-message {
    opacity: 0.9;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
    border-radius: 50%;
}

.msg-avatar:hover {
    transform: scale(1.1);
}

.bubble {
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.4;
    max-width: 100%;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.bubble br {
    display: block;
    margin: 4px 0;
    content: "";
}
.message.own .bubble {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
    color: white;
}

.msg-time {
    font-size: 9px;
    margin-top: 4px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* Для чужих сообщений — СЕРЫЙ текст (видно на белой теме) */
.message:not(.own) .msg-time {
    color: var(--text-secondary) !important;
}

/* Для своих сообщений — полупрозрачный белый */
.message.own .msg-time {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Реакции */
.reactions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.reaction-item {
    background: rgba(147, 51, 234, 0.1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    will-change: transform, opacity, background;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.reaction-item:hover {
    background: rgba(147, 51, 234, 0.2);
    transform: scale(1.05);
}

.reaction-item.active {
    background: var(--accent);
    color: white;
}

.reaction-count {
    font-size: 11px;
    font-weight: 600;
}

/* Анимации для эмодзи */
.emoji-animation {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    animation: emojiFloat 2s ease-out forwards;
    font-size: 50px;
}

@keyframes emojiFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-120px) scale(2);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 12px;
    height: 12px;
    background: var(--accent);
    animation: confettiFall 3s linear forwards;
    z-index: 10000;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.rain-drop {
    position: fixed;
    width: 3px;
    height: 25px;
    background: linear-gradient(transparent, var(--accent));
    animation: rain 1s linear infinite;
    z-index: 10000;
}

@keyframes rain {
    0% {
        transform: translateY(-100vh);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

.heart {
    position: fixed;
    color: #ff4d4d;
    font-size: 25px;
    animation: heartFloat 1.5s ease-out forwards;
    z-index: 10000;
}

@keyframes heartFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-120px) scale(2);
        opacity: 0;
    }
}

.win-line {
    position: absolute;
    height: 5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover), gold);
    border-radius: 3px;
    box-shadow: 0 0 25px gold;
    z-index: 5;
    animation: winPulse 0.5s ease infinite;
}

@keyframes winPulse {
    0%, 100% { opacity: 0.8; transform: scaleY(1); }
    50% { opacity: 1; transform: scaleY(1.5); }
}

.trophy {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 100px;
    animation: trophySpin 1s ease;
    z-index: 10001;
    pointer-events: none;
}

@keyframes trophySpin {
    0% { transform: translate(-50%, -50%) rotate(0deg) scale(0); }
    50% { transform: translate(-50%, -50%) rotate(180deg) scale(1.5); }
    100% { transform: translate(-50%, -50%) rotate(360deg) scale(1); }
}

.star {
    position: fixed;
    color: gold;
    font-size: 25px;
    animation: starTwinkle 1s ease-out forwards;
    z-index: 10001;
    pointer-events: none;
}

@keyframes starTwinkle {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    100% { transform: scale(2) rotate(360deg); opacity: 0; }
}

.dice-animation {
    position: fixed;
    font-size: 70px;
    animation: diceSpin 1s ease-out forwards;
    z-index: 10000;
    pointer-events: none;
}

@keyframes diceSpin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) rotate(360deg) scale(1.5);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) rotate(720deg) scale(2);
        opacity: 0;
    }
}

/* Эмодзи-сообщения */
.emoji-message {
    font-size: 60px;
    line-height: 1;
    text-align: center;
    padding: 8px;
    animation: emojiPop 0.3s ease;
    white-space: pre-wrap;
}

@keyframes emojiPop {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Фото */
.message-image {
    max-width: 250px;
    max-height: 250px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

/* Файлы */
.file-message {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
}

.file-icon {
    font-size: 24px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.file-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.file-download {
    color: var(--accent);
    cursor: pointer;
    font-size: 18px;
}

/* Аудио сообщения */
.audio-message {
    background: var(--bg-tertiary);
    border-radius: 25px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-message:hover {
    border-color: var(--accent);
}

.audio-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

.audio-play-btn.playing {
    animation: pulse 1s ease infinite;
}

.audio-wave-container {
    flex: 1;
    height: 28px;
    position: relative;
    cursor: pointer;
}

.audio-wave-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 14px;
}

.audio-wave-progress {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 14px;
    transition: width 0.1s linear;
    pointer-events: none;
}

.audio-time {
    color: var(--text-secondary);
    font-size: 11px;
    min-width: 40px;
    text-align: right;
    font-weight: 500;
}

.audio-speed {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 14px;
    padding: 3px 6px;
    font-size: 9px;
    cursor: pointer;
}

/* Опросы */
.poll-message {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    min-width: 240px;
}

.poll-question {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.poll-option {
    margin-bottom: 8px;
}

.poll-option-text {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.poll-bar-bg {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.poll-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Игры */
.game-message {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.game-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
    position: relative;
}

.game-cell {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: var(--text-primary);
    border-radius: 8px;
}

.game-cell:hover {
    background: rgba(147, 51, 234, 0.1);
    transform: scale(1.05);
}

.game-cell.winner {
    background: linear-gradient(135deg, gold, orange);
    color: white;
    animation: winnerPulse 0.5s ease infinite;
}

@keyframes winnerPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px gold; }
    50% { transform: scale(1.1); box-shadow: 0 0 30px gold; }
}

.game-cell.winner::after {
    content: '👑';
    position: absolute;
    top: -12px;
    right: -12px;
    font-size: 18px;
    animation: crownFloat 1s ease infinite;
}

@keyframes crownFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Кубик */
.dice-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dice-message:hover {
    border-color: var(--accent);
}

.dice-emoji {
    font-size: 36px;
    animation: diceRoll 0.5s ease;
}

@keyframes diceRoll {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
    100% { transform: rotate(360deg); }
}

.dice-number {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Закрепленные сообщения - НЕОНОВЫЙ СТИЛЬ */
.pinned-messages-bar {
    position: absolute !important;          
    top: 70px !important;                   
    left: 50% !important;                   
    transform: translateX(-50%) !important; 
    width: calc(100% - 24px) !important;    
    z-index: 15 !important;                 
    margin: 0 !important;
    background: linear-gradient(135deg, 
        rgba(123, 25, 214, 0.5) 0%, 
        rgba(79, 70, 229, 0.5) 100%);
    border: 1px solid var(--accent);
    border-radius: 12px;
    margin: 8px 12px;
    padding: 10px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.pinned-messages-bar::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(90deg, 
        var(--accent), 
        #ff00ff, 
        var(--accent));
    border-radius: 13px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.pinned-messages-bar:hover::before {
    opacity: 0.5;
    animation: borderRotate 3s linear infinite;
}

.pinned-messages-bar:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(147, 51, 234, 0.5), 0 0 20px var(--accent);
}

.pinned-icon {
    color: var(--accent);
    flex-shrink: 0;
    font-size: 18px;
    filter: drop-shadow(0 0 5px var(--accent));
    animation: iconPulse 2s ease-in-out infinite;
}

.pinned-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.pinned-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    flex: 1;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.pinned-counter {
    background: rgba(147, 51, 234, 0.3);
    backdrop-filter: blur(4px);
    font-size: 11px;
    font-weight: bold;
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(147, 51, 234, 0.3);
    color: var(--text-primary) !important;
}

.pinned-arrow {
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary) !important;
    opacity: 0.7;
}

.pinned-arrow:hover {
    background: rgba(147, 51, 234, 0.3);
    opacity: 1;
}

.pinned-arrow:first-of-type:hover {
    transform: translateX(-3px);
}

.pinned-arrow:last-of-type:hover {
    transform: translateX(3px);
}

.pinned-close {
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 16px;
    color: var(--text-secondary) !important;
}

.pinned-close:hover {
    background: rgba(255, 107, 107, 0.2);
    color: var(--danger) !important;
    transform: scale(1.1);
}

@keyframes borderRotate {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px var(--accent)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 15px var(--accent)); }
}
/* Поле ввода */
.input-area {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-direction: column;
    position: relative;
}

/* УЛУЧШЕННОЕ ПРЕВЬЮ ОТВЕТА - как в Telegram */
.reply-preview {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.2s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.reply-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.reply-preview-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

.reply-preview-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.reply-preview-sender {
    font-weight: 600;
    color: var(--accent);
    font-size: 11px;
    margin-bottom: 2px;
}

.reply-preview-message {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.reply-preview-close:hover {
    color: var(--danger);
}

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

.input-controls {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: flex-end; 
}

/* Эмодзи панель */
.emoji-panel {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    margin-bottom: 6px;
    display: none;
}

.emoji-panel.show {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.emoji-item {
    font-size: 26px;
    text-align: center;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.emoji-item:hover {
    background: rgba(147, 51, 234, 0.2);
}

.attach-btn, .emoji-btn, .voice-btn, .dice-btn, .send-btn {

    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    align-self: flex-end;  /* Добавить */
    margin-bottom: 0;      
}

.attach-btn:hover, .emoji-btn:hover, .voice-btn:hover, .dice-btn:hover {
    background: rgba(147, 51, 234, 0.2);
    border-color: var(--accent);
}

.voice-btn.recording {
    background: rgba(255, 107, 107, 0.3);
    border-color: var(--danger);
    animation: pulse 1s ease infinite;
}

.message-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
    resize: none;
    overflow-y: auto;
    max-height: 120px;
    min-height: 42px;
    font-family: inherit;
    line-height: 1.4;
}
.message-input::-webkit-scrollbar {
    width: 7px;
}
.message-input::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 10px;
    margin: 20px 0;  /* ← 50px сверху и 50px снизу */
}
.message-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.2);
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.5);
}

/* Индикатор записи */
.recording-indicator {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 107, 107, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 20px rgba(255, 107, 107, 0.3);
}

.recording-indicator.active {
    display: flex;
    animation: slideUp 0.2s ease;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s ease infinite;
}

/* Блокировка сообщения */
.blocked-message {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin: 12px;
}

.blocked-message button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    margin-top: 10px;
    cursor: pointer;
    font-size: 13px;
}

.blocked-message button:hover {
    background: var(--accent-hover);
}

/* МОДАЛЬНЫЕ ОКНА */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    color: white;
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 450px;
    border: 1px solid var(--accent);
    animation: modalIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 40px var(--accent);
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.modal-content * {
    color: var(--text-primary);
}

.modal-lg {
    max-width: 650px;
}

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

.modal-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 28px;
    text-align: center;
    background: linear-gradient(135deg, #9333ea, #a855f7, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(147, 51, 234, 0.5);
    letter-spacing: -0.5px;
}

/* УЛУЧШЕННЫЙ ПРОФИЛЬ - ВСЕ КРУГЛОЕ КРОМЕ МОДАЛКИ С КАРТИНКОЙ */
.avatar-preview {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
    font-weight: 600;
    cursor: pointer;
    border: 3px solid var(--accent);
    background-size: cover;
    background-position: center;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 0 3px var(--bg-secondary), 0 0 20px var(--accent);
    border-radius: 50%;
}

.avatar-preview.has-image::after {
    content: '🔍';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.avatar-preview.has-image:hover::after {
    opacity: 1;
}

.avatar-preview:hover {
    transform: scale(1.02);
    border-color: var(--accent-hover);
}

/* Аватарка в полный размер */
.fullsize-avatar {
    width: 300px;
    height: 300px;
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    border: 4px solid var(--accent);
    box-shadow: 0 0 30px var(--accent);
    margin: 0 auto;
}

/* Профиль в чате - КРУГЛЫЙ */
.profile-avatar-large {
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
    font-weight: 600;
    cursor: pointer;
    border: 4px solid var(--accent);
    background-size: cover;
    background-position: center;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px var(--accent);
    border-radius: 50%;
}

.profile-avatar-large.has-image::after {
    content: '🔍';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.profile-avatar-large.has-image:hover::after {
    opacity: 1;
}

.reset-avatar {
    text-align: center;
    margin: 12px 0 24px;
}

.reset-avatar-btn {
    background: rgba(147, 51, 234, 0.1);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-avatar-btn:hover {
    background: rgba(147, 51, 234, 0.2);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.3);
}

.modal-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px 20px;
    margin-bottom: 18px;
    font-size: 15px;
    transition: all 0.2s ease;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(147, 51, 234, 0.15);
}

.modal-input::placeholder {
    color: var(--text-secondary);
}

.color-picker {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin: 24px 0;
    justify-content: center;
}

.color-option {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.color-option:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px currentColor;
}

.color-option.selected {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent);
}

.theme-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-option:hover {
    transform: scale(1.15);
}

.theme-option.selected {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

.wallpaper-section {
    margin-bottom: 18px;
    padding: 18px;
    background: var(--bg-tertiary);
    border-radius: 18px;
    text-align: center;
}

.wallpaper-placeholder {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    border-radius: 20px;
    padding: 18px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 18px;
    box-shadow: 0 4px 15px rgba(147, 51, 234, 0.3);
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent);
}

.modal-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: none;
}

.modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.modal-tab {
    padding: 10px 22px;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal-tab:hover {
    color: var(--accent);
}

.modal-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.privacy-settings {
    margin: 18px 0;
}

.privacy-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--accent);
}

.privacy-option {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    font-size: 15px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 14px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.privacy-option:hover {
    border-color: var(--accent);
}

.privacy-option input[type="radio"] {
    accent-color: var(--accent);
    width: 20px;
    height: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    margin-bottom: 14px;
    color: var(--text-primary);
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 14px;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 20px;
    height: 20px;
}

/* Подтверждение удаления */
.confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    padding: 28px;
    border-radius: 24px;
    border: 1px solid var(--accent);
    z-index: 2000;
    min-width: 300px;
    text-align: center;
    animation: fadeIn 0.2s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent);
}

.confirm-dialog p {
    margin-bottom: 24px;
    font-size: 16px;
}

.confirm-dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.confirm-btn.yes {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
}

.confirm-btn.no {
    background: rgba(255, 107, 107, 0.2);
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.confirm-btn:hover {
    transform: translateY(-2px);
}

/* Тосты */
.toast {
    position: fixed;
    top: 25px;
    right: 25px;
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 16px 24px;
    font-size: 15px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 14px;
    animation: slideIn 0.3s ease;
    max-width: 350px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid transparent;
}

.toast.success {
    border-color: var(--success);
    box-shadow: 0 0 20px var(--success);
}

.toast.error {
    border-color: var(--danger);
    box-shadow: 0 0 20px var(--danger);
}

.toast.info {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent);
}

.toast-close {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

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

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ==================== УЛУЧШЕННЫЙ ИНДИКАТОР В ПРОФИЛЕ ==================== */
.online-dot {
    width: 12px;
    height: 12px;
    background: #4cd964;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7);
    animation: tgPulseProfile 2s ease infinite;
}

.online-dot.pulse {
    animation: tgPulseProfile 2s ease infinite;
}

@keyframes tgPulseProfile {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(76, 217, 100, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0);
    }
}

/* Для своего профиля (чуть больше) */
.profile-avatar-large + h2 + p + .online-dot {
    width: 14px;
    height: 14px;
}

/* ТОЛЬКО ДЛЯ УВЕЛИЧЕННОЙ АВАТАРКИ ПРИ КЛИКЕ - КВАДРАТНАЯ БЕЗ РАМОК */
.modal[style*="z-index: 10001"] .modal-content img,
.modal[style*="z-index: 10001"] .modal-content div[style*="background"] {
    border-radius: 12px !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Аватарка в настройках профиля - КРУГЛАЯ */
#profileModal .avatar-preview {
    border-radius: 50% !important;
}

/* ==================== БЛОКИРОВКА ЧАТА ==================== */
.blocked-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 59, 48, 0.1);
    border: 2px solid rgba(255, 59, 48, 0.5);
    border-radius: 12px;
    margin: 8px 0;
    color: #ff3b30;
    font-weight: 500;
}

.blocked-lock {
    font-size: 24px;
}

.blocked-text {
    font-size: 16px;
}

.unblock-btn {
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unblock-btn:hover {
    background: #ff5252;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.5);
}

/* Большой блок с замком в центре чата */
.blocked-chat-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px;
    background: var(--bg-tertiary);
    border-radius: 24px;
    margin: 20px auto;
    max-width: 300px;
    color: #ff3b30;
    border: 2px solid rgba(255, 59, 48, 0.3);
    box-shadow: 0 10px 30px rgba(255, 59, 48, 0.2);
}

.blocked-lock-large {
    font-size: 60px;
    animation: lockShake 0.5s ease infinite;
}

.blocked-text-large {
    font-size: 20px;
    font-weight: 600;
}

.unblock-btn-large {
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 30px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.unblock-btn-large:hover {
    background: transparent;
    border-color: #ff3b30;
    color: #ff3b30;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 59, 48, 0.5);
}

@keyframes lockShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}
/* ==================== КНОПКА ПРОКРУТКИ ВНИЗ ==================== */
.scroll-down-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 20px var(--accent);
    z-index: 100;
    transition: all 0.2s ease;
    animation: fadeIn 0.2s ease;
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.scroll-down-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 30px var(--accent);
}

.scroll-down-btn span {
    font-size: 24px;
    line-height: 1;
}
/* 🔥 ИСПРАВЛЕНИЕ: эмодзи в модальных окнах без свечения */
.modal-title span:first-child {
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: initial !important;
    color: inherit !important;
    text-shadow: none !important;
    font-size: 32px;
}
/* ==================== НОВЫЙ ДИЗАЙН АУДИО СООБЩЕНИЙ ==================== */
.audio-message {
    background: var(--bg-tertiary);
    border-radius: 25px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    min-width: 200px;
    max-width: 300px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-message:hover {
    border-color: var(--accent);
}

.audio-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

.audio-play-btn.playing {
    animation: pulse 1s ease infinite;
}

.audio-wave-container {
    flex: 1;
    height: 32px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.audio-waves {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 2px;
    z-index: 1;
}

.audio-wave {
    flex: 1;
    min-width: 2px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    transition: height 0.1s ease;
}

.message.own .audio-wave {
    background: rgba(255, 255, 255, 0.5);
}

.audio-wave-progress {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 14px;
    transition: width 0.1s linear;
    z-index: 2;
    opacity: 0.5;
    pointer-events: none;
}

.audio-time {
    color: var(--text-secondary);
    font-size: 11px;
    min-width: 40px;
    text-align: right;
    font-weight: 500;
    flex-shrink: 0;
}

.audio-speed {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 14px;
    padding: 3px 6px;
    font-size: 9px;
    cursor: pointer;
    flex-shrink: 0;
}
/* ==================== УЛУЧШЕННЫЕ ОБОИ ==================== */
.messages-container {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: local;
}
/* ==================== МОБИЛЬНАЯ АДАПТАЦИЯ ==================== */
@media (max-width: 768px) {
    .main-screen.active {
        flex-direction: column;
    }
    
    .chats-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        z-index: 1000;
        transition: left 0.3s ease;
        background: var(--bg-secondary);
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    }
    
    .chats-sidebar.open {
        left: 0;
    }
    
    .chat-area {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .chat-header {
        flex-shrink: 0;
        padding: 12px 16px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
    }
    
    .input-area {
        flex-shrink: 0;
        padding: 12px 16px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
    }
    
    .messages-container {
        flex: 1;
        overflow-y: auto;
        padding: 25px 35px !important;
        min-height: 0;
    }
    
    .menu-toggle {
        display: flex !important;
    }
    
    .message {
        max-width: 85%;
    }
    
    .message-checkbox {
        left: -35px;
    }
    
    .message.own .message-checkbox {
        right: -35px;
    }
    
    .checkbox {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }
    
    .selection-bar {
        width: auto;
        min-width: 200px;
        max-width: 90%;
        bottom: 70px;
        padding: 8px 16px;
        white-space: nowrap;
        gap: 12px;
    }
    
    .bubble {
        max-width: calc(100% - 12px) !important;
    }
    
    .attach-btn, .emoji-btn, .voice-btn, .dice-btn, .send-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .message-input {
        font-size: 16px;
        padding: 10px 14px;
    }
    
    .input-controls {
        gap: 4px;
    }
    
    /* Контекстное меню */
    .context-menu {
        position: fixed !important;
        left: 5vw !important;
        right: 5vw !important;
        bottom: 10px !important;
        top: auto !important;
        width: 90vw !important;
        max-height: 60vh !important;
        overflow-y: auto;
        z-index: 10001;
        padding: 4px 0 !important;
        border-radius: 16px !important;
    }
    /* Уменьшаем отступы у пунктов меню */
    .context-menu .context-menu-item {
        padding: 12px 18px !important;  /* было 10px 16px → чуть больше */
        font-size: 15px !important;      /* было 14px → чуть крупнее */
        margin: 6px 10px !important;     /* было 4px 8px → чуть больше места */
        border-radius: 10px !important;  /* было 8px → чуть скруглённее */
    }
    /* Уменьшаем эмодзи реакции */
    .context-menu .reactions-menu {
        padding: 6px 8px !important;
        gap: 5px !important;
        margin: 2px 8px !important;
    }
    
    .context-menu .reaction-option {
        font-size: 22px !important;
        padding: 5px !important;
        width: 36px !important;
        height: 36px !important;
    }
    
    /* Уменьшаем разделители */
    .context-menu .context-menu-divider {
        margin: 3px 0 !important;
    }
    
    /* Кнопка "Отмена" - компактная и всегда видна */
    .context-menu .context-menu-close {
        padding: 10px !important;
        margin: 6px 10px 4px 10px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }        
    /* Модальные окна */
    .modal-content {
        max-width: 95%;
        max-height: 85vh;
        padding: 20px 16px;
        margin: 10px;
    }
    
    .modal-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .modal-tab {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    /* Аватарки */
    .profile-avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .header-avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .msg-avatar {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .avatar-preview,
    .profile-avatar-large {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }
    
    /* Блокировка чата */
    .blocked-chat-message {
        padding: 25px;
        max-width: 90%;
    }
    
    /* Кнопка прокрутки */
    .scroll-down-btn {
        bottom: 80px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
    
    /* Индикатор записи */
    .recording-indicator {
        bottom: 100px;
        padding: 10px 20px;
        font-size: 14px;
    }
}
/* ==================== ПОЛЗУНОК РАЗМЕРА ШРИФТА ==================== */
.font-size-slider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.font-size-slider input[type="range"] {
    flex: 1;
    height: 5px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 5px;
    outline: none;
}

.font-size-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--accent);
}

.font-size-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.font-size-value {
    min-width: 45px;
    text-align: center;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
}

/* ==================== ПЕРЕМЕННАЯ РАЗМЕРА ШРИФТА ==================== */
:root {
    --message-font-size: 14px;
}

.bubble {
    font-size: var(--message-font-size);
}

.message-input {
    font-size: calc(var(--message-font-size) - 1px);
}

/* ==================== ПОДСВЕТКА СООБЩЕНИЯ ==================== */
@keyframes pulse {
    0%, 100% { 
        background-color: transparent; 
        box-shadow: 0 0 0 0 var(--accent);
    }
    50% { 
        background-color: rgba(147, 51, 234, 0.2); 
        box-shadow: 0 0 20px var(--accent);
    }
}
/* ==================== УЛУЧШЕННЫЕ МЕДИА СООБЩЕНИЯ ==================== */
.media-message {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    max-width: 300px;
    border: 2px solid var(--accent);
    transition: all 0.2s ease;
}

.media-message:hover {
    transform: scale(1.02);
    box-shadow: 0 0 20px var(--accent);
}

.media-image, .media-video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
}

.media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.media-message:hover .media-overlay {
    opacity: 1;
}

.media-download-icon, .media-play-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 0 20px var(--accent);
    margin: 0 5px;
}

.media-download-icon:hover, .media-play-icon:hover {
    transform: scale(1.1);
}

/* ==================== ИСПРАВЛЕННЫЕ АУДИО СООБЩЕНИЯ ==================== */
.audio-message-enhanced {
    background: var(--bg-tertiary);
    border-radius: 25px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid var(--accent);
    min-width: 260px;
    max-width: 350px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 5px 0;
    height: 52px; /* Фиксированная высота */
}

.audio-message-enhanced:hover {
    border-color: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent);
}

.audio-play-btn-enhanced {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-play-btn-enhanced:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent);
}

.audio-play-btn-enhanced.playing {
    animation: pulse 1s ease infinite;
}

.audio-wave-container-enhanced {
    flex: 1;
    height: 36px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 18px;
}

/* Контейнер для волн */
.audio-waves-enhanced {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    padding: 0 4px;
    z-index: 1;
    height: 100%;
}

/* Каждая волна */
.audio-wave-enhanced {
    flex: 1;
    min-width: 3px;
    max-width: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: height 0.2s ease, background 0.2s ease;
    height: calc(30% + (var(--height, 0) * 0.7%));
    max-height: 100%;
}

/* Прогресс поверх волн */
.audio-wave-progress-enhanced {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 18px;
    transition: width 0.1s linear;
    z-index: 2;
    opacity: 0.3;
    pointer-events: none;
}

/* При воспроизведении - волны внутри прогресса окрашиваются */
.audio-message-enhanced.playing .audio-wave-enhanced {
    background: var(--accent);
}

/* Время */
.audio-time-enhanced {
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 45px;
    text-align: right;
    font-weight: 500;
    flex-shrink: 0;
}

/* Скорость */
.audio-speed-enhanced {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 14px;
    padding: 4px 8px;
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    height: 28px;
}

.audio-speed-enhanced:hover {
    background: var(--accent);
    color: white;
}

/* Для своих сообщений */
.message.own .audio-message-enhanced {
    background: rgba(255, 255, 255, 0.1);
}

.message.own .audio-wave-enhanced {
    background: rgba(255, 255, 255, 0.5);
}

.message.own .audio-message-enhanced.playing .audio-wave-enhanced {
    background: white;
}
/* ==================== КНОПКИ ДЛЯ МЕДИА В ПОЛНОЭКРАННОМ РЕЖИМЕ ==================== */
.media-download-btn, .media-close-btn {
    transition: all 0.2s ease;
}

.media-download-btn:hover, .media-close-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px var(--accent);
}

/* ==================== АНИМАЦИЯ ДЛЯ НОВЫХ АУДИО ==================== */
@keyframes wavePulse {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.2); }
}

.audio-wave-enhanced {
    animation: wavePulse 1s ease infinite;
    animation-delay: calc(0.1s * var(--i));
}
/* Стили для реакций на медиа */
.media-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    backdrop-filter: blur(5px);
    font-size: 13px;
}

/* Время для медиа */
.media-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.media-time {
    font-size: 11px;
}

/* Убираем рамку у закреплённых */
.message.pinned {
    background: linear-gradient(90deg, transparent, var(--accent-color) 20%, transparent);
    animation: pinGlow 2s ease-in-out infinite;
    border: none !important;
    outline: none !important;
}

.message.pinned .bubble {
    border: none !important;
    outline: none !important;
    box-shadow: 0 0 15px var(--accent-color);
}

@keyframes pinGlow {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}
/* ==================== КРУГОВОЙ ИНДИКАТОР ЗАГРУЗКИ ==================== */
.video-upload-circle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    min-width: 200px;
    max-width: 250px;
}

.video-upload-circle {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
}

.video-upload-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.video-upload-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 6;
}

.video-upload-circle-bar {
    fill: none;
    stroke: var(--accent, #9333ea);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 226.2; /* Длина окружности: 2 * π * r (r=36) */
    stroke-dashoffset: 226.2;
    transition: stroke-dashoffset 0.2s ease;
    filter: drop-shadow(0 0 5px var(--accent, #9333ea));
}

.video-upload-circle-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: bold;
    color: var(--accent, #9333ea);
    text-shadow: 0 0 8px var(--accent, #9333ea);
}

.video-upload-filename {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.video-upload-status {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    animation: uploadPulse 1.5s ease infinite;
}

.video-upload-status::before {
    content: '⏫';
    font-size: 14px;
    animation: uploadArrow 1s ease infinite;
}

@keyframes uploadArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes uploadPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Вращение круга (анимация загрузки) */
.video-upload-circle-bar.animating {
    animation: circleRotate 2s linear infinite;
}

@keyframes circleRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Для темной темы */
.theme-dark .video-upload-circle-bg {
    stroke: rgba(255, 255, 255, 0.15);
}

/* Для светлой темы */
.theme-light .video-upload-circle-bg {
    stroke: rgba(0, 0, 0, 0.1);
}
/* Стили для статусов сообщений */
.message-status {
    font-size: 12px;
    margin-left: 4px;
    display: inline-block;
}

.message-status.clickable {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-status.clickable:hover {
    transform: scale(1.2);
}

.message.error-message .bubble {
    opacity: 0.7;
    border-left: 3px solid #ff3b30 !important;
}

/* Анимация для отправляемых сообщений */
.message[data-temp="true"] .bubble {
    animation: sendingPulse 1.5s ease infinite;
}

@keyframes sendingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}
/* ========== АНИМАЦИИ ДЛЯ НОВЫХ СООБЩЕНИЙ ========== */
@keyframes messageAppear {
    0% { 
        opacity: 0;
        transform: translateY(10px);
    }
    100% { 
        opacity: 1;
        transform: translateY(0);
    }
}

.message.new-message {
    animation: messageAppear 0.2s ease forwards;
}

/* ========== УЛУЧШЕНИЯ ДЛЯ ГОЛОСОВЫХ СООБЩЕНИЙ ========== */
.audio-message-enhanced {
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.audio-message-enhanced.playing {
    box-shadow: 0 0 20px var(--accent);
    border-color: var(--accent) !important;
    transform: scale(1.02);
}

.audio-play-btn-enhanced {
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-play-btn-enhanced:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

.audio-play-btn-enhanced.playing {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

.audio-wave-container-enhanced {
    flex: 1;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.audio-wave-enhanced {
    width: 3px;
    background: var(--accent);
    border-radius: 3px;
    transition: height 0.1s ease;
}

.audio-time-enhanced {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 45px;
}

.audio-speed-enhanced {
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.audio-speed-enhanced:hover {
    background: var(--accent);
    color: white;
}
/* ========== УЛУЧШЕННАЯ КНОПКА ПРОКРУТКИ ========== */
.unread-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 0 10px var(--accent);
    border: 2px solid var(--bg-primary);
}
/* ==================== АНИМАЦИИ ДЛЯ РЕАКЦИЙ ==================== */

/* Анимация появления реакций */
.reaction-item {
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: reactionAppear 0.3s ease-out forwards;
    transform-origin: center;
}

@keyframes reactionAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(10px);
    }
    50% {
        transform: scale(1.1) translateY(0);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Анимация для активной реакции (наша) */
.reaction-item.active {
    background: var(--accent) !important;
    color: white !important;
    box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
    border-color: transparent !important;
    transform: scale(1.05);
    position: relative;
    overflow: hidden;
}

.reaction-item.active::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    animation: reactionRipple 1s ease-out;
    pointer-events: none;
}

@keyframes reactionRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Анимация при наведении */
.reaction-item:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--accent);
}

/* Анимация для счетчика */
.reaction-count {
    transition: all 0.2s ease;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.reaction-item.active .reaction-count {
    color: white;
    text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

/* Анимация при клике */
.reaction-item:active {
    transform: scale(0.9);
}

/* Анимация для новых реакций (подсветка) */
@keyframes reactionHighlight {
    0% {
        box-shadow: 0 0 0 0 var(--accent);
    }
    50% {
        box-shadow: 0 0 20px var(--accent), 0 0 40px var(--accent);
        transform: scale(1.1);
    }
    100% {
        box-shadow: 0 0 0 0 var(--accent);
        transform: scale(1);
    }
}

.reaction-item.highlight {
    animation: reactionHighlight 0.5s ease-out;
}

/* Анимация для контейнера реакций */
.reactions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    padding: 2px 0;
    min-height: 32px;
}

/* Анимация для счетчика при изменении */
@keyframes countPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.5);
        color: var(--accent);
    }
    100% {
        transform: scale(1);
    }
}

.reaction-count.changed {
    animation: countPop 0.3s ease-out;
}

/* Анимация для эмодзи при клике (уже есть, но улучшим) */
.emoji-animation {
    position: fixed;
    font-size: 48px;
    pointer-events: none;
    z-index: 10000;
    animation: emojiFly 1.5s ease-out forwards;
    filter: drop-shadow(0 0 10px currentColor);
    text-shadow: 0 0 20px rgba(255,255,255,0.5);
}

@keyframes emojiFly {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
        filter: drop-shadow(0 0 5px gold);
    }
    25% {
        transform: translateY(-30px) scale(1.3) rotate(-10deg);
        filter: drop-shadow(0 0 15px var(--accent));
    }
    50% {
        transform: translateY(-60px) scale(1.5) rotate(0deg);
        filter: drop-shadow(0 0 25px var(--accent-hover));
    }
    75% {
        transform: translateY(-90px) scale(1.3) rotate(10deg);
        opacity: 0.8;
        filter: drop-shadow(0 0 15px gold);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) scale(0.5) rotate(20deg);
        filter: drop-shadow(0 0 5px transparent);
    }
}

/* Анимация для множественных реакций (когда быстро кликают) */
@keyframes reactionBurst {
    0% {
        transform: scale(1);
    }
    20% {
        transform: scale(1.2);
    }
    40% {
        transform: scale(0.9);
    }
    60% {
        transform: scale(1.1);
    }
    80% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.reactions-list.burst {
    animation: reactionBurst 0.4s ease-out;
}

/* Анимация для удаления реакции */
.reaction-item.removing {
    animation: reactionRemove 0.2s ease-out forwards;
    pointer-events: none;
}

@keyframes reactionRemove {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0);
    }
}

/* ==================== ИСПРАВЛЕНИЕ ПОЗИЦИИ РЕАКЦИЙ НА ГОЛОСОВЫХ ==================== */

/* Для голосовых сообщений ДРУГА (чужие) - реакции СПРАВА */
.message:not(.own) .audio-message-enhanced + .reactions-list {
    align-self: flex-end !important;
    margin-left: 0 !important;
    margin-right: 8px !important;
}

/* Для своих голосовых сообщений - реакции СЛЕВА */
.message.own .audio-message-enhanced + .reactions-list {
    align-self: flex-start !important;
    margin-left: 8px !important;
    margin-right: 0 !important;
}

/* Для всех медиа-сообщений */
.message:not(.own) .reactions-list {
    align-self: flex-end !important;
    margin-left: 0 !important;
    margin-right: 8px !important;
}

.message.own .reactions-list {
    align-self: flex-start !important;
    margin-left: 8px !important;
    margin-right: 0 !important;
}

/* Убираем старые проблемные стили */
.message .media-message + .reactions-list,
.message .audio-message-enhanced + .reactions-list,
.message .file-message + .reactions-list,
.message .poll-message + .reactions-list,
.message .game-message + .reactions-list {
    margin-top: 8px;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .reaction-item {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .reaction-count {
        min-width: 22px;
        font-size: 13px;
    }
    
    .reactions-list {
        gap: 8px;
    }
    
    .emoji-animation {
        font-size: 40px;
    }
}

/* Анимация для панели реакций в контекстном меню */
.reactions-menu {
    animation: menuReactionsAppear 0.3s ease-out;
    transform-origin: bottom center;
}

@keyframes menuReactionsAppear {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    50% {
        transform: scale(1.05) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.reaction-option {
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: reactionOptionAppear 0.2s ease-out forwards;
    animation-delay: calc(0.02s * var(--i, 0));
    opacity: 0;
}

@keyframes reactionOptionAppear {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.reaction-option:hover {
    transform: scale(1.3) rotate(5deg);
    filter: drop-shadow(0 0 15px currentColor);
}

/* Анимация для тултипа с количеством реакций (если нужен) */
.reaction-tooltip {
    position: absolute;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    border: 1px solid var(--accent);
    box-shadow: 0 0 15px var(--accent);
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    animation: tooltipAppear 0.2s ease-out;
}

@keyframes tooltipAppear {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация для "взрыва" реакций (если много реакций сразу) */
@keyframes reactionExplosion {
    0% {
        box-shadow: 0 0 0 0 var(--accent);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent);
        transform: scale(1.1);
    }
    100% {
        box-shadow: 0 0 0 0 var(--accent);
        transform: scale(1);
    }
}

.message.reaction-explosion {
    animation: reactionExplosion 0.5s ease-out;
}
/* ==================== РАЗДЕЛИТЕЛЬ ДАТЫ ==================== */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0 10px 0;
    position: relative;
    width: 100%;
    pointer-events: none;
}

.date-separator::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.3;
    z-index: 1;
}

.date-separator-text {
    background: var(--bg-secondary);
    padding: 6px 18px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid var(--accent);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), 0 0 15px var(--accent);
    backdrop-filter: blur(5px);
    z-index: 2;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: dateSeparatorAppear 0.2s ease-out;
}

@keyframes dateSeparatorAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Для темной темы можно сделать текст ярче */
.theme-dark .date-separator-text {
    background: rgba(44, 44, 46, 0.9);
    color: #fff;
}

/* Для светлой темы */
.theme-light .date-separator-text {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
}
/* ==================== ПЛАВНЫЕ ПЕРЕХОДЫ ==================== */
.messages-container {
    transition: opacity 0.1s ease;
    will-change: scroll-position;
    scroll-behavior: auto !important; /* Отключаем плавный скролл при загрузке */
}

/* Убираем мигание при смене чата */
.chat-area {
    transition: none;
}

/* Анимация только для новых сообщений, не для загрузки чата */
.message:not(.pulse-animation):not(.new-message) {
    animation: none !important;
}

.message.new-message {
    animation: messageAppear 0.2s ease forwards !important;
}

/* ==================== АНИМАЦИЯ ПУЛЬСАЦИИ ДЛЯ SCROLLTOMESSAGE ==================== */
.message.pulse-animation {
    animation: pulse 1s ease !important;
    position: relative;
    z-index: 10;
}
/* ==================== МОДАЛЬНОЕ ОКНО ПОИСКА ==================== */
.search-modal .search-modal-content {
    padding: 0;
    overflow: hidden;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 24px;
    border: 1px solid rgba(147, 51, 234, 0.3);
    box-shadow: 0 0 30px rgba(147, 51, 234, 0.3);
    transition: all 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    animation: modalFadeInScale 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    will-change: max-height, transform;
}

@keyframes modalFadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Анимация увеличения контейнера при появлении результатов */
.search-modal .search-modal-content.expanding {
    animation: modalExpand 0.5s cubic-bezier(0.2, 0.9, 0.4, 1.2) forwards;
}

@keyframes modalExpand {
    0% {
        max-height: 85vh;
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 50px rgba(147, 51, 234, 0.6);
    }
    100% {
        max-height: 90vh;
        transform: scale(1);
        opacity: 1;
    }
}

/* Анимация уменьшения контейнера при очистке */
.search-modal .search-modal-content.shrinking {
    animation: modalShrink 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.2) forwards;
}

@keyframes modalShrink {
    0% {
        max-height: 90vh;
        transform: scale(1);
    }
    100% {
        max-height: 70vh;
        transform: scale(0.98);
        opacity: 0.95;
    }
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(147, 51, 234, 0.3);
    background: var(--bg-secondary);
}

.search-modal-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 5px var(--accent));
    animation: iconGlow 2s ease-in-out infinite;
}

@keyframes iconGlow {
    0%, 100% { filter: drop-shadow(0 0 2px var(--accent)); }
    50% { filter: drop-shadow(0 0 10px var(--accent)); }
}

.search-modal-title {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.3px;
}

.search-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid rgba(147, 51, 234, 0.5);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-modal-close:hover {
    background: linear-gradient(135deg, var(--danger), #ff5252);
    border-color: transparent;
    color: white;
    transform: scale(1.05) rotate(90deg);
    box-shadow: 0 0 20px var(--danger);
}

.search-input-wrapper {
    position: relative;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(147, 51, 234, 0.2);
}

.search-messages-input {
    width: 100%;
    padding: 14px 48px 14px 20px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(147, 51, 234, 0.4);
    border-radius: 40px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

.search-messages-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.3), 0 0 20px var(--accent);
    transform: scale(1.01);
}

.search-clear-btn {
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(147, 51, 234, 0.2);
    border: 1px solid rgba(147, 51, 234, 0.5);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.search-clear-btn:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border-color: transparent;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

.search-filters {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(147, 51, 234, 0.2);
    background: var(--bg-secondary);
}

.search-filter-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(147, 51, 234, 0.4);
    border-radius: 40px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.search-filter-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-color: transparent;
    color: white;
    box-shadow: 0 0 20px var(--accent);
    transform: scale(1.02);
}

.search-filter-btn:hover:not(.active) {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: rgba(147, 51, 234, 0.1);
}

/* ==================== КОНТЕЙНЕР РЕЗУЛЬТАТОВ С АНИМАЦИЕЙ ==================== */
.search-results-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    min-height: 200px;
    max-height: 55vh;
    background: rgba(0, 0, 0, 0.1);
    transition: max-height 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

/* Анимация при появлении результатов */
.search-results-container.has-results {
    animation: containerHeightGrow 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

@keyframes containerHeightGrow {
    0% {
        max-height: 100px;
        opacity: 0.5;
        transform: scaleY(0.95);
        transform-origin: top;
    }
    100% {
        max-height: 55vh;
        opacity: 1;
        transform: scaleY(1);
        transform-origin: top;
    }
}

/* Анимация для каждого чата при загрузке */
.search-chat-group {
    margin-bottom: 24px;
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: 20px;
    overflow: hidden;
    background: var(--bg-tertiary);
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: groupSlideIn 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

.search-chat-group:nth-child(1) { animation-delay: 0.05s; }
.search-chat-group:nth-child(2) { animation-delay: 0.1s; }
.search-chat-group:nth-child(3) { animation-delay: 0.15s; }
.search-chat-group:nth-child(4) { animation-delay: 0.2s; }
.search-chat-group:nth-child(5) { animation-delay: 0.25s; }
.search-chat-group:nth-child(n+6) { animation-delay: 0.3s; }

@keyframes groupSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-chat-group:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.3);
    transform: translateY(-2px);
}

.search-chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(147, 51, 234, 0.2);
}

.search-chat-header:hover {
    background: rgba(147, 51, 234, 0.1);
    padding-left: 24px;
}

.search-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
    flex-shrink: 0;
    border: 2px solid var(--accent);
    box-shadow: 0 0 10px var(--accent);
    transition: transform 0.2s ease;
}

.search-chat-header:hover .search-chat-avatar {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent);
}

.search-chat-info {
    flex: 1;
}

.search-chat-name {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 16px;
    letter-spacing: -0.2px;
}

.search-chat-count {
    font-size: 12px;
    color: var(--accent);
    opacity: 0.8;
    display: inline-block;
    padding: 2px 8px;
    background: rgba(147, 51, 234, 0.2);
    border-radius: 20px;
    margin-top: 4px;
}

.search-chat-messages {
    padding: 8px 0;
}

/* Анимация для каждого сообщения */
.search-result-item {
    padding: 12px 20px 12px 68px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(147, 51, 234, 0.1);
    position: relative;
    animation: itemFadeIn 0.2s ease-out forwards;
    opacity: 0;
    transform: translateX(-10px);
}

.search-result-item:nth-child(1) { animation-delay: 0.02s; }
.search-result-item:nth-child(2) { animation-delay: 0.04s; }
.search-result-item:nth-child(3) { animation-delay: 0.06s; }
.search-result-item:nth-child(4) { animation-delay: 0.08s; }
.search-result-item:nth-child(5) { animation-delay: 0.1s; }
.search-result-item:nth-child(n+6) { animation-delay: 0.12s; }

@keyframes itemFadeIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.search-result-item:hover {
    background: rgba(147, 51, 234, 0.15);
    transform: translateX(6px);
}

.search-result-item:hover::before {
    opacity: 1;
}

.search-result-time {
    font-size: 11px;
    color: var(--accent);
    margin-bottom: 6px;
    font-weight: 500;
    letter-spacing: 0.3px;
    display: inline-block;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

.search-result-preview {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

.search-highlight {
    background: linear-gradient(135deg, var(--accent), #ff00cc);
    color: white;
    padding: 2px 4px;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: 0 0 8px var(--accent);
    text-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.search-result-more {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: inline-block;
    font-style: italic;
}

.search-show-more-chat {
    padding: 12px 20px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s ease;
    border-top: 1px solid rgba(147, 51, 234, 0.2);
    background: rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

.search-show-more-chat:hover {
    background: rgba(147, 51, 234, 0.2);
    color: white;
    text-shadow: 0 0 5px var(--accent);
    letter-spacing: 1px;
}

.search-stats {
    padding: 14px 24px;
    text-align: center;
    font-size: 13px;
    color: var(--accent);
    border-top: 1px solid rgba(147, 51, 234, 0.3);
    background: var(--bg-secondary);
    font-weight: 500;
}

.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px;
    color: var(--text-secondary);
}

.search-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(147, 51, 234, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: searchSpin 0.8s linear infinite;
    box-shadow: 0 0 15px var(--accent);
}

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

.search-placeholder,
.search-no-results,
.search-error {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    margin: 20px;
}

.search-error {
    color: var(--danger);
    text-shadow: 0 0 10px var(--danger);
}

/* Анимация пульсации для сообщения при поиске */
.message.search-highlight-message {
    animation: searchPulse 0.6s ease 3;
    position: relative;
    z-index: 10;
}

@keyframes searchPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--accent);
        background: transparent;
    }
    50% {
        box-shadow: 0 0 0 8px var(--accent);
        background: rgba(147, 51, 234, 0.3);
        border-radius: 12px;
    }
}

/* Адаптация для мобильных (768px) */
@media (max-width: 768px) {
    .search-modal .modal-content {
        width: 92%;
        max-height: 90vh;
        border-radius: 28px;
    }
    
    @keyframes modalExpand {
        0% {
            max-height: 85vh;
            transform: scale(1);
        }
        100% {
            max-height: 92vh;
            transform: scale(1);
        }
    }
    
    .search-modal-header {
        padding: 16px 20px;
    }
    
    .search-modal-title {
        font-size: 18px;
    }
    
    .search-input-wrapper {
        padding: 16px 20px;
    }
    
    .search-messages-input {
        padding: 12px 44px 12px 18px;
        font-size: 15px;
    }
    
    .search-clear-btn {
        right: 28px;
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .search-filters {
        padding: 12px 16px;
        gap: 8px;
    }
    
    .search-filter-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .search-result-item {
        padding: 12px 16px 12px 56px;
    }
    
    .search-chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .search-chat-name {
        font-size: 15px;
    }
    
    .search-chat-header {
        padding: 12px 16px;
    }
    
    .search-result-preview {
        font-size: 13px;
    }
    
    .search-stats {
        padding: 12px 16px;
        font-size: 12px;
    }
    
    .search-show-more-chat {
        padding: 10px 16px;
        font-size: 12px;
    }
}

/* Стили для кнопки "Показать ещё" в поиске */
.search-show-more-btn {
    text-align: center;
    padding: 12px 20px;
    margin: 16px auto;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-radius: 40px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 10px var(--accent);
    width: fit-content;
    max-width: 90%;
}

.search-show-more-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 20px var(--accent);
    letter-spacing: 0.5px;
}

.search-show-more-btn:active {
    transform: translateY(0);
}

.search-show-more-btn.loading {
    animation: searchPulseBtn 1s ease infinite;
    pointer-events: none;
    opacity: 0.7;
}

@keyframes searchPulseBtn {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.98); }
}
/* ==================== СТИЛИ ДЛЯ ССЫЛОК В СООБЩЕНИЯХ ==================== */
.message-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed rgba(147, 51, 234, 0.5);
    transition: all 0.2s ease;
    cursor: pointer;
    display: inline-block;
    word-break: break-all;
    position: relative;
}

.message-link:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent);
    text-shadow: 0 0 5px rgba(147, 51, 234, 0.3);
    transform: translateY(-1px);
}

.message-link:active {
    transform: translateY(0);
}

/* Telegram ссылки */
.message-link.telegram-link {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(79, 70, 229, 0.1));
    border-radius: 16px;
    padding: 2px 8px;
    border-bottom: none;
    font-weight: 500;
}

.message-link.telegram-link:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 2px 10px rgba(147, 51, 234, 0.4);
}

/* Email ссылки */
.message-link.email-link {
    color: #4cd964;
    border-bottom-color: rgba(76, 217, 100, 0.5);
}

.message-link.email-link:hover {
    color: #34c759;
    border-bottom-color: #34c759;
}

/* Телефонные номера */
.message-link.phone-link {
    color: #ff9f0a;
    border-bottom-color: rgba(255, 159, 10, 0.5);
}

.message-link.phone-link:hover {
    color: #ff9500;
    border-bottom-color: #ff9500;
}

/* Анимация подчеркивания */
.message-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
    transition: width 0.3s ease;
}

.message-link:hover::after {
    width: 100%;
}

/* Стили для ссылок в своих сообщениях */
.message.own .message-link {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.message.own .message-link:hover {
    color: white;
    border-bottom-color: white;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.message.own .message-link.telegram-link {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message.own .message-link.telegram-link:hover {
    background: white;
    color: var(--accent);
}

/* Тулип при наведении на ссылку */
.message-link[href^="http"]:hover::before {
    content: '🔗 Открыть ссылку';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid var(--accent);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    margin-bottom: 8px;
}

.message-link[href^="mailto"]:hover::before {
    content: '✉️ Отправить email';
}

.message-link[href^="tel"]:hover::before {
    content: '📞 Позвонить';
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .message-link {
        font-size: 14px;
        padding: 2px 4px;
    }
    
    .message-link.telegram-link {
        padding: 4px 12px;
    }
    
    .message-link:hover::before {
        display: none;
    }
}
/* Стили для ссылок с копированием */
.message-link.copy-link {
    cursor: pointer;
}

.message-link.copy-link:active {
    transform: scale(0.98);
}

/* Анимация для успешного копирования */
.message-link.copy-link.copied {
    animation: copyFlash 0.3s ease;
}

@keyframes copyFlash {
    0% { background-color: transparent; }
    50% { background-color: rgba(76, 217, 100, 0.3); }
    100% { background-color: transparent; }
}
    /* Анимация обновления времени в списке чатов */
    .chat-time {
        transition: all 0.3s ease;
    }
    
/* ==================== АНИМАЦИИ ДЛЯ ЗВОНКОВ ==================== */
@keyframes avatarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes incomingRing {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.call-action-btn {
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.call-mic-btn.muted {
    background: #ff3b30 !important;
    box-shadow: 0 0 20px #ff3b30;
}

.call-accept-btn:hover, .call-decline-btn:hover {
    transform: scale(1.1);
}

.call-accept-btn:active, .call-decline-btn:active {
    transform: scale(0.95);
}

/* Спиннер загрузки */
.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Кнопка вызова в шапке */
.call-header-btn {
    transition: all 0.2s ease;
}

.call-header-btn:hover {
    transform: scale(1.1);
    text-shadow: 0 0 10px var(--accent);
}
/* ==================== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ДЛЯ ВИДЕОЗВОНКОВ ==================== */

/* Контейнер звонка - полный экран */
.call-container {
    position: relative;
    overflow: hidden;
    background: #000;
}

/* Удаленное видео (на весь экран) */
.call-video-remote {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    background: #000 !important;
    z-index: 3 !important;  /* БЫЛО 1 — СТАЛО 3, чтобы быть ПОВЕРХ аватарки */
    border-radius: 28px !important;
    display: block !important;  /* ЯВНО УКАЗЫВАЕМ */
    pointer-events: none;  /* Чтобы не мешало кликам по кнопкам */
}

/* Локальное видео (маленькое окошко в углу) */
.call-video-local {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: 16px;
    border: 3px solid var(--accent, #9333ea);
    background: #000;
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(147, 51, 234, 0.3);
}

.call-video-local:hover {
    transform: scale(1.02);
    border-width: 4px;
}

/* Анимация появления видео */
@keyframes videoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.call-video-remote {
    animation: videoFadeIn 0.3s ease-out;
}

.call-video-local {
    animation: videoFadeIn 0.2s ease-out;
}

/* Анимация скрытия аватарки */
.call-avatar-wrapper.hiding {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Панель с кнопками при видео звонке */
.call-actions {
    background: transparent;
    padding: 20px 0 30px 0;
    backdrop-filter: none;
    border-radius: 0 0 28px 28px;
}

/* Кнопка видео в активном состоянии */
.call-video-btn.video-enabled {
    background: linear-gradient(135deg, #4cd964, #34c759) !important;
    box-shadow: 0 0 20px #4cd964;
    animation: videoBtnPulse 2s ease infinite;
}

@keyframes videoBtnPulse {
    0%, 100% {
        box-shadow: 0 0 20px #4cd964;
    }
    50% {
        box-shadow: 0 0 30px #4cd964, 0 0 10px #34c759;
    }
}

/* Статус видеозвонка */
.call-status.video-call {
    background: rgba(76, 217, 100, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(76, 217, 100, 0.5);
}

/* Контейнер звонка в модальном окне */
.call-modal .call-container {
    position: relative;
    background: #000;
    transition: all 0.3s ease;
}

/* Для мобильных устройств */
@media (max-width: 768px) {
    .call-video-local {
        width: 100px;
        height: 133px;
        bottom: 15px;
        right: 15px;
    }
    
    .call-actions {
        gap: 20px !important;
    }
    
    .call-action-btn {
        width: 55px !important;
        height: 55px !important;
        font-size: 24px !important;
    }
    
    .call-container {
        max-width: 95% !important;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .call-video-local {
        width: 80px;
        height: 107px;
        bottom: 10px;
        right: 10px;
        border-width: 2px;
    }
}

/* Улучшенный контейнер звонка */
.call-modal .call-container {
    position: relative;
    overflow: hidden;
    background: #000;
    border-radius: 28px;
}

/* Затемнение фона при звонке */
.call-modal {
    backdrop-filter: blur(20px);
}

/* Анимация пульсации для кнопки видео */
@keyframes videoBtnGlow {
    0% {
        box-shadow: 0 0 5px #4cd964;
    }
    100% {
        box-shadow: 0 0 20px #4cd964;
    }
}

/* Микрофон выключен */
.call-mic-btn.muted {
    background: #ff3b30 !important;
    box-shadow: 0 0 20px #ff3b30;
    animation: micMutedPulse 1.5s ease infinite;
}

@keyframes micMutedPulse {
    0%, 100% {
        box-shadow: 0 0 15px #ff3b30;
    }
    50% {
        box-shadow: 0 0 25px #ff3b30, 0 0 5px #ff3b30;
    }
}

/* Индикатор записи экрана (если будет) */
.screen-share-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: white;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Панель управления при клике */
.call-actions {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.call-actions.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.call-actions.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
/* ==================== КНОПКА МЕНЮ ==================== */
/* На ПК кнопка скрыта */
.header-btn.menu-toggle {
    display: none !important;
}

/* Скрываем стрелочку */
.back-arrow {
    display: none !important;
}

/* Убираем оверлей */
.sidebar-overlay {
    display: none !important;
}

/* СТИЛИ ДЛЯ МОБИЛЬНОГО РЕЖИМА (ПОЛНОЭКРАННЫЙ ВЫЕЗД) */
@media (max-width: 768px) {
    /* Кнопка меню видна только на телефонах */
    .header-btn.menu-toggle {
        display: flex !important;
    }
    
    /* Боковая панель на ВЕСЬ экран */
    .chats-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 100% !important;
        max-width: none !important;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
        background: var(--bg-primary);
        border-right: none;
        box-shadow: none;
        overflow-y: auto;
    }
    
    .chats-sidebar.open {
        left: 0;
    }
    
    /* УВЕЛИЧЕННЫЕ РАЗМЕРЫ В СПИСКЕ ЧАТОВ */
    .chats-sidebar .profile-header {
        padding: 20px 24px;
    }
    
    .chats-sidebar .profile-avatar {
        width: 60px;
        height: 60px;
        font-size: 26px;
        border-width: 2px;
    }
    
    .chats-sidebar .profile-name {
        font-size: 18px;
        font-weight: 700;
        margin-bottom: 6px;
    }
    
    .chats-sidebar .profile-status {
        font-size: 14px;
    }
    
    .chats-sidebar .logout-btn {
        padding: 8px 14px;
        font-size: 14px;
    }
    
    /* Увеличенный поиск */
    .chats-sidebar .search-section {
        padding: 16px 20px;
    }
    
    .chats-sidebar .search-input {
        padding: 14px 18px;
        font-size: 16px;
        border-radius: 12px;
    }
    
    /* Увеличенные элементы чатов */
    .chats-sidebar .chat-item {
        padding: 14px 18px;
        margin-bottom: 8px;
        border-radius: 12px;
    }
    
    .chats-sidebar .chat-avatar {
        width: 56px;
        height: 56px;
        font-size: 22px;
        border-width: 2px;
    }
    
    .chats-sidebar .chat-name-row {
        margin-bottom: 6px;
    }
    
    .chats-sidebar .chat-name {
        font-size: 17px;
        font-weight: 600;
    }
    
    .chats-sidebar .chat-time {
        font-size: 12px;
    }
    
    .chats-sidebar .chat-last-msg {
        font-size: 14px;
        line-height: 1.4;
    }
    
    .chats-sidebar .chat-badge {
        font-size: 11px;
        padding: 4px 10px;
        min-width: 24px;
        border-radius: 20px;
    }
    
    /* Индикатор онлайн увеличен */
    .chats-sidebar .online-indicator {
        width: 14px;
        height: 14px;
        border-width: 2px;
        bottom: 2px;
        right: 2px;
    }
}

/* Панель ответа не должна перехватывать свайпы */
.reply-preview {
    touch-action: pan-y pinch-zoom;
    pointer-events: auto;
}

/* Улучшенный просмотр изображений */
.image-viewer-modal img {
    transition: transform 0.1s ease-out;
    user-select: none;
    -webkit-user-select: none;
}

.image-viewer-modal img:active {
    cursor: grabbing;
}

/* Индикатор зума */
.image-viewer-modal .zoom-info {
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}
/* Полное отключение выделения текста на мобильных устройствах */
.message,
.bubble,
.msg-avatar,
.audio-message-enhanced,
.file-message,
.poll-message,
.game-message,
.media-message,
.voice-btn,
.emoji-btn,
.send-btn,
.attach-btn,
.header-btn,
.input-controls button,
.reply-preview,
.pinned-messages-bar,
.date-separator {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Для поля ввода текст должен выделяться (оставляем как есть) */
.message-input,
.search-input,
.modal-input,
.auth-input,
textarea,
input[type="text"],
input[type="password"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Отключаем контекстное меню браузера на этих элементах */
.message,
.bubble,
.voice-btn,
.emoji-btn,
.send-btn,
.attach-btn,
.header-btn {
    -webkit-touch-callout: none;
    pointer-events: auto;
}
.chat-item.chat-unread:not(.active) {
    box-shadow: 0 0 0 2px var(--accent), 0 0 15px var(--accent);
    border-radius: 12px;
    transition: box-shadow 0.2s ease;
}

/* Активный чат (открытый) - даже если есть unread_count, НЕ светим */
.chat-item.active {
    box-shadow: none !important;
}

/* Скрываем бейдж с цифрой/точкой (если не нужен) */
.chat-badge {
    display: none !important;
}
/* Для медиа-сообщений (фото, видео, ГС, файлы) - фиолетовый фон + чёрный текст */
.message.own .reply-to-media {
    background: rgba(147, 51, 234, 0.25) !important;
    border-left: 3px solid var(--accent) !important;
    backdrop-filter: blur(2px);
}

.message.own .reply-to-media:hover {
    background: rgba(147, 51, 234, 0.35) !important;
}
/* ==================== ПЛАВАЮЩАЯ АВАТАРКА ЗВОНКА ==================== */
.floating-call-avatar {
    position: fixed;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--bg-secondary);
    box-shadow: 
        0 0 0 3px var(--accent, #9333ea),
        0 0 20px rgba(147, 51, 234, 0.3),
        0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 30000;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: none;
    will-change: transform;
}

.floating-call-avatar:hover {
    transform: scale(1.05);
    box-shadow: 
        0 0 0 4px var(--accent, #9333ea),
        0 0 30px rgba(147, 51, 234, 0.5),
        0 4px 20px rgba(0, 0, 0, 0.4);
}

.floating-call-avatar:active {
    transform: scale(0.95);
}

/* Аватар внутри плавающей иконки */
.floating-avatar-img {
    width: calc(100% - 6px);
    height: calc(100% - 6px);
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 28px;
    position: relative;
    z-index: 1;
}

/* Длительность звонка - СВЕТИТСЯ ЗЕЛЕНЫМ */
.floating-call-duration {
    position: absolute;
    bottom: -5px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    color: #4cd964;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    border: 1px solid rgba(76, 217, 100, 0.5);
    box-shadow: 0 0 15px rgba(76, 217, 100, 0.3), 0 0 30px rgba(76, 217, 100, 0.1);
    pointer-events: none;
    z-index: 2;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(76, 217, 100, 0.5);
}

/* Пульсирующая точка статуса звонка */
.floating-call-pulse {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    background-color: #4cd964;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7);
    animation: floatingPulse 1.5s ease infinite;
    z-index: 3;
}

@keyframes floatingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(76, 217, 100, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 217, 100, 0);
    }
}

/* Анимация появления */
@keyframes floatingAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.floating-call-avatar.show {
    animation: floatingAppear 0.3s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

/* Анимация исчезновения */
@keyframes floatingDisappear {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
        visibility: hidden;
    }
}

.floating-call-avatar.hide {
    animation: floatingDisappear 0.2s ease forwards;
}

/* Кнопка сворачивания в модальном окне звонка */
.call-minimize-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    transition: all 0.2s ease;
    font-family: monospace;
    line-height: 1;
}

.call-minimize-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
    border-color: var(--accent);
}

/* Стили для drag & drop */
.floating-call-avatar.dragging {
    transition: none;
    cursor: grabbing;
    opacity: 0.9;
    transform: scale(1.02);
    box-shadow: 
        0 0 0 5px var(--accent, #9333ea),
        0 0 40px rgba(147, 51, 234, 0.6),
        0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .floating-call-avatar {
        width: 60px;
        height: 60px;
    }
    
    .floating-avatar-img {
        font-size: 24px;
        width: calc(100% - 4px);
        height: calc(100% - 4px);
    }
    
    .floating-call-duration {
        font-size: 9px;
        padding: 2px 6px;
        bottom: -4px;
    }
    
    .floating-call-pulse {
        width: 12px;
        height: 12px;
        bottom: 1px;
        right: 1px;
    }
    
    .call-minimize-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
        top: 15px;
        right: 15px;
    }
}
/* ==================== ОТКЛЮЧЕНИЕ АНИМАЦИЙ ДЛЯ СЛАБЫХ УСТРОЙСТВ ==================== */
.slow-device .message.new-message {
    animation: none !important;
    opacity: 1 !important;
}

.slow-device .emoji-animation,
.slow-device .confetti,
.slow-device .heart,
.slow-device .star,
.slow-device .dice-animation,
.slow-device .trophy {
    display: none !important;
}

.slow-device .reaction-item {
    transition: none !important;
}

.slow-device .pinned-messages-bar {
    animation: none !important;
}

.slow-device .auth-screen {
    animation: none !important;
}

.slow-device .modal-content {
    animation: none !important;
}
/* Только для чата в шапке */
.chat-header {
    position: relative !important;
    z-index: 10 !important;
}

/* Кнопки в шапке — поверх всего */
.header-actions {
    position: relative !important;
    z-index: 20 !important;
}
#messagesContainer {
    padding-top: 45px !important;
}