/*
 * web/css/call.css
 *
 * Layout + motion for the call screen. Everything on this screen is
 * stacked on top of the ambient background; when the remote video is
 * playing, the body toggles data-bg="hidden" to fade the background
 * away so we don't double-paint moving colour behind moving video.
 *
 * Key ideas:
 *  - .stage is the big area (peer video). Video is never stretched;
 *    .stage-backdrop is a blurred copy that paints letterbox bars
 *    when the peer's aspect ratio doesn't match the container.
 *  - .pip is the small self preview. Tap / swap exchanges it with
 *    the stage visually by toggling body[data-swapped]. The DOM
 *    doesn't move; only styles flip, so <video> elements never
 *    re-attach streams (that would drop frames and kill audio).
 *  - Header + footer auto-hide on inactivity. body[data-ui="hidden"]
 *    slides them off-screen via transform; tap/mouse revives them.
 */

.screen-call {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   STAGE — the large peer video
   ══════════════════════════════════════════════════════════════ */

.stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: transparent;
    isolation: isolate;
    z-index: var(--z-content);
    transition: transform var(--dur-slow) var(--ease-out),
                opacity  var(--dur-slow) var(--ease-out);
}

/* When swapped the stage collapses into where the PiP was and the
   PiP expands into where the stage was. Both animate together. */
body[data-swapped="yes"] .stage       { /* visual positions flipped below via .pip rules */ }

/* Blurred ambient backdrop — takes the same stream as .stage-video,
   sits behind it, cover-fits (always fills), blurs hard, slight zoom
   to hide blurred edges. */
.stage-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: scale(1.15);
    filter: blur(44px) saturate(1.4) brightness(0.7);
    opacity: 0.9;
    pointer-events: none;
    transition: opacity 500ms var(--ease-out);
    /* Keep iOS from rendering a flash before the first frame. */
    background: transparent;
}
body[data-stage="placeholder"] .stage-backdrop { opacity: 0; }

.stage-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* contain so portrait-from-phone stays portrait and landscape-
       from-desktop stays landscape; the backdrop fills the rest. */
    object-fit: contain;
    object-position: center;
    background: transparent;
    opacity: 0;
    transition: opacity 500ms var(--ease-out);
}
body[data-stage="video"] .stage-video { opacity: 1; }

/* Placeholder (alone / camera-off) — ambient gradient + pulse avatar. */
.stage-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 0 24px;
    text-align: center;
    opacity: 0;
    transition: opacity 500ms var(--ease-out);
    pointer-events: none;
}
body[data-stage="placeholder"] .stage-placeholder { opacity: 1; }

.stage-avatar {
    position: relative;
    width: min(168px, 34vmin);
    height: min(168px, 34vmin);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: min(68px, 13vmin);
    letter-spacing: -0.03em;
    background:
        radial-gradient(circle at 30% 25%,
            rgba(255, 255, 255, 0.22), transparent 55%),
        linear-gradient(140deg, var(--accent-bright), var(--accent-deep));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.18),
        0 28px 80px -24px rgba(124, 77, 255, 0.7);
    animation: stage-avatar-breath 4.5s ease-in-out infinite;
}
.stage-avatar-initial { line-height: 1; }

.stage-avatar-pulse {
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 2px solid rgba(167, 139, 250, 0.4);
    opacity: 0;
    animation: stage-avatar-ring 2.8s var(--ease-out) infinite;
}
.stage-avatar-pulse::after {
    content: '';
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    border: 1px solid rgba(167, 139, 250, 0.25);
}

@keyframes stage-avatar-breath {
    0%, 100% { transform: scale(1);    }
    50%      { transform: scale(1.04); }
}
@keyframes stage-avatar-ring {
    0%   { transform: scale(0.9); opacity: 0; }
    25%  { opacity: 0.7; }
    100% { transform: scale(1.3); opacity: 0; }
}

.stage-placeholder-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(22px, 4.5vmin, 32px);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.stage-placeholder-sub {
    color: var(--text-tertiary);
    font-size: 14px;
    letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════════════════════
   PIP — self preview floating in one of 4 corners
   ══════════════════════════════════════════════════════════════ */

.pip {
    position: absolute;
    /* Computed from data-corner below; transform is driven by JS
       during drag, style-reset on release. */
    z-index: var(--z-pip);
    width: min(36vw, 180px);
    aspect-ratio: 3 / 4;
    border-radius: var(--r-lg);
    overflow: hidden;
    isolation: isolate;
    cursor: grab;
    touch-action: none;
    box-shadow: var(--sh-pip);
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 55%),
        linear-gradient(140deg, #36235D, #0C071A);
    transform-origin: center;

    transition:
        top    var(--dur-slow) var(--ease-spring),
        right  var(--dur-slow) var(--ease-spring),
        bottom var(--dur-slow) var(--ease-spring),
        left   var(--dur-slow) var(--ease-spring),
        width  var(--dur-slow) var(--ease-out),
        height var(--dur-slow) var(--ease-out),
        box-shadow var(--dur-med) var(--ease-out),
        transform var(--dur-med) var(--ease-out);

    animation: pip-in 620ms var(--ease-spring) both;
}
@keyframes pip-in {
    from { transform: translateY(16px) scale(0.8); opacity: 0; }
    to   { transform: translateY(0)    scale(1);   opacity: 1; }
}

.pip:hover   { box-shadow: var(--sh-pip), 0 0 0 1px rgba(167, 139, 250, 0.35); }
.pip:active  { cursor: grabbing; transform: scale(0.98); }
.pip[data-dragging="true"] {
    transition: none;
    cursor: grabbing;
    transform: scale(1.04);
    box-shadow: 0 32px 80px -20px rgba(0, 0, 0, 0.9),
                0 0 0 2px rgba(167, 139, 250, 0.45);
}

/* Corner positions (top-left, top-right, bottom-left, bottom-right). */
.pip[data-corner="tl"] { top:  calc(var(--safe-top) + 72px); left:  16px; right: auto; bottom: auto; }
.pip[data-corner="tr"] { top:  calc(var(--safe-top) + 72px); right: 16px; left:  auto; bottom: auto; }
.pip[data-corner="bl"] { bottom: calc(var(--safe-bottom) + 112px); left:  16px; right: auto; top: auto; }
.pip[data-corner="br"] { bottom: calc(var(--safe-bottom) + 112px); right: 16px; left:  auto; top: auto; }

.pip-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Mirror self video so it feels like a mirror. */
    transform: scaleX(-1);
    opacity: 0;
    transition: opacity 420ms var(--ease-out);
    background: transparent;
}
body[data-self="on"] .pip-video { opacity: 1; }

.pip-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 420ms var(--ease-out);
}
body[data-self="on"] .pip-placeholder { opacity: 0; }

.pip-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    background:
        radial-gradient(circle at 30% 25%, rgba(255,255,255,0.22), transparent 55%),
        linear-gradient(140deg, var(--accent-bright), var(--accent-deep));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15),
                0 8px 22px -8px rgba(124,77,255,0.6);
}
.pip-placeholder-hint {
    color: var(--text-tertiary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pip-mute-dot {
    position: absolute;
    left: 10px; bottom: 10px;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 59, 92, 0.92);
    color: #fff;
    box-shadow: 0 6px 16px -4px rgba(255, 59, 92, 0.55);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity var(--dur-med) var(--ease-spring),
                transform var(--dur-med) var(--ease-spring);
    pointer-events: none;
}
.pip-mute-dot svg { width: 16px; height: 16px; }
body[data-self-mic="off"] .pip-mute-dot { opacity: 1; transform: scale(1); }

/* Hint icon that fades in on hover/focus to suggest "tap to swap". */
.pip-swap-hint {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity var(--dur-med) var(--ease-out),
                transform var(--dur-med) var(--ease-out);
    pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
    .pip:hover .pip-swap-hint { opacity: 1; transform: scale(1.04); }
}

/* ── SWAP mode ───────────────────────────────────────────────── */
body[data-swapped="yes"] .stage {
    /* shrink the old "stage" area to occupy the pip's slot */
    position: absolute;
    z-index: var(--z-pip);
    inset: auto;
    top:  var(--pip-top,    auto);
    right:var(--pip-right,  16px);
    bottom: var(--pip-bottom, calc(var(--safe-bottom) + 112px));
    left: var(--pip-left,   auto);
    width: min(36vw, 180px);
    height: auto;
    aspect-ratio: 3 / 4;
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-pip);
}
body[data-swapped="yes"] .pip {
    inset: 0;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    animation: none;
    cursor: default;
}
body[data-swapped="yes"] .pip-video   { object-fit: contain; }
body[data-swapped="yes"] .pip-swap-hint { display: none; }
body[data-swapped="yes"] .pip-mute-dot  { display: none; }

/* When swapped, the stage video letterboxes too (contain), and its
   backdrop still fills thanks to its own blur layer. */

/* ══════════════════════════════════════════════════════════════
   HEADER — peer name, signal, timer, back, more
   ══════════════════════════════════════════════════════════════ */

.call-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: var(--z-header);
    display: flex;
    align-items: center;
    gap: 12px;
    padding:
        calc(var(--safe-top) + 10px)
        calc(var(--safe-right) + 12px)
        10px
        calc(var(--safe-left) + 12px);
    background:
        linear-gradient(180deg,
            rgba(7, 7, 11, 0.55) 0%,
            rgba(7, 7, 11, 0.25) 55%,
            rgba(7, 7, 11, 0) 100%);
    transition: opacity var(--dur-med) var(--ease-out),
                transform var(--dur-med) var(--ease-out);
    pointer-events: auto;
}

body[data-ui="hidden"] .call-header {
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
}

.header-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 8px 8px;
    border-radius: var(--r-pill);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
}
.header-back .icon { width: 22px; height: 22px; }
.header-back:hover  { background: rgba(255, 255, 255, 0.16); }
.header-back:active { transform: scale(0.95); }
@media (max-width: 380px) { .header-back span { display: none; } }

.header-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
}
.header-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}
.header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}
.header-signal {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
}
.header-signal i {
    display: block;
    width: 3px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.3;
    transition: opacity var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
}
.header-signal i:nth-child(1) { height: 4px; }
.header-signal i:nth-child(2) { height: 7px; }
.header-signal i:nth-child(3) { height: 9px; }
.header-signal i:nth-child(4) { height: 12px; }
.header-signal[data-level="1"] i:nth-child(-n+1) { opacity: 1; background: var(--status-danger); }
.header-signal[data-level="2"] i:nth-child(-n+2) { opacity: 1; background: var(--status-warn); }
.header-signal[data-level="3"] i:nth-child(-n+3) { opacity: 1; background: var(--status-ok); }
.header-signal[data-level="4"] i { opacity: 1; background: var(--status-ok); }

.header-timer {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    min-width: 3.5ch;
    text-align: left;
}

.header-more {
    width: 38px; height: 38px;
    border-radius: var(--r-pill);
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.10);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
}
.header-more .icon { width: 22px; height: 22px; }
.header-more:hover  { background: rgba(255, 255, 255, 0.16); color: var(--text-primary); }
.header-more:active { transform: scale(0.92); }

/* ══════════════════════════════════════════════════════════════
   FOOTER — primary call controls
   ══════════════════════════════════════════════════════════════ */

.call-footer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: var(--z-footer);
    padding:
        14px
        calc(var(--safe-right) + 14px)
        calc(var(--safe-bottom) + 14px)
        calc(var(--safe-left) + 14px);
    background:
        linear-gradient(0deg,
            rgba(7, 7, 11, 0.70) 0%,
            rgba(7, 7, 11, 0.30) 55%,
            rgba(7, 7, 11, 0) 100%);
    transition: opacity var(--dur-med) var(--ease-out),
                transform var(--dur-med) var(--ease-out);
}
body[data-ui="hidden"] .call-footer {
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
}

.footer-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(10px, 3.5vw, 22px);
    max-width: 620px;
    margin: 0 auto;
}

/* Control button — the circular frosted surface + label underneath. */
.ctl {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.ctl-surface {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--glass-mid);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3),
        0 6px 20px -6px rgba(0, 0, 0, 0.55);
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
}

.ctl .icon { width: 26px; height: 26px; }
.ctl .icon-on  { display: inline-block; }
.ctl .icon-off { display: none; }
.ctl[data-active="false"] .icon-on  { display: none; }
.ctl[data-active="false"] .icon-off { display: inline-block; }

.ctl:hover .ctl-surface  { background: rgba(255, 255, 255, 0.2); }
.ctl:active .ctl-surface { transform: scale(0.92); }

/* Inactive mic/cam: go bright white with red icon (telegram style). */
.ctl[data-active="false"] .ctl-surface {
    background: rgba(255, 255, 255, 0.9);
    color: #0b0b12;
}
.ctl[data-active="false"] .icon-off path { fill: #0b0b12; }

.ctl-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Active screen share gets a violet glow. */
.ctl[data-action="toggle-screen"][data-active="true"] .ctl-surface {
    background: linear-gradient(135deg, #9D5BFF, #6B3FEA);
    box-shadow: 0 12px 32px -10px rgba(139, 92, 246, 0.8);
}

/* The red end-call button is always filled. */
.ctl-danger .ctl-surface {
    background: linear-gradient(145deg, #FF5374, #E02244);
    color: #fff;
    box-shadow: 0 14px 32px -10px rgba(255, 59, 92, 0.65),
                inset 0 1px 0 rgba(255, 255, 255, 0.3),
                inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}
.ctl-danger:hover .ctl-surface {
    background: linear-gradient(145deg, #FF6985, #E83556);
    box-shadow: 0 18px 42px -10px rgba(255, 59, 92, 0.8),
                inset 0 1px 0 rgba(255, 255, 255, 0.34),
                inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.ctl[data-visible="false"]     { display: none; }
.ctl-desktop-only               { display: none; }
@media (min-width: 900px) and (pointer: fine) {
    .ctl-desktop-only           { display: flex; }
}

/* Hide labels on narrow phones to give buttons breathing room. */
@media (max-width: 380px) {
    .ctl-label { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   STATUS PILLS — toast-style notifications above footer
   ══════════════════════════════════════════════════════════════ */

.pills {
    position: absolute;
    bottom: calc(var(--safe-bottom) + 112px);
    left: 0; right: 0;
    z-index: var(--z-pills);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    pointer-events: none;
    transition: transform var(--dur-med) var(--ease-out);
}
body[data-ui="hidden"] .pills { transform: translateY(-60px); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 12px;
    border-radius: var(--r-pill);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(15, 13, 24, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    max-width: min(90vw, 360px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    animation: pill-in 420ms var(--ease-spring) both;
}
@keyframes pill-in {
    0%   { opacity: 0; transform: translateY(16px) scale(0.92); }
    60%  { opacity: 1; transform: translateY(-4px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0)    scale(1); }
}
.pill[data-leaving="true"] {
    animation: pill-out 260ms var(--ease-accel) both;
}
@keyframes pill-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-14px) scale(0.92); }
}
.pill .icon { width: 15px; height: 15px; color: var(--text-secondary); }
.pill[data-tone="danger"]  { border-color: rgba(255, 59, 92, 0.35); }
.pill[data-tone="danger"] .icon { color: var(--status-danger); }
.pill[data-tone="accent"]  { border-color: rgba(139, 92, 246, 0.4); }
.pill[data-tone="accent"] .icon { color: var(--accent-bright); }

/* ══════════════════════════════════════════════════════════════
   ALONE WARNING — the "30s to kick" banner
   ══════════════════════════════════════════════════════════════ */

.alone-warning {
    position: absolute;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    opacity: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 40%,
            rgba(255, 59, 92, 0.3), transparent 55%),
        rgba(7, 7, 11, 0.7);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transition: opacity var(--dur-med) var(--ease-out);
}
body[data-state="alone-warning"] .alone-warning {
    opacity: 1;
    pointer-events: auto;
}

.alone-warning-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 320px;
    text-align: center;
}
.alone-warning-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.alone-warning-title .mono { color: var(--status-danger); }
.alone-warning-sub {
    color: var(--text-secondary);
    font-size: 15px;
}
.alone-warning-stay {
    margin-top: 8px;
    height: 52px;
    padding: 0 28px;
    border-radius: var(--r-pill);
    background: #fff;
    color: #0b0b12;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    transition: transform var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    box-shadow: 0 14px 30px -10px rgba(255, 255, 255, 0.35);
}
.alone-warning-stay:hover  { background: #f4efff; box-shadow: 0 18px 40px -10px rgba(255, 255, 255, 0.55); }
.alone-warning-stay:active { transform: scale(0.96); }

/* ══════════════════════════════════════════════════════════════
   CAMERA PREVIEW MODAL — shown when turning cam on mid-call
   ══════════════════════════════════════════════════════════════ */

.camera-preview {
    position: absolute;
    inset: 0;
    z-index: var(--z-modal);
    padding:
        calc(var(--safe-top) + 16px)
        calc(var(--safe-right) + 16px)
        calc(var(--safe-bottom) + 16px)
        calc(var(--safe-left) + 16px);
    background: rgba(7, 7, 11, 0.5);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-med) var(--ease-out);
}
body[data-state="preview-camera"] .camera-preview {
    opacity: 1;
    pointer-events: auto;
}

.camera-preview-card {
    width: min(460px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(139, 92, 246, 0.25), transparent 60%),
        linear-gradient(165deg, #14102A, #08060F);
    border: 1px solid rgba(167, 139, 250, 0.18);
    border-radius: var(--r-xl);
    box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.8),
                0 14px 50px -16px rgba(139, 92, 246, 0.45);
    overflow: hidden;
    animation: modal-in 460ms var(--ease-spring) both;
}
@keyframes modal-in {
    from { transform: translateY(12px) scale(0.95); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.camera-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.camera-preview-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
}
.camera-preview-close, .camera-preview-spacer {
    width: 36px; height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--r-pill);
    color: var(--text-tertiary);
}
.camera-preview-close { background: var(--glass-weak); transition: background var(--dur-fast) var(--ease-out); }
.camera-preview-close:hover { background: var(--glass-mid); color: var(--text-primary); }
.camera-preview-spacer { visibility: hidden; }
.camera-preview-close .icon { width: 20px; height: 20px; }

.camera-preview-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    max-height: 55vh;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(139, 92, 246, 0.3), transparent 60%),
        #0B071A;
}
.camera-preview-stage video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.camera-preview-footer {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.camera-preview-devices {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.camera-preview-devices::-webkit-scrollbar { display: none; }
.camera-preview-devices button {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: var(--r-pill);
    background: var(--glass-weak);
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}
.camera-preview-devices button[data-selected="true"] {
    background: rgba(139, 92, 246, 0.28);
    color: var(--text-primary);
    border: 1px solid rgba(167, 139, 250, 0.45);
}

.camera-preview-ok {
    height: 52px;
    border-radius: var(--r-pill);
    background: #fff;
    color: #0b0b12;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    transition: transform var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
    box-shadow: 0 14px 30px -10px rgba(255, 255, 255, 0.35);
}
.camera-preview-ok:hover  { background: #f4efff; }
.camera-preview-ok:active { transform: scale(0.98); }

/* ══════════════════════════════════════════════════════════════
   MESSAGE SCREEN — denied / error / kicked
   ══════════════════════════════════════════════════════════════ */

.message {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: center;
    padding: 48px;
}
.message-icon {
    width: 80px; height: 80px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--accent-bright);
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.22), rgba(99, 102, 241, 0.08));
    box-shadow: 0 18px 50px -20px rgba(139, 92, 246, 0.6),
                inset 0 0 0 1px rgba(167, 139, 250, 0.3);
}
.message-icon .icon { width: 38px; height: 38px; }
.message-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.message-text {
    color: var(--text-secondary);
    max-width: 360px;
    font-size: 15px;
}
.message-btn {
    margin-top: 8px;
    height: 52px;
    padding: 0 26px;
    border-radius: var(--r-pill);
    background: #fff;
    color: #0b0b12;
    font-weight: 700;
    font-size: 16px;
    transition: transform var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
    box-shadow: 0 14px 30px -10px rgba(255, 255, 255, 0.35);
}
.message-btn:hover  { background: #f4efff; }
.message-btn:active { transform: scale(0.97); }

/* ══════════════════════════════════════════════════════════════
   ORIENTATION / LANDSCAPE on mobile
   ══════════════════════════════════════════════════════════════ */

@media (orientation: landscape) and (max-height: 480px) {
    .call-footer { padding-bottom: 10px; }
    .footer-row { gap: clamp(8px, 2.5vw, 18px); }
    .ctl-surface { width: 52px; height: 52px; }
    .ctl-label   { font-size: 10px; }
    .header-name { font-size: 16px; }
}
