/* ---------------------------------- */
/* АДАПТИВНОСТЬ (МОБИЛЬНЫЕ УСТРОЙСТВА)*/
/* ---------------------------------- */

@media (max-width: 768px) {
    /* Левая панель – выезжающая */
    .chats-panel {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1100;
        transition: left 0.3s ease;
        border-radius: 0;
        background: var(--bg-surface);
        backdrop-filter: blur(16px);
    }
    .chats-panel.open {
        left: 0;
    }
    .mobile-chats-toggle {
        display: inline-flex !important;
    }

    /* Область чата – на всю ширину */
    .chat-area {
        width: 100%;
        position: relative;
    }

    /* Сообщения – уменьшаем отступы */
    .messages {
        padding: 12px 12px;
    }
    .message {
        max-width: 85%;
    }
    .message-bubble {
        padding: 8px 12px;
    }
    .message-text {
        font-size: 13px;
    }
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    /* Панель ввода – компактнее */
    .input-area {
        padding: 8px 12px;
        gap: 8px;
    }
    .input-area input {
        padding: 10px 14px;
        font-size: 13px;
    }
    .input-area button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* Заголовок чата */
    .chat-header {
        padding: 8px 12px;
    }
    .chat-name-header {
        font-size: 16px;
    }
    .online-status {
        font-size: 10px;
    }

    /* Кнопка прокрутки вниз */
    .scroll-down-button {
        bottom: 70px;
        right: 12px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* Голосовая панель записи */
    .voice-recorder-panel {
        min-height: 180px;
        backdrop-filter: blur(16px);
    }
    .voice-recorder-panel-microphone {
        width: 60px;
        height: 60px;
    }
    .voice-recorder-panel-cancel-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .voice-recorder-panel-visual {
        width: 160px;
        height: 160px;
    }
    .voice-recorder-panel-canvas,
    .voice-recorder-panel-red-canvas {
        width: 100%;
        height: 100%;
    }

    /* Панель с закреплёнными сообщениями */
    .pinned-bar {
        padding: 6px 12px;
        gap: 8px;
    }
    .pinned-message-bar-item {
        padding: 4px 10px;
        font-size: 11px;
    }

    /* Ответы */
    .reply-bar {
        margin: 4px 8px;
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Резервный фон для браузеров, где backdrop-filter не работает или даёт прозрачность */
@media (max-width: 768px) {
    .chat-area,
    .messages {
        background: var(--bg-dark) !important;
    }
    .chat-header,
    .input-area,
    .message-bubble,
    .chats-panel,
    .voice-recorder-panel,
    .pinned-bar,
    .reply-bar {
        background: rgba(10, 15, 28, 0.95) !important;
        backdrop-filter: none !important;
    }
    body.light-theme .chat-header,
    body.light-theme .input-area,
    body.light-theme .message-bubble,
    body.light-theme .chats-panel,
    body.light-theme .voice-recorder-panel,
    body.light-theme .pinned-bar,
    body.light-theme .reply-bar {
        background: rgba(242, 244, 248, 0.95) !important;
    }
}