/* ==========================================================================
   Meeting room — lobby, call stage, controls. Always dark on Deep Navy: the room
   re-points the foundation tokens so shared components (.btn, .input, .field…)
   render dark too. Quantum Cyan marks live states (speaking, active controls).
   ========================================================================== */

.room {
    color-scheme: dark;

    --bg: #0b1220;
    --bg-subtle: #0f172a;
    --surface: #131c2e;
    --surface-muted: #1e293b;
    --surface-hover: #273449;
    --text: #f8fafc;
    --text-2: #cbd5e1;
    --text-3: #94a3b8;
    --text-4: #64748b;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.28);
    --brand: #3b82f6;
    --brand-ink: #93c5fd;
    --brand-soft: rgba(59, 130, 246, 0.16);
    --brand-glow: rgba(59, 130, 246, 0.4);
    --accent: #06b6d4;
    --accent-ink: #67e8f9;
    --accent-soft: rgba(6, 182, 212, 0.16);
    --primary-bg: #f8fafc;
    --primary-bg-hover: #ffffff;
    --primary-fg: #0f172a;
    --secondary-bg: #2563eb;
    --secondary-bg-hover: #3b82f6;
    --secondary-fg: #ffffff;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --danger-soft: rgba(239, 68, 68, 0.16);
    --danger-ink: #fca5a5;
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --focus: #93c5fd;
    --shadow: 0 8px 32px rgba(2, 6, 23, 0.5);
    --shadow-sm: none;

    --tile-bg: #1e293b;
    --gap: 12px;

    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
}

.room h1,
.room h2,
.room h3 {
    color: var(--text);
}

.room a:hover {
    color: var(--text);
}

.room-btn-dark {
    --btn-bg: var(--surface-muted);
    --btn-bg-hover: var(--surface-hover);
    --btn-border: var(--border);
}

.room-btn-danger {
    --btn-bg: var(--danger-soft);
    --btn-fg: var(--danger-ink);
    --btn-border: transparent;
    --btn-bg-hover: rgba(239, 68, 68, 0.26);
}

.room-icon-btn {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
}

.room-icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.room-avatar {
    display: grid;
    place-items: center;
    width: clamp(44px, 24cqi, 112px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: linear-gradient(145deg, #3b82f6, #1e3a8a);
    color: #f8fafc;
    font-family: var(--font-heading);
    font-size: clamp(1rem, 9cqi, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    user-select: none;
}

.room-avatar--lg {
    width: 96px;
    font-size: 2.25rem;
}

.room-avatar--sm {
    width: 36px;
    font-size: var(--fs-sm);
}

.room-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.room-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --------------------------------------------------------------------------
   Centered states: loading, unavailable, ended
   -------------------------------------------------------------------------- */
.room-center {
    display: grid;
    place-items: center;
    gap: 16px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
    color: var(--text-3);
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, rgba(59, 130, 246, 0.12), transparent 70%),
        var(--bg);
}

.room-center[role="status"] {
    align-content: center;
}

.room-message {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(100%, 460px);
    padding: 40px 32px 32px;
    text-align: center;
}

.room-message h1 {
    font-size: var(--fs-xl);
}

.room-message h1:focus {
    outline: none;
}

.room-message p {
    color: var(--text-3);
}

.room-message__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 4px;
    border-radius: var(--radius-lg);
    background: var(--danger-soft);
    color: var(--danger-ink);
}

.room-message__icon--muted {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.room-message__meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
}

.room-message__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

/* --------------------------------------------------------------------------
   Lobby
   -------------------------------------------------------------------------- */
.room--lobby {
    background:
        radial-gradient(ellipse 70% 60% at 15% 0%, rgba(59, 130, 246, 0.14), transparent 60%),
        radial-gradient(ellipse 50% 50% at 100% 100%, rgba(6, 182, 212, 0.08), transparent 60%),
        var(--bg);
}

.room-lobby {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1160px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 0 var(--gutter) 32px;
}

.room-lobby__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
}

.room-secure {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.room-secure svg {
    color: var(--accent);
}

.room-lobby__grid {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
    align-items: center;
    gap: clamp(20px, 4vw, 48px);
}

.room-preview {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.room-preview__frame {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    container-type: inline-size;
}

.room-preview__frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
}

.room-preview__frame.is-live video {
    opacity: 1;
}

.room-preview__placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    color: var(--text-3);
    font-size: 0.9375rem;
    background: radial-gradient(circle at 50% 40%, #273449, var(--surface) 75%);
}

.room-meter {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 20px;
    padding: 6px 8px;
    border-radius: var(--radius-pill);
    background: rgba(2, 6, 23, 0.6);
    box-sizing: content-box;
}

.room-meter i {
    display: block;
    width: 4px;
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
    transform-origin: bottom;
    transform: scaleY(max(0.15, min(1, calc(var(--level, 0) * var(--k, 1)))));
    transition: transform 0.08s linear;
}

.room-meter i:nth-child(1),
.room-meter i:nth-child(5) { --k: 0.7; }
.room-meter i:nth-child(2),
.room-meter i:nth-child(4) { --k: 1.1; }
.room-meter i:nth-child(3) { --k: 1.5; }

.room-meter--off i {
    background: var(--text-4);
    transform: scaleY(0.15);
}

.room-meter--hidden {
    display: none;
}

.room-preview__controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    min-height: 52px;
}

.room-round {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--text);
    transition: background-color 0.15s var(--ease);
}

.room-round:hover {
    background: var(--surface-hover);
}

.room-round--off {
    border-color: transparent;
    background: var(--danger);
    color: #ffffff;
}

.room-preview__label {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: rgba(2, 6, 23, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #f8fafc;
    font-size: var(--fs-sm);
    font-weight: 500;
}

.room-round--off:hover {
    background: var(--danger-hover);
}

.room-round:disabled {
    opacity: 0.45;
}

.room-alert {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger-ink);
    font-size: 0.9375rem;
}

.room-alert > svg {
    margin-top: 2px;
}

.room-alert > div {
    display: grid;
    gap: 4px;
}

.room-alert strong {
    color: #fee2e2;
}

.room-alert__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.room-alert .link-button {
    color: #fee2e2;
}

.room-alert--inline {
    align-items: center;
    padding: 10px 14px;
    font-size: 0.875rem;
}

.room-join {
    display: grid;
    gap: 14px;
    padding: clamp(24px, 3vw, 32px);
}

.room-join h1 {
    font-size: clamp(var(--fs-xl), 1.2rem + 1.2vw, var(--fs-2xl));
    overflow-wrap: anywhere;
}

.room-join__description {
    color: var(--text-3);
    white-space: pre-line;
}

.room-facts {
    display: grid;
    gap: 10px;
    margin: 4px 0 8px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-subtle);
}

.room-facts > div {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
    font-size: 0.875rem;
}

.room-facts dt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-3);
}

.room-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.room-join__form {
    display: grid;
    gap: 16px;
}

.room-join__form .field + .field {
    margin-top: 0;
}

.room-join__privacy {
    color: var(--text-3);
    font-size: var(--fs-sm);
    text-align: center;
}

@media (max-width: 860px) {
    .room-lobby__grid {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }

    .room-preview__frame {
        max-height: 46vh;
    }
}

@media (max-width: 560px) {
    .room-lobby {
        padding-inline: 12px;
    }

    .room-lobby__header {
        min-height: 60px;
    }

    .room-join {
        border-radius: var(--radius-lg);
    }

    .room-facts > div {
        grid-template-columns: 80px minmax(0, 1fr);
    }
}

/* --------------------------------------------------------------------------
   In call: frame
   -------------------------------------------------------------------------- */
.room--call {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.room-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}

.room-topbar__meeting {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.room-topbar__mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.room-topbar__meeting > div {
    display: grid;
    min-width: 0;
}

.room-topbar h1 {
    overflow: hidden;
    font-size: var(--fs-base);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-topbar__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.room-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.room-status i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-4);
}

.room-status[data-state="connected"] i { background: var(--accent); }
.room-status[data-state="connecting"] i,
.room-status[data-state="reconnecting"] i { background: var(--warning); animation: blink 1.2s infinite; }
.room-status[data-state="error"] i,
.room-status[data-state="disconnected"] i { background: var(--danger); }
.room-status[data-state="reconnecting"] { color: var(--warning); }

.room-topbar__locked {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--warning);
}

.room-topbar__actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
}

.room-toggle {
    display: inline-flex;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.room-toggle button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-3);
}

.room-toggle button:hover {
    color: var(--text);
}

.room-toggle button[aria-pressed="true"] {
    background: var(--brand-soft);
    color: var(--brand-ink);
}

.room-playback {
    position: absolute;
    top: 64px;
    left: 50%;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: var(--radius-pill);
    background: #2a2210;
    color: #fde68a;
    font-size: 0.875rem;
    transform: translateX(-50%);
    box-shadow: var(--shadow);
}

.room-body {
    display: flex;
    flex: 1;
    gap: 12px;
    min-height: 0;
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}

/* --------------------------------------------------------------------------
   Stage and video grid
   -------------------------------------------------------------------------- */
.room-stage {
    position: relative;
    display: grid;
    flex: 1;
    place-items: center;
    min-width: 0;
    min-height: 0;
    container: stage / size;
}

.room-grid {
    --cols: 1;
    --rows: 1;
    --arw: 16;
    --arh: 9;

    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: var(--gap);
    /* Largest grid of 16:9 tiles that fits both the width and the height of the stage. */
    width: min(100cqw, calc((100cqh - (var(--rows) - 1) * var(--gap)) / var(--rows) * var(--arw) / var(--arh) * var(--cols) + (var(--cols) - 1) * var(--gap)));
}

.room-grid[data-count="2"] { --cols: 2; }
.room-grid[data-count="3"],
.room-grid[data-count="4"] { --cols: 2; --rows: 2; }
.room-grid[data-count="5"],
.room-grid[data-count="6"] { --cols: 3; --rows: 2; }
.room-grid[data-count="7"],
.room-grid[data-count="8"],
.room-grid[data-count="9"] { --cols: 3; --rows: 3; }

.tile {
    position: relative;
    aspect-ratio: var(--arw) / var(--arh);
    min-width: 0;
    overflow: hidden;
    border-radius: 16px;
    background: var(--tile-bg);
    container-type: inline-size;
    isolation: isolate;
}

.tile::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
    pointer-events: none;
    transition: box-shadow 0.2s var(--ease);
}

.tile--speaking::after {
    box-shadow: inset 0 0 0 3px var(--accent), 0 0 24px rgba(6, 182, 212, 0.35);
}

.tile video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #020617;
}

.tile--self:not(.tile--screen) video {
    transform: scaleX(-1);
}

.tile--screen video {
    object-fit: contain;
}

.tile--video-off video {
    visibility: hidden;
}

.tile__avatar {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
    place-items: center;
    background: radial-gradient(circle at 50% 45%, #273449, var(--tile-bg) 70%);
}

.tile--video-off .tile__avatar {
    display: grid;
}

.tile__label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 16px);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: rgba(2, 6, 23, 0.62);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: 1.4;
}

.tile__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile__muted {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-left: -4px;
    border-radius: 50%;
    background: var(--danger);
    color: #ffffff;
}

.tile__muted svg {
    width: 12px;
    height: 12px;
}

.tile__role {
    flex: none;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: rgba(59, 130, 246, 0.3);
    color: #dbeafe;
    font-size: var(--fs-sm);
}

.tile__actions {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s var(--ease);
}

.tile:hover .tile__actions,
.tile:focus-within .tile__actions {
    opacity: 1;
}

@media (hover: none) {
    .tile__actions {
        opacity: 1;
    }
}

.tile__action {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.62);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #ffffff;
}

.tile__action:hover {
    background: rgba(2, 6, 23, 0.85);
}

.tile__action[aria-pressed="true"] {
    background: var(--secondary-bg);
    color: #ffffff;
}

/* Small tiles: keep only what fits. */
@container (max-width: 220px) {
    .tile__role,
    .tile__action:not(:last-child) {
        display: none;
    }

    .tile__label {
        left: 6px;
        bottom: 6px;
        padding: 2px 8px;
        font-size: var(--fs-sm);
    }
}

/* Speaker view: one large tile plus a strip of the others. */
.room-grid--speaker {
    --strip: clamp(140px, 20cqw, 240px);

    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: var(--gap);
    width: 100%;
    height: 100%;
    padding-left: calc(100% - var(--strip));
    overflow: hidden;
}

.room-grid--speaker .tile {
    flex: 0 1 auto;
    width: 100%;
    min-height: 0;
}

.room-grid--speaker .tile--featured {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: calc(100% - var(--strip) - var(--gap));
    aspect-ratio: auto;
}

.room-grid--speaker .tile--featured:not(.tile--screen) video {
    object-fit: contain;
}

.room-alone {
    position: absolute;
    left: 50%;
    top: 16px;
    z-index: 5;
    display: grid;
    justify-items: center;
    gap: 4px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(19, 28, 46, 0.9);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    text-align: center;
    transform: translateX(-50%);
    box-shadow: var(--shadow);
    animation: fade-in 0.3s var(--ease);
}

.room-alone span {
    margin-bottom: 8px;
    color: var(--text-3);
    font-size: 0.875rem;
}

/* Portrait stages (phones): taller tiles, picture-in-picture self view for 1:1 calls. */
@container stage (orientation: portrait) {
    .room-grid {
        --arw: 3;
        --arh: 4;
    }

    .room-grid[data-count="1"],
    .room-grid[data-count="2"] {
        width: 100%;
        height: 100%;
        grid-template-columns: minmax(0, 1fr);
    }

    .room-grid[data-count="1"] .tile,
    .room-grid[data-count="2"] .tile:not(.tile--self) {
        height: 100%;
        aspect-ratio: auto;
    }

    .room-grid[data-count="2"]:not(.room-grid--speaker) .tile--self {
        position: absolute;
        right: 12px;
        bottom: 12px;
        z-index: 4;
        width: clamp(96px, 28cqw, 160px);
        aspect-ratio: 3 / 4;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(2, 6, 23, 0.6);
    }

    .room-grid[data-count="3"] { --cols: 1; --rows: 3; --arw: 16; --arh: 9; }
    .room-grid[data-count="4"] { --cols: 2; --rows: 2; }
    .room-grid[data-count="5"],
    .room-grid[data-count="6"] { --cols: 2; --rows: 3; }

    .room-grid--speaker {
        --strip: clamp(84px, 16cqh, 140px);

        flex-direction: row;
        align-items: flex-end;
        justify-content: center;
        padding-left: 0;
    }

    .room-grid--speaker .tile {
        flex: 0 1 calc(var(--strip) * 3 / 4);
        width: auto;
        height: var(--strip);
        aspect-ratio: auto;
    }

    .room-grid--speaker .tile--featured {
        right: 0;
        bottom: calc(var(--strip) + var(--gap));
        width: 100%;
        height: auto;
    }

}

/* --------------------------------------------------------------------------
   People panel
   -------------------------------------------------------------------------- */
.room-panel {
    display: flex;
    flex: none;
    flex-direction: column;
    width: 340px;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    animation: fade-in 0.2s var(--ease);
}

.room-panel-backdrop {
    display: none;
}

.room-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 12px 20px;
    border-bottom: 1px solid var(--border);
}

.room-panel__header h2 {
    font-size: 1rem;
}

.room-panel__header h2 span {
    margin-left: 4px;
    color: var(--text-3);
    font-weight: 500;
}

.room-people {
    display: grid;
    flex: 1;
    align-content: start;
    gap: 2px;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    list-style: none;
}

.room-person {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
}

.room-person:hover {
    background: var(--surface-muted);
}

.room-person__identity {
    display: grid;
    min-width: 0;
}

.room-person__identity strong {
    overflow: hidden;
    font-size: 0.9375rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-person__identity span {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.room-person__state {
    display: flex;
    gap: 8px;
    color: var(--text-3);
}

.room-person__state .is-off {
    color: var(--danger-ink);
}

.room-person__actions {
    display: flex;
    grid-column: 2 / -1;
    gap: 8px;
    margin-top: 4px;
}

.room-panel__footer {
    display: grid;
    gap: 8px;
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}

.room-panel__hint {
    color: var(--text-3);
    font-size: var(--fs-sm);
    text-align: center;
}

@media (max-width: 900px) {
    .room-panel-backdrop {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: block;
        border: 0;
        background: rgba(2, 6, 23, 0.6);
        animation: fade-in 0.2s var(--ease);
    }

    .room-panel {
        position: fixed;
        top: 8px;
        right: 8px;
        bottom: 8px;
        z-index: 41;
        width: min(360px, calc(100% - 16px));
        box-shadow: var(--shadow-lg);
    }
}

@media (max-width: 560px) {
    .room-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 82dvh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* --------------------------------------------------------------------------
   Control dock
   -------------------------------------------------------------------------- */
.room-dock {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.room-dock__group {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.room-control {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 80px;
    height: 60px;
    padding: 8px 12px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.room-control:hover:not(:disabled) {
    background: var(--surface-hover);
}

.room-control:disabled {
    opacity: 0.5;
}

.room-control svg {
    width: 22px;
    height: 22px;
}

.room-control--off {
    background: var(--danger-soft);
    color: var(--danger-ink);
}

.room-control--off:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.26);
}

.room-control--active {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.room-control--active:hover:not(:disabled) {
    background: rgba(6, 182, 212, 0.24);
}

/* #DC2626 keeps the white label above 4.5:1. */
.room-control--leave {
    min-width: 96px;
    background: #dc2626;
    color: #ffffff;
    box-shadow: var(--shadow);
}

.room-control--leave:hover:not(:disabled) {
    background: #b91c1c;
}

.room-control__icon {
    position: relative;
    display: inline-flex;
}

/* Live microphone level: a cyan bar under the mic icon so you can see you're being heard. */
.room-control__level {
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 18px;
    height: 3px;
    overflow: hidden;
    border-radius: 2px;
    background: rgba(148, 163, 184, 0.25);
    transform: translateX(-50%);
}

.room-control__level::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(var(--level, 0));
    transition: transform 0.08s linear;
}

.room-control--off .room-control__level {
    display: none;
}

.room-control__count {
    position: absolute;
    top: -6px;
    right: -12px;
    min-width: 18px;
    padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--secondary-bg);
    color: #ffffff;
    font-size: var(--fs-xs);
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Status banners over the stage: reconnecting, talking while muted. */
.room-banner {
    position: absolute;
    left: 50%;
    top: 12px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 24px);
    padding: 8px 8px 8px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: rgba(19, 28, 46, 0.94);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--text);
    font-size: 0.875rem;
    box-shadow: var(--shadow);
    transform: translateX(-50%);
    animation: banner-in 0.2s var(--ease);
}

.room-banner > svg {
    flex: none;
    color: var(--accent);
}

.room-banner--warning {
    border-color: rgba(251, 191, 36, 0.4);
}

.room-banner--warning > svg {
    color: var(--warning);
}

.room-banner--warning .room-spinner {
    flex: none;
    width: 16px;
    height: 16px;
    border-width: 2px;
    border-top-color: var(--warning);
}

.room-banner span {
    min-width: 0;
}

.room-banner .btn {
    flex: none;
}

.room-banner:not(:has(.btn)) {
    padding-right: 16px;
}

/* Elapsed time next to the connection status. Filled in by meetingRoom.js. */
.room-clock {
    font-variant-numeric: tabular-nums;
}

.room-clock:empty {
    display: none;
}

.room-clock::before {
    content: "·";
    margin-right: 12px;
    color: var(--text-4);
}

/* Lobby device pickers */
.room-devices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 12px;
}

.room-devices .field {
    gap: 4px;
}

.room-devices label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-3);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.room-devices .input {
    min-height: 40px;
    padding-block: 8px;
    font-size: 0.875rem;
    text-overflow: ellipsis;
}

/* In-call audio and video settings dialog */
.room-settings {
    display: grid;
    gap: 20px;
}

.room-settings .field {
    gap: 8px;
}

.room-settings label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.room-settings label svg {
    color: var(--text-3);
}

.room-settings .input {
    text-overflow: ellipsis;
}

/* Live input level for the selected microphone; --level is set by meetingRoom.js. */
.room-settings__meter {
    position: relative;
    display: block;
    height: 6px;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
}

.room-settings__meter > span {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(var(--level, 0));
    transition: transform 0.08s linear;
}

@keyframes banner-in {
    from { opacity: 0; transform: translate(-50%, -6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Keep transient toasts above the dock. */
body:has(.room--call) .toast-region {
    bottom: calc(96px + env(safe-area-inset-bottom));
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
.room-show-sm {
    display: none;
}

@media (max-width: 720px) {
    .room-hide-sm {
        display: none;
    }

    .room-topbar .btn--sm {
        width: 40px;
        padding: 0;
    }

    .room-dock {
        gap: 8px;
        padding-top: 8px;
    }

    .room-dock__group {
        flex: 1;
        gap: 2px;
    }

    .room-control {
        flex: 1 1 0;
        min-width: 0;
        height: 56px;
        padding-inline: 4px;
        border-radius: 14px;
    }

    .room-control--leave {
        min-width: 0;
    }

    .room-control span:not(.room-control__icon):not(.room-control__count):not(.visually-hidden) {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .room-control--leave {
        flex: 0 0 64px;
    }
}

@media (max-width: 420px) {
    .room-hide-xs {
        display: none;
    }

    .room-topbar__meta .room-topbar__locked,
    .room-clock {
        display: none;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .room-topbar {
        padding-block: 6px;
    }

    .room-control {
        height: 48px;
    }

    .room-control > span:last-child {
        display: none;
    }

    .room-dock {
        padding-top: 6px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

@keyframes blink {
    50% { opacity: 0.35; }
}
