:root {
    --primary: #e8cb58;
    --primary-dark: #b9a150;
    --bg-dark: #090a0f;
    --bg-card: #0f1117;
    --bg-hover: #1a1d26;
    --text-primary: #ffffff;
    --date-primary: #E0E0E0;
    --text-secondary: #8a8f9e;
    --border: #1e2129;
    --accent: #616774;
    --accent-dark: #37414a;
    --success: #4ade80;
    --danger: #f87171;
    --warning: #fbbf24;
    --online: #4ade80;
    --offline: #6b7280;
    --vh: 1vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* SVG иконки */
.icon-svg {
    width: 20px;
    height: 20px;
    display: inline-block;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    /* filter: invert(1); Для светлой темы */
}

/* Размеры */
.icon-svg.sm { width: 16px; height: 16px; }
.icon-svg.md { width: 24px; height: 24px; }
.icon-svg.lg { width: 32px; height: 32px; }
.icon-svg.xl { width: 48px; height: 48px; }
.icon-svg.ct { margin-left: 2px; }

/* Отдельные иконки */
.icon-user { background-image: url('/icons/user.svg'); }
.icon-users { background-image: url('/icons/users.svg'); }
.icon-comments { background-image: url('/icons/comments.svg'); }
.icon-lamp { background-image: url('/icons/lamp.svg'); }
.icon-login { background-image: url('/icons/login.svg'); }
.icon-logout { background-image: url('/icons/logout.svg'); }
.icon-plus { background-image: url('/icons/plus.svg'); }
.icon-search { background-image: url('/icons/search.svg'); }
.icon-send { background-image: url('/icons/send.svg'); }
.icon-microphone { background-image: url('/icons/microphone.svg'); }
.icon-video { background-image: url('/icons/video.svg'); }
.icon-phone { background-image: url('/icons/phone.svg'); }
.icon-trash { background-image: url('/icons/trash.svg'); }
.icon-edit { background-image: url('/icons/edit.svg'); }
.icon-reply { background-image: url('/icons/reply.svg'); }
.icon-share { background-image: url('/icons/share.svg'); }
.icon-copy { background-image: url('/icons/copy.svg'); }
.icon-download { background-image: url('/icons/download.svg'); }
.icon-play { background-image: url('/icons/play.svg'); }
.icon-pause { background-image: url('/icons/pause.svg'); }
.icon-check { background-image: url('/icons/check.svg'); }
.icon-close { background-image: url('/icons/close.svg'); }
.icon-chevron-down { background-image: url('/icons/chevron-down.svg'); }
.icon-chevron-left { background-image: url('/icons/chevron-left.svg'); }
.icon-chevron-right { background-image: url('/icons/chevron-right.svg'); }
.icon-camera { background-image: url('/icons/camera.svg'); }
.icon-settings { background-image: url('/icons/settings.svg'); }
.icon-volume-up { background-image: url('/icons/volume-up.svg'); }
.icon-volume-mute { background-image: url('/icons/volume-mute.svg'); }
.icon-volume-down { background-image: url('/icons/volume-down.svg'); }
.icon-block { background-image: url('/icons/block.svg'); }
.icon-user-plus { background-image: url('/icons/user-plus.svg'); }
.icon-user-minus { background-image: url('/icons/user-minus.svg'); }
.icon-admin { background-image: url('/icons/admin.svg'); }
.icon-pen { background-image: url('/icons/pen.svg'); }
.icon-emoji { background-image: url('/icons/emoji.svg'); }
.icon-attach { background-image: url('/icons/attach.svg'); }
.icon-sendb { background-image: url('/icons/sendb.svg'); }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.app-container, .screen, .chat-layout, .chat-area {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ========== ЭКРАН АВТОРИЗАЦИИ ========== */
#auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
}

.auth-container {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo i {
    font-size: 48px;
    color: var(--primary);
}

.logo h1 {
    font-size: 32px;
    color: var(--primary);
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.auth-tabs .tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.auth-tabs .tab-btn.active {
    color: var(--primary);
}

.auth-tabs .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.input-group input {
    width: 100%;
    padding: 14px 15px 14px 45px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--accent-dark);
}

.auth-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

.auth-message.error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.auth-message.success {
    background: rgba(74, 222, 128, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.auth-message.info {
    background: rgba(232, 203, 88, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
}

/* ========== ОСНОВНОЙ ИНТЕРФЕЙС ========== */
.chat-layout {
    display: flex;
    height: 100vh;
    background: var(--bg-dark);
    position: relative;
}

/* ========== САЙДБАР ========== */
.sidebar {
    width: 340px;
    min-width: 250px;
    max-width: 600px;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s;
    padding: 8px 12px;
    border-radius: 12px;
    margin: -8px -12px;
}

.user-info:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img,
.chat-avatar img,
.group-avatar img,
.profile-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* ✅ Для Safari */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* ✅ Предотвращает серый фон */
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    user-select: none;
}

/* ✅ Если изображение не загрузилось — показываем цветной фон */
.avatar img[src=""],
.avatar img:not([src]),
.chat-avatar img[src=""],
.chat-avatar img:not([src]) {
    display: none;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 600;
    font-size: 14px;
}

.status {
    font-size: 12px;
    color: var(--text-secondary);
}

.status.online { color: var(--online); }
.status.offline { color: var(--offline); }
.status.hidden { color: var(--text-secondary); }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.search-bar {
    padding: 10px 15px;
}

.search-bar input {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
    user-select: none;
}

.search-bar input:focus {
    border-color: var(--primary);
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

.sidebar-tabs {
    display: flex;
    padding: 10px;
    gap: 5px;
    user-select: none;
}

.sidebar-tabs .tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 5px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 13px;
}

.sidebar-tabs .tab-btn i {
    font-size: 14px;
}

.sidebar-tabs .tab-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.sidebar-panel {
    display: none;
    padding: 10px 0px;
    user-select: none;
}

.sidebar-panel.active {
    display: block;
}

.sidebar-footer {
    display: none;
}

.chat-item, .friend-item, .request-item, .search-user-item {
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 7px;
}

.chat-item {
    margin: 6px;
    border-radius: 12px;
}

.chat-item:hover, .friend-item:hover, .request-item:hover, .search-user-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--primary);
    color: var(--bg-dark);
}

.chat-item.active .chat-last-message {
    color: var(--bg-dark);
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

/* Добавляем новые стили для шапки чата */
.chat-header-info {
    display: flex;
    flex-direction: column;
    flex: 100;
    cursor: pointer;
    pointer-events: none;
    padding-left: 5px;
}

.chat-header-info * {
    pointer-events: none;
}

.chat-header-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.chat-info * {
    pointer-events: auto;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-avatar-status {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--online);
    border: 2px solid var(--bg-card);
    z-index: 5;
}

.friend-status-badge {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--online);
    border: 2px solid var(--bg-card);
    z-index: 5;
}

.friend-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
}

.friend-status-indicator.online { background: var(--online); }
.friend-status-indicator.offline { background: var(--offline); }
.friend-status-indicator.hidden { display: none; }

/* Индикатор печати */
.chat-status.typing {
    color: var(--primary);
    font-style: italic;
    animation: typingPulse 1.5s ease-in-out infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Анимация точек печатания */
.typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 4px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-status.voice {
    color: var(--primary);
    font-style: normal;
    animation: voicePulse 1.2s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.chat-status.voice::before {
    display: inline-block;
    animation: voiceWave 1s ease-in-out infinite;
}

@keyframes voiceWave {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.tab-badge {
    background: var(--primary);
    color: var(--bg-hover);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.tab-btn.active .tab-badge {
    background: var(--bg-hover);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.friends-section-header {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

.friends-section-header:first-child {
    margin-top: 0;
}

.friends-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

.chat-details {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-last-message {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Специальные сообщения в списке чатов (фото, видео, аудио, ГС, файлы) */
.chat-last-message.special {
    color: var(--primary);
    opacity: 0.9;
}

.chat-last-message .sender-name {
    font-weight: 500;
    color: var(--primary);
    margin-right: 4px;
}

.chat-item.active .chat-last-message .sender-name {
    color: var(--bg-dark);
}

.chat-last-message .sender-name.own {
    color: var(--primary);
}

.chat-item.active .chat-last-message .sender-name.own {
    color: var(--bg-dark);
    opacity: 0.8;
}
.chat-meta {
    margin-bottom: auto;
    text-align: right;
    flex-shrink: 0;
}

.chat-time {
    font-size: 11px;
    margin-top: 8px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.chat-item.active .chat-time {
    color: var(--bg-hover);
}

.unread-badge {
    background: var(--primary);
    color: var(--bg-dark);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    margin-top: 4px;
}

.request-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.request-actions button {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    pointer-events: auto;
}

.accept-btn {
    background: var(--success);
    color: var(--bg-dark);
}

.accept-btn:hover {
    background: #22c55e;
}

.reject-btn {
    background: var(--danger);
    color: white;
}

.reject-btn:hover {
    background: #ef4444;
}

/* ========== КНОПКА ПРОКРУТКИ ВНИЗ (как в Telegram) ========== */
.scroll-down-btn {
    position: absolute;
    bottom: 90px;
    right: 20px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
    z-index: 50;
    font-size: 18px;
    padding: 0;
    margin: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    will-change: transform, opacity;
}

/* Десктоп (ширина более 768px) */
@media (min-width: 769px) {
    .scroll-down-btn {
        visibility: hidden;
        opacity: 0;
        transform: translateY(20px) scale(0.8);
        transition: opacity 0.2s ease, 
                    transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1),
                    visibility 0.2s ease;
        pointer-events: none;
    }
    
    .scroll-down-btn.visible {
        visibility: visible;
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
}

/* Мобильные устройства (768px и меньше) */
@media (max-width: 768px) {
    .scroll-down-btn {
        bottom: 80px;
        right: 16px;
        width: 48px;
        height: 48px;
        min-width: 48px;
        max-width: 48px;
        font-size: 20px;
        visibility: visible;
        opacity: 0;
        transform: translateY(30px) scale(0.7);
        transition: opacity 0.3s ease, 
                    transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
        pointer-events: none;
    }
    
    .scroll-down-btn.visible {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .scroll-down-btn {
        bottom: 75px;
        right: 12px;
        width: 44px;
        height: 44px;
        min-width: 44px;
        max-width: 44px;
        font-size: 18px;
    }
}

/* Ховер эффекты для десктопа */
@media (min-width: 769px) {
    .scroll-down-btn:hover {
        background: var(--bg-card);
        color: var(--text-primary);
        border-color: var(--primary);
        border-width: 2px;
        box-shadow: 0 6px 20px rgba(232, 203, 88, 0.3);
        transform: translateY(-2px) scale(1.05);
    }
    
    .scroll-down-btn:active {
        transform: scale(0.95);
    }
}

/* Анимация для мобильных при клике */
@media (max-width: 768px) {
    .scroll-down-btn:active {
        transform: scale(0.9);
    }
}

/* Бейдж с количеством новых сообщений (опционально) */
.scroll-down-btn .unread-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-card);
    pointer-events: none;
}

/* Анимация появления счётчика */
.scroll-down-btn .unread-indicator {
    animation: unreadBadgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes unreadBadgePop {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Обновляем z-index чтобы кнопка была над сообщениями */
.messages-container {
    position: relative;
}

/* Кнопка не перекрывает поле ввода */
@media (max-width: 768px) {
    .scroll-down-btn {
        bottom: 80px; /* Над полем ввода */
    }
}

/* Когда есть аудиоплеер в шапке — опускаем кнопку ниже */
.chat-header:has(.header-audio-player[style*="display: flex"]) ~ .scroll-down-btn {
    bottom: 95px;
}

@media (max-width: 768px) {
    .chat-header:has(.header-audio-player[style*="display: flex"]) ~ .scroll-down-btn {
        bottom: 85px;
    }
}

/* Когда есть мини-бар звонка */
.mini-call-bar[style*="display: block"] ~ .scroll-down-btn {
    bottom: 140px;
}

@media (max-width: 768px) {
    .mini-call-bar[style*="display: block"] ~ .scroll-down-btn {
        bottom: 130px;
    }
}

/* ========== СЕКЦИЯ ПРОЧИТАВШИХ В КОНТЕКСТНОМ МЕНЮ ========== */
.context-readers-loading {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.7;
    font-style: italic;
    padding: 4px 0;
}

.context-readers-loading::after {
    content: '...';
    animation: loadingDots 1.5s steps(4) infinite;
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.context-readers-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 15px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.context-readers-header i {
    color: var(--success);
    font-size: 14px;
}

.context-readers-header span {
    color: var(--text-primary);
}

.context-readers-avatars {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 10px;
    flex-wrap: wrap;
}

.context-reader-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.context-reader-avatar:hover {
    transform: scale(1.15);
    border-color: var(--primary);
    z-index: 2;
}

.context-reader-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.context-reader-avatar i {
    font-size: 12px;
    color: var(--text-secondary);
}

.context-readers-more {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0 4px;
}

.context-readers-empty {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.6;
    font-style: italic;
    padding: 2px 0;
}

/* Для мобильных устройств */
@media (max-width: 768px) {
    .context-reader-avatar {
        width: 32px;
        height: 32px;
    }
    
    .context-readers-header {
        font-size: 14px;
        padding: 6px 15px;
    }
}

/* Анимация появления аватарок */
.context-reader-avatar {
    animation: readerAvatarPop 0.2s ease forwards;
    opacity: 0;
    transform: scale(0.8);
}

.context-reader-avatar:nth-child(1) { animation-delay: 0.05s; }
.context-reader-avatar:nth-child(2) { animation-delay: 0.10s; }
.context-reader-avatar:nth-child(3) { animation-delay: 0.15s; }
.context-reader-avatar:nth-child(4) { animation-delay: 0.20s; }
.context-reader-avatar:nth-child(5) { animation-delay: 0.25s; }

@keyframes readerAvatarPop {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Стиль для счётчика прочитавших в своих сообщениях */
.message-own .message-status.read i {
    color: var(--bg-dark);
}

.message-own .message-status .fa-check-double {
    color: var(--bg-dark);
}

/* ========== РЕАКЦИИ ========== */

/* Контейнер реакций под сообщением */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    position: relative;
    justify-content: space-between;
}

/* Отдельная реакция (бейдж) */
.reaction-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 4px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    line-height: 1.4;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 28px;
}

.message-own .reaction-badge {
    background: rgba(232, 203, 88, 0.2);
    border-color: rgba(232, 203, 88, 0.3);
}

.message-other .reaction-badge {
    background: var(--bg-hover);
    border-color: var(--border);
}

.reaction-badge:active {
    transform: scale(0.95);
}

/* Активная реакция (пользователь поставил) */
.reaction-badge.user-reacted {
    background: rgba(232, 203, 88, 0.25);
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(232, 203, 88, 0.15);
}

.message-own .reaction-badge.user-reacted {
    background: #0000003d;
    border-color: #585858b8;
}

/* Эмодзи в реакции */
.reaction-emoji {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

/* Аватарки в реакции */
.reaction-avatars {
    display: flex;
    position: relative;
}

.reaction-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border: 1.5px solid var(--bg-card);
    margin-left: -4px;
    overflow: hidden;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 600;
}

.reaction-avatar:first-child {
    margin-left: 0;
}

.reaction-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reaction-extra {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border: 1.5px solid var(--bg-card);
    margin-left: -4px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Счётчик реакций */
.reaction-count {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 2px;
    font-weight: 500;
}

.reaction-badge.user-reacted .reaction-count {
    color: var(--primary);
}

/* ========== ПЛАВАЮЩАЯ КНОПКА СОЗДАНИЯ ГРУППЫ ========== */
.floating-create-group-btn {
    position: absolute;
    bottom: 25px;
    right: 25px;
    width: 45px;
    height: 45px;
    min-width: 45px;
    max-width: 45px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
    font-size: 20px;
    padding: 0;
    margin: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

/* Десктоп (ширина более 768px) */
@media (min-width: 769px) {
    .floating-create-group-btn {
        visibility: hidden;
        opacity: 0;
        transform: translateY(80px) scale(0.8);
        transition: opacity 0.2s ease, 
                    transform 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
        pointer-events: none;
        will-change: transform, opacity;
    }
    
    .floating-create-group-btn.visible {
        visibility: visible;
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
}

/* Мобильные устройства (768px и меньше) - кнопка всегда видна */
@media (max-width: 768px) {
    .floating-create-group-btn {
        visibility: visible;
        transform: translateY(0);
        transition: none;
    }
}

.floating-create-group-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 16px rgba(232, 203, 88, 0.3);
}

.floating-create-group-btn i {
    font-size: 20px;
    color: var(--bg-dark);
    margin: 0;
    padding: 0;
    line-height: 1;
}

/* ========== ОБЛАСТЬ ЧАТА ========== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    min-width: 0;
    overflow: visible;
    position: relative;
}

.sidebar-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    cursor: ew-resize;
    z-index: 100;
}

/* ========== БАННЕР ЗАПРОСА УВЕДОМЛЕНИЙ ========== */
.notification-request-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5000;
    background: var(--bg-card);
    border-bottom: 1px solid var(--primary);
    padding: 12px 20px;
    /* ✅ Отступ для iPhone notch/dynamic island */
    padding-top: max(12px, env(safe-area-inset-top));
    animation: slideDown 0.3s ease;
}

.notification-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
    flex-wrap: wrap;
    /* ✅ Компактнее на мобильных */
}

.notification-banner-content i {
    color: var(--primary);
    font-size: 20px;
    flex-shrink: 0;
}

.notification-banner-content span {
    flex: 1;
    color: var(--text-primary);
    font-size: 13px;
    min-width: 150px;
    line-height: 1.3;
}

.notification-banner-content .btn-primary {
    flex-shrink: 0;
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
}

.notification-banner-content .icon-btn {
    flex-shrink: 0;
    padding: 6px;
    font-size: 16px;
}

/* ✅ Адаптивность для мобильных */
@media (max-width: 768px) {
    .notification-request-banner {
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
    }
    
    .notification-banner-content {
        gap: 6px;
    }
    
    .notification-banner-content i {
        font-size: 18px;
    }
    
    .notification-banner-content span {
        font-size: 11px;
        min-width: 120px;
    }
    
    .notification-banner-content .btn-primary {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .notification-banner-content .icon-btn {
        padding: 4px;
        font-size: 14px;
    }
}

/* ✅ Очень маленькие экраны (iPhone SE) */
@media (max-width: 380px) {
    .notification-request-banner {
        padding: 6px 8px;
        padding-top: max(6px, env(safe-area-inset-top));
    }
    
    .notification-banner-content span {
        font-size: 10px;
    }
    
    .notification-banner-content .btn-primary {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* ========== ШАПКА ЧАТА ========== */
.chat-header {
    padding: 20px;
    background: var(--bg-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 101;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.chat-header > .chat-info {
    flex: 1;
    cursor: pointer;
    pointer-events: none;
}

.chat-header > .chat-info * {
    pointer-events: none;
}

.chat-header > .chat-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.chat-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-status.online { color: var(--online); }
.chat-status.offline { color: var(--offline); }
.chat-status.hidden { display: none; }

.chat-header > .chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.chat-header > .chat-actions .icon-btn {
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 2;
}

.chat-header .mobile-menu-btn {
    pointer-events: auto;
    cursor: pointer;
}

/* ========== АУДИОПЛЕЕР В ШАПКЕ ========== */
.header-audio-player {
    display: none;
    flex-direction: column;
    background: var(--bg-hover);
    border-radius: 12px;
    padding: 8px 12px;
    margin: 0 10px;
    min-width: 200px;
    max-width: 280px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    pointer-events: auto;
    cursor: default;
}

.header-audio-player * {
    pointer-events: auto;
}

.header-audio-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.header-audio-btn {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--bg-dark);
    flex-shrink: 0;
}

.header-audio-btn:hover {
    
    background: var(--primary-dark);
}

.header-audio-btn i {
    font-size: 14px;
}

.header-audio-time {
    font-size: 12px;
    color: var(--text-primary);
    min-width: 70px;
    text-align: center;
    font-family: monospace;
    white-space: nowrap;
    line-height: 1;
}

.header-audio-volume {
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-audio-volume i {
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.header-audio-volume i:hover {
    color: var(--primary);
}

.header-volume-slider {
    width: 50px;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

.header-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.header-volume-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.header-audio-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.header-audio-close:hover {
    background: var(--bg-dark);
    color: var(--danger);
}

.header-audio-filename {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 5px;
}

/* ========== ГЛОБАЛЬНЫЙ ПЛЕЕР ДЛЯ ГОЛОСОВЫХ СООБЩЕНИЙ ========== */
.global-voice-player {
    display: none;
    position: fixed;
    top: 100px;
    right: 25px;
    z-index: 99;
    animation: voicePlayerSlideDown 0.3s ease;
}

.voice-player-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: 30px;
    padding: 8px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.voice-player-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-player-info i {
    color: var(--primary);
    font-size: 16px;
}

.voice-player-duration {
    font-size: 13px;
    color: var(--text-primary);
    font-family: monospace;
    min-width: 70px;
}

.voice-player-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-player-btn {
    background: var(--bg-hover);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.voice-player-btn:hover {
    background: var(--primary);
    color: var(--bg-dark);
    transform: scale(1.05);
}

.voice-player-btn:active {
    transform: scale(0.95);
}

@keyframes voicePlayerSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .global-voice-player {
        top: 90px;
        right: 20px;
        left: auto;
    }
    
    .voice-player-content {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .voice-player-duration {
        font-size: 11px;
        min-width: 60px;
    }
    
    .voice-player-btn {
        width: 28px;
        height: 28px;
    }
}

/* Для случаев, когда шапка чата выше (например, с аудиоплеером) */
.chat-header:has(.header-audio-player[style*="display: flex"]) ~ .global-voice-player {
    top: 110px;
}

@media (max-width: 768px) {
    .chat-header:has(.header-audio-player[style*="display: flex"]) ~ .global-voice-player {
        top: 95px;
    }
}

/* ========== КАСТОМНЫЕ УВЕДОМЛЕНИЯ ========== */
.custom-notification {
    position: fixed;
    z-index: 9999;
    animation: notificationSlideIn 0.3s ease;
    max-width: 380px;
    cursor: pointer;
    pointer-events: auto;

}

.custom-notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    line-height: 1.4;
}

.custom-notification-content i {
    font-size: 18px;
    flex-shrink: 0;
}

.custom-notification-content span {
    flex: 1;
}

/* Типы */
.custom-notification-success .custom-notification-content {
    background: rgba(74, 222, 128, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.4);
    color: #4ade80;
}

.custom-notification-error .custom-notification-content {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #f87171;
}

.custom-notification-warning .custom-notification-content {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: #fbbf24;
}

.custom-notification-info .custom-notification-content {
    background: rgba(232, 203, 88, 0.15);
    border: 1px solid rgba(232, 203, 88, 0.4);
    color: #e8cb58;
}

/* Позиции */
.custom-notification-top-right {
    top: 20px;
    right: 20px;
}

.custom-notification-top-center {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.custom-notification-bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.custom-notification-inline {
    position: relative;
    width: 100%;
}

/* Анимации */
@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

@keyframes notificationSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* top-center анимация */
.custom-notification-top-center {
    animation: notificationSlideDown 0.3s ease;
}

/* bottom анимация */
.custom-notification-bottom {
    animation: notificationSlideUp 0.3s ease;
}

@keyframes notificationSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .custom-notification {
        max-width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
    }
    
    .custom-notification-top-right {
        top: max(10px, env(safe-area-inset-top));
        right: 10px;
        left: auto;
    }
    
    .custom-notification-top-center {
        top: max(10px, env(safe-area-inset-top));
    }
    
    .custom-notification-bottom {
        bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Telegram-style loader for mobile pagination */
.loading-more {
    padding: 12px;
    text-align: center;
}

.telegram-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.telegram-loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: telegram-spin 0.8s linear infinite;
}

@keyframes telegram-spin {
    to { transform: rotate(360deg); }
}

/* Для мобильных - увеличиваем область касания */
@media (max-width: 768px) {
    .loading-more {
        padding: 16px;
    }
}

/* ========== РАЗДЕЛИТЕЛЬ "НЕПРОЧИТАННЫЕ СООБЩЕНИЯ" ========== */
.unread-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
    position: relative;
    width: 100%;
    padding: 0 10px;
    flex-shrink: 0;
}

.unread-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--primary);
    opacity: 0.3;
    z-index: 0;
}

.unread-divider span {
    background: var(--bg-dark);
    padding: 4px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
    border-radius: 12px;
    border: 1px solid var(--primary);
    background: var(--bg-card);
}

/* Для мобильных */
@media (max-width: 768px) {
    .unread-divider span {
        font-size: 11px;
        padding: 3px 12px;
    }
}

/* ========== СООБЩЕНИЯ ========== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-anchor: none;
    padding: 10px 20px 0px 20px;
    display: flex;
    flex-direction: column-reverse;
    background: var(--bg-dark);
    position: relative;
    z-index: 1;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    
}

.messages-container > * {
    flex-shrink: 0;
}

.messages-container .welcome-message {
    order: 0;
    align-self: center;
    margin: auto 0;
}

.messages-container .message {
    order: 0;
}

.messages-container .loading {
    order: 0;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    margin: auto 0;
    align-self: center;
    flex-shrink: 0;
    order: 0;
}

/* галочки */
.message-status {
    margin-left: 4px;
    font-size: 10px;
    display: inline-block;
}

.message-status.sent {
    color: var(--text-secondary);
    opacity: 0.7;
}

.message-status.read {
    padding-right: 2px;
    letter-spacing: -5px;
    color: var(--primary);
}

/* Для тёмной темы, свои сообщения */
.message-own .message-status.sent {
    color: var(--bg-dark);
    opacity: 0.7;
}

.message-own .message-status.read {
    color: var(--bg-dark);
}

/* В CSS добавьте: */
.message-own .media-message .message-status.read,
.message-own .video-note-message .message-status.read {
    color: #ffffff !important;
}

.message-own .media-message .message-status.sent,
.message-own .video-note-message .message-status.sent {
    color: #ffffff !important;
}

/* И для обновленных через JS */
.message-own .message-status.read i,
.message-own .message-status.sent i {
    color: inherit;
}

.message {
    margin-top: 0 !important;
    margin-bottom: 7px !important;
    display: flex;
    flex-shrink: 0;
}

/* Последнее сообщение в DOM (самое старое визуально снизу) не должно иметь отступа */
.messages-container > .message:last-child {
    margin-bottom: 7 !important;
}

/* Добавляем отступ перед первым сообщением (самым новым визуально сверху) */
.messages-container > .message:first-child {
    margin-top: 0 !important;
    margin-bottom: 0px !important;
}

.message-own { justify-content: flex-end; }
.message-other { justify-content: flex-start; }

.message-content {
    max-width: 70%;
    padding: 6px 10px;
    position: relative;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-own .message-content {
    background: var(--primary);
    color: var(--bg-dark);
    border-radius: 15px 8px 8px 15px;
}

.message-other .message-content {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-radius: 8px 15px 15px 8px;
}

/* Первое сообщение от пользователя или после паузы - нормальный отступ */
.message-other:has(.message-username) .message-content {
    margin-top: 8px;
}

/* ✅ ПОСЛЕДНЕЕ сообщение в группе (от собеседника) */
.message-other.message-last-in-group .message-content {
    border-radius: 15px 15px 15px 0px;
}

/* ✅ ПОСЛЕДНЕЕ сообщение в группе (своё) */
.message-own.message-last-in-group .message-content {
    border-radius: 15px 15px 0px 15px;
}

.message-username {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    display: block;
    text-align: left;
}

.message-text-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 9px;
}

.message-text {
    display: inline-block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 15px;
    text-align: left;
    line-height: 1.5;
    white-space: pre-wrap;
    flex: 1;
    min-width: 0;
}

.message-text a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
    cursor: pointer;
    pointer-events: auto;
}

.message-own .message-text a {
    color: var(--bg-dark);
}

.message-other .message-text a {
    color: var(--primary);
}

.message-text a:hover {
    opacity: 0.8;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
    line-height: 2.35;
    height: 20px;
    margin-left: 7px;
    float: right;
    align-self: flex-end;
    position: relative;
    top: 5px;
    display: inline;
    cursor: default;
}

.message-edited {
    font-size: 10px;
    font-style: italic;
    opacity: 0.6;
}

/* Группа сообщений по дате */
.message-date-group {
    display: flex;
    flex-direction: column;
}

.message-date-header {
    text-align: center;
    font-size: 12px;
    color: var(--date-primary);
    margin: 10px 0;
    font-weight: 500;
    background: var(--bg-hover);
    backdrop-filter: blur(4px);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    border-radius: 12px;
    padding: 6px 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ========== РЕЖИМ ВЫДЕЛЕНИЯ СООБЩЕНИЙ ========== */

/* Режим выделения активирован */
.messages-container.selection-mode .message *{
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.messages-container.selection-mode .message {
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* Выделенное сообщение */
.message.selected {
    position: relative;
}

.message.selected .message-content {
    border: 2px solid var(--primary) !important;
    transition: border 0.15s ease;
}

/* Кружок выделения справа от сообщения */
.message .selection-circle {
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    background: transparent;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    z-index: 10;
    pointer-events: none;
}

/* В режиме выделения показываем кружки у всех сообщений */
.messages-container.selection-mode .message .selection-circle {
    display: flex;
}

/* Кружок выделенного сообщения */
.message.selected .selection-circle {
    background: var(--primary);
    border-color: var(--primary);
}

.message.selected .selection-circle::after {
    content: '✓';
    color: var(--bg-dark);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

/* Hover эффект для кружка (на ПК) */
.messages-container.selection-mode .message:not(.selected) .selection-circle:hover {
    border-color: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

/* Анимация появления кружков */
.messages-container.selection-mode .message .selection-circle {
    animation: circleAppear 0.2s ease forwards;
}

@keyframes circleAppear {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Адаптация для своих сообщений - кружок справа от всего сообщения */
.message-own .selection-circle {
    right: -15px;
}

/* Для своих сообщений тоже добавляем отступ */
.messages-container.selection-mode .message-own {
    padding-right: 15px;
    position: relative;
}

.messages-container.selection-mode .message-other {
    padding-right: 0px;
    position: relative;
}

/* Для сообщений без бабла (медиа) */
.message .selection-circle {
    pointer-events: none;
}

/* Панель действий в режиме выделения (для мобильных) */
.selection-toolbar {
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    padding: 12px 20px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 100;
    animation: slideDown 0.25s ease;
}

.selection-toolbar.active {
    display: flex;
}

.selection-toolbar .toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 10px;
    transition: all 0.2s;
    font-size: 11px;
}

.selection-toolbar .toolbar-btn i {
    font-size: 22px;
}

.selection-toolbar .toolbar-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.selection-toolbar .toolbar-btn:active {
    transform: scale(0.95);
}

.selection-toolbar .toolbar-btn.danger:hover {
    color: var(--danger);
}

.selection-toolbar .toolbar-btn .badge {
    background: var(--primary);
    color: var(--bg-dark);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.selection-toolbar .toolbar-count {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-right: auto;
}

.selection-toolbar .toolbar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.selection-toolbar .toolbar-close:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

/* Затемнение фона при выделении (опционально) */
.messages-container.selection-mode .message:not(.selected) {
    opacity: 0.85;
}

.messages-container.selection-mode .message.selected {
    opacity: 1;
}

/* Для мобильных - увеличиваем область касания кружка */
@media (max-width: 768px) {
    .message .selection-circle {
        right: -15px;
        width: 28px;
        height: 28px;
        border-width: 2.5px;
    }
    
    .message-own .selection-circle {
        right: -15px;
    }
    
    .message.selected .selection-circle::after {
        font-size: 16px;
    }
    
    .selection-toolbar {
        padding: 10px 16px;
        padding-top: max(8px, env(safe-area-inset-top));
        gap: 12px;
    }
    
    .selection-toolbar .toolbar-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
    
    .selection-toolbar .toolbar-btn i {
        font-size: 20px;
    }
    
    .selection-toolbar .toolbar-count {
        font-size: 12px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .message .selection-circle {
        right: -15px;
        width: 24px;
        height: 24px;
    }
    
    .message-own .selection-circle {
        right: -15px;
    }
    
    .selection-toolbar {
        gap: 8px;
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
    }
    
    .selection-toolbar .toolbar-btn {
        padding: 4px 8px;
        font-size: 9px;
    }
    
    .selection-toolbar .toolbar-btn i {
        font-size: 18px;
    }
}

/* Анимация для панели */
@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 1;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Сброс выделения при нажатии на пустую область */
.messages-container.selection-mode .selection-clear-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Индикатор количества выделенных в заголовке */
.selection-header-indicator {
    font-size: 14px;
    color: var(--primary);
    font-weight: 500;
}

/* ========== DRAG & DROP ========== */
.chat-area.drag-over::before {
    content: '📎 Отпустите файлы для загрузки';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 20px 40px;
    border-radius: 16px;
    border: 3px dashed var(--primary);
    font-size: 18px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: dragDropPulse 1.5s ease-in-out infinite;
}

@keyframes dragDropPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.02); }
}

/* ========== ПОЛЕ ВВОДА ========== */
.message-input-container {
    padding: 15px 20px;
    background: var(--bg-dark);
    flex-shrink: 0;
    display: none;
    width: 100%;
    position: relative;
    z-index: 1;
}

.message-input-container.active {
    display: flex;
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1500;
    background: var(--bg-dark);
    padding: 10px 15px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    transition: bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ✅ Без эмодзи - поле ввода внизу */
.message-input-container.active:not(.emoji-open) {
    bottom: 0;
}

.message-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: end;
    background: var(--bg-card);
    border-radius: 24px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    transition: all 0.3s;
    width: 100%;
}

.message-input-wrapper:focus-within {
    border-color: var(--primary);
}

.message-input-wrapper textarea {
    flex: 1;
    padding: 10px 5px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    resize: none;
    font-family: inherit;
    max-height: 150px;
    min-height: 38px;
    line-height: 1.4;
    outline: none;
    width: 100%;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    user-select: none;
    scrollbar-width: none;
}

.input-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.input-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.send-btn {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: var(--bg-dark);
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    font-size: 18px;
    margin-right: 5px;
}

.send-btn:hover {
    background: var(--primary-dark);
    
}

/* ========== ПАНЕЛЬ ЭМОДЗИ ========== */
.emoji-panel {
    position: absolute;
    bottom: 75px;
    left: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    overflow-y: auto;
    max-height: 300px;
}

.emoji-panel button {
    user-select: none;
    width: 40px;
    height: 40px;
    font-size: 24px;
    background: var(--bg-dark);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-panel button:hover {
    background: var(--primary);
    transform: scale(1.1);
}

/* Индикатор навигации по сообщениям в баннере редактирования */
.edit-navigation-counter {
    font-size: 12px;
    opacity: 0.7;
    margin-left: 8px;
    font-weight: normal;
    color: var(--text-secondary);
}

.edit-navigation-counter:before {
    content: '•';
    margin-right: 6px;
}

/* ========== ЗАПИСЬ ГОЛОСОВЫХ СООБЩЕНИЙ ========== */
.recording-visualization {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0px 8px 12px;
    background: var(--bg-dark);
    border-radius: 20px;
    min-height: 38px;
    max-width: 100px
}

.recording-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.recording-cancel {
    font-size: 14px;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger);
    animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
}

.recording-timer {
    font-size: 14px;
    font-family: monospace;
    color: var(--text-primary);
    min-width: 45px;
    text-align: center;
    flex-shrink: 0;
}

.recording-timer.warning {
    color: var(--warning);
    animation: blink 0.5s ease-in-out infinite;
}

.recording-timer.danger {
    color: var(--danger);
    animation: blink 0.3s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.recording-waveform {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.recording-waveform canvas {
    width: 100%;
    height: 40px;
    opacity: 0.7;
}

.cancel-recording-btn {
    background: transparent;
    margin-right: 5px;
    color:var(--danger) !important;
}

.cancel-recording-btn:hover {
    background: transparent;
    color: #ef4444 !important;
    
}

/* Кнопка записи в активном состоянии */
#voice-record-btn.recording {
    background: var(--primary);
    color: var(--bg-hover);
    /* animation: recordingPulse 1.5s ease-in-out infinite; */
    margin-right: 5px;
    scale: 1.2;
}

#voice-record-btn.recording:hover {
    background: var(--primary-dark);
    color: var(--bg-hover);
}

/* Универсальная кнопка записи */
#record-btn {
    transition: all 0.3s ease;
    position: relative;
}

#record-btn.recording {
    background: var(--primary);
    color: var(--bg-hover);
    animation: recordingPulse 1.5s ease-in-out infinite;
}

#record-btn.recording-video {
    background: var(--danger);
    color: white;
    animation: recordingPulse 1.5s ease-in-out infinite;
}

#record-btn.recording-video i {
    color: white;
}

/* Голосовое сообщение - как в Telegram */
.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    max-width: 280px;
    background: var(--bg-hover);
    border-radius: 16px;
    transition: background 0.2s;
}

.message-own .voice-message {
    background: var(--primary);
    border-radius: 16px 8px 16px 16px;
}

.message-other .voice-message {
    background: var(--bg-hover);
    border-radius: 8px 16px 16px 16px;
}

/* style.css */

/* ========== ВИДЕОСООБЩЕНИЯ (КРУЖКИ) ========== */
.video-note-message {
    position: relative;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    background: var(--bg-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: width 0.3s cubic-bezier(0.31, 1.28, 0.58, 0.93), height 0.3s cubic-bezier(0.31, 1.28, 0.58, 0.93), border-radius 0.3s cubic-bezier(0.31, 1.28, 0.58, 0.93), transform 0.3s cubic-bezier(0.31, 1.28, 0.58, 0.93);
    z-index: 1;
    transform-origin: center center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.video-note-message:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.video-note-player {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
    background: var(--bg-dark);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Длительность видео (слева) */
.video-note-duration {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 10px;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 10px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: none;
    z-index: 2;
    font-family: monospace;
}

/* Время отправки (справа) */
.video-note-time {
    position: absolute;
    bottom: 6px;
    right: 0px;
    font-size: 10px;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 10px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: none;
    z-index: 2;
}

.message-other .video-note-time {
    right: 6px;
}

/* ========== РАСШИРЕННЫЙ РЕЖИМ (ПОЛНЫЙ ЭКРАН ВНУТРИ ЧАТА) ========== */
.video-note-message.expanded {
    position: relative;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    z-index: 1000;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
    background: var(--bg-dark);
    cursor: default;
    transform: scale(1);
    user-select: none;
    /* ✅ Отключаем выделение при касании */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

.video-note-message.expanded .video-note-duration,
.video-note-message.expanded .video-note-time {
    bottom: 12px;
    padding: 4px 10px;
}

/* Кнопка закрытия в расширенном режиме */
.video-note-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
    transition: all 0.2s;
}

.video-note-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Затемнение фона при расширении */
body.video-expanded::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}


/* ========== АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ ========== */
@media (min-width: 900px) {
    .video-note-message.expanded {
        width: 500px;
        height: 500px;
    } 
}

@media (max-width: 768px) {
    .message-own .video-note-message.expanded {
        width: 350px;
        height: 350px;
        right:20px;
    }
    .message-other .video-note-message.expanded {
        width: 350px;
        height: 350px;
        left:10px;
    }
          
    .video-note-close-btn {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
}

@media (max-width: 480px) {
    .video-note-message {
        width: 230px;
        height: 230px;   
    }   
}

/* Стиль для кнопки записи видео */
#video-note-btn.recording {
    background: var(--danger);
    color: white;
    animation: recordingPulse 1.5s ease-in-out infinite;
}

#video-note-btn.recording i {
    color: white;
}

/* Кнопка воспроизведения/паузы */
.voice-message-play-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.message-own .voice-message-play-btn {
    transition: all 0.2s;
    background: var(--bg-dark);
}

.message-own .voice-message-play-btn:hover {
    background: var(--bg-hover);
    
}

.voice-message-play-btn i {
    font-size: 18px;
    color: var(--bg-dark);
}

.message-own .voice-message-play-btn i {
    color: var(--primary);
}

/* Контейнер с информацией */
.voice-message-info {
    flex: 1;
    min-width: 0;
}

/* Волновая форма (вертикальные линии) */
.voice-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 32px;
    margin-bottom: 4px;
}

.voice-waveform-bar {
    width: 3px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: height 0.1s ease;
}

.message-own .voice-waveform-bar {
    background: var(--bg-dark);
    opacity: 0.7;
}

/* Активная волна (при воспроизведении) */
.voice-waveform-bar.active {
    background: var(--primary);
}

.message-own .voice-waveform-bar.active {
    background: var(--bg-dark);
    opacity: 1;
}

/* Время и размер */
.voice-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    
}

.voice-time {
    margin-top: -5px;
    cursor: default;
}
.voice-size {
    margin-top: -5px;
    cursor: default;
}

.voice-separator{
    font-size: 10px;
    opacity: 0.5;
    margin-top: -5px;
    cursor: default;
}

.message-own .voice-meta {
    color: var(--bg-dark);
    opacity: 0.8;
}

.voice-sent-time {
    font-size: 10px;
    opacity: 0.7;
    margin-left: auto;
}

/* Для своих сообщений галочки */
.message-own .voice-meta .message-status {
    margin-left: -5px;
}

.voice-duration {
    font-family: monospace;
    min-width: 35px;
}

.voice-size {
    font-size: 10px;
    opacity: 0.7;
}

/* Прогресс-бар поверх волновой формы */
.voice-waveform-wrapper {
    position: relative;
}

.voice-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    pointer-events: none;
    transition: width 0.1s linear;
}

.message-own .voice-progress-overlay {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .voice-message {
        min-width: 160px;
        max-width: 240px;
        gap: 8px;
    }
    
    .voice-message-play-btn {
        width: 32px;
        height: 32px;
    }
    
    .voice-message-play-btn i {
        font-size: 12px;
    }
    
    .voice-waveform-bar {
        width: 2px;
    }
    
    .voice-meta {
        font-size: 10px;
        gap: 6px;
    }
    
    .voice-duration {
        font-size: 10px;
    }
    
    .voice-size {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .voice-message {
        min-width: 140px;
        max-width: 200px;
    }
    
    .voice-waveform-bar {
        width: 2px;
    }
}

/* Адаптивность для записи */
@media (max-width: 768px) {
    .recording-visualization {
        gap: 6px;
    }
    
    .recording-timer {
        font-size: 12px;
    }
}

/* ========== МОДАЛЬНЫЕ ОКНА ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s;
    user-select: none;
}

.close-modal:hover {
    color: var(--danger);
}

.modal-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 16px;
    user-select: none;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 10px;
}

/* ========== ПРОФИЛЬ ========== */
.profile-modal-content {
    max-width: 450px;
    padding: 25px;
    max-height: 88vh;
}

.profile-content {
    display: flex;
    flex-direction: column;
}

.profile-avatar-section {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.profile-avatar-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    background: var(--bg-dark);
    user-select: none;
}

.change-avatar-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--bg-dark);
    border: 2px solid var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.change-avatar-btn:hover {
    background: var(--primary-dark);
    
}

.profile-info-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-username-display {
    color: var(--primary, #e8cb58);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    text-align: center;
}

.profile-username-display:hover {
    opacity: 0.8;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-field label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.profile-field label i {
    margin-right: 6px;
    width: 16px;
}

.profile-field input,
.profile-field textarea {
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s;
    user-select: none;
}

.profile-field input:focus,
.profile-field textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.profile-field input[readonly] {
    background: var(--bg-hover);
    opacity: 0.7;
    cursor: not-allowed;
}

.profile-checkbox-field {
    padding: 8px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-text {
    font-size: 14px;
    color: var(--text-primary);
}

.field-hint {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-left: 30px;
}

.bio-counter {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
    user-select: none;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 20px;
    user-select: none;
}

.profile-actions .btn-secondary {
    width: auto;
}

.profile-actions .btn-primary {
    width: 100%;
}

/* ========== ПРОФИЛЬ ПОЛЬЗОВАТЕЛЯ ========== */
.user-profile-modal-content {
    max-width: 400px;
    padding: 25px;
}

.user-profile-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.user-profile-avatar-section {
    display: flex;
    justify-content: center;
}

.user-profile-avatar-wrapper {
    width: 120px;
    height: 120px;
}

.user-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    background: var(--bg-dark);
    user-select: none;
}

.user-profile-info {
    text-align: center;
}

.user-profile-info h2 {
    font-size: 22px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.user-profile-username {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.user-profile-bio-section {
    text-align: left;
    margin: 15px 0;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 10px;
}

.user-profile-bio-section label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.user-profile-bio-section label i {
    margin-right: 6px;
}

.user-profile-bio-section p {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    word-break: break-word;
    min-height: 40px;
}

.user-profile-bio-section p:empty::before {
    content: 'Не указано';
    color: var(--text-secondary);
    font-style: italic;
}

#profile-bio {
    resize: none;
}

.user-profile-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-indicator.online {
    background: var(--online);
    box-shadow: 0 0 10px var(--online);
}

.status-indicator.offline {
    background: var(--offline);
}

.status-indicator.hidden {
    display: none;
}

#user-profile-status-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.user-profile-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.user-profile-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.user-profile-btn i {
    font-size: 14px;
}

.btn-add-friend {
    background: var(--primary);
    color: var(--bg-dark);
}

.btn-add-friend:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-remove-friend {
    background: var(--danger);
    color: white;
}

.btn-remove-friend:hover {
    background: #ef4444;
    transform: translateY(-2px);
}

.btn-block {
    background: var(--accent);
    color: white;
}

.btn-block:hover {
    background: var(--danger);
    transform: translateY(-2px);
}

.btn-unblock {
    background: var(--success);
    color: var(--bg-dark);
}

.btn-unblock:hover {
    background: #22c55e;
    transform: translateY(-2px);
}

.btn-accept-request {
    background: var(--success);
    color: var(--bg-dark);
}

.btn-accept-request:hover {
    background: #22c55e;
    transform: translateY(-2px);
}

.btn-pending {
    background: var(--warning);
    color: var(--bg-dark);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-pending:hover {
    transform: none;
}

.blocked-message {
    text-align: center;
    padding: 15px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--danger);
    border-radius: 10px;
    color: var(--danger);
    margin-top: 15px;
}

.blocked-message i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.blocked-message span {
    font-size: 14px;
}

.chat-blocked-message {
    text-align: center;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    margin: 20px;
    color: var(--text-secondary);
    align-self: center;
    flex-shrink: 0;
    order: 0;
}

.chat-blocked-message i {
    font-size: 32px;
    color: var(--danger);
    margin-bottom: 12px;
}

.chat-blocked-message h4 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.chat-blocked-message p {
    font-size: 13px;
}

/* ========== МОДАЛЬНОЕ ОКНО ГРУППЫ ========== */
.group-info-modal-content {
    max-width: 450px;
    padding: 25px;
    max-height: 90vh;
}

/* Модальное окно профиля пользователя */
#user-profile-modal {
    z-index: 2100; /* Выше чем окно группы (2000) */
}

#group-info-modal {
    z-index: 2000;
}

.group-info-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.group-avatar-section {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.group-avatar-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
}

.group-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    background: var(--bg-dark);
    user-select: none;
}

.change-group-avatar-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--bg-dark);
    border: 2px solid var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 14px;
}

.change-group-avatar-btn:hover {
    background: var(--primary-dark);
    
}

.group-info-details {
    text-align: center;
}

.group-info-details h2 {
    font-size: 22px;
    margin-bottom: 4px;
    color: var(--text-primary);
    word-break: break-word;
}

.group-members-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.group-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.group-action-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    background: var(--bg-hover);
    color: var(--text-primary);
    border: none;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
}

.group-action-btn:hover {
    background: var(--border);
}

.group-action-btn.danger {
    color: var(--danger);
}

.group-action-btn.danger:hover {
    background: rgba(248, 113, 113, 0.1);
}

.group-action-btn i {
    font-size: 14px;
}

.group-members-section {
    margin-top: 10px;
}

.group-members-section h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    user-select: none;
}

.group-members-list {
    max-height: 300px;
    overflow-y: auto;
}

.group-member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    transition: background 0.2s;
    cursor: pointer;
    position: relative;
}

.group-member-item:hover {
    background: var(--bg-hover);
}

/* ========== КНОПКА УДАЛЕНИЯ УЧАСТНИКА ГРУППЫ ========== */
.remove-member-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 14px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 2;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    font-family: inherit;
}

/* Показываем кнопку при наведении на элемент */
.group-member-item:hover .remove-member-btn {
    opacity: 1;
}

.remove-member-btn:hover {
    color: var(--primary);
    transform: translateY(-50%) scale(1.05);
}

.remove-member-btn:active {
    transform: translateY(-50%) scale(0.95);
    background: rgba(232, 203, 88, 0.15);
}

.remove-member-btn span {
    pointer-events: none;
    line-height: 1;
}


/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .remove-member-btn {
        opacity: 0.7;
        padding: 8px 16px;
        right: 8px;
        font-size: 14px;
        color: var(--primary);
    }
    
    .remove-member-btn:active {
        opacity: 1;
    }
}

/* Анимация удаления */
.group-member-item.removing {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.group-member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.group-member-avatar i {
    font-size: 18px;
    color: var(--text-secondary);
}

.group-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    user-select: none;
}

.member-status-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--online);
    border: 2px solid var(--bg-card);
}

.member-status-badge.offline {
    background: var(--offline);
}

.group-member-info {
    flex: 1;
    min-width: 0;
}

.group-member-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-member-role {
    font-size: 11px;
    color: var(--primary);
    margin-top: 2px;
}

.group-member-role.admin {
    color: var(--primary);
}

/* ========== НАСТРОЙКИ ГРУППЫ ========== */
.group-settings-modal-content {
    max-width: 400px;
    padding: 25px;
}

.group-settings-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-avatar-section {
    display: flex;
    justify-content: center;
}

.settings-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-field label {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-field input {
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
}

.settings-field input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== ДОБАВЛЕНИЕ УЧАСТНИКОВ ========== */
.add-members-modal-content {
    max-width: 400px;
    padding: 25px;
}

.add-members-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.friends-select-list {
    max-height: 300px;
    overflow-y: auto;
}

.friend-to-add-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.friend-to-add-item:hover {
    background: var(--bg-hover);
}

.friend-to-add-item.selected {
    background: var(--primary);
    color: var(--bg-dark);
}

.friend-to-add-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.friend-to-add-avatar i {
    font-size: 18px;
}

.friend-to-add-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.friend-to-add-info {
    flex: 1;
}

.friend-to-add-name {
    font-weight: 500;
    font-size: 14px;
}

.friend-to-add-username {
    font-size: 12px;
    color: var(--text-secondary);
}

.friend-to-add-item.selected .friend-to-add-username {
    color: var(--bg-dark);
    opacity: 0.8;
}

.no-friends-message {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

/* ========== ПОИСК ========== */
.search-section {
    margin-bottom: 20px;
}

.search-section h4 {
    color: var(--text-secondary);
    font-size: 12px;
    padding-left: 12px;
}

.add-friend-from-search {
    padding: 6px 12px;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    pointer-events: auto;
}

.add-friend-from-search:hover {
    background: var(--primary-dark);
}

/* ========== ПРОГРЕСС ЗАГРУЗКИ ========== */
.file-progress {
    margin-top: 8px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.file-progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
    width: 0%;
}

/* ========== МЕДИА В СООБЩЕНИЯХ ========== */
.media-message {
    position: relative;
    display: inline-block;
    max-width: 250px;
    line-height: 0;
}

.media-message img,
.media-message video {
    max-width: 250px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    object-fit: cover;
    -webkit-touch-callout: none; /* Запрет вызова контекстного меню на iOS */
    -webkit-user-select: none;
    user-select: none;
}

.media-message video::-webkit-media-controls,
.media-message video::-webkit-media-controls-panel,
.media-message video::-webkit-media-controls-play-button,
.media-message video::-webkit-media-controls-start-playback-button,
.media-message video::-webkit-media-controls-enclosure {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.media-message video {
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-media-controls: none !important;
    pointer-events: auto;
}

.media-message video[data-loaded="true"] {
    opacity: 1;
}

.media-time {
    position: absolute;
    bottom: 6px;
    right: 6px;
    font-size: 10px;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 3px 6px;
    border-radius: 12px;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

.media-time .message-edited {
    color: rgba(255, 255, 255, 0.8);
    margin-left: 3px;
}

.media-sound-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
    margin: 0;
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.media-sound-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.media-sound-btn:active {
    transform: scale(0.9);
}

.media-sound-btn i {
    font-size: 11px;
    color: white;
}

/* Позиционирование на мобильных */
@media (max-width: 768px) {
    .media-sound-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
        top: 6px;
        right: 6px;
    }
    
    .media-sound-btn i {
        font-size: 12px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .media-sound-btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
        top: 4px;
        right: 4px;
    }
    
    .media-sound-btn i {
        font-size: 10px;
    }
}

/* ========== ВРЕМЯ ВИДЕО В СООБЩЕНИЯХ ========== */
.video-time-container {
    position: absolute;
    bottom: 5px;
    left: 28px;
    height: 20px;
    font-size: 11px;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 8px 2px 0px;
    border-radius: 0px 10px 10px 0px;
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 2px;
    pointer-events: none;
    z-index: 5;
    user-select: none;
    line-height: 1.4;
}

.video-current-time {
    color: #ffffff;
    font-weight: 400;
    min-width: 32px;
    text-align: center;
}

.video-time-separator {
    opacity: 0.5;
    font-size: 10px;
}

.video-duration {
    opacity: 0.7;
    font-weight: 300;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .video-time-container {
        font-size: 9px;
        left: 25px;
    }
    
    .video-current-time {
        min-width: 26px;
    }
}

.media-download-btn {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 9px;
    border-radius: 12px;
    font-size: 10px;
    text-decoration: none;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: background 0.2s;
}

.media-download-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.media-download-btn i {
    font-size: 9px;
}

.video-download-btn {
    position: absolute;
    bottom: 5px;
    left: 7px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 6px;
    border-radius: 10px 0px 0px 10px;
    font-size: 10px;
    text-decoration: none;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: background 0.2s;
}

.video-download-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.video-download-btn i {
    font-size: 9px;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .video-download-btn {
        left: 6px;
        bottom: 5px;
    }
    .video-download-btn i {
        font-size: 7px;
    }
}

.message-content:has(.media-message), .message-content:has(.video-note-message) {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible;
    user-select: none;
    outline: none;
}

/* ========== ФАЙЛЫ В СООБЩЕНИЯХ ========== */
.file-message {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.file-message i {
    font-size: 20px;
    color: var(--primary);
}

.message-own .file-message i {
    color: var(--bg-card);
}

.file-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.file-time {
    font-size: 10px;
    opacity: 0.7;
    margin-left: auto;
    white-space: nowrap;
}

/* ========== АУДИО В СООБЩЕНИЯХ ========== */
.audio-message {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.audio-message.active-audio {
    border-radius: 8px;
    padding: 6px;
    margin: -6px;
}

.audio-message-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.audio-message-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.audio-message-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-message-progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.audio-message-progress {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.audio-message-progress.dragging {
    cursor: grabbing;
}

.audio-message-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary-dark);
    border-radius: 2px;
    width: 0%;
    transition: none !important;
}

.audio-message-progress.dragging .audio-message-progress-bar {
    background: var(--primary-dark);
}

.audio-message-thumb {
    position: absolute;
    left: 0%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid var(--bg-card);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 3;
}

.audio-message-progress.dragging .audio-message-thumb {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3);
}

.audio-message:hover .audio-message-thumb,
.audio-message.active-audio .audio-message-thumb {
    opacity: 1;
}

.audio-message-progress:hover .audio-message-thumb {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
}

.audio-message-time {
    font-size: 10px;
    color: var(--text-secondary);
    min-width: 60px;
    max-width: 65px;
    text-align: right;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
}

.audio-message-size {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.play-audio-btn {
    background: var(--bg-dark);
    border: none;
    padding-left: 1px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.play-audio-btn:hover {
    background: var(--bg-hover);
}

.play-audio-btn i {
    color: var(--primary);
    font-size: 14px;
}

/* ========== ЗАГРУЗКА ========== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* ========== МОБИЛЬНОЕ МЕНЮ ========== */
.mobile-menu-btn {
    display: none;
    pointer-events: auto;
    cursor: pointer;
}

/* ========== КОНТЕКСТНОЕ МЕНЮ ========== */
.context-menu {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    max-width: 220px;
}

.context-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 15px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.3s;
    text-align: left;
    white-space: nowrap;
}

.context-menu button:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.context-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}


.context-menu button i {
    width: 20px;
    font-size: 16px;
}

/* Мобильная версия - ПОЛНОСТЬЮ переопределяем */
@media (max-width: 768px) {
    .context-menu {
        min-width: 180px !important;
        max-width: 200px !important;
        width: auto !important;
        border-radius: 14px;
        padding: 6px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }
    
    .context-menu button {
        padding: 12px 14px;
        font-size: 14px;
        gap: 10px;
        border-radius: 10px;
    }
    
    .context-menu button i {
        font-size: 16px;
        width: 20px;
    }
}

@media (max-width: 380px) {
    .context-menu {
        min-width: 160px !important;
        max-width: 180px !important;
        padding: 5px;
    }
    
    .context-menu button {
        padding: 10px 12px;
        font-size: 13px;
        gap: 8px;
    }
    
    .context-menu button i {
        font-size: 14px;
        width: 18px;
    }
}


/* ========== РЕАКЦИИ В КОНТЕКСТНОМ МЕНЮ ========== */
.context-reactions-section {
    display: flex;
    position: absolute;
    padding: 4px 6px 6px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 30px;
    left: -65px;
    top: -50px;
    width: 172%;
    max-height: 56px;
    z-index: 1500;
}

.context-reactions-section.expanded {
    max-height: 330px;
    overflow-y: auto;
}

.context-reactions-list {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    align-items: center;
}

.context-menu .context-reaction-btn {
    width: 10px;
    height: 10px;
    border: none;
    border-radius: 20px;
    background: transparent;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.context-menu .context-reaction-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.15);
}

.context-menu .context-reaction-more {
    width: 10px;
    height: 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    padding: 15px;
    
}

.context-menu .context-reaction-more:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ========== БЫСТРЫЙ ВЫБОР РЕАКЦИЙ ========== */
.quick-reaction-picker {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: reactionPickerPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes reactionPickerPop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.quick-reaction-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.quick-reaction-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}

.quick-reaction-btn:active {
    transform: scale(0.9);
}

.quick-reaction-btn.active {
    background: rgba(232, 203, 88, 0.2);
    border: 2px solid var(--primary);
}

.quick-reaction-more {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.quick-reaction-more:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* ========== ПОЛНЫЙ ВЫБОР РЕАКЦИЙ (МОДАЛЬНОЕ ОКНО) ========== */
.reaction-picker-modal .modal-content {
    max-width: 450px;
    padding: 20px;
    max-height: 70vh;
}

.reaction-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 4px;
}

.reaction-picker-btn {
    aspect-ratio: 1;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.reaction-picker-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.reaction-picker-btn:active {
    transform: scale(0.9);
}

.reaction-picker-btn.active {
    background: rgba(232, 203, 88, 0.2);
    border: 2px solid var(--primary);
    border-radius: 10px;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    .reaction-badge {
        padding: 2px 8px 2px 4px;
        font-size: 13px;
        min-height: 24px;
    }
    
    .reaction-emoji {
        font-size: 14px;
    }
    
    .reaction-avatar,
    .reaction-extra {
        width: 16px;
        height: 16px;
        font-size: 6px;
    }
    
    .reaction-count {
        font-size: 10px;
    }
    
    .reaction-add-btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    
    .context-reaction-btn {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }
    
    .context-reaction-more {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }
    
    .quick-reaction-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
    
    .quick-reaction-more {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .reaction-picker-grid {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .reaction-picker-btn {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .reaction-picker-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .reaction-picker-btn {
        font-size: 22px;
    }
}


/* ========== УВЕДОМЛЕНИЯ ========== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 3000;
    animation: slideIn 0.3s ease;
    font-size: 14px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.notification.success {
    background: var(--success);
    color: var(--bg-dark);
}

.notification.error {
    background: var(--danger);
    color: white;
}

.notification.info {
    background: var(--primary);
    color: var(--bg-dark);
}

/* ========== СОЗДАНИЕ ГРУППЫ ========== */
.friends-select {
    margin: 5px 0;
    padding: 0;
}

.friends-select h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 14px;
}

#friends-select-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
    margin-bottom: 20px;
}

.friend-select-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    user-select: none;
    cursor: pointer;
    border: 2px solid transparent;
}

.friend-select-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.friend-select-item.selected {
    background: var(--primary);
    color: var(--bg-dark);
    border-color: var(--primary-dark);
}

.friend-select-item.selected .friend-select-username {
    color: var(--bg-dark);
    opacity: 0.8;
}

.friend-select-item.selected .friend-select-name {
    color: var(--bg-dark);
}

/* Аватар в списке выбора */
.friend-select-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.friend-select-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.friend-select-avatar i {
    color: var(--text-secondary);
}

.friend-select-item.selected .friend-select-avatar {
    background: var(--bg-dark);
}

.friend-select-item.selected .friend-select-avatar i {
    color: var(--primary);
}

/* Информация о друге */
.friend-select-info {
    flex: 1;
    min-width: 0;
}

.friend-select-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-select-username {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Кастомный чекбокс */
.friend-select-checkbox {
    flex-shrink: 0;
}

.custom-checkbox {
    padding-left: 6px;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.custom-checkbox i {
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Состояние "включено" */
.custom-checkbox.checked {
    color: var(--bg-dark);
    background: var(--primary);
    border-color: var(--primary);
}

.custom-checkbox.checked i {
    opacity: 1;
}

/* Состояние "выключено" */
.custom-checkbox:not(.checked) {
    background: var(--bg-dark);
    border-color: var(--border);
}

.custom-checkbox:not(.checked) i {
    opacity: 0;
}

/* Ховер эффекты */
.custom-checkbox:hover {
    border-color: var(--primary);
    
}

/* Для мобильных устройств - увеличиваем область касания */
@media (max-width: 768px) {
    .custom-checkbox {
        width: 28px;
        height: 28px;
    }
    
    .custom-checkbox i {
        font-size: 16px;
    }
}

.friend-select-item.selected .custom-checkbox {
    background: var(--bg-dark);
    border-color: var(--bg-dark);
}

.friend-select-item.selected .custom-checkbox i {
    opacity: 1;
    color: var(--primary);
}

.friend-select-item.selected:hover .custom-checkbox {
    background: var(--bg-hover);
    border-color: var(--bg-hover);
}

/* Анимация выбора */
.friend-select-item {
    animation: selectFadeIn 0.2s ease;
}

@keyframes selectFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Скрываем стандартные чекбоксы */
#friends-select-list input[type="checkbox"] {
    display: none;
}

/* Адаптивность */
@media (max-width: 768px) {
    .friend-select-item {
        padding: 14px 12px;
    }
    
    .friend-select-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .friend-select-name {
        font-size: 15px;
    }
    
    .custom-checkbox {
        width: 28px;
        height: 28px;
    }
    
    .custom-checkbox i {
        font-size: 14px;
    }
}

#friends-select-list .loading {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

#friends-select-list .loading i {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

#friends-select-list::-webkit-scrollbar {
    width: 4px;
}

#friends-select-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 2px;
}

#friends-select-list::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}

#friends-select-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ========== МОДАЛЬНОЕ ОКНО ЗВОНКА ========== */
.call-modal-content {
    max-width: 500px;
    padding: 0;
    overflow: hidden;
    border-radius: 20px;
    background: var(--bg-card);
}

.call-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    position: relative;
}

.call-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 111%;
    flex: 0 0 auto;
}

.call-user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.call-avatar-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--primary);
}

.call-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-avatar-wrapper i {
    font-size: 40px;
    color: var(--primary);
}

.call-user-info h2 {
    font-size: 22px;
    color: var(--text-primary);
    text-align: center;
}

.call-status-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.call-duration {
    font-size: 18px;
    color: var(--primary);
    font-family: monospace;
    margin-top: 10px;
}

.call-actions-incoming,
.call-actions-active {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.call-action-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 22px;
    color: white;
    background: var(--bg-hover);
    position: relative;
}

.call-action-btn:hover {
    transform: scale(1.1);
}

.call-action-btn span {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    white-space: nowrap;
    color: var(--text-secondary);
}

.call-action-btn.accept {
    background: var(--success);
    width: 55px;
    height: 55px;
}

.call-action-btn.reject {
    background: var(--danger);
    width: 55px;
    height: 55px;
}

.call-action-btn.accept:hover {
    background: #22c55e;
}

.call-action-btn.reject:hover {
    background: #ef4444;
}

.call-action-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
}

.video-containers {
    display: none;
    position: relative;
    width: 100%;
    height: 300px;
    margin-top: 20px;
    margin-bottom: 20px; 
    border-radius: 12px;
    overflow: hidden;
}

.remote-video-container {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.remote-video-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    /* По умолчанию скрыто, показывается только когда есть видео */
    display: none;
}

.remote-video-container.has-remote-video{
    background: none;
}

.remote-video-container.has-remote-video video {
    display: block;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 1;
}

.remote-video-container.has-remote-video .video-placeholder {
    display: none;
}

.video-placeholder-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
}

.video-placeholder-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.video-placeholder-status {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Стили для локального имени в плейсхолдере */
.local-video-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 100px;
    height: 70px;
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.local-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.screen-share-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    background: var(--bg-card);
    padding: 10px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 10px;
}

.call-tones {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.tone-bar {
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 2px;
    animation: toneAnimation 1s ease-in-out infinite;
}

.tone-bar:nth-child(1) { animation-delay: 0s; height: 10px; }
.tone-bar:nth-child(2) { animation-delay: 0.2s; height: 20px; }
.tone-bar:nth-child(3) { animation-delay: 0.4s; height: 15px; }
.tone-bar:nth-child(4) { animation-delay: 0.6s; height: 25px; }
.tone-bar:nth-child(5) { animation-delay: 0.8s; height: 12px; }

/* ========== СВЁРНУТЫЙ ЗВОНОК (компактный, справа) ========== */
.mini-call-bar {
    display: none;
    position: fixed;
    top: 90px;
    right: 16px;
    z-index: 100;
    animation: miniCallSlideDown 0.25s ease;
    pointer-events: auto;
}

@keyframes miniCallSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mini-call-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 14px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.mini-call-content:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(232, 203, 88, 0.2);
}

.mini-call-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mini-call-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

.mini-call-duration {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: monospace;
    letter-spacing: 0.5px;
    min-width: 42px;
}

/* Мини-видео собеседника */
.mini-call-video-container {
    width: 64px;
    height: 44px;
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.mini-call-video-container:hover {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(232, 203, 88, 0.3);
}

.mini-call-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.mini-call-video-container.has-video video {
    display: block;
}

.mini-call-video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 18px;
}

.mini-call-video-container.has-video .mini-call-video-placeholder {
    display: none;
}

.mini-call-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mini-call-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: var(--bg-hover);
    color: var(--text-primary);
    font-size: 13px;
    flex-shrink: 0;
}

.mini-call-btn:hover {
    background: var(--border);
    transform: scale(1.1);
}

.mini-call-btn.muted {
    background: var(--danger);
    color: white;
}

.mini-call-end {
    background: var(--danger) !important;
    color: white !important;
}

.mini-call-end:hover {
    background: #ef4444 !important;
    transform: scale(1.15);
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .mini-call-bar {
        top: 60px;
        right: 8px;
    }
    
    .mini-call-content {
        padding: 6px 10px;
        gap: 8px;
        border-radius: 14px;
    }
    
    .mini-call-video-container {
        width: 48px;
        height: 34px;
    }
    
    .mini-call-duration {
        font-size: 12px;
        min-width: 38px;
    }
    
    .mini-call-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* ========== БАННЕР РЕДАКТИРОВАНИЯ (как в Telegram) ========== */
.edit-banner {
    background: transparent;
    padding: 0px 21px;
    margin: 0;
    flex-shrink: 0;
    animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    cursor: pointer;
}

.edit-banner-content {
    background: transparent;
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    padding-left: 15px ;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-banner-header {
    background: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
}

.edit-banner-header i {
    font-size: 12px;
}

.edit-banner-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-banner-close:hover {
    background: var(--bg-dark);
    color: var(--danger);
}

.edit-banner-message {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 80px;
    overflow-y: auto;
    word-break: break-word;
    line-height: 1.4;
}

/* Подсветка редактируемого сообщения */
.message.editing {
    position: relative;
}

.message.editing::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    pointer-events: none;
    animation: pulse-border 1.5s ease-in-out infinite;
    z-index: 1;
}

/* ========== ОТВЕТ НА СООБЩЕНИЕ ========== */
.reply-container {
    display: flex;
    flex-direction: column;
}

.reply-bubble {
    padding: 8px 10px;
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.2s;
    cursor: pointer;
}

.message-own .reply-bubble {
    background: rgba(0, 0, 0, 0.1);
    border-left-color: var(--bg-dark);
}

.message-other .reply-bubble {
    background: rgba(255, 255, 255, 0.05);
}

.reply-bubble:hover {
    filter: brightness(1.2);
}

.reply-header {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--primary);
}

.message-own .reply-header {
    color: var(--bg-dark);
    opacity: 0.8;
}

.reply-text {
    font-size: 13px;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}


/* ========== ПЕРЕСЛАННЫЙ ФАЙЛ ========== */
.forwarded-file-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ========== ПЕРЕСЛАННОЕ СООБЩЕНИЕ ========== */
.forwarded-message-container {
    display: flex;
    flex-direction: column;
}

.forwarded-message-header {
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-own .forwarded-message-header {
    opacity: 0.8;
}

.message-other .forwarded-message-header {
    color: var(--primary);
}

.forwarded-message-header:hover {
    opacity: 1;
    text-decoration: underline;
}

.forwarded-message-header i {
    font-size: 10px;
    margin-right: 4px;
    width: 12px;
    text-align: center;
}

.forwarded-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.message-own .forwarded-divider {
    background: rgba(0, 0, 0, 0.15);
}

.forwarded-message-content {
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.forwarded-message-content.forwarded-emoji {
    font-size: 30px;
    text-align: center;
    line-height: 1.2;
    padding: 2px 0;
}

.forwarded-message-time {
    font-size: 10px;
    opacity: 0.5;
    text-align: right;
    margin-top: 2px;
}

.forwarded-time {
    display: block;
    text-align: right;
}

.forwarded-message-container .forwarded-message-time {
    margin-right: 10px;
}

.forwarded-message-header:first-child {
    /* Первая строка всегда видна полностью */
    opacity: 1 !important;
    font-size: 12px !important;
}

/* ========== МОДАЛЬНОЕ ОКНО ПЕРЕСЫЛКИ ========== */
.forward-modal-content {
    max-width: 450px;
    padding: 25px;
}

.forward-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.forward-hint {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 5px;
}

.forward-chats-list {
    max-height: 350px;
    overflow-y: auto;
}

.forward-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.forward-chat-item:hover {
    background: var(--bg-hover);
}

.forward-chat-item.selected {
    background: var(--primary);
    color: var(--bg-dark);
}

.forward-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.forward-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.forward-chat-info {
    flex: 1;
    min-width: 0;
}

.forward-chat-name {
    font-weight: 600;
    font-size: 14px;
}

.forward-chat-type {
    font-size: 12px;
    opacity: 0.7;
}

.forward-chat-item.selected .forward-chat-type {
    opacity: 0.9;
}

.forward-chat-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.forward-chat-check i {
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--bg-dark);
}

.forward-chat-item.selected .forward-chat-check {
    background: var(--bg-dark);
    border-color: var(--bg-dark);
}

.forward-chat-item.selected .forward-chat-check i {
    opacity: 1;
}

/* Разделитель в контекстном меню */
.context-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ========== ОБРАТНАЯ СВЯЗЬ В ПРОФИЛЕ ========== */
.profile-feedback-link {
    text-align: center;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.feedback-link-text {
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    user-select: none;
}

.feedback-link-text:hover {
    color: var(--primary);
}

.feedback-link-text i {
    font-size: 16px;
}

/* ========== МОДАЛЬНОЕ ОКНО ОБРАТНОЙ СВЯЗИ ========== */
.feedback-modal-content {
    max-width: 500px;
    padding: 25px;
}

.feedback-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feedback-input-wrapper {
    position: relative;
}

.feedback-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    max-height: 300px;
    transition: border-color 0.3s;
    line-height: 1.5;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.feedback-textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.feedback-char-counter {
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    padding-right: 4px;
}

.feedback-char-counter.warning {
    color: var(--warning);
}

.feedback-char-counter.danger {
    color: var(--danger);
}

.feedback-buttons {
    margin-top: -6px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .feedback-modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .feedback-textarea {
        font-size: 16px;
        min-height: 100px;
    }
}

@media (max-width: 480px) {
    .feedback-modal-content {
        padding: 16px;
    }
    
    .feedback-textarea {
        min-height: 80px;
        font-size: 15px;
    }
}

/* ========== МЕДИА-ПРОСМОТРЩИК ========== */
.media-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    animation: mediaViewerFadeIn 0.3s ease;
    /* Убираем выделение на всём просмотрщике */
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* Убираем выделение со всех элементов внутри просмотрщика */
.media-viewer * {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

/* Но возвращаем возможность взаимодействия с элементами */
.media-viewer .media-viewer-nav,
.media-viewer .media-viewer-close,
.media-viewer .video-player-overlay,
.media-viewer .video-player-overlay * {
    -webkit-user-select: none;
    user-select: none;
}

@keyframes mediaViewerFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.media-viewer-closing {
    animation: mediaViewerFadeOut 0.3s ease forwards;
}

@keyframes mediaViewerFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Кнопка закрытия */
.media-viewer-close {
    position: absolute;
    top: 20px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3002;
    transition: all 0.3s;
    color: white;
    font-size: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.media-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Счетчик страниц */
.media-viewer-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 3002;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: monospace;
}

/* Зоны навигации */
.media-viewer-nav {
    position: absolute;
    top: 25%;
    width: 15%;
    height: 50%;
    z-index: 3001;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Убираем выделение */
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

.media-viewer-prev {
    left: 0;
}

.media-viewer-next {
    right: 0;
}

.media-viewer-arrow {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
    /* Убираем выделение */
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

.media-viewer-nav:hover .media-viewer-arrow {
    opacity: 1;
}

.media-viewer-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Контент */
.media-viewer-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3001;
}

/* Изображение */
#media-viewer-image {
    max-width: 80vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
    pointer-events: auto; /* ИЗМЕНИТЕ НА AUTO, чтобы ловить события */
    z-index: 1;
    touch-action: none; /* Отключаем нативные жесты браузера */
    -webkit-user-drag: none; /* Запрещаем перетаскивание изображения */
    user-select: none;
    -webkit-user-select: none;
}

#media-viewer-image.swipe-down {
    transform: translateY(100px) scale(0.9);
    opacity: 0;
}

/* Видео контейнер */
#media-viewer-video-container {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: auto;
    cursor: default;
}

#media-viewer-video {
    width: 100%;
    height: auto;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Кастомный видеоплеер */
/* Кастомный видеоплеер */
.video-player-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    opacity: 1;
    transition: opacity 0.3s;
    border-radius: 0 0 8px 8px;
}

.video-player-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.video-player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.video-player-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 14px;
}

.video-player-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Прогресс-бар */
.video-player-progress {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.video-player-progress-filled {
    position: absolute;
    left: 0;
    top: 0;
    height: 4px;
    background: var(--primary, #e8cb58);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
    z-index: 1;
}

.video-player-progress-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: var(--primary, #e8cb58);
    border-radius: 50%;
    left: 0%;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.video-player-progress:hover .video-player-progress-thumb {
    opacity: 1;
}

/* Время */
.video-player-time {
    color: white;
    font-size: 12px;
    font-family: monospace;
    white-space: nowrap;
}

/* Регулятор громкости */
.video-player-volume {
    overflow: hidden;
    transition: width 0.3s ease, opacity 0.3s ease;
    height: 32px;
    display: flex;
    align-items: center;
    opacity: 0;
    width: 0;
}

.video-player-volume.active {
    width: 80px;
    opacity: 1;
}

.video-player-volume-bar-wrapper {
    position: relative;
    width: 100%;
    height: 32px;
    display: flex;
    align-items: center;
}

/* Визуальная полоска */
.video-player-volume-track {
    position: absolute;
    left: 7px;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    pointer-events: none;
    z-index: 1;
}

/* Заполненная часть */
.video-player-volume-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary, #e8cb58);
    border-radius: 2px;
    width: 0%;
    z-index: 2;
}

/* Ползунок */
.video-player-volume-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: var(--primary, #e8cb58);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 3;
    left: 0%;
    transition: none;
}

/* Сам input range (прозрачный, поверх всего) */
.video-player-volume-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
    z-index: 4;
    margin: 0;
    padding: 0;
}

.video-player-volume-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    border: none;
}

.video-player-volume-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    border: none;
}

.video-player-volume-input::-webkit-slider-runnable-track {
    width: 100%;
    height: 20px;
    background: transparent;
    border-radius: 2px;
}

.video-player-volume-input::-moz-range-track {
    width: 100%;
    height: 20px;
    background: transparent;
    border-radius: 2px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .media-viewer-close {
        top: 15px;
        left: 15px;
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    /* Зоны навигации — на всю ширину, поверх контента */
    .media-viewer-nav {
        position: absolute;
        top: 25%;
        height: 50%;
        width: 50%;
        z-index: 3005;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: auto;
        /* Убираем фон при наведении */
    }
    
    .media-viewer-prev {
        left: 0;
        justify-content: flex-start;
        padding-left: 10px;
    }
    
    .media-viewer-next {
        right: 0;
        justify-content: flex-end;
        padding-right: 10px;
    }
    
    /* Стрелки видны всегда, но полупрозрачные */
    .media-viewer-arrow {
        width: 36px;
        height: 36px;
        font-size: 18px;
        opacity: 0.5;
        background: rgba(0, 0, 0, 0.4);
        pointer-events: auto;

    }
    
    .media-viewer-prev:hover .media-viewer-arrow,
    .media-viewer-next:hover .media-viewer-arrow {
        opacity: 0.8;
        background: rgba(0, 0, 0, 0.6);
        transform: none;
    }
    
    /* Убираем фон при наведении на зону */
    .media-viewer-prev:hover,
    .media-viewer-next:hover {
        background: transparent;
    }
    
    .media-viewer-counter {
        bottom: 20px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .video-player-controls {
        gap: 8px;
    }
    
    .video-player-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .media-viewer-arrow {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    #media-viewer-video {
        border-radius: 4px;
    }
}

/* Скрываем нативные контролы видео */
#media-viewer-video::-webkit-media-controls {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-panel {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-play-button {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-timeline {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-current-time-display,
#media-viewer-video::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-mute-button,
#media-viewer-video::-webkit-media-controls-volume-slider {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

#media-viewer-video::-webkit-media-controls-enclosure {
    display: none !important;
}

/* Скрываем нативные контролы в Firefox */
#media-viewer-video::-moz-media-controls {
    display: none !important;
}

/* ========== УВЕДОМЛЕНИЕ О КОПИРОВАНИИ (МОБИЛЬНЫЕ) ========== */
.mobile-copy-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.mobile-copy-notification.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.mobile-copy-notification i {
    color: var(--success);
    font-size: 18px;
}

/* Запрет выделения текста на мобильных в сообщениях */
@media (max-width: 768px) {
    .message-content {
        -webkit-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
    }
    
    .message-content * {
        -webkit-user-select: none !important;
        user-select: none !important;
    }
    
    /* Разрешаем выделение только для ссылок */
    .message-content a {
        -webkit-user-select: auto !important;
        user-select: auto !important;
    }
}

/* Анимация нажатия на бабл */
.message {
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== ОВЕРЛЕЙ ДЛЯ МОБИЛЬНОГО САЙДБАРА ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* При открытом сайдбаре делаем остальную область некликабельной */
.sidebar-overlay.active ~ .chat-layout .chat-area,
.sidebar-overlay.active ~ .chat-layout .message-input-container {
    pointer-events: none;
}

/* Стили для мобильного контекстного меню */
@media (max-width: 768px) {
    .context-menu {
        min-width: 240px;
        max-width: 300px;
        border-radius: 16px;
        padding: 10px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }
    
    .context-menu button {
        padding: 14px 18px;
        font-size: 16px;
        gap: 14px;
        border-radius: 10px;
    }
    
    .context-menu button i {
        font-size: 18px;
        width: 24px;
    }
}

@keyframes pulse-border {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Кнопка отправки меняет цвет при редактировании */
.send-btn.editing-mode {
    background: var(--success);
    animation: pulse-edit 1.5s ease-in-out infinite;
}

.send-btn.editing-mode:hover {
    background: #22c55e;
}

@keyframes pulse-edit {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
}

/* Адаптивность */
@media (max-width: 768px) {
    .edit-banner {
        padding: 8px 12px;
    }
    
    .edit-banner-message {
        font-size: 13px;
        max-height: 60px;
    }
}

@keyframes toneAnimation {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.5); }
}

@media (max-width: 768px) {
    .call-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 0;
    }
    
    .local-video-container {
        width: 80px;
        height: 60px;
    }
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 900px) {
    .header-audio-player {
        min-width: 180px;
        max-width: 250px;
        padding: 6px 10px;
    }
    
    .header-audio-time {
        font-size: 11px;
        min-width: 60px;
    }
    
    .audio-message {
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -340px;
        top: 0;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.active { left: 0; }
    .sidebar-resizer { display: none; }
    
    .mobile-menu-btn {
        display: block;
        margin-right: 10px;
    }
    
    .message-input-container {
        padding: 12px 15px;
    }
    
    .message-input-wrapper {
        gap: 8px;
        padding: 4px 6px;
    }
    
    .input-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .message-input-wrapper textarea {
        font-size: 16px;
        min-height: 45px;
    }
    
    .message-content { max-width: 85%; }
    .chat-header { padding: 15px; }
    .messages-container { 
        padding: 15px 15px 0px 15px;
        /* Дополнительные правила для мобильных */
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
        /* Принудительно используем column-reverse */
        display: flex !important;
        flex-direction: column-reverse !important;
    }
    
    .chat-header {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .chat-header[title]:hover::after {
        display: none;
    }
    
    .message-input-container {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .sidebar-header { padding-top: max(16px, env(safe-area-inset-top)); }
    
    .context-menu {
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 300px;
    }
    
    /* ✅ Контейнер ввода фиксируется внизу */
    .message-input-container.active {
        position: relative;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 987;
        background: var(--bg-dark);
        padding: 10px 15px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        transition: bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
    }
    
    /* ✅ Когда панель эмодзи открыта - поднимаем поле ввода */
    .message-input-container.active.emoji-open {
        bottom: 45vh; /* Высота панели эмодзи */
    }

    .messages-inner.active {
        position: relative;
        transition: bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .messages-inner.active.emoji-open {
        bottom: 45vh; /* Высота панели эмодзи */
    }

    .emoji-panel {
        left: 20px;
    }
    
    /* ✅ Панель эмодзи прижата к низу */
    .emoji-panel.mobile-keyboard-mode {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 45vh;
        max-height: 45vh;
        background: var(--bg-card);
        border: none;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        padding: 12px 8px 8px 8px;
        display: grid ;
        grid-template-columns: repeat(8, 1fr);
        gap: 4px;
        z-index: 1499;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        animation: emojiSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        pointer-events: auto;
    }
    
    .emoji-panel.mobile-keyboard-mode .emoji-btn {
        width: 100%;
        aspect-ratio: 1;
        font-size: 24px;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.15s;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
    }
    
    .emoji-panel.mobile-keyboard-mode .emoji-btn:active {
        background: var(--bg-hover);
        transform: scale(0.9);
    }
    
    .emoji-panel.mobile-keyboard-mode::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        cursor: pointer;
        pointer-events: auto;
    }
    
    @keyframes emojiSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    @keyframes emojiSlideDown {
        from {
            transform: translateY(0);
            opacity: 1;
        }
        to {
            transform: translateY(100%);
            opacity: 0;
        }
    }
    
    .emoji-panel.mobile-keyboard-mode.closing {
        animation: emojiSlideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }
    
    .modal-content.call-modal-content {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 70%;
        min-width: 370px;
        max-width: 440px;
        height: 50%;
        padding: 20px;
        margin: 10px;
        border-radius: 20px;
    }

    .modal-content {
        width: 95%;
        /* padding: 20px; */
        margin: 10px;
    }

    /* ✅ Если внутри есть видео-контейнер с display: block — увеличиваем высоту */
    .modal-content.call-modal-content:has(.video-containers[style*="display: block"]) {
        height: 70%;
        max-height: 500px;
    }

    .call-container {
        padding: 10px;
    }

    .call-action-btn, .call-action-btn.accept, .call-action-btn.reject {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    #incoming-call-screen .call-action-btn.accept, #incoming-call-screen .call-action-btn.reject {
        width: 60px;
        height: 60px;
        font-size: 22px;
    }
    
    .modal-header h3 { font-size: 18px; }
    
    .profile-modal-content { padding: 20px; }
    .profile-avatar-wrapper { width: 100px; height: 100px; }
    .profile-avatar { width: 100px; height: 100px; }
    
    .user-profile-modal-content { padding: 20px; }
    .user-profile-avatar-wrapper,
    .user-profile-avatar { width: 100px; height: 100px; }
    .user-profile-info h2 { font-size: 20px; }
    .user-profile-buttons { flex-direction: column; }
    .user-profile-btn { padding: 10px; }

    
    
    .group-info-modal-content,
    .group-settings-modal-content,
    .add-members-modal-content {
        padding: 20px;
    }
    
    .group-actions {
        flex-direction: column;
    }
    
    .group-action-btn {
        width: 100%;
    }
    
    .friends-select { margin: 15px 0; }
    #friends-select-list { max-height: 250px; margin-bottom: 15px; }
    .friend-select-item { padding: 10px; }
    .modal-buttons { margin-top: 15px; padding-top: 15px; }
    
    .header-audio-player {
        min-width: 160px;
        max-width: 220px;
        padding: 6px 8px;
        margin: 0 5px;
        border-radius: 20px;
    }
    
    .header-audio-controls { gap: 6px; }
    
    .header-audio-btn {
        width: 28px;
        height: 28px;
    }
    
    .header-audio-btn i { font-size: 12px; }
    
    .header-audio-volume { display: none !important; }
    
    .header-audio-time {
        font-size: 10px;
        min-width: 55px;
    }
    
    .header-audio-close { padding: 4px; }
    
    .header-audio-filename {
        font-size: 10px;
        margin-top: 3px;
    }
    
    .audio-message { min-width: 160px; }
    .audio-message-name { font-size: 12px; }
    
    .audio-message-time {
        font-size: 9px;
        min-width: 60px;
        max-width: 65px;
    }
    
    .play-audio-btn {
        width: 32px;
        height: 32px;
    }
    
    .floating-create-group-btn {
        width: 52px;
        height: 52px;
        min-width: 52px;
        max-width: 52px;
        bottom: 20px;
        left: auto;
        right: 20px;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    .floating-create-group-btn i {
        font-size: 22px;
    }
    
    .sidebar:not(.active) ~ .floating-create-group-btn {
        opacity: 0;
        pointer-events: none;
    }
    
    .sidebar.active ~ .floating-create-group-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 480px) {
    .sidebar-tabs .tab-btn span { display: none; }
    .sidebar-tabs .tab-btn i { font-size: 18px; }
    
    .auth-container {
        padding: 30px 20px;
        margin: 20px;
        width: calc(100% - 40px);
    }
    
    .logo h1 { font-size: 28px; }
    .logo i { font-size: 40px; }
    
    .auth-tabs .tab-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .sidebar {
        width: 85%;
        max-width: 280px;
    }
    
    .chat-header h3 { font-size: 16px; }
    .message-content { max-width: 90%; }
    
    .header-audio-player {
        min-width: 140px;
        max-width: 170px;
        padding: 5px 6px;
    }
    
    .header-audio-controls { gap: 4px; }
    
    .header-audio-btn {
        width: 26px;
        height: 26px;
    }
    
    .header-audio-time {
        font-size: 9px;
        min-width: 45px;
    }
    
    .header-audio-filename { display: none; }
    
    .audio-message { min-width: 140px; }
    .audio-message-name { font-size: 11px; }
    
    .audio-message-time {
        font-size: 8px;
        min-width: 55px;
        max-width: 60px;
    }
    
    .floating-create-group-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        max-width: 48px;
        bottom: 16px;
        right: 16px;
    }
    
    .floating-create-group-btn i {
        font-size: 20px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 280px; }

    .emoji-panel {
    left: 300px;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .chat-header { padding: 10px 15px; }
    .messages-container { padding: 10px; }
    .message-input-container { padding: 10px 15px; }
    .sidebar-header { padding: 10px 15px; }
    .sidebar-tabs .tab-btn { padding: 6px; }
    .chat-item, .friend-item, .request-item { padding: 8px 12px; }
    .chat-avatar { width: 36px; height: 36px; font-size: 16px; }
    
    .header-audio-player {
        min-width: 180px;
        max-width: 250px;
    }
    
    .header-audio-filename { display: none; }
}

/* ========== iOS СПЕЦИФИЧНЫЕ СТИЛИ ========== */
@supports (-webkit-touch-callout: none) {
    .app-container, .screen, .chat-layout, .chat-area {
        height: -webkit-fill-available;
    }
    body { height: -webkit-fill-available; }
    .messages-container { -webkit-overflow-scrolling: touch; }
    
    input, textarea, button {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0;
    }
}

.messages-container, .sidebar-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
}

button, .chat-item, .friend-item, .tab-btn, .user-info {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@supports (padding-top: env(safe-area-inset-top)) {
    .chat-header { padding-top: max(16px, env(safe-area-inset-top)); }
    .sidebar-header { padding-top: max(16px, env(safe-area-inset-top)); }
    .message-input-container { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* ========== СПЕЦИАЛЬНЫЕ ПРАВИЛА ДЛЯ МОБИЛЬНЫХ SAFARI ========== */
@supports (-webkit-touch-callout: none) {
    .messages-container {
        /* Для iOS Safari */
        display: -webkit-flex !important;
        -webkit-flex-direction: column-reverse !important;
        flex-direction: column-reverse !important;
        /* Отключаем overflow-anchor для iOS */
        overflow-anchor: none;
    }
    
    .messages-container .message {
        /* Предотвращаем скачки на iOS */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* ========== ДОПОЛНИТЕЛЬНЫЕ ПРАВИЛА ДЛЯ ANDROID CHROME ========== */
@media screen and (max-width: 768px) {
    .messages-container {
        /* Фикс для Android Chrome */
        display: flex !important;
        flex-direction: column-reverse !important;
        -webkit-flex-direction: column-reverse !important;
        /* Предотвращаем автоматическую прокрутку */
        scroll-behavior: auto;
        overflow-anchor: none;
    }
    
    /* Обеспечиваем правильный порядок элементов */
    .messages-container .welcome-message,
    .messages-container .chat-blocked-message {
        align-self: center;
        margin: auto 0;
        order: 0;
    }
}

/* ========== АНИМАЦИИ ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}