/* ===== ÁÀÇÎÂÛÅ ÏÅÐÅÌÅÍÍÛÅ (Ò¨ÌÍÀß ÒÅÌÀ) ===== */
:root {
    --bg: #0a0a0a;
    --bg-secondary: #111111;
    --glass: rgba(20, 20, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.12);
    --accent: #6c5ce7;
    --accent2: #a29bfe;
    --text: #f0f0f0;
    --text-secondary: #b0b0b0;
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --input-bg: rgba(255, 255, 255, 0.06);
    --input-border: rgba(255, 255, 255, 0.12);
    --button-bg: rgba(255, 255, 255, 0.07);
    --button-border: rgba(255, 255, 255, 0.1);
    --panel-bg: rgba(0, 0, 0, 0.4);
    --chat-bg: rgba(20, 20, 30, 0.85);
    --message-other: rgba(255, 255, 255, 0.1);
    --diagnostics-bg: rgba(0, 0, 0, 0.3);
    --header-bg: rgba(10, 10, 10, 0.7);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --notification-bg: rgba(20, 20, 30, 0.8);
    --radius: 18px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== ÑÂÅÒËÀß ÒÅÌÀ ===== */
body.light-theme {
    --bg: #f5f5f7;
    --bg-secondary: #e8e8ed;
    --glass: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-hover: rgba(0, 0, 0, 0.06);
    --accent: #5b4cc4;
    --accent2: #7c6ff7;
    --text: #1a1a1a;
    --text-secondary: #666666;
    --danger: #c0392b;
    --success: #27ae60;
    --warning: #e67e22;
    --input-bg: rgba(0, 0, 0, 0.04);
    --input-border: rgba(0, 0, 0, 0.12);
    --button-bg: rgba(0, 0, 0, 0.05);
    --button-border: rgba(0, 0, 0, 0.1);
    --panel-bg: rgba(0, 0, 0, 0.03);
    --chat-bg: rgba(255, 255, 255, 0.9);
    --message-other: rgba(0, 0, 0, 0.06);
    --diagnostics-bg: rgba(0, 0, 0, 0.03);
    --header-bg: rgba(255, 255, 255, 0.8);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    --notification-bg: rgba(255, 255, 255, 0.9);
}

/* ===== ÑÁÐÎÑ È ÁÀÇÎÂÛÅ ÑÒÈËÈ ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    background-image: radial-gradient(ellipse at 30% 20%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
                      radial-gradient(ellipse at 70% 80%, rgba(162, 155, 254, 0.05) 0%, transparent 60%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ===== ØÀÏÊÀ ===== */
.site-header {
    width: 100%;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--header-bg);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    z-index: 50;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}
.theme-toggle-btn {
    background: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: 12px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: var(--transition);
}
.theme-toggle-btn:hover {
    background: var(--glass-hover);
}

/* ===== ÎÑÍÎÂÍÎÉ ÊÎÍÒÅÍÒ ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
}
.container {
    width: 95%;
    max-width: 1300px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border 0.3s ease, box-shadow 0.3s ease;
}

/* ===== ÏÀÍÅËÜ ÓÏÐÀÂËÅÍÈß ===== */
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(128, 128, 128, 0.05);
    border-radius: calc(var(--radius) - 4px);
    flex-wrap: wrap;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}
.controls input,
.controls select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    width: 110px;
    transition: var(--transition);
}
.controls input:focus {
    border-color: var(--accent2);
    background: var(--glass-hover);
}
.controls button {
    padding: 10px 18px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--button-bg);
    color: var(--text);
    backdrop-filter: blur(5px);
    border: 1px solid var(--button-border);
    letter-spacing: 0.3px;
}
.controls button:hover {
    background: var(--glass-hover);
    transform: translateY(-1px);
}
.controls button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 14px rgba(108, 92, 231, 0.4);
}
.controls button.primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
}
.controls button.warning {
    background: rgba(243, 156, 18, 0.2);
    border-color: var(--warning);
    color: var(--warning);
}
.controls button:disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.4);
}
.controls select option {
    background: var(--bg-secondary);
    color: var(--text);
}

/* ===== ÂÈÄÅÎ ===== */
.videos {
    display: flex;
    flex: 1;
    gap: 12px;
    min-height: 0;
}
.panel {
    flex: 1;
    position: relative;
    background: var(--panel-bg);
    border-radius: calc(var(--radius) - 4px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
}
.panel video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: calc(var(--radius) - 4px);
}
.pin-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 20px 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.pin-label {
    font-size: 16px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.pin-value {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: 6px;
    color: white;
    line-height: 1;
}
.waiting-text {
    font-size: 18px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
}
.fullscreen-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    z-index: 20;
}
.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}
.hidden { display: none !important; }

/* ===== ÄÈÀÃÍÎÑÒÈÊÀ ===== */
.diagnostics {
    background: var(--diagnostics-bg);
    backdrop-filter: blur(8px);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    max-height: 130px;
    overflow-y: auto;
}
.diagnostics div { margin-bottom: 4px; }
.ice-status { color: var(--success); font-weight: 600; }
.ice-status.failed { color: var(--danger); }
.candidate { margin-left: 14px; opacity: 0.8; }

/* ===== ×ÀÒ ===== */
.chat-container {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 320px;
    max-height: 70vh;
    background: var(--chat-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease;
}
.chat-container.hidden {
    transform: translateY(-50%) translateX(120%);
    opacity: 0;
    pointer-events: none;
}
.chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    animation: fadeIn 0.2s ease;
    display: flex;
    flex-direction: column;
}
.message.mine {
    align-self: flex-end;
    background: var(--accent);
    color: white;
}
.message.other {
    align-self: flex-start;
    background: var(--message-other);
    color: var(--text);
}
.message .msg-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}
.chat-link {
    color: #74b9ff;
    text-decoration: underline;
    word-break: break-all;
}
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--glass-border);
}
.chat-input-area input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.chat-input-area button {
    background: var(--accent);
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    color: white;
    font-weight: 600;
    cursor: pointer;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== ÓÂÅÄÎÌËÅÍÈß ===== */
.notification-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.notification {
    padding: 14px 24px;
    border-radius: 14px;
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
    pointer-events: auto;
    backdrop-filter: blur(20px);
    background: var(--notification-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.35s ease-out, fadeOut 0.3s 3.7s forwards;
}
.notification.info { border-left: 4px solid var(--accent2); }
.notification.success { border-left: 4px solid var(--success); }
.notification.warning { border-left: 4px solid var(--warning); }
.notification.error { border-left: 4px solid var(--danger); }

body:not(.light-theme) .notification {
    color: white;
}

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

/* ===== ÌÎÁÈËÜÍÀß ÀÄÀÏÒÀÖÈß ===== */
@media (max-width: 768px) {
    .site-header {
        padding: 8px 12px;
    }
    .logo {
        font-size: 1.1rem;
        gap: 6px;
    }
    .theme-toggle-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    .main-content {
        padding: 10px;
    }
    .container {
        width: 100%;
        height: auto;
        min-height: 90vh;
        padding: 10px;
        gap: 8px;
        border-radius: 0;
        border: none;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
    }
    .controls {
        gap: 6px;
        padding: 8px 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .controls input,
    .controls select,
    .controls button {
        padding: 8px 10px;
        font-size: 12px;
        border-radius: 8px;
        flex-shrink: 0;
    }
    .controls input {
        width: 80px;
    }
    .videos {
        flex-direction: column;
        gap: 8px;
    }
    .panel {
        min-height: 200px;
    }
    .pin-overlay {
        padding: 14px 20px;
        border-radius: 16px;
        gap: 4px;
    }
    .pin-label {
        font-size: 13px;
    }
    .pin-value {
        font-size: 32px;
        letter-spacing: 4px;
    }
    .waiting-text {
        font-size: 16px;
    }
    .fullscreen-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
        bottom: 10px;
        right: 10px;
    }
    .diagnostics {
        padding: 8px 10px;
        font-size: 11px;
        max-height: 100px;
    }
    .chat-container {
        right: 5px;
        left: 5px;
        width: auto;
        max-height: 60vh;
        border-radius: 16px;
    }
    .chat-header {
        padding: 10px 14px;
    }
    .chat-messages {
        padding: 8px;
        gap: 6px;
    }
    .message {
        font-size: 13px;
        padding: 8px 10px;
    }
    .chat-input-area {
        padding: 8px;
        gap: 6px;
    }
    .chat-input-area input {
        padding: 8px 10px;
        font-size: 13px;
    }
    .chat-input-area button {
        padding: 8px 12px;
    }
    .notification-container {
        width: 90%;
    }
    .notification {
        font-size: 13px;
        padding: 10px 16px;
    }
}