:root {
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --danger-color: #dc2626;
    --success-color: #16a34a;
}

* { box-sizing: border-box; }
html, body { 
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 100%; 
    height: 100dvh; 
    overflow: hidden; 
    background: var(--bg-color); 
    color: var(--text-main); 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}

/* Авторизация и общие модальные карточки */
#authScreen, #callTypeModal, #incomingModal, #addFriendModal, #createRoomModal { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.85); 
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 350; 
}

.auth-card, .call-type-card, .incoming-card { 
    background: var(--panel-bg); 
    padding: 25px; 
    border-radius: 16px; 
    width: 90%; 
    max-width: 320px; 
    text-align: center; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); 
}

.auth-card h2, .auth-card h3, .call-type-card h3, .incoming-card h3 { 
    margin: 0; 
    font-size: 1.3rem; 
    color: var(--text-main); 
}

.auth-card input { 
    padding: 12px; 
    border-radius: 8px; 
    background: var(--border-color); 
    border: 1px solid transparent; 
    color: white; 
    font-size: 1rem; 
    outline: none; 
    width: 100%; 
}

.auth-card button, .btn-type-audio, .btn-type-video, .btn-type-cancel, .btn-accept, .btn-reject { 
    padding: 12px; 
    border-radius: 8px; 
    background: var(--accent-color); 
    color: white; 
    border: none; 
    font-size: 1rem; 
    font-weight: 600; 
    cursor: pointer; 
    width: 100%; 
    transition: background 0.2s;
}

.btn-type-video, .btn-accept { background: var(--success-color); }
.btn-type-cancel, .btn-reject { background: var(--danger-color); }
.incoming-actions { display: flex; gap: 10px; justify-content: center; width: 100%; }

/* Полноэкранный вызов */
#callOverlay { position: fixed; inset: 0; background: radial-gradient(circle at center, #1e293b 0%, #0b0f19 100%); display: none; flex-direction: column; z-index: 200; }

.videos-wrapper { 
    flex: 1; 
    position: relative; 
    display: grid; 
    gap: 8px; 
    padding: 8px; 
    box-sizing: border-box; 
    overflow: hidden; 
    align-items: center; 
    justify-content: center; 
}

/* 1 видео: на весь экран */
.videos-wrapper.grid-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* 2 видео: делим экран пополам */
.videos-wrapper.grid-2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr;
}

/* 3 и более видео: автоматическая адаптивная сетка */
.videos-wrapper.grid-multi {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-auto-rows: 1fr;
}

.videos-wrapper video { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 8px; 
    background: #111; 
}

#remoteVideo { width: 100%; height: 100%; object-fit: contain; background: transparent; display: none; position: absolute; inset: 0; z-index: 1; }
#localVideo { position: absolute; bottom: 90px; right: 20px; width: 90px; height: 130px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.6); object-fit: cover; background: #222; z-index: 3; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }

.audio-call-placeholder { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    gap: 15px; 
    color: var(--text-muted); 
    z-index: 2; 
    position: absolute; 
    inset: 0; 
    text-align: center; 
}

.avatar-circle { width: 110px; height: 110px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-color), #1d4ed8); display: flex; justify-content: center; align-items: center; font-size: 3rem; color: white; font-weight: bold; box-shadow: 0 0 30px rgba(37,99,235,0.5); animation: pulse-avatar 2s infinite ease-in-out; }

@keyframes pulse-avatar {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(37,99,235,0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(37,99,235,0.7); }
    100% { transform: scale(1); box-shadow: 0 0 20px rgba(37,99,235,0.4); }
}

.call-action-bar { height: 80px; background: var(--panel-bg); display: flex; justify-content: center; align-items: center; gap: 15px; flex-shrink: 0; border-top: 1px solid var(--border-color); z-index: 4; }
.call-ctrl-btn { width: 50px; height: 50px; border-radius: 50%; border: none; display: flex; justify-content: center; align-items: center; cursor: pointer; color: white; font-size: 1.2rem; background-color: var(--border-color); transition: background 0.2s; }
.btn-hangup { background-color: var(--danger-color); }
.call-ctrl-btn.disabled { background-color: var(--danger-color); }

/* Каркас приложения */
.app-container { display: flex; width: 100%; height: 100%; height: 100dvh; overflow: hidden; position: relative; }

/* Левая панель (сайдбар) */
.sidebar { width: 320px; background: var(--panel-bg); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; height: 100%; flex-shrink: 0; z-index: 10; transition: transform 0.3s ease; }
.sidebar-header { padding: 12px 15px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { margin: 0; font-size: 1.1rem; }

.user-item { padding: 10px 12px; margin: 4px 8px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.03); transition: background 0.2s; }
.user-item:hover { background: #334155; }
.user-name { font-weight: 500; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; flex-shrink: 0; }
.status-indicator.busy { background: #f59e0b; }

.user-actions { display: flex; gap: 4px; align-items: center; }
.action-btn { background: var(--border-color); color: white; border: none; border-radius: 6px; padding: 5px 8px; font-size: 0.75rem; cursor: pointer; }
.action-btn.call { background: var(--accent-color); }
.action-btn.return { background: var(--success-color); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.profile-area { padding: 12px 15px; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.2); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.profile-info { display: flex; flex-direction: column; }
.profile-name { font-weight: 600; font-size: 0.95rem; }
.profile-status { font-size: 0.75rem; color: var(--text-muted); }
.logout-btn { background: none; border: 1px solid var(--border-color); color: var(--text-muted); border-radius: 6px; padding: 4px 8px; font-size: 0.75rem; cursor: pointer; }
.logout-btn:hover { background: var(--danger-color); color: white; border-color: transparent; }

/* Правая панель (Чат) */
.main { flex: 1; display: flex; flex-direction: column; background: var(--bg-color); height: 100%; overflow: hidden; min-width: 0; }

.chat-header { background: var(--panel-bg); padding: 12px 15px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; height: 60px; }
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.back-btn { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; padding: 0 5px; display: none; }

#welcomeMessage { flex: 1; display: flex; justify-content: center; align-items: center; color: var(--text-muted); text-align: center; padding: 20px; }

#chatInterface { display: none; flex: 1; flex-direction: column; height: calc(100dvh - 60px); overflow: hidden; }
.messages-list { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }

/* Стили для сообщений */
.message { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 0.95rem; line-height: 1.4; word-break: break-word; color: #ffffff; }
.message.in { align-self: flex-start; background: #202c33; color: #ffffff; }
.message.out { align-self: flex-end; background: #2563eb; color: #ffffff; }

.chat-input-area { padding: 10px 15px; background: var(--panel-bg); display: flex; gap: 10px; border-top: 1px solid var(--border-color); flex-shrink: 0; align-items: center; }
.chat-input-area input { flex: 1; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--border-color); background: var(--bg-color); color: white; outline: none; font-size: 1rem; }
.send-btn { background-color: var(--accent-color); color: white; border: none; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; display: flex; justify-content: center; align-items: center; flex-shrink: 0; font-size: 1.1rem; }

/* Мобильная адаптивность */
@media (max-width: 768px) {
    .sidebar { position: absolute; inset: 0; width: 100% !important; z-index: 5; }
    .sidebar.hidden-mobile { transform: translateX(-100%); }
    .back-btn { display: block; }
    #chatInterface { height: calc(100dvh - 60px); }
}
```[cite: 1]