/* ═══════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg:          #08091a;
    --surface:     rgba(255,255,255,0.04);
    --surface2:    rgba(255,255,255,0.07);
    --border:      rgba(255,255,255,0.09);
    --border2:     rgba(255,255,255,0.14);
    --accent:      #6366f1;
    --accent2:     #8b5cf6;
    --accent-glow: rgba(99,102,241,0.35);
    --green:       #22c55e;
    --green-glow:  rgba(34,197,94,0.35);
    --red:         #ef4444;
    --text:        #e2e8f0;
    --text2:       #94a3b8;
    --text3:       #475569;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ═══════════════════════════════════════
   HOME PAGE
═══════════════════════════════════════ */

body.home {
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 24px;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,0.12) 0%, transparent 70%), var(--bg);
}

.join-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border2);
    border-radius: 24px;
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 380px;
    max-width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

.join-card .logo-text {
    font-size: 30px;
    font-weight: 800;
    text-align: center;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #a5b4fc 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.join-card input[type="text"],
.join-card input:not([type="hidden"]) {
    padding: 13px 16px;
    border-radius: 12px;
    border: 1px solid var(--border2);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.join-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.join-card input::placeholder { color: var(--text3); }

/* ── Emoji picker ── */
.emoji-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.emoji {
    font-size: 24px;
    cursor: pointer;
    padding: 7px;
    border-radius: 10px;
    transition: background 0.15s, transform 0.15s;
    user-select: none;
}
.emoji:hover  { background: var(--surface2); transform: scale(1.18); }
.emoji.selected { background: rgba(99,102,241,0.3); transform: scale(1.18); outline: 2px solid var(--accent); }

/* ── Actions ── */
.home-actions { display: flex; flex-direction: column; gap: 14px; }
.action-section { display: flex; flex-direction: column; gap: 8px; }

.section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text3);
    font-weight: 600;
}

.home-divider {
    text-align: center;
    font-size: 13px;
    color: var(--text3);
    position: relative;
    line-height: 1;
}
.home-divider::before, .home-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--border);
}
.home-divider::before { left: 0; }
.home-divider::after  { right: 0; }

/* ── Buttons ── */
.join-btn {
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.join-btn:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}
.join-btn:active { transform: translateY(0); }

.create-btn { background: var(--green); }
.create-btn:hover {
    background: #16a34a;
    box-shadow: 0 6px 20px var(--green-glow);
}

/* ── Link-join mode ── */
.link-join-heading {
    text-align: center;
    font-size: 14px;
    color: var(--text2);
    margin-top: -6px;
}
.link-join-room-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: #a5b4fc;
    font-weight: 500;
}

/* ═══════════════════════════════════════
   SHARED: RANGE SLIDER
═══════════════════════════════════════ */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 4px;
    background: var(--border2);
    outline: none;
    cursor: pointer;
    flex: 1;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-glow);
    transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
}
/* #70 — Firefox range track: без этого правила трек отображается серым браузерным цветом */
input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 4px;
    background: var(--border2);
}

/* ═══════════════════════════════════════
   LOBBY PAGE
═══════════════════════════════════════ */

body.lobby-page {
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 24px;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,0.12) 0%, transparent 70%), var(--bg);
}

.lobby-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border2);
    border-radius: 24px;
    padding: 32px;
    width: 480px;
    max-width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.lobby-card .logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #a5b4fc 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lobby-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
}
.lobby-user-avatar {
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lobby-preview {
    position: relative;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lobby-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    transform: scaleX(-1);
}

.lobby-preview-off {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text3);
}
.lobby-preview-off .big-avatar {
    font-size: 56px;
    width: 100px;
    height: 100px;
    background: var(--surface2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lobby-preview-off p {
    font-size: 14px;
}

.lobby-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.lobby-ctrl-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1.5px solid var(--border2);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.lobby-ctrl-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.lobby-ctrl-btn:hover { background: var(--surface2); transform: scale(1.08); }
.lobby-ctrl-btn.active {
    background: rgba(34,197,94,0.18);
    border-color: var(--green);
    box-shadow: 0 0 14px var(--green-glow);
    color: var(--green);
}
.lobby-ctrl-btn.inactive {
    background: rgba(239,68,68,0.12);
    border-color: rgba(239,68,68,0.4);
    color: #f87171;
}

.lobby-status {
    text-align: center;
    font-size: 13px;
    color: var(--text3);
}

.lobby-join-btn {
    padding: 15px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.lobby-join-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--accent-glow);
}
.lobby-join-btn svg { width: 20px; height: 20px; }

/* ── Mic meter section ── */
.mic-meter-section {
    display: none;
    flex-direction: column;
    gap: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}
.mic-meter-section.visible { display: flex; }

.mic-meter-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mic-meter-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text3);
}

.mic-meter-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.07);
    border-radius: 6px;
    overflow: hidden;
}
.mic-meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    background: var(--green);
    transition: width 0.06s linear, background 0.15s;
}

/* ── Gain slider row ── */
.gain-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.gain-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text3);
    font-weight: 600;
}
.gain-slider-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.gain-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text3);
}
.gain-value {
    font-size: 12px;
    color: var(--text2);
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Подсказка «используйте наушники» ── */
.earphone-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #f59e0b;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 8px;
    padding: 8px 10px;
    line-height: 1.4;
}
.earphone-hint svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: #f59e0b;
}

/* ═══════════════════════════════════════
   TOPBAR
═══════════════════════════════════════ */

.topbar {
    height: 60px;
    background: rgba(8,9,26,0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    gap: 12px;
    position: relative;
    z-index: 50;
}

.logo {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #a5b4fc 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text2);
    min-width: 0;
    font-weight: 500;
}
.room-info #roomTitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    background: var(--surface2);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    letter-spacing: 1px;
    font-weight: 600;
    color: var(--text2);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    user-select: all;
}
.room-info #roomTitle:hover {
    background: rgba(99,102,241,0.12);
    color: #a5b4fc;
    border-color: rgba(99,102,241,0.4);
}
.room-info #roomTitle[title]:hover::after {
    content: " 📋";
    font-size: 11px;
}

#copyBtn {
    background: var(--surface);
    border: 1px solid var(--border2);
    color: var(--text2);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
}
#copyBtn svg { width: 16px; height: 16px; }
#copyBtn:hover { background: var(--surface2); color: var(--text); }

/* ═══════════════════════════════════════
   MAIN LAYOUT
═══════════════════════════════════════ */

.main {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ═══════════════════════════════════════
   VIDEO GRID
═══════════════════════════════════════ */

.video-grid {
    flex: 1;
    display: grid;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    min-height: 0;
}

/* scrollbar styling */
.video-grid { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.video-grid::-webkit-scrollbar { width: 4px; }
.video-grid::-webkit-scrollbar-track { background: transparent; }
.video-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ═══════════════════════════════════════
   VIDEO BOX
═══════════════════════════════════════ */

.video-box {
    position: relative;
    background: rgba(0,0,0,0.6);
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 160px;
    cursor: pointer;
    transition: box-shadow 0.25s, border-color 0.25s;
}

.video-box:hover { border-color: var(--border2); }

.video-box:hover::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cpolyline points='9 21 3 21 3 15'/%3E%3Cline x1='21' y1='3' x2='14' y2='10'/%3E%3Cline x1='3' y1='21' x2='10' y2='14'/%3E%3C/svg%3E") center/16px no-repeat;
    border-radius: 8px;
    opacity: 0.85;
    pointer-events: none;
    z-index: 3;
}

/* ── Connection quality indicator ── */
.quality-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding: 5px 8px 5px;
    /* Явная граница делает контейнер видимым даже на чёрном фоне */
    background: rgba(10,12,22,0.82);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px;
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.qbar {
    width: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.45);
    transition: background 0.4s;
}
.qbar1 { height: 6px; }
.qbar2 { height: 11px; }
.qbar3 { height: 16px; }

/* Хорошее — все три зелёные */
.quality-good .qbar { background: #22c55e; }

/* Среднее — две жёлтые, третья серая */
.quality-fair .qbar1,
.quality-fair .qbar2 { background: #f59e0b; }
.quality-fair .qbar3 { background: rgba(255,255,255,0.35); }

/* Плохое — одна красная, остальные серые */
.quality-poor .qbar1 { background: #ef4444; }
.quality-poor .qbar2,
.quality-poor .qbar3 { background: rgba(255,255,255,0.35); }

/* Speaking indicator ── */
.video-box.speaking {
    box-shadow: 0 0 0 2.5px var(--green), 0 0 18px 2px var(--green-glow);
    border-color: transparent;
}

/* ── Expanded / focus mode ── */
.video-box.expanded {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1001;
    border-radius: 0;
    cursor: zoom-out;
    border: none;
}
.video-box.expanded::after { display: none; }
.video-box.expanded video { object-fit: contain !important; }
.video-box.expanded .name-label { bottom: 86px; }

#videoBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    cursor: zoom-out;
}
#videoBackdrop.active { display: block; }

/* ═══════════════════════════════════════
   VIDEO ELEMENT
═══════════════════════════════════════ */

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    display: block;
}

video.screen-video {
    object-fit: contain;
    background: #000;
    border-radius: 15px;
}

video.flip-h { transform: scaleX(-1); }

/* ═══════════════════════════════════════
   AVATAR (camera off)
═══════════════════════════════════════ */

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(99,102,241,0.12);
    border: 1.5px solid rgba(99,102,241,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    flex-shrink: 0;
    pointer-events: none;
}

/* ═══════════════════════════════════════
   NAME LABEL
═══════════════════════════════════════ */

.name-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 2;
    pointer-events: none;
    max-width: calc(100% - 20px);
    overflow: hidden;
}
.name-label .label-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.75;
}
.icon svg { width: 13px; height: 13px; }
.icon.mic-off { color: #f87171; opacity: 1; }
.icon.cam-off { color: #f87171; opacity: 1; }
.icon.mic-on  { color: var(--green); opacity: 1; }
.icon.cam-on  { color: var(--green); opacity: 1; }

/* ═══════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════ */

.sidebar {
    width: 272px;
    display: flex;
    flex-direction: column;
    background: rgba(8,9,26,0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.participants {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.participants h3 {
    margin-bottom: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text3);
    font-weight: 600;
}
.participant {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 13px;
    padding: 5px 8px;
    border-radius: 8px;
    color: var(--text2);
    transition: background 0.15s;
}
.participant:hover { background: var(--surface2); }
.participant-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.participant-avatar svg {
    width: 30px;
    height: 30px;
    display: block;
}
.participant-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text2);
}
.participant-crown {
    font-size: 14px;
    flex-shrink: 0;
    line-height: 1;
}

/* ── Chat ── */
.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-header {
    padding: 10px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text3);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

#messages {
    flex: 1;
    padding: 10px 12px;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.message {
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.45;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text2);
}
.message.message-self {
    background: rgba(99,102,241,0.12);
    border-color: rgba(99,102,241,0.22);
}
.message .msg-author {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    font-size: 12px;
}
.message.message-self .msg-author { color: #a5b4fc; }
.message .msg-text { color: var(--text2); }

/* ── Бейдж непрочитанных сообщений ── */
#chatBtn { position: relative; }
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    line-height: 1;
}

.chat-input {
    display: flex;
    flex-shrink: 0;
    padding: 10px;
    gap: 8px;
    border-top: 1px solid var(--border);
}
.chat-input input {
    flex: 1;
    padding: 9px 13px;
    border: 1px solid var(--border2);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input input:focus { border-color: var(--accent); }
.chat-input input::placeholder { color: var(--text3); }
.chat-input button {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-input button svg { width: 16px; height: 16px; }
.chat-input button:hover { background: #4f46e5; transform: scale(1.05); }

/* ═══════════════════════════════════════
   CONTROLS BAR
═══════════════════════════════════════ */

.controls {
    height: 86px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background: rgba(8,9,26,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 1002;
    position: relative;
    padding: 0 20px;
}

.controls button {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1.5px solid var(--border2);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.controls button svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.controls button:hover { transform: scale(1.08); background: rgba(255,255,255,0.1); }
.controls button:active { transform: scale(0.96); }

.controls button.btn-active {
    background: rgba(34,197,94,0.18);
    border-color: var(--green);
    color: var(--green);
    box-shadow: 0 0 14px var(--green-glow);
}
.controls button.btn-inactive {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.35);
    color: #f87171;
}
.controls button.btn-screen-active {
    background: rgba(99,102,241,0.2);
    border-color: var(--accent);
    color: #a5b4fc;
    box-shadow: 0 0 14px var(--accent-glow);
}

#leaveBtn {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.4);
    color: #f87171;
}
#leaveBtn:hover {
    background: var(--red);
    border-color: var(--red);
    color: white;
    box-shadow: 0 0 16px rgba(239,68,68,0.4);
}

/* ── Screen share audio panel (sharer) ── */
.screen-audio-panel {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 12px;
    padding: 8px 14px;
    margin-right: 4px;
    flex-shrink: 0;
}
.screen-audio-panel svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #a5b4fc;
}
.screen-audio-label {
    font-size: 12px;
    color: #a5b4fc;
    white-space: nowrap;
    font-weight: 500;
}
.screen-audio-panel input[type="range"] { width: 90px; flex: none; }
.screen-audio-value {
    font-size: 12px;
    color: #a5b4fc;
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Screen audio panel overlay inside video box (receiver) ── */
.remote-screen-audio-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 4;
    border-radius: 10px;
    display: flex !important;
    padding: 6px 12px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(8px);
    border-color: rgba(99,102,241,0.3);
}

/* chat btn — only on mobile */
#chatBtn { display: none; }

/* flip btn — hidden until cam enabled */
#flipBtn { display: none; }

/* ═══════════════════════════════════════
   MOBILE
═══════════════════════════════════════ */

@media (max-width: 900px) {
    .sidebar {
        display: none;
        position: fixed;
        top: 60px;
        right: 0;
        bottom: 86px;
        width: 100%;
        max-width: 300px;
        z-index: 200;
        border-left: 1px solid var(--border);
        box-shadow: -8px 0 32px rgba(0,0,0,0.6);
    }
    .sidebar.mobile-open { display: flex; }

    #chatBtn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .controls { gap: 8px; }
    .controls button { width: 48px; height: 48px; }
    .controls button svg { width: 20px; height: 20px; }
}

@media (max-width: 480px) {
    .join-card { padding: 28px 20px; }
    .lobby-card { padding: 24px 18px; }
}

/* ═══════════════════════════════════════
   iOS SAFE AREA — поддержка notch / Dynamic Island
═══════════════════════════════════════ */
.topbar {
    padding-top: env(safe-area-inset-top, 0px);
}
.controls {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(86px + env(safe-area-inset-bottom, 0px));
}
.main {
    /* Учитываем topbar + controls с безопасными зонами */
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
}

/* ═══════════════════════════════════════
   LANDSCAPE — оптимизация горизонтального режима
═══════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 500px) {
    .topbar { height: 44px; }
    .controls { height: calc(64px + env(safe-area-inset-bottom, 0px)); }
    .controls button { width: 44px; height: 44px; }
    .main { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

/* ═══════════════════════════════════════
   ДОСТУПНОСТЬ — скрытый текст для ридеров
═══════════════════════════════════════ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════
   TOAST УВЕДОМЛЕНИЯ — вместо alert()
═══════════════════════════════════════ */
.vc-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: rgba(10, 10, 30, 0.96);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: var(--text);
    padding: 13px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 99999;
    max-width: min(90vw, 420px);
    text-align: center;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    line-height: 1.4;
}
.vc-toast.vc-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.vc-toast.vc-toast-error  { border-color: rgba(239, 68, 68, 0.5); }
.vc-toast.vc-toast-success { border-color: rgba(34, 197, 94, 0.5); }
.vc-toast.vc-toast-info   { border-color: rgba(99, 102, 241, 0.45); }

/* Toast на лобби-странице — ниже из-за отсутствия controls-bar */
body.lobby-page .vc-toast,
body.home .vc-toast {
    bottom: 32px;
}

/* ═══════════════════════════════════════
   ВАЛИДАЦИЯ ПОЛЕЙ ВВОДА (главная страница)
═══════════════════════════════════════ */
input.input-error {
    border-color: rgba(239, 68, 68, 0.7) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
    animation: shake 0.35s ease;
}
@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}
.input-hint {
    font-size: 13px;
    color: #ef4444;
    margin: -8px 0 8px 0;
    display: none;
    text-align: center;
    animation: fadeInDown 0.2s ease;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════
   СОСТОЯНИЕ DISABLED У КНОПОК
═══════════════════════════════════════ */
.lobby-join-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
.join-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Focus-visible для клавиатурной навигации */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* #71 — touch-action: manipulation убирает задержку 300ms перед tap на мобильных браузерах */
button, .join-btn, .lobby-ctrl-btn, .lobby-join-btn {
    touch-action: manipulation;
}

/* #72 — Уважаем настройку «уменьшить анимацию» для пользователей с вестибулярными нарушениями */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .flip-digit.flipping { animation: none !important; }
    .vc-toast { transition: none !important; }
}


/* ── SVG в видео-боксах (когда камера выкл.) ── */
.avatar {
    overflow: hidden;
}
.avatar svg {
    width: 64px;
    height: 64px;
    display: block;
    flex-shrink: 0;
}

/* ── SVG в маленьком аватаре лобби ── */
.lobby-user-avatar {
    overflow: hidden;
}
.lobby-user-avatar svg {
    width: 32px;
    height: 32px;
    display: block;
}

/* ── SVG в большом превью лобби ── */
.lobby-preview-off .big-avatar {
    overflow: hidden;
}
.lobby-preview-off .big-avatar svg {
    width: 80px;
    height: 80px;
    display: block;
}

/* ═══════════════════════════════════════
   ОНЛАЙН-СЧЁТЧИК на главной
═══════════════════════════════════════ */
.online-counter-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 2px 0;
}
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    flex-shrink: 0;
    animation: online-pulse 2.4s ease-in-out infinite;
}
@keyframes online-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.8); }
}
.online-label {
    font-size: 13px;
    color: var(--text3);
}
.flip-counter {
    display: flex;
    gap: 2px;
    font-family: "SF Mono", "Fira Code", "Fira Mono", monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    align-items: center;
}
.flip-digit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 5px;
    width: 22px;
    height: 26px;
    position: relative;
    overflow: hidden;
}
.flip-digit .digit-val {
    display: block;
    line-height: 1;
}
@keyframes flip-in {
    0%   { transform: translateY(-110%); opacity: 0; }
    100% { transform: translateY(0);     opacity: 1; }
}
.flip-digit.flipping .digit-val {
    animation: flip-in 0.28s cubic-bezier(.22,.68,0,1.2) forwards;
}

/* ═══════════════════════════════════════
   КНОПКА КОПИРОВАНИЯ ССЫЛКИ В CONTROLS
═══════════════════════════════════════ */
#copyBtn {
    /* Override topbar-specific sizing — use controls button defaults */
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    border: 1.5px solid var(--border2);
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s, color 0.2s;
}
#copyBtn svg { width: 22px; height: 22px; }
#copyBtn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
    transform: scale(1.08);
}
#copyBtn.copy-success {
    background: rgba(34,197,94,0.18);
    border-color: var(--green);
    color: var(--green);
}
