* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #08080a;
    --bg-soft: #0f0f12;
    --bg-elev: #16161c;
    --bg-hover: #1c1c24;
    --accent: #ff2d6f;
    --accent-h: #ff4585;
    --accent-soft: #ff2d6f33;
    --white: #ffffff;
    --gray: #8b8b96;
    --gray-dim: #4a4a55;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --r-md: 20px;
    --r-lg: 28px;
    --r-pill: 999px;
    
    /* Стеклянные панели */
    --glass-bg: rgba(15, 15, 18, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--white);
    overflow: hidden;
    font-size: 15px;
}

.bg-glow {
    position: fixed;
    top: -40%;
    left: 50%;
    transform: translateX(-50%);
    width: 120vw;
    height: 120vw;
    max-width: 1200px;
    max-height: 1200px;
    background: radial-gradient(circle, #ff2d6f33 0%, transparent 60%);
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
}

.screen { position: fixed; inset: 0; display: none; z-index: 1; }
.screen.active { display: flex; }
.hidden { display: none !important; }

input {
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    border: none;
    background: transparent;
    box-shadow: none;
    font-family: inherit;
    color: inherit;
    caret-color: var(--accent);
    padding: 0;
    margin: 0;
}
input:focus { outline: none; }

/* ============================================================
   КНОПКИ (С анимацией)
   ============================================================ */
button, .chat-item { transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1); }
button:active, .chat-item:active { transform: scale(0.96); }

.server-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--bg-elev); border: 1px solid var(--border);
    color: var(--gray); display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0; flex-shrink: 0;
}

.server-btn-auth {
    position: fixed; top: 24px; left: 24px; z-index: 50;
    width: 48px; height: 48px; transition: opacity 0.3s, transform 0.25s;
}

body.app-active .server-btn-auth { opacity: 0; pointer-events: none; transform: scale(0.5); }

/* ============================================================
   АВТОРИЗАЦИЯ
   ============================================================ */
#auth-screen { align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 20px 0; }
.auth-header { text-align: center; }
.auth-logo { width: 68px; height: 68px; background: var(--accent); border-radius: 20px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 50px #ff2d6f55; margin: 0 auto 16px; }
.auth-title { font-size: 28px; font-weight: 900; letter-spacing: -0.8px; margin-bottom: 4px; background: linear-gradient(135deg, #fff 0%, #ffb3d9 50%, #ff2d6f 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-sub { font-size: 13px; color: var(--gray); }
.auth-toggle { position: relative; display: flex; background: var(--bg-elev); border-radius: var(--r-pill); padding: 5px; border: 1px solid var(--border); height: 50px; }
.auth-toggle-slider { position: absolute; top: 5px; left: 5px; width: calc(50% - 5px); height: calc(100% - 10px); background: var(--accent); border-radius: var(--r-pill); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1; }
.auth-toggle-slider.right { transform: translateX(100%); }
.auth-toggle-btn { position: relative; z-index: 2; flex: 1; border: none; background: transparent; color: var(--gray); font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; border-radius: var(--r-pill); }
.auth-toggle-btn.active { color: var(--white); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-field { display: flex; align-items: center; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px; padding: 0 16px; height: 54px; }
.auth-field:focus-within { border-color: var(--accent); }
.auth-field-icon { color: var(--gray-dim); margin-right: 12px; }
.auth-field:focus-within .auth-field-icon { color: var(--accent); }
.auth-field input { flex: 1; color: var(--white); font-size: 15px; }
.btn-primary { background: var(--accent); color: var(--white); border: none; border-radius: var(--r-pill); padding: 15px 32px; font-size: 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:active { transform: scale(0.97); }
.btn-full { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: transparent; border: 1px solid var(--border); color: var(--gray); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--bg-elev); color: var(--white); }
.auth-status { font-size: 12.5px; color: var(--accent); text-align: center; min-height: 16px; }

/* ============================================================
   ПРИЛОЖЕНИЕ
   ============================================================ */
#app-screen { display: none; }
#app-screen.active { display: grid; grid-template-columns: 340px 1fr; overflow: hidden; }
.sidebar { background: var(--bg-soft); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.logo { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 16px; }
.logo-mark { width: 36px; height: 36px; background: var(--accent); border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.sidebar-search { padding: 12px 20px; }
.search-wrap { display: flex; align-items: center; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 0 16px; height: 44px; }
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { color: var(--gray-dim); margin-right: 10px; }
.search-input { flex: 1; color: var(--white); font-size: 14px; }
.btn-new-chat { margin: 0 20px 10px; padding: 13px; font-size: 14px; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.chat-item { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 16px; cursor: pointer; margin-bottom: 2px; position: relative; transition: background 0.15s; }
.chat-item:hover, .chat-item.active { background: var(--bg-elev); }
.chat-item.active::before { content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%); width: 4px; height: 24px; background: var(--accent); border-radius: 0 4px 4px 0; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; flex-shrink: 0; color: var(--white); }
.avatar-sm { width: 40px; height: 40px; font-size: 15px; }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 700; font-size: 14.5px; margin-bottom: 2px; }
.chat-item-preview { font-size: 12.5px; color: var(--gray); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.logout-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: transparent; border: none; color: var(--gray); font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 12px; }
.logout-btn:hover { background: var(--bg-elev); color: var(--accent); }

/* ============================================================
   ЧАТ И БЛЮР
   ============================================================ */
.chat-area { background: var(--bg); display: flex; flex-direction: column; overflow: hidden; position: relative; min-height: 0; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--gray-dim); }
.empty-icon { opacity: 0.35; }
.empty-text { font-size: 16px; text-align: center; }
.active-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* Блюр шапки */
.chat-header {
    padding: 12px 20px;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    border-bottom: 1px solid var(--glass-border) !important;
    display: flex; align-items: center; gap: 12px; flex-shrink: 0; z-index: 10;
}
.back-btn { display: none; }
.chat-header-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.chat-name { font-weight: 700; font-size: 15.5px; }
.chat-status { font-size: 12.5px; color: var(--accent); margin-top: 2px; }

/* Блюр инпута */
.input-area {
    padding: 12px 20px 16px;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    border-top: 1px solid var(--glass-border) !important;
    display: flex; gap: 10px; align-items: center; flex-shrink: 0; z-index: 10;
}
.input-wrap { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 0 18px; display: flex; align-items: center; height: 46px; }
.input-wrap:focus-within { border-color: var(--accent); background: rgba(0,0,0,0.5); }
.msg-input { flex: 1; color: var(--white); font-size: 14.5px; }
.send-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); border: none; color: var(--white); display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* ============================================================
   СООБЩЕНИЯ И РЕПЛАИ
   ============================================================ */
.messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.msg-row { display: flex; width: 100%; }
.msg-row.out { justify-content: flex-end; }
.msg-row.in { justify-content: flex-start; }

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

.msg-bubble {
    display: inline-block; max-width: min(480px, 75%);
    padding: 8px 14px 7px; border-radius: 16px;
    font-size: 14.5px; line-height: 1.35; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
    background: var(--bg-elev);
    animation: msgIn 0.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}
.msg-row.out .msg-bubble { background: linear-gradient(135deg, #ff2d6f, #ff4585); border-bottom-right-radius: 4px; box-shadow: 0 4px 15px rgba(255, 45, 111, 0.2); }
.msg-row.in .msg-bubble { background: #1c1c24; border-bottom-left-radius: 4px; border: 1px solid rgba(255,255,255,0.05); }
.msg-time { display: inline-block; font-size: 10px; opacity: 0.65; margin-left: 6px; font-weight: 500; }

/* Плашка реплая */
.msg-reply {
    display: flex; flex-direction: column; gap: 2px;
    border-left: 3px solid rgba(255, 255, 255, 0.6);
    padding: 4px 8px; margin-bottom: 8px; font-size: 12px; line-height: 1.3;
    cursor: pointer; border-radius: 4px; background: rgba(0, 0, 0, 0.15);
}
.msg-reply:hover { background: rgba(0, 0, 0, 0.25); }
.msg-row.out .msg-reply { border-left-color: rgba(255, 255, 255, 0.9); }
.msg-row.in .msg-reply { border-left-color: var(--accent); background: rgba(255, 255, 255, 0.05); }
.msg-reply-author { font-weight: 700; font-size: 11px; color: var(--white); opacity: 0.9; }
.msg-row.in .msg-reply-author { color: var(--accent); opacity: 1; }
.msg-reply-text { color: var(--white); opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-size: 12px; }

/* Подсветка при скролле */
.msg-highlight .msg-bubble { animation: msgHighlight 1.2s ease; }
@keyframes msgHighlight {
    0% { box-shadow: 0 0 0 0 rgba(255, 45, 111, 0); }
    20% { box-shadow: 0 0 0 4px rgba(255, 45, 111, 0.45); }
    100% { box-shadow: 0 0 0 0 rgba(255, 45, 111, 0); }
}

/* Стикеры */
.sticker-bubble { background: transparent !important; padding: 0 !important; border: none !important; box-shadow: none !important; }
.sticker-image { width: 150px; height: 150px; object-fit: contain; display: block; cursor: pointer; }
.sticker-meta { display: flex; justify-content: flex-end; align-items: center; font-size: 11px; color: #fff; margin-top: 4px; opacity: 0.8; }

/* ============================================================
   ГАЛЕРЕЯ (ЛАЙТБОКС)
   ============================================================ */
.media-viewer-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px); z-index: 2000; display: flex; flex-direction: column;
    align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s;
}
.media-viewer-overlay.active { opacity: 1; }
.media-viewer-content { max-width: 90vw; max-height: 80vh; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); transform: scale(0.95); transition: transform 0.2s; }
.media-viewer-overlay.active .media-viewer-content { transform: scale(1); }
.media-viewer-panel { position: absolute; bottom: 30px; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 16px; padding: 12px 20px; display: flex; align-items: center; gap: 15px; box-shadow: var(--glass-shadow); backdrop-filter: blur(20px); }
.media-viewer-info { display: flex; align-items: center; gap: 10px; padding-right: 15px; border-right: 1px solid rgba(255,255,255,0.1); }
.media-viewer-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.media-viewer-name { font-weight: 600; font-size: 14px; color: var(--white); }
.media-viewer-actions { display: flex; gap: 10px; }
.media-action-btn { background: transparent; border: none; color: var(--gray); cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 8px; }
.media-action-btn:hover { background: rgba(255,255,255,0.1); color: var(--white); }
.media-action-btn svg { width: 18px; height: 18px; }
.media-close-btn { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.1); border: none; color: var(--white); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.media-close-btn:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   ПОПОВЕР СТИКЕРОВ, МЕНЮ ФАЙЛОВ И КОНТЕКСТ
   ============================================================ */
#stickers-popover {
    position: absolute; bottom: 80px; left: 20px; right: 20px; max-width: 400px; height: 380px;
    background: var(--glass-bg) !important; backdrop-filter: blur(30px) saturate(200%) !important;
    border: 1px solid var(--glass-border) !important; box-shadow: var(--glass-shadow) !important;
    border-radius: 20px; z-index: 50; display: flex; flex-direction: column; overflow: hidden;
}
.sticker-pack-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sticker-item { width: 100%; aspect-ratio: 1; background: rgba(255,255,255,0.05); border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; }
.sticker-item:hover { background: rgba(255,255,255,0.1); }
.sticker-item img { width: 80%; height: 80%; object-fit: contain; }

.attach-menu {
    position: absolute; bottom: 80px; left: 20px; width: 200px;
    background: var(--glass-bg) !important; backdrop-filter: blur(30px) saturate(200%) !important;
    border: 1px solid var(--glass-border) !important; box-shadow: var(--glass-shadow) !important;
    border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 4px; z-index: 100;
}
.attach-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: transparent; border: none; color: var(--white); font-size: 14px; font-weight: 600; border-radius: 10px; cursor: pointer; }
.attach-item:hover { background: rgba(255,255,255,0.1); }
.attach-item svg { width: 20px; height: 20px; opacity: 0.8; }

@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
#stickers-popover:not(.hidden), .attach-menu:not(.hidden) { animation: slideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1) forwards; }

.context-menu {
    position: fixed; background: var(--glass-bg) !important; backdrop-filter: blur(30px) saturate(200%) !important;
    border: 1px solid var(--glass-border) !important; box-shadow: var(--glass-shadow) !important;
    border-radius: 16px; padding: 8px; z-index: 1000; display: flex; flex-direction: column; min-width: 180px;
}
.ctx-item { background: transparent; border: none; padding: 12px 16px; color: var(--white); font-size: 14px; font-weight: 600; text-align: left; border-radius: 10px; cursor: pointer; }
.ctx-item:hover { background: rgba(255,255,255,0.1); }

/* ============================================================
   МОДАЛКИ И НАСТРОЙКИ
   ============================================================ */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-content { background: var(--bg-soft); border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: 28px 24px; width: 100%; max-width: 420px; position: relative; max-height: 85vh; overflow-y: auto; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; background: transparent; border: 1px solid var(--border); color: var(--gray); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.modal-close:hover { background: var(--bg-elev); color: var(--accent); border-color: var(--accent); }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--gray); margin-bottom: 20px; }

.settings-window { width: 92vw; max-width: 1100px; height: 85vh; background: var(--bg-soft); border: 1px solid var(--border-strong); border-radius: var(--r-lg); display: grid; grid-template-columns: 240px 1fr; overflow: hidden; position: relative; }
.settings-sidebar { background: var(--bg); border-right: 1px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.settings-title { font-size: 20px; font-weight: 900; padding: 8px 12px 16px; }
.settings-nav { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: transparent; border: none; color: var(--gray); font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 12px; text-align: left; }
.settings-nav:hover { background: var(--bg-elev); color: var(--white); }
.settings-nav.active { background: var(--accent); color: var(--white); }
.settings-content { padding: 32px 40px; overflow-y: auto; position: relative; }
.settings-close { position: absolute; top: 20px; right: 20px; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-h2 { font-size: 26px; font-weight: 900; margin-bottom: 6px; }
.settings-h3 { font-size: 18px; font-weight: 800; margin-top: 28px; margin-bottom: 14px; }
.settings-desc { font-size: 14px; color: var(--gray); margin-bottom: 28px; }
.settings-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-width: 480px; }
.settings-field label { font-size: 12px; color: var(--gray-dim); font-weight: 700; text-transform: uppercase; }
.settings-field input { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; color: var(--white); font-size: 14px; width: 100%; }
.settings-field input:focus { border-color: var(--accent); }

/* Список серверов */
.servers-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.server-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; cursor: pointer; }
.server-item.active { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-soft); }
.server-item-name { font-size: 14px; font-weight: 700; }
.server-item-addr { font-size: 11.5px; color: var(--gray-dim); }
.server-item-menu { background: transparent; border: none; color: var(--gray); cursor: pointer; }

/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ (С ПЛАВНЫМ ПЕРЕХОДОМ)
   ============================================================ */
@media (max-width: 768px) {
    #app-screen.active { 
        grid-template-columns: 1fr; 
        position: relative; 
        overflow: hidden; 
        display: block; 
    }

    .sidebar {
        position: absolute; top: 0; left: 0; width: 100%; height: 100%;
        border-right: none; z-index: 10; background: var(--bg-soft);
        transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
        transform: translateX(0);
    }

    .chat-area {
        position: absolute; top: 0; left: 0; width: 100%; height: 100%;
        z-index: 20; background: var(--bg);
        transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
        transform: translateX(100%);
    }

    /* Сдвигаем */
    #app-screen.chat-open .sidebar {
        transform: translateX(-30%);
        opacity: 0.5;
    }

    #app-screen.chat-open .chat-area {
        transform: translateX(0);
    }

    .back-btn { display: flex !important; }
    .msg-bubble { max-width: 85%; padding: 10px 14px; }
    .messages { padding: 16px; gap: 6px; }
    .input-area { padding: 10px 16px 14px; gap: 8px; }
    .chat-header { padding: 12px 16px; }
    .chat-name { font-size: 16px; }

    #stickers-popover { left: 10px; right: 10px; bottom: 80px; max-width: none; }
    .attach-menu { left: 10px; bottom: 80px; width: 200px; }
    .server-btn-auth { top: 16px; left: 16px; width: 42px; height: 42px; }
    .settings-window { grid-template-columns: 1fr; height: 92vh; }
    .settings-sidebar { flex-direction: row; overflow-x: auto; padding: 12px; border-right: none; border-bottom: 1px solid var(--border); }
    .settings-title { display: none; }
    .settings-nav { flex-shrink: 0; padding: 10px 16px; }
    .settings-nav span { display: none; }
    .settings-content { padding: 24px 20px; }
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--gray-dim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
/* ============================================================
   ЗВОНКИ (WebRTC)
   ============================================================ */
.chat-call-actions { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.chat-call-actions.hidden { display: none; }
.call-header-btn { width: 38px; height: 38px; border-radius: 12px; }
.call-header-btn:hover { color: var(--accent); border-color: var(--accent); }

.call-layer {
    position: fixed; inset: 0; z-index: 400;
    background: radial-gradient(circle at 50% 20%, #ff2d6f22, transparent 55%), var(--bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 24px; overflow: hidden; animation: callFadeIn .18s ease;
}
.call-layer.hidden { display: none; }
@keyframes callFadeIn { from { opacity: 0; } to { opacity: 1; } }

.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: block; opacity: 0; pointer-events: none; transition: opacity .2s; }
.call-layer.video-active .call-remote { opacity: 1; }
.call-layer.video-active { background: #000; }

.call-card { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; transition: opacity .2s; }
.call-layer.video-active .call-card { opacity: 0; pointer-events: none; }

.call-avatar-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.call-avatar { width: 120px; height: 120px; border-radius: 50%; font-size: 46px; box-shadow: 0 0 0 6px rgba(255,45,111,.12); }
.call-layer.incoming .call-avatar { animation: callPulse 1.6s ease-in-out infinite; }
@keyframes callPulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(255,45,111,.12); }
    50% { box-shadow: 0 0 0 18px rgba(255,45,111,.04); }
}

.call-name { font-size: 24px; font-weight: 800; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-sub { font-size: 14px; color: var(--gray); }
.call-layer.is-active .call-sub { color: var(--green); }

.call-actions {
    position: absolute; z-index: 3; bottom: max(40px, calc(env(safe-area-inset-bottom, 0px) + 28px));
    left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 26px;
}
.call-btn {
    width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--border-strong);
    background: rgba(22,22,28,.9); color: var(--white); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform .15s, background .2s, color .2s; backdrop-filter: blur(10px);
}
.call-btn svg { width: 26px; height: 26px; }
.call-btn:hover { transform: scale(1.07); background: var(--bg-hover); }
.call-btn:active { transform: scale(.96); }
.call-btn.accept { background: var(--green); border-color: transparent; }
.call-btn.decline, .call-btn.hangup { background: var(--red); border-color: transparent; }
.call-btn.off { background: var(--white); color: var(--bg); border-color: transparent; }

.call-top {
    position: absolute; z-index: 3; top: max(20px, calc(env(safe-area-inset-top, 0px) + 12px));
    left: 0; right: 0; display: none; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
}
.call-layer.video-active .call-top { display: flex; }
.call-top-name { font-size: 16px; font-weight: 700; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.call-timer { font-size: 13px; color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; }

.call-local {
    position: absolute; z-index: 3; right: 20px; bottom: 130px; width: 148px; aspect-ratio: 3 / 4;
    object-fit: cover; border-radius: 16px; border: 1px solid var(--border-strong); background: #000;
    display: none; box-shadow: 0 10px 30px rgba(0,0,0,.6); transform: scaleX(-1);
}
.call-layer.has-local-video .call-local { display: block; }

.fc-toast {
    position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px);
    background: var(--bg-elev); border: 1px solid var(--border-strong); color: var(--white);
    font-size: 13px; padding: 12px 20px; border-radius: var(--r-pill); z-index: 500;
    opacity: 0; pointer-events: none; transition: all .25s;
}
.fc-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 768px) {
    .call-avatar { width: 96px; height: 96px; font-size: 36px; }
    .call-name { font-size: 20px; }
    .call-btn { width: 58px; height: 58px; }
    .call-btn svg { width: 24px; height: 24px; }
    .call-actions { gap: 20px; }
    .call-local { width: 104px; bottom: 120px; right: 14px; }
    .chat-header-btn { width: 34px; height: 34px; }
}
