/* Конференция: верхняя панель, сетка плиток, панель участников. */

.app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    overflow: hidden;
}

/* ---------- Верхняя панель ---------- */

.topbar {
    position: relative;
    z-index: 1500;
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    height: calc(var(--topbar-height) + var(--safe-top));
    padding: var(--safe-top) calc(var(--safe-right) + 14px) 0 calc(var(--safe-left) + 14px);
    background: linear-gradient(180deg, rgba(9, 10, 12, 0.94), rgba(9, 10, 12, 0.55) 72%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    backdrop-filter: blur(14px) saturate(1.1);
}

.topbar-side {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 0;
    min-width: 0;
}

.topbar-right {
    justify-content: flex-end;
}

.topbar-center {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: none;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #04121f;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.28);
}

.brand-name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.room-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--line);
    color: var(--text);
    transition: background-color 0.18s ease, border-color 0.18s ease;
    min-width: 0;
}

.room-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--line-strong);
}

.room-chip-label {
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
}

.room-chip-code {
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0.14em;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.room-chip-icon {
    font-size: 13px;
    color: var(--text-3);
}

.timer {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}

.net-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 11px;
    border-radius: 999px;
    max-width: 220px;
    font-size: 12px;
    color: var(--text-2);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--line);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.net-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
    background: var(--text-3);
}

.net-count {
    display: none;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}

.net-pill[data-tone="ok"] .net-dot {
    background: var(--ok);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.8);
}

.net-pill[data-tone="warn"] .net-dot {
    background: var(--warn);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.8);
}

.net-pill[data-tone="error"] .net-dot {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(var(--danger-rgb), 0.8);
}

/* ---------- Сцена и сетка ---------- */

.stage {
    position: relative;
    isolation: isolate;
    flex: 1 1 auto;
    min-height: 0;
}

.grid {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: var(--gap);
    padding-top: 8px;
    padding-right: calc(var(--safe-right) + 12px);
    padding-bottom: calc(var(--safe-bottom) + var(--controls-offset) + var(--controls-height) + 12px);
    padding-left: calc(var(--safe-left) + 12px);
    overflow: hidden;
}

/* Размеры плитки считаются от числа колонок и рядов, которые задаёт layout.js.
   Неполный последний ряд центрируется благодаря justify-content: center. */
.grid > .tile {
    flex: 0 0 var(--tile-w, calc((100% - (var(--cols, 1) - 1) * var(--gap)) / var(--cols, 1)));
    height: var(--tile-h, calc((100% - (var(--rows, 1) - 1) * var(--gap)) / var(--rows, 1)));
    min-width: 0;
    min-height: 0;
}

/* Режим докладчика возвращается к обычной сетке */
.grid.spotlight {
    display: grid;
}

.grid.spotlight > .tile {
    flex: none;
    height: auto;
}

/* ---------- Плитка ---------- */

.tile {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: linear-gradient(160deg, #1b1e24 0%, #121418 100%);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-tile);
    min-width: 0;
    min-height: 0;
    contain: paint;
    /* Клик по плитке разворачивает её как демонстрацию экрана */
    cursor: pointer;
    transition: box-shadow 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
}

.tile:fullscreen,
.tile.is-maximized {
    cursor: default;
}

/* Тонкая светлая кромка сверху: придаёт объём без «стеклянности» */
.tile::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tile.off-page {
    display: none;
}

.tile.is-speaking {
    border-color: rgba(var(--accent-rgb), 0.55);
    box-shadow:
        0 0 0 2px rgba(var(--accent-rgb), 0.5),
        0 0 28px rgba(var(--accent-rgb), 0.18),
        var(--shadow-tile);
}

.tile-video {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #0d0f12;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.tile.no-video .tile-video {
    opacity: 0;
}

/* Кадр не режем: видео целиком, а поля закрывает размытая копия кадра */
.tile-backdrop {
    position: absolute;
    inset: -8%;
    width: 116%;
    height: 116%;
    object-fit: cover;
    filter: blur(22px) saturate(1.4) brightness(0.55);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.tile.is-letterboxed .tile-backdrop {
    opacity: 1;
}

.tile.is-letterboxed .tile-video {
    background: transparent;
}

/* Своё видео зеркалим, чтобы движения совпадали с жестами (только фронтальная камера) */
.tile-self.is-mirrored .tile-video {
    transform: scaleX(-1);
}

/* ...но не демонстрацию экрана */
.tile.is-screen .tile-video {
    object-fit: contain;
    background: #000;
}

.tile.is-maximized {
    position: fixed;
    inset: 0;
    /* Размеры заданы раскладкой (--tile-w/--tile-h) — здесь их перебиваем */
    width: 100vw !important;
    height: 100vh !important;
    max-width: none;
    max-height: none;
    z-index: 9000;
    border: none;
    border-radius: 0;
    background: #000;
}

.tile:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
    background: #000;
}

.tile.is-maximized .tile-video,
.tile:fullscreen .tile-video {
    object-fit: contain !important;
}

/* В портретном полноэкранном режиме 16:9-экран маленький — подсказываем поворот */
@media (orientation: portrait) and (max-width: 900px) {
    .tile.is-maximized::after {
        content: 'Поверните телефон — экран станет крупнее';
        position: absolute;
        left: 50%;
        bottom: 72px;
        transform: translateX(-50%);
        padding: 8px 14px;
        border-radius: 999px;
        background: rgba(4, 10, 18, 0.82);
        border: 1px solid var(--line);
        font-size: 12px;
        color: var(--text-2);
        white-space: nowrap;
        pointer-events: none;
    }
}

body.has-maximized {
    overflow: hidden;
}

.tile-shade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 44%;
    background: linear-gradient(to top, rgba(6, 7, 9, 0.86), rgba(6, 7, 9, 0.32) 45%, transparent);
    pointer-events: none;
    z-index: 2;
}

.tile-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px;
    text-align: center;
    background: radial-gradient(circle at 50% 32%, #23262d 0%, #14161a 72%);
    z-index: 2;
}

.avatar {
    --hue: 210;
    width: clamp(42px, 22%, 74px);
    max-width: 74px;
    min-width: 34px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: clamp(15px, 2.2vw, 25px);
    color: rgba(255, 255, 255, 0.94);
    /* Спокойная пара оттенков: цвет по имени, но без «радуги» */
    background: linear-gradient(140deg, hsl(var(--hue), 34%, 38%), hsl(calc(var(--hue) + 26), 30%, 24%));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    flex: none;
}

.placeholder-title {
    font-size: 13px;
    font-weight: 500;
    max-width: 92%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.placeholder-sub {
    font-size: 11px;
    color: var(--text-3);
}

.tile-top {
    position: absolute;
    top: 9px;
    left: 9px;
    right: 9px;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 3;
}

.tile-flag {
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text);
    background: rgba(10, 11, 13, 0.72);
    border: 1px solid var(--line-strong);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.tile-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 9px 9px;
    pointer-events: none;
    z-index: 3;
}

.tile-name {
    min-width: 0;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 550;
    letter-spacing: 0.005em;
    color: var(--text);
    background: rgba(8, 9, 11, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(12px) saturate(1.15);
    backdrop-filter: blur(12px) saturate(1.15);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-icons {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: none;
    font-size: 13px;
    color: #fecdd3;
}

.tile-action {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: none;
    place-items: center;
    font-size: 16px;
    color: #fff;
    background: rgba(8, 9, 11, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.16);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 4;
}

.tile:hover .tile-action,
.tile:focus-within .tile-action,
.tile.is-screen .tile-action,
.tile.is-maximized .tile-action {
    display: grid;
}

.tile-action:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ---------- Режим докладчика ---------- */

.grid.spotlight .tile.spotlight-main {
    grid-column: 1 / -1;
    grid-row: 1;
}

.grid.spotlight .tile.filmstrip {
    grid-row: 2;
    border-radius: var(--radius-md);
}

.grid.spotlight .tile.filmstrip .tile-bottom {
    padding: 5px 6px 6px;
}

.grid.spotlight .tile.filmstrip .tile-name {
    font-size: 11px;
    padding: 3px 8px;
}

.grid.spotlight .tile.filmstrip .tile-placeholder {
    gap: 4px;
}

.grid.spotlight .tile.filmstrip .placeholder-sub {
    display: none;
}

/* ---------- Панель участников ---------- */

.panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(348px, 88vw);
    display: flex;
    flex-direction: column;
    background: rgba(18, 20, 24, 0.96);
    border-left: 1px solid var(--line);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    transform: translateX(102%);
    transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
    z-index: 3000;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.panel.is-open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.count-badge {
    min-width: 26px;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(var(--accent-rgb), 0.14);
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    color: var(--accent);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

.panel-toolbar .chip-button {
    flex: 1 1 auto;
    min-width: 0;
}

.participant-list {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 12px calc(16px + var(--safe-bottom));
}

.participant {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.participant:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line);
}

.participant.is-speaking {
    border-color: rgba(var(--accent-rgb), 0.45);
    background: rgba(var(--accent-rgb), 0.08);
}

.participant .avatar {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    font-size: 14px;
}

.participant-main {
    flex: 1 1 auto;
    min-width: 0;
}

.participant-name {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant-sub {
    display: block;
    font-size: 11px;
    color: var(--text-3);
}

.participant-icons {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    color: var(--text-3);
    flex: none;
}

.participant-icons .is-muted {
    color: var(--danger);
}

.participant-icons .is-sharing {
    color: var(--accent);
}

.panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 7, 0.55);
    z-index: 2900;
    animation: fade-in 0.2s ease;
}

/* ---------- Пагинация ---------- */

.pagination {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--safe-bottom) + var(--controls-offset) + var(--controls-height) + 6px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(21, 23, 27, 0.94);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-bar);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    z-index: 1500;
}

.pagination-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 17px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    transition: background-color 0.16s ease;
}

.pagination-btn:hover:not([disabled]) {
    background: rgba(255, 255, 255, 0.16);
}

.pagination-btn[disabled] {
    opacity: 0.3;
    pointer-events: none;
}

.page-indicator {
    min-width: 46px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

/* ---------- Разблокировка звука (iOS) ---------- */

.audio-unlock {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--safe-bottom) + var(--controls-offset) + var(--controls-height) + 10px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--warn), #f97316);
    color: #1a0f00;
    font-weight: 600;
    font-size: 14px;
    z-index: 2500;
    box-shadow: 0 14px 34px rgba(251, 191, 36, 0.32);
    animation: audio-unlock-pulse 1.9s ease-in-out infinite;
}

.audio-unlock-icon .icon {
    font-size: 19px;
}

@keyframes audio-unlock-pulse {
    50% {
        transform: translateX(-50%) scale(1.03);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ---------- Экран выхода ---------- */

.goodbye {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(8, 9, 11, 0.95);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.goodbye-card {
    width: min(400px, 100%);
    padding: 30px 24px;
    border-radius: var(--radius-lg);
    background: rgba(21, 23, 27, 0.96);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-bar);
    text-align: center;
}

.goodbye-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    border-radius: 16px;
    font-size: 24px;
    color: var(--danger);
    background: rgba(var(--danger-rgb), 0.12);
    border: 1px solid rgba(var(--danger-rgb), 0.3);
}

.goodbye-card h1 {
    font-size: 20px;
    margin-bottom: 8px;
}

.goodbye-card p {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-2);
    margin-bottom: 20px;
}

.goodbye-card strong {
    color: var(--accent);
    letter-spacing: 0.1em;
}

.goodbye-card .btn {
    width: 100%;
    margin-bottom: 10px;
}

/* ---------- Панель настроек устройств ---------- */

.sheet {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Отступы учитывают «чёлку» и домашнюю полосу на телефоне */
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    background: rgba(4, 5, 7, 0.62);
    backdrop-filter: blur(4px);
    /* Если карточка выше экрана — прокручивается слой, а не обрезается низ */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sheet-card {
    width: min(420px, 100%);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--bg-2);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-card);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Заголовок и крестик остаются на виду при прокрутке */
.sheet-head {
    position: sticky;
    top: -20px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -20px -20px 0;
    padding: 20px 20px 12px;
    background: var(--bg-2);
}

.sheet-head h2 {
    font-size: 16px;
    font-weight: 600;
}

.sheet-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sheet-label {
    font-size: 12px;
    color: var(--text-2);
}

.sheet-select {
    appearance: none;
    -webkit-appearance: none;
    min-height: 44px;
    padding: 0 40px 0 12px;
    border-radius: var(--radius-sm);
    /* Своя стрелка: системная на тёмном фоне выглядит иначе в каждом браузере */
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a6b0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 14px;
    outline: none;
    max-width: 100%;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: border-color 0.16s ease, background-color 0.16s ease;
}

.sheet-select:hover {
    background-color: rgba(255, 255, 255, 0.075);
}

.sheet-select:focus {
    border-color: rgba(var(--accent-rgb), 0.6);
    background-color: rgba(255, 255, 255, 0.075);
}

/* Сам выпадающий список: в тёмной теме, читаемый */
.sheet-select option,
.sheet-select optgroup {
    background-color: #15171b;
    color: #f4f5f7;
}

.sheet-select option:checked {
    background-color: #2a3350;
    color: #ffffff;
}

/* Поле вывода звука может быть скрыто на iPhone — тогда и подписи нет */
.sheet-field[hidden] {
    display: none;
}

.sheet-meter {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.sheet-meter-fill {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4ade80, #22d3ee);
    transition: width 0.08s linear;
}

.sheet-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--text-2);
    cursor: pointer;
}

.sheet-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.sheet-hint {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-3);
}

/* Кнопка диагностики: полная ширина, внизу листа устройств. */
.sheet-diag {
    width: 100%;
    margin-top: 14px;
    font-size: 13px;
}
.sheet-range {
    width: 100%;
    height: 26px;
    accent-color: var(--accent);
}

.sheet-range + .sheet-label,
.sheet-label output {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
/* ---------- Вкладки панели и чат ---------- */

.panel-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--line);
}

.panel-tab {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 550;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.panel-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.panel-tab.is-active {
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.22), rgba(var(--accent-rgb), 0.12));
    border-color: rgba(var(--accent-rgb), 0.28);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.panel-view {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.panel-view[hidden] {
    display: none;
}

.count-badge.is-accent {
    background: var(--accent);
    color: #10131a;
}

.chat-log {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.chat-message {
    max-width: 88%;
    align-self: flex-start;
    padding: 8px 11px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--line);
}

.chat-message.is-self {
    align-self: flex-end;
    background: rgba(var(--accent-rgb), 0.16);
    border-color: rgba(var(--accent-rgb), 0.34);
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 11px;
    color: var(--text-3);
}

.chat-message.is-self .chat-meta {
    justify-content: flex-end;
}

.chat-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55%;
}

.chat-time {
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}

/* Стрелка «ответить» в строке автора: на ПК появляется при наведении,
   на устройствах без наведения (телефоны) видна всегда. */
.chat-reply-btn {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-3);
    font-size: 15px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.chat-message.is-self .chat-reply-btn {
    margin-left: 0;
    order: -1;
}

.chat-message:hover .chat-reply-btn,
.chat-message:focus-within .chat-reply-btn {
    opacity: 1;
}

.chat-reply-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

@media (hover: none) {
    .chat-reply-btn {
        opacity: 0.6;
    }
}

/* Цитата внутри сообщения: на что ответили */
.chat-quote {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    margin-bottom: 6px;
    padding: 5px 9px;
    border: 0;
    border-left: 2px solid var(--accent);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    text-align: left;
    cursor: pointer;
}

.chat-quote:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-quote-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.chat-quote-text {
    font-size: 12px;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-message.is-flash {
    animation: chat-flash 0.9s ease;
}

@keyframes chat-flash {
    0% {
        box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.55);
        background: rgba(var(--accent-rgb), 0.28);
    }
    100% {
        box-shadow: none;
    }
}

/* Полоска «отвечаю на…» над полем ввода */
.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 12px 2px;
    padding: 7px 10px;
    border-left: 2px solid var(--accent);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.chat-reply-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    color: var(--accent);
    font-size: 15px;
}

.chat-reply-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1 1 auto;
}

.chat-reply-name {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-reply-text {
    font-size: 12px;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-reply-cancel {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-3);
    font-size: 15px;
    cursor: pointer;
}

.chat-reply-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.chat-text {
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--line);
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 42px;
    padding: 0 13px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.chat-input:focus {
    border-color: rgba(var(--accent-rgb), 0.6);
}

.chat-input::placeholder {
    color: var(--text-3);
}

.chat-send {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 11px;
    background: var(--accent);
    color: #10131a;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.16s ease;
}

.chat-send:hover {
    filter: brightness(1.08);
}

.chat-send:active {
    transform: scale(0.96);
}

/* Точка с непрочитанными сообщениями на кнопке панели */
.icon-btn {
    position: relative;
}

.icon-btn.has-unread::after {
    content: attr(data-unread);
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #ef6a6a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-1, #0b0c0e);
}
/* Тост чата: кликабельный, открывает переписку */
.toast.is-clickable {
    cursor: pointer;
}

.toast.is-clickable:hover {
    border-color: rgba(var(--accent-rgb), 0.4);
    background: rgba(var(--accent-rgb), 0.12);
}
/* ---------- Качество связи участника ---------- */

.tile-quality {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-left: 2px;
    background: var(--warn);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35);
    transition: background-color 0.2s ease;
}

.tile-quality[data-state='warn'] {
    background: var(--warn);
}

.tile-quality[data-state='bad'] {
    background: var(--danger);
}

.tile-quality[hidden] {
    display: none;
}

/* ---------- Сцена: слабый градиент под плитками ---------- */



.stage::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(1200px 700px at 50% 8%, rgba(var(--accent-rgb), 0.055), transparent 62%),
        radial-gradient(900px 520px at 50% 108%, rgba(90, 110, 200, 0.045), transparent 60%);
}

/* Лёгкое затемнение по краям: кадр «собирается» в центр */
.stage::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    box-shadow: inset 0 0 160px 40px rgba(0, 0, 0, 0.45);
}

/* На тач-устройствах кнопка разворота всегда доступна, но не отвлекает */
@media (pointer: coarse) {
    .tile-action {
        display: grid;
        width: 30px;
        height: 30px;
        opacity: 0.55;
        transition: opacity 0.18s ease;
    }

    .tile-action:active {
        opacity: 1;
    }
}
/* В развёрнутом виде кнопка не должна прятаться под верхней панелью */
.tile.is-maximized .tile-action {
    top: calc(var(--topbar-height) + var(--safe-top) + 10px);
}

/* Плашка имени в развёрнутом виде — над доком с кнопками */
.tile.is-maximized .tile-bottom {
    bottom: calc(var(--controls-height) + var(--controls-offset) + 10px);
}
/* ---------- Приглашение: QR и ссылка ---------- */

.invite {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 12px;
    margin: 0 12px 10px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line);
}

.invite[hidden] {
    display: none;
}

.invite-qr {
    display: grid;
    place-items: center;
    padding: 10px;
    border-radius: 12px;
    /* QR должен быть тёмным на светлом: инверсию сканеры читают плохо */
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.invite-qr .qr-canvas {
    display: block;
    border-radius: 4px;
}

.invite-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    max-width: 100%;
}

.invite-code {
    font-size: 12.5px;
    color: var(--text-2);
}

.invite-code b {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.invite-url {
    max-width: 100%;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-button-quiet {
    background: transparent;
    border-color: var(--line);
    color: var(--text-2);
}

.chip-button-quiet.is-active {
    background: rgba(var(--accent-rgb), 0.18);
    border-color: rgba(var(--accent-rgb), 0.4);
    color: var(--text);
}

/* Кнопка QR не должна растягиваться на всю ширину */
.panel-toolbar .chip-button-quiet {
    flex: 0 0 auto;
    min-width: 46px;
}
/* ---------- Инструкция по разрешениям браузера ---------- */

.permission-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 6px;
    padding-left: 20px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-2);
}

.permission-steps li::marker {
    color: var(--accent);
    font-weight: 600;
}

.permission-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.permission-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
}

/* Кнопка камеры в ожидании разрешения */
.control-btn.is-pending {
    opacity: 0.75;
    cursor: progress;
}

.control-btn.is-pending .icon {
    animation: pending-pulse 1.1s ease-in-out infinite;
}

@keyframes pending-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}