/* ===== PNG ФОН NỌX ВМЕСТО CANVAS ===== */
/* Фон чата с noxbg.png - заменяет динамический Canvas */
.chat-container {
    background: url('noxbg.png') center top/auto 100% repeat-x;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 8px;
    gap: 4px;
}

/* Удаляем Canvas стили - заменены на PNG фон */
#noxDynamicBackground {
    display: none;
}

/* ===== ОСНОВНЫЕ СТИЛИ СБРОСА ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ===== ОСНОВНЫЕ СТИЛИ СТРАНИЦы ===== */
body {
    font-family: 'DejaVu Sans', ui-sans-serif, system-ui, sans-serif;
    background: url('noxbg.png'), rgba(26,26,46,0.7);
    background-blend-mode: overlay;
    background-size: cover;
    background-attachment: fixed;
    color: #D8B9F2;
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

/* ===== СИСТЕМА ЭКРАНОВ ===== */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    padding: 20px;
}

#auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== КАРТОЧКИ В СТИЛЕ GLASS MORPHISM ===== */
.nox-glass-card {
    width: 100%;
    max-width: 400px;
    background: linear-gradient(145deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 16px;
    padding: 30px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06),
                inset 0 0 8px rgba(180,130,255,.08),
                0 10px 24px rgba(0,0,0,.35);
    position: relative;
}

.nox-materials-title {
    color: #fff;
    font-size: 1.8em;
    margin: 0 0 10px;
    text-align: center;
}

.nox-materials-sub {
    color: #B9F2F0;
    margin: 0 0 25px;
    text-align: center;
    opacity: .9;
}

/* ===== ФОРМЫ И ИНПУТЫ ===== */
.form-group {
    margin-bottom: 20px;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(34,34,48,.7);
    border: 1px solid rgba(64,224,208,.36);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: rgba(177,76,255,.7);
    box-shadow: 0 0 0 2px rgba(177,76,255,.3);
}

/* ===== КНОПКИ NỌX ===== */
.nox-btn {
    --turq: #40E0D0;
    --vio: #B14CFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    padding: 12px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .35px;
    border: 1px solid transparent;
    font-size: 15px;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
    color: #EBDDFF;
    background: linear-gradient(135deg, rgba(177,76,255,.18), rgba(177,76,255,.12));
    border-color: rgba(177,76,255,.74);
    box-shadow: 0 6px 18px rgba(177,76,255,.22), 0 0 10px rgba(177,76,255,.18);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.nox-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(64,224,208,.88);
    box-shadow: 0 0 22px rgba(64,224,208,.40), 0 0 8px rgba(64,224,208,.25);
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(64,224,208,.18), rgba(64,224,208,.12)) !important;
    border-color: rgba(64,224,208,.74) !important;
    box-shadow: 0 6px 18px rgba(64,224,208,.22), 0 0 10px rgba(64,224,208,.18) !important;
}

/* ===== НОВЫЕ КНОПКИ УПРАВЛЕНИЯ КОНТАКТАМИ ===== */
.contacts-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 11px !important;
    padding: 10px 15px !important;
    background: rgba(34,34,48,.8);
    border-bottom: 1px solid rgba(64,224,208,.15);
}

.control-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(177,76,255,.15), rgba(64,224,208,.1));
    border: 1px solid rgba(177,76,255,.4);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    font-size: 18px;
    color: #EBDDFF;
}

.control-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(64,224,208,.7);
    box-shadow: 0 4px 12px rgba(64,224,208,.3);
    background: linear-gradient(135deg, rgba(177,76,255,.25), rgba(64,224,208,.2));
}

/* ===== ИСПРАВЛЕНИЕ РАЗМЕРОВ И ЦВЕТНОСТИ ДЛЯ QR ИЗОБРАЖЕНИЙ НА КНОПКАХ ===== */
.control-btn img,
.control-btn .qr-button-image,
.contacts-controls img {
    width: 34px !important;
    height: 34px !important;
    filter: none !important;
    -webkit-filter: none !important;
    opacity: 1 !important;
    mix-blend-mode: normal !important;
    background: none !important;
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: crisp-edges !important;
    image-rendering: pixelated !important;
    transition: all 0.3s ease !important;
    box-shadow: none !important;
}

/* Ховер эффекты без изменения цветности */
.control-btn:hover img,
.control-btn:hover .qr-button-image {
    transform: scale(1.1) !important;
    filter: none !important;
    -webkit-filter: none !important;
    opacity: 1 !important;
}

/* СТАНДАРТНЫЕ ИКОНКИ (не QR) - сохраняем оригинальные стили */
.control-icon {
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(177,76,255,0.5));
}

/* Стили для PNG иконок действий */
.action-icon {
    width: 1.1em;
    height: 1.1em;
    vertical-align: middle;
    pointer-events: none;
    object-fit: contain;
}

#main-screen {
    display: none;
    grid-template-columns: 350px 1fr;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    gap: 8px;
    padding: 0 !important;
    margin: 0 !important;
    background-color: rgba(0,0,0,0);
    align-items: stretch;
    overflow: hidden;
}

/* ===== ЗАМЕНА КНОПОК НА PNG ===== */
#attach-btn {
    background: url('noxattach.png') center/contain no-repeat,
                linear-gradient(135deg, rgba(177,76,255,.15), rgba(64,224,208,.1));
    border: 1px solid rgba(177,76,255,.4);
    border-radius: 10px;
    font-size: 0;
    width: 38px;
    height: 38px;
}

#emoji-btn {
    background: url('noxemoji.png') center/contain no-repeat,
                linear-gradient(135deg, rgba(177,76,255,.15), rgba(64,224,208,.1));
    border: 1px solid rgba(177,76,255,.4);
    border-radius: 10px;
    font-size: 0;
    width: 38px;
    height: 38px;
}

/* КНОПКА МИКРОФОНА - ПОЛНОСТЬЮ ИСПРАВЛЕНА */
#mic-btn {
    background: url('noxmic.png') center/contain no-repeat,
                linear-gradient(135deg, rgba(177,76,255,.15), rgba(64,224,208,.1));
    border: 1px solid rgba(177,76,255,.4);
    border-radius: 10px;
    font-size: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#mic-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(64,224,208,.7);
    box-shadow: 0 4px 12px rgba(64,224,208,.3);
    background: url('noxmic.png') center/contain no-repeat,
                linear-gradient(135deg, rgba(177,76,255,.25), rgba(64,224,208,.2));
}

#mic-btn img {
    width: 36px !important;
    height: 36px !important;
    transition: all 0.3s ease !important;
}

#mic-btn:hover img {
    transform: scale(1.1) !important;
}

/* Скрываем текст Send на десктопе */
#send-button .btn-text {
    display: none !important;
}
/* DISABLED — old send icon size

#send-button img {
    width: 36px !important;
    height: 36px !important;
    margin-right: 0 !important;
}
 */
/* ===== МОДАЛЬНЫЕ ОКНА QR-КОДОВ ===== */
.qr-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.qr-modal-content {
    background: linear-gradient(145deg, rgba(34,34,48,.95), rgba(34,34,48,.9));
    margin: 5% auto;
    padding: 0;
    border-radius: 16px;
    border: 1px solid rgba(64,224,208,.3);
    box-shadow: 0 20px 40px rgba(0,0,0,.5),
                inset 0 1px 0 rgba(255,255,255,.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

/* Адаптивная ширина для модальных окон */
@media (max-width: 768px) {
    .qr-modal-content {
        width: 90%;
        margin: 10% auto;
    }
}

@media (min-width: 769px) {
    .qr-modal-content {
        width: 50%;
        max-width: 500px;
    }
}

.qr-modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(64,224,208,.15);
    background: rgba(34,34,48,.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qr-modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3em;
    background: linear-gradient(135deg, #B14CFF, #40E0D0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.close-scan-qr-modal,
.close-show-qr-modal {
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    transition: all 0.3s ease;
}

.close-scan-qr-modal:hover,
.close-show-qr-modal:hover {
    background: rgba(255,255,255,.2);
    transform: scale(1.1);
}

.qr-modal-body {
    padding: 25px;
}

#qr-scanner-container {
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,.3);
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#qr-video {
    width: 100%;
    height: auto;
    max-height: 400px;
    background: #000;
}

.qr-result {
    padding: 15px;
    background: rgba(64,224,208,.1);
    border: 1px solid rgba(64,224,208,.3);
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    color: #40E0D0;
    font-weight: 600;
}

.qr-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.qr-modal-actions .nox-btn {
    flex: 1;
    margin: 0;
}

#my-qr-container {
    padding: 10px;
}

#my-qr-image {
    border: 2px solid rgba(64,224,208,.3);
    box-shadow: 0 8px 25px rgba(0,0,0,.4);
}

/* ===== ИСПРАВЛЕННЫЕ СТИЛИ ДЛЯ NOX ID И НАСТРОЕК ===== */

/* Контейнер для Nox ID и кнопки настроек */
#current-user-display-container {
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 3px 7px !important;
    border-radius: 8px;
    background: rgba(64,224,208,.1);
    border: 1px solid rgba(64,224,208,.2);
    display: flex;
    align-items: center;
    gap: 5px !important;
    min-width: 200px;
    justify-content: center;
}

#current-user-display-container:hover {
    background: rgba(64,224,208,.15);
    border-color: rgba(64,224,208,.3);
}

/* Текст Nox ID - сохраняем оригинальный шрифт и размер */
#current-user-display {
    font-family: 'DejaVu Sans', ui-sans-serif, system-ui, sans-serif;
    font-size: 1.1em;
    font-weight: bold;
    color: #EBDDFF;
    opacity: 0.7;
    transition: all 0.3s ease;
    min-width: 85px;
    text-align: center;
    display: inline-block;
}

/* ПРАВИЛЬНАЯ ЛОГИКА СО ЗВЕЗДОЧКАМИ */
#current-user-display.hidden {
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

/* Звездочки показываются когда ID скрыт */
#current-user-display.hidden::after {
    content: "abcdefgh";
    position: absolute;
    left: 0;
    top: 0;
    color: #EBDDFF;
    opacity: 0.7;
    font-weight: bold;
}

/* Реальный ID скрываем когда показаны звездочки */
#current-user-display.hidden .real-id {
    visibility: hidden;
    opacity: 0;
}

/* Когда ID видим - показываем реальный ID */
#current-user-display.visible .real-id {
    visibility: visible;
    opacity: 1;
}

/* Убираем звездочки когда ID видим */
#current-user-display.visible::after {
    content: none;
}

/* ===== МОДАЛЬНОЕ ОКНО НАСТРОЕК ===== */
.settings-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.settings-modal-content {
    background: linear-gradient(145deg, rgba(34,34,48,.95), rgba(34,34,48,.9));
    margin: 5% auto;
    padding: 0;
    border-radius: 16px;
    border: 1px solid rgba(64,224,208,.3);
    box-shadow: 0 20px 40px rgba(0,0,0,.5),
                inset 0 1px 0 rgba(255,255,255,.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    animation: modalFadeIn 0.3s ease;
}

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

/* Desktop стили для настроек */
@media (min-width: 769px) {
    .settings-modal-content {
        width: 400px;
        max-width: 90%;
    }
}

/* Mobile стили - top-sheet */
@media (max-width: 768px) {
    .settings-modal-content {
        width: 100%;
        height: 75%;
        margin: 0;
        border-radius: 20px 20px 0 0;
        position: fixed;
        top: 0;
        animation: settingsSlideDown 0.3s ease;
    }

    @keyframes settingsSlideDown {
        from {
            transform: translateY(-100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

.settings-modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(64,224,208,.15);
    background: rgba(34,34,48,.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3em;
    background: linear-gradient(135deg, #B14CFF, #40E0D0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.close-settings-modal {
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    transition: all 0.3s ease;
}

.close-settings-modal:hover {
    background: rgba(255,255,255,.2);
    transform: scale(1.1);
}

.settings-modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Стили для меню настроек */
.settings-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-menu-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(177,76,255,.1), rgba(64,224,208,.08));
    border: 1px solid rgba(64,224,208,.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.settings-menu-item:hover {
    background: linear-gradient(135deg, rgba(177,76,255,.2), rgba(64,224,208,.15));
    border-color: rgba(64,224,208,.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(64,224,208,.2);
}

.settings-menu-item:active {
    transform: translateY(0);
}

.settings-icon {
    font-size: 20px;
    margin-right: 15px;
    width: 24px;
    text-align: center;
}

.settings-text {
    color: #EBDDFF;
    font-weight: 600;
    font-size: 16px;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .settings-menu-item {
        padding: 18px 20px;
    }

    .settings-text {
        font-size: 17px;
    }

    #current-user-display-container {
        padding: 5px 9px !important;
        font-size: 1em;
    }
}

/* ===== ГЛАВНЫЙ ЭКРАН ЧАТА - ДЕСКТОП ===== */

/* ===== БОКОВАЯ ПАНЕЛЬ КОНТАКТОВ ===== */
.contacts-sidebar {
    margin-bottom: 10px;
    background: linear-gradient(145deg, rgba(34,34,48,.95), rgba(34,34,48,.85));
    border: 1px solid rgba(64,224,208,.15);
    display: flex;
    flex-direction: column;
    height: 100% !important;
    border-radius: 12px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.08),
        inset 0 0 12px rgba(180,130,255,.12),
        0 12px 32px rgba(0,0,0,.4),
        0 4px 16px rgba(0,0,0,.3);
    position: relative;
    z-index: 2;
}

.sidebar-header {
    padding: 15px !important;
    background: rgba(34,34,48,.95);
    border-bottom: 1px solid rgba(64,224,208,.15);
    border-radius: 12px 12px 0 0;
    backdrop-filter: blur(5px);
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    min-height: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

/* ===== ЭЛЕМЕНТЫ КОНТАКТОВ ===== */
.contact-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-radius: 8px;
    margin: 4px 0;
    background: rgba(255,255,255,.02);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    min-height: 48px;
}

.contact-item:hover {
    background: rgba(64,224,208,.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

/* ===== СИСТЕМА НЕПРОЧИТАННЫХ СООБЩЕНИЙ ===== */
.unread-badge {
    background: linear-gradient(135deg, #B14CFF, #40E0D0);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-left: auto;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.contact-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #B14CFF, #40E0D0);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 10px;
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.contact-id {
    font-size: 0.8em;
    opacity: 0.7;
    color: #B9F2F0;
}

/* ===== КНОПКИ УПРАВЛЕНИЯ КОНТАКТАМИ ===== */
.contact-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.edit-contact-btn, .delete-contact-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.edit-contact-btn:hover {
    background: rgba(64,224,208,0.3);
    border-color: rgba(64,224,208,0.5);
}

.delete-contact-btn:hover {
    background: rgba(255,0,0,0.3);
    border-color: rgba(255,0,0,0.5);
}

/* ===== ХЕДЕР NỌX ===== */
.nox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px !important;
    background: rgba(34,34,48,.95);
    border-bottom: 1px solid rgba(64,224,208,.15);
}

.nox-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nox-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(177,76,255,0.3));
}

.nox-title {
    color: #fff;
    font-size: 1.5em;
    font-weight: bold;
    background: linear-gradient(135deg, #B14CFF, #40E0D0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nox-slogan {
    color: #B9F2F0;
    font-size: 0.9em;
    font-style: italic;
    opacity: 0.9;
    text-shadow: 0 0 10px rgba(64,224,208,0.3);
}

.nox-footer-logo {
    width: 140px;
    height: auto;
    opacity: 0.8;
    margin: 0 auto 4px auto !important;
    display: block;
    filter: drop-shadow(0 0 15px rgba(177,76,255,0.4));
    transition: opacity 0.3s ease;
}

.nox-footer-logo:hover {
    opacity: 1;
}

/* ===== ОБЛАСТЬ ЧАТА ===== */
.chat-area {
    display: flex !important;
    flex-direction: column !important;
    flex-direction: column;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(34,34,48,.85), rgba(34,34,48,.75));
    border: 1px solid rgba(64,224,208,.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.08),
        inset 0 0 12px rgba(180,130,255,.12),
        0 12px 32px rgba(0,0,0,.4),
        0 4px 16px rgba(0,0,0,.3);
    position: relative;
    z-index: 2;
}

.chat-header {
    padding: 15px;
    background: rgba(34,34,48,.95);
    border-bottom: 1px solid rgba(64,224,208,.15);
    border: 1px solid rgba(64, 224, 208, 0.4);
    position: relative;
    z-index: 1;
    border-radius: 12px 12px 0 0;
    backdrop-filter: blur(5px);
}

/* ===== СИСТЕМА СООБЩЕНИЙ ===== */
.messages-container {
    flex: 1 1 auto;
    min-height: 0;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: auto;
    height: auto;
    position: relative;
    z-index: 1;
    margin: 4px;
    border-radius: 8px;
    background: rgba(255,255,255,.02);
    -webkit-overflow-scrolling: touch;
}

/* ===== КАСТОМНЫЕ СКРОЛЛБАРЫ ===== */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(64,224,208,0.5);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(177,76,255,0.5);
}

.contacts-list::-webkit-scrollbar {
    width: 6px;
}

.contacts-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

.contacts-list::-webkit-scrollbar-thumb {
    background: rgba(64,224,208,0.5);
    border-radius: 3px;
}

/* ===== ОБНОВЛЕННЫЕ ПУЗЫРЬКИ СООБЩЕНИЙ ===== */
.message {
    max-width: 70%;
    min-width: 120px;
    padding: 14px 18px;
    border-radius: 18px;
    background: linear-gradient(135deg,
        rgba(64, 224, 208, 0.25),
        rgba(64, 224, 208, 0.15));
    border: 1px solid rgba(204, 224, 208, 0.5);
    word-wrap: break-word;
    align-self: flex-start;
    position: relative;
    z-index: 2;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.message.own {
    align-self: flex-end;
    background: linear-gradient(135deg,
        rgba(177, 76, 255, 0.25),
        rgba(177, 76, 255, 0.15));
    border: 1px solid rgba(207, 206, 255, 0.5);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.message:hover {
    transform: translateY(-2px);
    box-shadow:
        0 12px 25px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

/* ===== СТИЛИ ДЛЯ ВРЕМЕНИ СООБЩЕНИЙ ===== */
.message-text {
    font-size: 14px;
    line-height: 1.4;
    color: #EBDDFF;
    margin-bottom: 4px;
    word-wrap: break-word;
    .message-text {
    white-space: pre-line;
}

    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    text-align: right;
    margin-top: 6px;
    opacity: 0.72;
    font-style: normal;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* ===== ПАНЕЛЬ ВВОДА СООБЩЕНИЙ ===== */
.message-input-container {
    padding: 10px;
    background: rgba(34,34,48,.9);
    border: 1px solid rgba(64, 224, 208, 0.4);
    border-top: 1px solid rgba(64,224,208,.15);
    z-index: 1;
    border-radius: 0 0 12px 12px;
    margin: 4px;
    backdrop-filter: blur(5px);
}

.message-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

#message-input {
    flex: 1;
    padding: 12px 15px;
    background: rgba(34,34,48,.7);
    border: 1px solid rgba(64,224,208,.36);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
}

/* ===== СИСТЕМА СТАТУСОВ И УВЕДОМЛЕНИЙ ===== */
.status-message {
    padding: 10px;
    text-align: center;
    margin-top: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,.05);
}

.error {
    background: rgba(255,0,0,.1);
    border: 1px solid rgba(255,0,0,.3);
}

.success {
    background: rgba(0,255,0,.1);
    border: 1px solid rgba(0,255,0,.3);
}

.divider {
    margin: 20px 0;
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
}

.debug-info {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 10px;
    text-align: center;
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.password-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.password-modal-content {
    background: linear-gradient(145deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 16px;
    padding: 30px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06),
                inset 0 0 8px rgba(180,130,255,.08),
                0 10px 24px rgba(0,0,0,.35);
    width: 90%;
    max-width: 400px;
}

/* ===== СИСТЕМА КОНТАКТОВ - МОДАЛЬНЫЕ ОКНА ===== */
.add-contact-btn {
    width: 90%;
    margin: 10px auto;
    padding: 12px;
    background: linear-gradient(135deg, #6a1b9a, #009688);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    min-height: 44px;
}

.add-contact-btn:hover {
    background: linear-gradient(135deg, #7b1fa2, #00b3a1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,150,136,.4);
}

.contact-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.contact-modal-content {
    background: linear-gradient(135deg, rgba(106, 27, 154, 0.95), rgba(0, 150, 136, 0.95));
    margin: 10% auto;
    padding: 0;
    border-radius: 15px;
    width: 400px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.contact-modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.2em;
}

.close-contact-modal {
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.contact-modal-body {
    padding: 20px;
}

.contact-modal-body input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    box-sizing: border-box;
}

.contact-modal-body input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-result {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-found {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

/* ===== МОДАЛЬНОЕ ОКНО РЕДАКТИРОВАНИЯ КОНТАКТА ===== */
.edit-contact-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
}

.edit-contact-modal-content {
    background: linear-gradient(135deg, rgba(177, 76, 255, 0.95), rgba(64, 224, 208, 0.95));
    margin: 15% auto;
    padding: 0;
    border-radius: 15px;
    width: 350px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* ===== ОБНОВЛЕННЫЕ СТИЛИ АКТИВНЫХ КОНТАКТОВ И ИНДИКАТОРОВ ===== */
.contact-item.active {
    background: linear-gradient(135deg, rgba(177, 76, 255, 0.3), rgba(64, 224, 208, 0.2)) !important;
    border-left: 3px solid #B14CFF;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(177, 76, 255, 0.3);
}

.unread-indicator {
    width: 14px;
    height: 14px;
    background-color: #00ffa8;
    border-radius: 50%;
    border: 2px solid #ce03d0;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.6);
    margin-left: auto;
    margin-right: 8px;
}

.contact-item:hover {
    background: rgba(177, 76, 255, 0.15) !important;
    border-radius: 8px;
}

/* ===== ИСПРАВЛЕНИЕ ДЛЯ ЛЕВОЙ ПАНЕЛИ ===== */
.sidebar-footer {
    padding: 0px !important;
    background: rgba(34,34,48,.7);
    border-top: 1px solid rgba(64,224,208,.15);
    border-radius: 0 0 12px 12px;
    margin-top: 0px !important;
    backdrop-filter: blur(5px);
    min-height: auto;
}

/* ===== ИСПРАВЛЕНИЯ ДЛЯ ДЕСКТОПА ===== */
@media (min-width: 769px) {
    .mobile-container {
        display: contents;
    }

    .contacts-sidebar {
        position: static !important;
        width: 350px !important;
        height: 100% !important;
        transform: none !important;
        margin-bottom: 10px;
    }

    .chat-area {
        position: static !important;
        width: auto !important;
        height: 100% !important;
        transform: none !important;
        display: flex !important;
    }

    .back-to-contacts {
        display: none !important;
    }
}

/* ===== ИСПРАВЛЕНИЕ КНОПКИ SEND НА ДЕСКТОПЕ ===== */
@media (min-width: 769px) {
    #send-button {
        width: 40px !important;
        height: 40px;
        padding: 0 !important;
        border-radius: 10px !important;
        background: linear-gradient(135deg, rgba(177,76,255,.15), rgba(64,224,208,.1)) !important;
        border: none !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #send-button:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    #send-button .btn-text {
        display: none !important;
    }
/* DISABLED — old send icon size
    #send-button img {
        width: 36px !important;
        height: 36px !important;
        margin-right: 0 !important;
    }*/
}

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    #main-screen {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        position: relative;
        overflow: hidden;
        padding: 0;
        gap: 0;
    }

    .mobile-container {
        position: relative;
        width: 100%;
        height: 100vh;
        height: -webkit-fill-available;
        overflow: hidden;
    }

    .contacts-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateX(0);
        margin-bottom: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .chat-area {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 20;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 0;
        display: flex !important;
        flex-direction: column !important;
        flex-direction: column;
    }

    .chat-area.mobile-active {
        transform: translateX(0);
    }

    .contacts-sidebar.mobile-hidden {
        transform: translateX(-100%);
    }

    .back-to-contacts {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        padding: 4px 8px !important;
        background: rgba(177, 76, 255, 0.2);
        border: 1px solid rgba(177, 76, 255, 0.4);
        border-radius: 6px !important;
        color: #EBDDFF;
        cursor: pointer;
        margin-bottom: 3px;
        font-size: 12px !important;
        font-weight: 600;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        touch-action: manipulation;
        height: 28px !important;
    }

    .back-to-contacts img {
        width: 16px !important;
        height: 16px !important;
        margin: 0 !important;
        vertical-align: middle !important;
    }

    .back-to-contacts:active {
        background: rgba(177, 76, 255, 0.3);
        transform: scale(0.98);
    }

    .contacts-controls {
        padding: 7px 13px !important;
        gap: 7px !important;
    }

    .control-btn {
        width: 36px;
        height: 36px;
    }

    .control-icon {
        width: 32px;
        height: 32px;
    }

    .add-contact-btn {
        flex: 0.7;
        font-size: 13px;
        padding: 10px 12px;
    }

    .contact-item {
        min-height: 56px;
        padding: 12px 12px;
        margin: 4px 0;
        border-radius: 12px;
    }

    .contact-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .contact-name {
        font-size: 16px;
    }

    .contact-id {
        font-size: 13px;
    }

    .contact-actions {
        gap: 8px;
    }

    .edit-contact-btn, .delete-contact-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
        border-radius: 8px;
    }

    .message {
        max-width: 85%;
        min-width: 80px;
        padding: 12px 16px;
    }

    .message-text {
        font-size: 15px;
        line-height: 1.5;
    }

    .message-input-container {
        padding: 16px;
        flex-shrink: 0;
    }

    .message-input-container {
        padding: 10px 16px 12px 16px !important;
        flex-shrink: 0;
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        background: rgba(34,34,48,.95) !important;
        backdrop-filter: blur(10px) !important;
        z-index: 1000 !important;
        border-top: 1px solid rgba(64,224,208,0.3) !important;
        align-items: stretch;
        min-height: 44px;
    }

    #message-input {
        padding: 12px 14px;
        font-size: 15px;
        min-height: 44px;
        min-width: 0;
    }

    #message-input {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 50px;
        min-width: 0;
    }

    #send-button {
        width: 44px !important;
        height: 44px;
        padding: 0 !important;
        border-radius: 10px !important;
        background: linear-gradient(135deg, rgba(177,76,255,.15), rgba(64,224,208,.1)) !important;
        border: none !important;
        font-size: 18px;
        display: flex !important;
        flex-direction: column !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        margin-right: -5px;
        margin-top: 3px;
    }

    #send-button:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    #send-button img {
        width: 42px !important;
        height: 42px !important;
        margin-right: 0 !important;
    } 

    #send-button .btn-text {
        display: none !important;
    }

    #attach-btn {
        margin-left: -5px;
        margin-top: 3px;
    }

    #mic-btn {
        margin-right: -5px;
        margin-top: 3px;
    }

    #mic-btn:not(.hidden) {
        display: flex !important;
    }

    #mic-btn.hidden {
        display: none !important;
    }

    #send-button.hidden {
        display: none !important;
    }

    .contacts-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: auto;
    }

    .messages-container {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: auto;
        padding: 15px;
        height: auto;
    }

    .contact-modal-content,
    .edit-contact-modal-content,
    .password-modal-content {
        width: 95%;
        margin: 5% auto;
        max-width: none;
    }

    .nox-glass-card {
        margin: 10px;
        padding: 20px;
    }
}

/* Маленькие телефоны */
@media (max-width: 375px) and (max-height: 667px) {
    body {
        font-size: 13px;
    }

    .contacts-controls {
        padding: 5px 11px !important;
        gap: 5px !important;
        margin: 0 6px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

    .control-icon {
        width: 42px;
        height: 42px;
    }

    .add-contact-btn {
        flex: 0.8;
        font-size: 12px;
        padding: 8px 10px;
    }

    .contact-item {
        min-height: 48px;
        padding: 8px 10px;
    }

    .contact-avatar {
        width: 34px;
        height: 34px;
        font-size: 16px;
        margin-right: 10px;
    }

    .message {
        max-width: 90%;
        padding: 10px 14px;
    }

    .message-text {
        font-size: 14px;
    }

    .back-to-contacts {
        padding: 2px 6px !important;
        font-size: 11px !important;
        height: 16px !important;
        min-height: 16px !important;
        max-height: 16px !important;
        line-height: 16px !important;
        margin: 0 !important;
    }

    .sidebar-header,
    .chat-header {
        padding: 10px !important;
    }

    .messages-container {
        padding: 10px !important;
    }

    .message-input-container {
        padding: 12px;
    }

    .message-input-row {
        gap: 4px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

    #message-input {
        padding: 10px 12px;
        font-size: 15px;
    }

    #send-button {
        width: 44px !important;
        height: 44px;
    }
}

/* Ландшафтный режим */
@media (max-width: 768px) and (orientation: landscape) {
    .contacts-sidebar,
    .chat-area {
        height: 100vh;
    }

    .contacts-list {
        max-height: 60vh;
    }

    .messages-container {
        max-height: 50vh;
    }

    .contact-item {
        min-height: 52px;
        padding: 10px 12px;
    }

    .sidebar-header,
    .chat-header {
        padding: 7px 15px !important;
    }

    .message-input-row {
        min-height: 44px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

    #send-button {
        width: 44px !important;
        height: 44px;
    }
}

/* iOS Safari специфичные исправления */
@supports (-webkit-touch-callout: none) {
    .chat-container {
        height: -webkit-fill-available;
    }

    #main-screen {
        height: -webkit-fill-available;
    }

    .contacts-sidebar,
    .chat-area {
        height: -webkit-fill-available;
    }
}

/* Безопасные зоны */
@supports (padding: max(0px)) {
    .chat-container {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    @media (max-width: 768px) {
        .contacts-sidebar,
        .chat-area {
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
    }
}

/* ===== ШАПКА ЧАТА ДЛЯ МОБИЛЬНЫХ ===== */
@media (max-width: 768px) {
    .chat-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 5px;
        gap: 5px;
        min-height: 20px;
    }

    .back-to-contacts {
        margin-right: auto;
        white-space: nowrap;
        flex-shrink: 0;
    }

    #current-contact {
        flex: 1;
        text-align: center;
        margin: 0;
        font-size: 1.2em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-icon-right {
        margin-left: auto;
        flex-shrink: 0;
    }

    .nox-icon-small {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        object-fit: contain;
        filter: drop-shadow(0 0 8px rgba(177,76,255,0.3));
    }
}

/* ===== СКРЫТЬ ИКОНКУ НА ДЕСКТОПЕ ===== */

/* ===== ЭКСТРЕННЫЕ ФИКСЫ ДЛЯ SAFARI IPHONE ===== */
@media (max-width: 768px) {
    .messages-container {
        flex: 1 !important;
        height: auto !important;
        min-height: 300px !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-anchor: auto !important;
    }

    .chat-area.mobile-active {
        height: 100vh !important;
        height: -webkit-fill-available !important;
    }

    .message-input-container {
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        bottom: 0 !important;
        background: rgba(34,34,48,.95) !important;
        backdrop-filter: blur(10px) !important;
        z-index: 1000 !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
}

/* Фикс для виртуальной клавиатуры Safari */
@supports (-webkit-touch-callout: none) {
    .chat-area {
        height: 100vh;
        height: -webkit-fill-available;
    }
}

/* ===== КРИТИЧЕСКИЙ ФИКС СКРОЛЛА ДЛЯ SAFARI IPHONE ===== */
@supports (-webkit-touch-callout: none) and (max-width: 768px) {
    .chat-container {
        height: auto !important;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        display: flex !important;
        flex-direction: column !important;
    }

    .chat-area.mobile-active {
        display: flex !important;
        flex-direction: column !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
    }

    .chat-area.mobile-active .messages-container {
        flex: 1 !important;
        height: auto !important;
        min-height: 200px !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .chat-area.mobile-active .chat-header,
    .chat-area.mobile-active .message-input-container {
        flex-shrink: 0 !important;
    }
}

/* ===== СТИЛИ ДЛЯ ПАНЕЛИ ЭМОДЗИ ===== */
.emoji-panel-container {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 350px;
    background: linear-gradient(145deg, rgba(34,34,48,.95), rgba(34,34,48,.9));
    border: 1px solid rgba(64,224,208,.3);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0,0,0,.5),
                inset 0 1px 0 rgba(255,255,255,.1);
    z-index: 1000;
    overflow: hidden;
    display: none;
}

.emoji-panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(64,224,208,.15);
    background: rgba(34,34,48,.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-weight: 600;
}

.close-emoji-btn {
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    transition: all 0.3s ease;
    border: none;
}

.close-emoji-btn:hover {
    background: rgba(255,255,255,.2);
    transform: scale(1.1);
}

/* Кастомизация emoji-picker-element */
emoji-picker {
    --background: rgba(34,34,48,0.95) !important;
    --border-color: rgba(64,224,208,0.3) !important;
    --border-radius: 0 0 16px 16px !important;
    --category-emoji-padding: 12px !important;
    --category-emoji-size: 28px !important;
    --emoji-padding: 8px !important;
    --emoji-size: 24px !important;
    --indicator-color: #40E0D0 !important;
    --input-border-color: rgba(64,224,208,0.5) !important;
    --input-font-color: #EBDDFF !important;
    --input-placeholder-color: rgba(235,221,255,0.7) !important;
    --num-columns: 8 !important;
    --outline-color: rgba(177,76,255,0.5) !important;
    --padding: 15px !important;
    --preview-placeholder-color: rgba(235,221,255,0.7) !important;
    --search-background-color: rgba(255,255,255,0.1) !important;
    --search-font-color: #EBDDFF !important;
    --search-icon-color: rgba(235,221,255,0.7) !important;
    --shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .emoji-panel-container {
        width: 90%;
        left: 5%;
        bottom: 70px;
    }

    emoji-picker {
        --num-columns: 6 !important;
        --category-emoji-size: 24px !important;
        --emoji-size: 20px !important;
    }
}

/* Скрываем эмодзи-панель на мобильных */
@media (max-width: 768px) {
    .emoji-panel-container {
        display: none !important;
    }

    #emoji-btn {
        display: none !important;
    }
}

/* Показываем эмодзи-панель только на десктопе */
@media (min-width: 769px) {
    .emoji-panel-container {
        display: none;
    }

    #emoji-btn {
        display: flex !important;
    }
}

/* Анимация появления */
.emoji-panel-container.show {
    display: block;
    animation: emojiPanelFadeIn 0.3s ease;
}

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

/* ===== УТИЛИТЫ ДЛЯ СКРЫТИЯ ЭЛЕМЕНТОВ ===== */
.hidden {
    display: none !important;
}

/* FILE MESSAGE STYLES */
.file-message-container {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(64, 224, 208, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(64, 224, 208, 0.3);
    max-width: 300px;
}

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

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: #40E0D0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-size {
    font-size: 0.8em;
    opacity: 0.7;
    margin-bottom: 8px;
}

.download-action {
    background: rgba(64, 224, 208, 0.2);
    border: 1px solid rgba(64, 224, 208, 0.5);
    color: #40E0D0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    cursor: pointer;
}

.download-action:hover {
    background: rgba(64, 224, 208, 0.4);
}

/* ========== СТИЛИ ДЛЯ КОНТЕКСТНОГО МЕНЮ СООБЩЕНИЙ ========== */
.message-context-menu {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10000;
    min-width: 200px;
    overflow: hidden;
    animation: slideIn 0.2s ease;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.menu-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-item:hover {
    background-color: var(--hover-bg);
}

.menu-item.delete {
    color: #ff4757;
    font-weight: 600;
}

.menu-item.hide {
    color: #ffa502;
    font-weight: 600;
}

.menu-item:last-child {
    border-bottom: none;
    color: #888;
}

.menu-item:active {
    background-color: var(--active-bg);
}

/* Анимации */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* Уведомления */
.message-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    font-size: 14px;
    max-width: 300px;
    display: none;
}

.message-notification.success {
    border-color: #00b894;
    background: rgba(0, 184, 148, 0.1);
    color: #00b894;
}

.message-notification.error {
    border-color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
    color: #ff4757;
}

.message-notification.info {
    border-color: #2d3436;
    background: rgba(45, 52, 54, 0.1);
    color: var(--text-color);
}

/* Удаленное сообщение */
.message[style*="opacity: 0.5"] {
    transition: opacity 0.3s ease;
}

.message[style*="opacity: 0.5"] .message-text {
    color: #888 !important;
    font-style: italic !important;
    text-decoration: line-through !important;
}

/* Мобильная адаптация контекстного меню */
/* ========== ИСПРАВЛЕНИЕ КОНТЕКСТНОГО МЕНЮ ДЛЯ МОБИЛЬНОЙ ВЕРСИИ ========== */
@media (max-width: 768px) {
    .message-context-menu {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 80% !important;
        max-width: 300px !important;
        max-height: 70vh !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
        animation: contextMenuFadeIn 0.3s ease !important;
        bottom: auto !important;
        right: auto !important;
    }

    .menu-item {
        padding: 16px 20px !important;
        font-size: 16px !important;
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    @keyframes contextMenuFadeIn {
        from {
            opacity: 0;
            transform: translate(-50%, -60%) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }

    .message-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Для touch-устройств улучшаем доступность */
@media (hover: none) and (pointer: coarse) {
    .menu-item {
        padding: 16px 20px;
        min-height: 48px; /* Минимальная высота для touch */
    }

    .menu-item:active {
        background-color: rgba(64, 224, 208, 0.2);
    }
}

/* ========== УЛУЧШЕНИЯ ДЛЯ ПАНЕЛИ ЭМОДЗИ ========== */

/* Основные стили для emoji-picker */
emoji-picker {
    --background: #1a1a2e !important;
    --border-color: #40E0D0 !important;
    --border-radius: 12px !important;
    --button-active-background: rgba(64, 224, 208, 0.2) !important;
    --button-hover-background: rgba(64, 224, 208, 0.1) !important;
    --category-emoji-padding: 10px !important;
    --category-font-size: 14px !important;
    --category-icon-color: #888 !important;
    --category-icon-active-color: #40E0D0 !important;
    --emoji-size: 28px !important;
    --emoji-padding: 8px !important;
    --indicator-color: #40E0D0 !important;
    --input-border-color: rgba(64, 224, 208, 0.3) !important;
    --input-border-radius: 8px !important;
    --input-font-color: white !important;
    --input-font-size: 14px !important;
    --input-line-height: 1.5 !important;
    --input-padding: 10px 12px !important;
    --input-placeholder-color: #888 !important;
    --outline-color: #40E0D0 !important;
    --outline-width: 2px !important;
    --padding: 15px !important;
}

/* Улучшаем внешний вид панели */
.emoji-panel-container {
    border: 2px solid #40E0D0 !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    background: #1a1a2e !important;
    overflow: hidden !important;
}

.emoji-panel-header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%) !important;
    border-bottom: 1px solid rgba(64, 224, 208, 0.3) !important;
    padding: 15px 20px !important;
    color: #40E0D0 !important;
    font-weight: bold !important;
    font-size: 16px !important;
    display: flex !important;
    justify-content: space-between !important;
}

/* ========== УЛУЧШЕНИЯ ТОЛЬКО ДЛЯ ПАНЕЛИ ЭМОДЗИ ========== */

/* Стили ТОЛЬКО для emoji-picker внутри панели */
#emoji-panel-container emoji-picker {
    --background: #1a1a2e !important;
    --border-color: #40E0D0 !important;
    --border-radius: 12px !important;
    --button-active-background: rgba(64, 224, 208, 0.2) !important;
    --button-hover-background: rgba(64, 224, 208, 0.1) !important;
    --category-emoji-padding: 10px !important;
    --category-font-size: 14px !important;
    --category-icon-color: #888 !important;
    --category-icon-active-color: #40E0D0 !important;
    --emoji-size: 28px !important;
    --emoji-padding: 8px !important;
    --indicator-color: #40E0D0 !important;
    --input-border-color: rgba(64, 224, 208, 0.3) !important;
    --input-border-radius: 8px !important;
    --input-font-color: white !important;
    --input-font-size: 14px !important;
    --input-line-height: 1.5 !important;
    --input-padding: 10px 12px !important;
    --input-placeholder-color: #888 !important;
    --outline-color: #40E0D0 !important;
    --outline-width: 2px !important;
    --padding: 15px !important;
}

/* Анимация при выборе эмодзи ТОЛЬКО в панели */
#emoji-panel-container emoji-picker .emoji {
    transition: all 0.2s ease !important;
    border-radius: 8px !important;
}

#emoji-panel-container emoji-picker .emoji:hover {
    transform: scale(1.2) !important;
    background: rgba(64, 224, 208, 0.2) !important;
    box-shadow: 0 0 15px rgba(64, 224, 208, 0.3) !important;
}

/* Категории ТОЛЬКО в панели */
#emoji-panel-container emoji-picker .category {
    padding: 5px 0 !important;
}

#emoji-panel-container emoji-picker .sticky-header {
    background: rgba(64, 224, 208, 0.1) !important;
    color: #40E0D0 !important;
    font-weight: bold !important;
    padding: 8px 15px !important;
    border-radius: 6px !important;
    margin: 5px 0 !important;
}

/* Поиск ТОЛЬКО в панели */
#emoji-panel-container emoji-picker input {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(64, 224, 208, 0.3) !important;
    color: white !important;
    border-radius: 8px !important;
    padding: 10px 15px !important;
    margin: 10px !important;
    font-size: 14px !important;
}

#emoji-panel-container emoji-picker input:focus {
    border-color: #40E0D0 !important;
    box-shadow: 0 0 10px rgba(64, 224, 208, 0.3) !important;
    outline: none !important;
}

/* Скроллбар ТОЛЬКО в панели */
#emoji-panel-container emoji-picker::-webkit-scrollbar {
    width: 8px !important;
}

#emoji-panel-container emoji-picker::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 4px !important;
}

#emoji-panel-container emoji-picker::-webkit-scrollbar-thumb {
    background: rgba(64, 224, 208, 0.5) !important;
    border-radius: 4px !important;
}

#emoji-panel-container emoji-picker::-webkit-scrollbar-thumb:hover {
    background: rgba(64, 224, 208, 0.8) !important;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    #emoji-panel-container emoji-picker {
        --emoji-size: 24px !important;
        --emoji-padding: 6px !important;
        --padding: 10px !important;
    }

    .emoji-panel-container {
        width: 90vw !important;
        max-width: none !important;
        left: 5vw !important;
        right: 5vw !important;
    }
}

/* ВАЖНО: Эмодзи в сообщениях должны оставаться цветными! */
.message .message-text {
    /* Сбрасываем любые стили для эмодзи в сообщениях */
    color: inherit !important;
    filter: none !important;
}

.message .message-text img.emoji,
.message .message-text span.emoji {
    display: inline !important;
    filter: none !important;
    color: inherit !important;
}

/* ========== ВОССТАНОВЛЕНИЕ ЦВЕТНЫХ ЭМОДЗИ В СООБЩЕНИЯХ ========== */

/* Эмодзи в сообщениях должны быть цветными и нормального размера */
.message .message-text {
    font-size: 16px !important;
    line-height: 1.5 !important;
}

/* Эмодзи как текст */
.message .message-text span[role="img"],
.message .message-text span.emoji {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif !important;
    font-size: 1.2em !important;
    vertical-align: middle !important;
    display: inline-block !important;
}

/* Изображения эмодзи (если используются) */
.message .message-text img.emoji {
    width: 1.2em !important;
    height: 1.2em !important;
    vertical-align: middle !important;
    margin: 0 0.05em !important;
}

/* Гарантируем что эмодзи не черно-белые */
.message .message-text * {
    color: inherit !important;
    filter: none !important;
    -webkit-filter: none !important;
}

/* ========== ЭМОДЗИ В ЦВЕТЕ NOX ========== */

/* 1. ВСЕ эмодзи в сообщениях получают цвет Nox */
.message .message-text img.emoji,
.message .message-text .emoji,
.message .message-text span[role="img"] {
    /* Основной фильтр: сине-бирюзовый (#40E0D0) */
    filter:
        sepia(0.8)              /* теплый базовый оттенок */
        saturate(500%)          /* повышенная насыщенность */
        hue-rotate(165deg)      /* поворот к сине-бирюзовому (Nox цвет) */
        brightness(0.95)        /* немного приглушенный */
        contrast(1.1) !important;

    transition: filter 0.3s ease !important;
}

/* 2. Разные цвета для разных категорий эмодзи */
/* Улыбающиеся - золотистые */
.message .message-text img.emoji[src*="smile"],
.message .message-text img.emoji[src*="happy"],
.message .message-text img.emoji[src*="laugh"] {
    filter:
        sepia(1)
        saturate(600%)
        hue-rotate(30deg)       /* золотистый */
        brightness(1.1)
        contrast(1.2) !important;
}

/* Сердечки - розовые/красные */
.message .message-text img.emoji[src*="heart"],
.message .message-text img.emoji[src*="love"] {
    filter:
        sepia(1)
        saturate(800%)
        hue-rotate(320deg)      /* розовый */
        brightness(1)
        contrast(1.3) !important;
}

/* Руки/жесты - зеленые */
.message .message-text img.emoji[src*="hand"],
.message .message-text img.emoji[src*="clap"] {
    filter:
        sepia(0.7)
        saturate(400%)
        hue-rotate(90deg)       /* зеленый */
        brightness(1)
        contrast(1.1) !important;
}

/* 3. Анимация при наведении */
.message .message-text img.emoji:hover {
    filter:
        sepia(0.8)
        saturate(700%)
        hue-rotate(165deg)
        brightness(1.2)
        contrast(1.3) !important;

    transform: scale(1.1) !important;
    transition: all 0.2s ease !important;
}

/* 4. Для текстовых эмодзи (не изображения) */
.message .message-text span.emoji,
.message .message-text .emojitext {
    color: #40E0D0 !important;
    font-size: 1.3em !important;
    display: inline-block !important;
    text-shadow:
        0 0 5px rgba(64, 224, 208, 0.5),
        0 0 10px rgba(64, 224, 208, 0.3) !important;
}

/* 5. Градиент для особых эмодзи */
.message .message-text .special-emoji {
    background: linear-gradient(45deg, #40E0D0, #00ff88, #40E0D0) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-size: 200% 200% !important;
    animation: nox-gradient 3s ease infinite !important;
}

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

/* 6. Гарантируем что все эмодзи видны */
.message .message-text * {
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* ========== СТИЛИ ДЛЯ МИНИАТЮР ИЗОБРАЖЕНИЙ ========== */

/* Миниатюры изображений в чате */
.image-thumbnail {
    transition: all 0.3s ease !important;
    cursor: pointer !important;
}

.image-thumbnail:hover {
    transform: scale(1.03) !important;
    box-shadow: 0 5px 20px rgba(64, 224, 208, 0.3) !important;
    border-color: #40E0D0 !important;
}

/* Кнопки действий для изображений */
.image-action-btn {
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    border: none !important;
    transition: all 0.2s ease !important;
    font-weight: 500 !important;
}

.view-btn {
    background: rgba(64, 224, 208, 0.2) !important;
    color: #40E0D0 !important;
    border: 1px solid rgba(64, 224, 208, 0.5) !important;
}

.view-btn:hover {
    background: rgba(64, 224, 208, 0.3) !important;
    transform: translateY(-2px) !important;
}

.download-btn {
    background: rgba(0, 255, 136, 0.2) !important;
    color: #00ff88 !important;
    border: 1px solid rgba(0, 255, 136, 0.5) !important;
}

.download-btn:hover {
    background: rgba(0, 255, 136, 0.3) !important;
    transform: translateY(-2px) !important;
}

/* Модальное окно просмотра изображений */
.image-viewer-modal {
    animation: fadeIn 0.3s ease !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .image-thumbnail {
        width: 100px !important;
        height: 100px !important;
    }

    .image-action-btn {
        padding: 8px 10px !important;
        font-size: 12px !important;
        flex: 1 !important;
        text-align: center !important;
    }
}

/* Загрузка миниатюр */
.image-thumbnail.loading {
    background: linear-gradient(90deg, #1a1a2e 25%, #2a2a3e 50%, #1a1a2e 75%) !important;
    background-size: 200% 100% !important;
    animation: loading 1.5s infinite !important;
}

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

/* Специальный размер для иконки выхода */
#logout-btn .control-icon {
}

/* УЛЬТРА-МИНИМАЛЬНЫЙ ФИКС ТОЛЬКО ДЛЯ ДЕСКТОПА */
/* Применяется через JS при загрузке на десктопе */
.desktop-height-fix #main-screen {
    height: 100vh !important;
    min-height: 100vh !important;
}

.desktop-height-fix .contacts-sidebar,
.desktop-height-fix .chat-area {
    height: 100% !important;
    min-height: 100% !important;
}

.desktop-height-fix .contacts-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* === ФИКС ВЫСОТЫ КНОПКИ НАЗАД В МОБИЛЬНЫХ === */
@media (max-width: 768px) {
    .back-to-contacts img {
        display: inline-block !important;
        vertical-align: middle !important;
    }
}

/* === SAFARI IPHONE: ФИКС ФУТЕРА === */
@supports (-webkit-touch-callout: none) and (max-width: 768px) {
    .chat-area.mobile-active .message-input-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        background: rgba(34,34,48,.98) !important;
        border-top: 1px solid rgba(64,224,208,0.3) !important;
    }

    .chat-area.mobile-active .messages-container {
        padding-bottom: 80px !important; /* Место для футера */
    }
}

/* ===== SEND BUTTON (CLEAN) ===== */
/* ===== SEND BUTTON (FINAL) ===== */

/* Кнопка SEND — полностью без эффектов .nox-btn */
#send-button.send-btn-new {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;

  --turq: transparent !important;
  --vio: transparent !important;

  transform: none !important;
  transition: none !important;
}

#send-button.send-btn-new:hover {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
}

/* ===== SEND ICON STRUCTURE ===== */

/* Обёртка — ТОЛЬКО для hover-scale */
.send-icon-wrap {
  display: inline-block;
  transition: transform 0.25s ease;
}

#send-button.send-btn-new:hover .send-icon-wrap {
  transform: scale(1.2);
}

/* Сама иконка — ТОЛЬКО rotate */
.send-icon-wrap img {
  width: 46px !important;
  height: 46px !important;
  display: block;

  transform-origin: 50% 50%;
  will-change: transform;
  filter: drop-shadow(0 0 5px rgba(64,224,208,0.5)) !important;
}

/* Мобильная версия */
@media (max-width: 768px) {
  .send-icon-wrap img {
    width: 50px !important;
    height: 50px !important;
  }
}

/* ===== SEND ICON ROTATION (SUCCESS) ===== */

@keyframes send-rotate-ccw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-720deg); } /* 2 оборота против часовой */
}

.send-icon-wrap img.rotate {
  animation: send-rotate-ccw 420ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== INPUT FOCUS (FIX) ===== */
#message-input:focus,
input#message-input:focus,
.message-input-container input:focus {
  border-color: rgba(64,224,208,0.8) !important;
  outline: none !important;
  box-shadow: 0 0 8px rgba(64,224,208,0.4) !important;
}

/* XYZ-markers */


.nox-marker {
  font-size: 9px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* X — закомментирован, стилей можно не держать */

/* Y — версия под логотипом */
.y-marker {
  margin-top: 1px;
  font-size: 9px;
  color: #fbf8fb; /* мягкий NỌX-бирюзовый */
  opacity: 0.65;
}

/* Z — иконка справа в chat-header */
.z-marker {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.z-marker img {
  width: 38px;
  height: 38px;
  display: block;
  opacity: 1.0;
}

.z-marker img:hover {
  transform: scale(1.12);
  filter: drop-shadow(0 0 8px rgba(64, 224, 208, 0.8));
}

.z-marker {
  pointer-events: auto;
}

.z-marker img {
  pointer-events: auto;
}

/* Desktop-only empty state marker */
.nox-empty-desktop-marker {
  display: none;
}

/* Показываем ТОЛЬКО на десктопе */
@media (min-width: 800px) {
  .nox-empty-desktop-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 48px;
    opacity: 0.4;
    color: #40E0D0;
    user-select: none;
    pointer-events: none;
  }
}

@media (min-width: 800px) {
  .nox-empty-image {
    width: 30vw;
    max-width: 420px;
    opacity: 0.75;
  }
}

@media (min-width: 800px) {

  .nox-empty-desktop-marker {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;   /* ВАЖНО: текст над картинкой */
    align-items: center;
    justify-content: center;
    gap: 16px;                /* расстояние между текстом и картинкой */
  }

  .nox-empty-text {
    font-size: 16px;          /* 14–16px, выбрано оптимальное */
    line-height: 1.4;
    text-align: center;
    color: rgba(250, 250, 250, 1); /* серо-фиолетовый, читается на тёмно-фиолетовом */
    user-select: none;
    pointer-events: none;
  }

  .nox-empty-image {
    width: 10vw;
    max-width: 420px;
    opacity: 0.9;            /* полупрозрачная картинка */
    display: block;
  }

}

/* ===== ANDROID/TABLET FIX: real viewport height (prevents bottom cutoff) ===== */
@supports (height: 100dvh) {
  body {
    height: 100dvh;
  }

  .screen {
    height: 100dvh;
  }

  .chat-container {
    height: 100dvh;
  }
}

@media (min-width: 769px) and (max-width: 1200px) and (orientation: portrait) {
  @supports (height: 100dvh) {
    .chat-container {
      height: 100dvh;
    }
  }
}

/* ===== Scroll-to-bottom (NỌX style) ===== */

.nox-scroll-bottom {
  position: absolute;
  left: 50%;
  bottom: 85px;               /* 5–7px над input фактически */
  transform: translateX(-50%);
  z-index: 30;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.nox-scroll-bottom.visible {
  opacity: 0.5;
  pointer-events: auto;
}

.nox-scroll-bottom-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(140, 140, 160, 0.75); /* почти непрозрачный */
  color: #111;

  font-size: 18px;
  font-weight: 600;
  color: #fff;

  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  cursor: pointer;
  user-select: none;
}

/* ===== Pulse animation ===== */

@keyframes noxPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(64, 224, 208, 0.9);
  }
  60% {
    box-shadow: 0 0 0 10px rgba(80, 255, 200, 0.45);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(64, 224, 208, 0.0);
  }
}

.nox-scroll-bottom.pulse .nox-scroll-bottom-btn {
  animation: noxPulse 1.6s ease-out infinite;
}

#message-input {
  resize: none;          /* запрещаем ручное растягивание */
  overflow-y: auto;      /* включаем внутренний скролл */
  max-height: 64px;      /* ~3 строки */
  line-height: 1.4;
}

/* === NOX WEB QR MODAL === */

/* === NOX WEB QR MODAL === */

#nox-qr-web-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

/* Desktop: НЕ показываем модалку вообще (не лезем в фреймы) */
@media (min-width: 769px) {
  #nox-qr-web-modal,
  #nox-qr-web-modal.active {
    display: none !important;
  }
}

/* Active state (по умолчанию, но на desktop всё равно задавлено media выше) */
#nox-qr-web-modal.active {
  display: flex;
}

.nox-qr-web-content {
  width: 45vw;
  max-width: 520px;
  background: rgba(20, 20, 30, 0.9);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.nox-qr-web-image {
  width: 100%;
  height: auto;
  display: block;
}

/* Mobile: ширина 90% */
@media (max-width: 768px) {
  .nox-qr-web-content {
    width: 90vw;
    max-width: none;
  }
}

/* === NOX EMPTY CHAT STATE (DESKTOP) === */

/* === NOX EMPTY CHAT STATE === */
.chat-area.chat-empty .chat-header,
.chat-area.chat-empty .message-input-container {
  display: none;
}

.chat-area.chat-empty .messages-container {
  display: flex;
  align-items: center;
  justify-content: center;
}






/* === NOX: FORCE PORTRAIT ON MOBILE (iOS SAFE) === */
@media screen and (max-width: 1024px) and (orientation: landscape) {
  body {
    overflow: hidden !important;
  }

  body::before {
    content: "Please rotate your device to portrait mode";
    position: fixed;
    inset: 0;
    background: #0b0b10;
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px;
    padding: 24px;
    z-index: 2147483647;
  }

  #main-screen,
  #auth-screen {
    display: none !important;
  }
}


/* === Z CALL POPOVER (Audio / Video) === */

/* === Z CALL POPOVER — ETALON v2 (fast, softer, glassy, rounded items) === */

/* Хедер поверх сообщений — НЕ МЕНЯЕМ ЛОГИКУ */
.chat-header {
  position: relative;
  z-index: 999900 !important;
}

.messages-container {
  position: relative;
  z-index: 10;
}

/* === POPUP === */
.z-call-popover {
  position: absolute;
  top: calc(100% + 10px);   /* зафиксировано */
  right: 0;
  left: auto;

  z-index: 999999 !important;

  /* скрыто по умолчанию */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px); /* было -6 → почти мгновенно */

  /* 🔹 УБРАЛИ ОЩУЩЕНИЕ ЗАДЕРЖКИ */
  transition:
    opacity 70ms linear,
    transform 70ms linear,
    box-shadow 120ms ease;

  /* 🔹 ЧУТЬ СВЕТЛЕЕ ПОДЛОЖКА */
  background:
    linear-gradient(
      rgba(22, 18, 30, 0.68),
      rgba(22, 18, 30, 0.68)
    ),
    rgba(100, 60, 140, 0.42);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  /* градиентный бордер NỌX */
  border: 1px solid transparent;
  border-radius: 16px;
  background-clip: padding-box;

  overflow: hidden;
  min-width: 190px;
}

/* Градиентный бордер */
.z-call-popover::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: 16px;
  background: linear-gradient(135deg, #D612D3, #00A2F8);

  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;

  pointer-events: none;
}

/* === ACTIVE === */
.z-call-popover.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);

  /* 🔹 УСИЛЕННЫЙ, НО ЧИСТЫЙ GLOW */
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.70),
    0 0 36px rgba(64, 224, 208, 0.32),
    0 0 14px rgba(214, 18, 211, 0.22);
}

/* === ITEMS === */
.z-call-popover .z-call-item {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 17px 22px;
  font-size: 15.5px;

  /* 🔹 светло-серо-бирюзовый, не кислотный */
  color: rgba(175, 225, 225, 0.92);

  cursor: pointer;
  user-select: none;
  white-space: nowrap;

  /* 🔹 СКРУГЛЕНИЕ КАЖДОГО ПУНКТА */
  border-radius: 12px;

  /* 🔹 ЧИСТЫЙ HOVER (УБРАЛ КОРИЧНЕВЫЙ) */
  transition: background 90ms linear, color 90ms linear;
}

/* разделитель аккуратный */
.z-call-popover .z-call-item + .z-call-item {
  margin-top: 2px;
}

/* hover */
.z-call-popover .z-call-item:hover {
  background: rgba(120, 180, 200, 0.12);
  color: rgba(200, 240, 240, 0.96);
}

#nox-autolock-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
}

.message-text a {
    color: #40E0D0;                 /* фирменная бирюза NỌX */
    text-decoration: none;          /* убрать подчёркивание */
    font-weight: 500;
    transition: 
        color 0.15s ease,
        text-shadow 0.15s ease,
        opacity 0.15s ease;
}

.message-text a:hover {
    color: #5FF5E6;                 /* чуть светлее при hover */
    text-shadow: 
        0 0 6px rgba(64, 224, 208, 0.6),
        0 0 12px rgba(64, 224, 208, 0.35);
    opacity: 0.95;
}


/* ===== exact context menu overlay fix ===== */
body.message-context-open {
    overflow: hidden !important;
}

.message-context-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

@media (hover: none) and (pointer: coarse) {
    body.message-context-open .message,
    body.message-context-open .message * {
        -webkit-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
    }
}


/* ===== exact native emoji rendering reset ===== */
.message .message-text {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        sans-serif !important;
}

.message .message-text img.emoji,
.message .message-text .emoji,
.message .message-text span[role="img"] {
    filter: none !important;
    -webkit-filter: none !important;
    color: inherit !important;
    transition: none !important;
    font-family:
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Noto Color Emoji",
        sans-serif !important;
}

.message .message-text img.emoji[src*="smile"],
.message .message-text img.emoji[src*="happy"],
.message .message-text img.emoji[src*="laugh"],
.message .message-text img.emoji[src*="heart"],
.message .message-text img.emoji[src*="love"],
.message .message-text img.emoji[src*="fire"],
.message .message-text img.emoji[src*="star"],
.message .message-text img.emoji[src*="thumb"],
.message .message-text img.emoji[src*="ok"] {
    filter: none !important;
    -webkit-filter: none !important;
}


/* ===== twemoji message render ===== */
.message .message-text img.nox-twemoji,
.message .message-text img.emoji {
    width: calc(1em + 10px) !important;
    height: calc(1em + 10px) !important;
    vertical-align: -0.16em !important;
    margin: 0 0.03em !important;
    display: inline-block !important;
    object-fit: contain;
}
