:root {
    --stream-bg: #07111f;
    --stream-surface: rgba(12, 23, 40, 0.82);
    --stream-border: rgba(148, 163, 184, 0.2);
    --stream-text: #f8fafc;
    --stream-muted: #94a3b8;
    --stream-accent: #22c55e;
    --stream-accent-2: #38bdf8;
    --stream-warn: #f59e0b;
    --stream-danger: #ef4444;
    --stream-font: 'Outfit', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--stream-font);
    color: var(--stream-text);
    background:
        radial-gradient(circle at top left, rgba(34, 197, 94, 0.14), transparent 26%),
        radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 24%),
        linear-gradient(180deg, #040913 0%, var(--stream-bg) 100%);
}

.stream-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.stream-hero,
.stream-card {
    background: var(--stream-surface);
    border: 1px solid var(--stream-border);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.stream-hero {
    padding: 28px;
    margin-bottom: 20px;
}

.stream-hero-compact {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.stream-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.14);
    border: 1px solid rgba(34, 197, 94, 0.26);
    color: #bbf7d0;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stream-hero h1,
.stream-card h2,
.stream-card h3 {
    margin: 0;
}

.stream-hero p,
.stream-card p,
.stream-card li,
.stream-meta,
.stream-empty {
    color: var(--stream-muted);
}

.stream-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 20px;
}

.stream-card {
    padding: 22px;
}

.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: 1 / -1; }

.stream-form {
    display: grid;
    gap: 14px;
}

.stream-form label,
.stream-field label {
    display: block;
    margin-bottom: 8px;
    color: #dbeafe;
    font-size: 0.92rem;
    font-weight: 600;
}

.stream-form input,
.stream-form select,
.stream-login input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.72);
    color: var(--stream-text);
    font: inherit;
}

.stream-form input:focus,
.stream-login input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.7);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.14);
}

.stream-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stream-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.stream-btn:hover { transform: translateY(-1px); }
.stream-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.stream-btn-primary {
    background: linear-gradient(135deg, var(--stream-accent) 0%, #16a34a 100%);
    color: #04110b;
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.24);
}

.stream-btn-secondary {
    background: rgba(56, 189, 248, 0.14);
    color: #bae6fd;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.stream-btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.28);
}

.stream-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.7);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.is-live { color: #bbf7d0; border-color: rgba(34, 197, 94, 0.3); }
.is-preview { color: #bae6fd; border-color: rgba(56, 189, 248, 0.34); }
.is-standby { color: #fde68a; border-color: rgba(245, 158, 11, 0.3); }
.is-blocked { color: #fecaca; border-color: rgba(239, 68, 68, 0.32); }

.stream-video-frame,
.stream-output-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background:
        linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(34, 197, 94, 0.12)),
        #020817;
}

.stream-video-frame video,
.stream-output-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.stream-video-overlay,
.stream-output-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    padding: 20px;
    background: linear-gradient(180deg, rgba(2, 6, 23, 0) 20%, rgba(2, 6, 23, 0.84) 100%);
}

.stream-peer-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.stream-peer-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(180deg, rgba(48, 54, 64, 0.96), rgba(20, 24, 31, 0.96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.stream-peer-card.is-live-card {
    border-color: rgba(239, 68, 68, 0.55);
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35), 0 12px 28px rgba(239, 68, 68, 0.14);
}

.stream-peer-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.stream-peer-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stream-peer-title strong {
    font-size: 1rem;
    letter-spacing: 0.03em;
}

.stream-peer-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.stream-actions-compact .stream-btn,
.stream-peer-actions .stream-btn {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
}

.stream-btn-chip {
    background: linear-gradient(180deg, #f5f7fb, #cfd6df);
    color: #101827;
    border: 1px solid rgba(12, 18, 28, 0.28);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 2px 0 rgba(12, 18, 28, 0.34);
}

.stream-btn-chip.is-onair {
    background: linear-gradient(180deg, #ff7a7a, #c81e1e);
    color: #fff7f7;
    border-color: rgba(95, 10, 10, 0.7);
}

.stream-btn-chip.is-preview {
    background: linear-gradient(180deg, #8cff84, #3ea93f);
    color: #06250a;
    border-color: rgba(12, 83, 19, 0.58);
}

.stream-btn-chip.is-standby {
    background: linear-gradient(180deg, #f5f7fb, #cfd6df);
    color: #101827;
    border-color: rgba(12, 18, 28, 0.28);
}

.stream-btn-chip.is-block {
    background: linear-gradient(180deg, #ffd9d9, #f19797);
    color: #4a0d0d;
    border-color: rgba(114, 19, 19, 0.38);
}

.stream-switcher-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.stream-switcher-console {
    background: linear-gradient(180deg, #3b4048, #242830 68%, #1b1f26);
    border-color: rgba(255,255,255,0.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 18px 46px rgba(0,0,0,0.26);
}

.stream-console-topbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.74rem;
    font-weight: 700;
}

.stream-monitor-wall {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 16px;
}

.stream-monitor {
    border-radius: 20px;
    background: linear-gradient(180deg, #11161d, #06090f);
    border: 1px solid rgba(255,255,255,0.08);
    min-height: 220px;
    overflow: hidden;
}

.stream-monitor-label {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stream-monitor-label-preview {
    background: linear-gradient(180deg, rgba(34,197,94,0.85), rgba(22,163,74,0.85));
    color: #07120a;
}

.stream-monitor-label-program {
    background: linear-gradient(180deg, rgba(239,68,68,0.92), rgba(185,28,28,0.92));
    color: #fff5f5;
}

.stream-monitor-body {
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 12px;
    min-height: 168px;
    padding: 20px;
}

.stream-console-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.stream-bus-panel {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.stream-bus-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    align-items: center;
}

.stream-bus-row-program {
    --bus-accent: rgba(239,68,68,0.9);
}

.stream-bus-row-preview {
    --bus-accent: rgba(34,197,94,0.9);
}

.stream-bus-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04));
    border: 1px solid rgba(255,255,255,0.08);
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stream-bus-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 8px;
}

.stream-bus-btn {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(12, 18, 28, 0.3);
    background: linear-gradient(180deg, #f5f7fb, #cfd6df);
    color: #111827;
    font: inherit;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 2px 0 rgba(12,18,28,0.34);
}

.stream-bus-btn.is-active {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bus-accent) 86%, white 14%), color-mix(in srgb, var(--bus-accent) 72%, black 28%));
    color: #fff;
    border-color: color-mix(in srgb, var(--bus-accent) 55%, black 45%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.24), 0 0 0 1px color-mix(in srgb, var(--bus-accent) 28%, transparent 72%);
}

.stream-source-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stream-source-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: #98a6b7;
    font-size: 0.82rem;
}

.stream-output-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px;
}

.stream-output-frame {
    width: min(1440px, 100%);
    aspect-ratio: 16 / 9;
}

.stream-output-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 30px;
}

.stream-output-center.is-live {
    opacity: 0;
    pointer-events: none;
}

.stream-output-center h1 {
    font-size: clamp(2rem, 5vw, 4.8rem);
    line-height: 0.95;
}

.stream-output-center p {
    max-width: 680px;
    margin: 12px auto 0;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
}

.stream-notice,
.stream-empty {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.55);
}

.stream-login {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.hidden {
    display: none !important;
}

@media (max-width: 960px) {
    .span-7,
    .span-6,
    .span-5,
    .span-12 {
        grid-column: 1 / -1;
    }

    .stream-shell {
        width: min(100% - 20px, 100%);
        padding-top: 18px;
    }

    .stream-hero,
    .stream-card {
        border-radius: 20px;
        padding: 18px;
    }

    .stream-hero-compact,
    .stream-switcher-head {
        flex-direction: column;
        align-items: start;
    }

    .stream-monitor-wall,
    .stream-peer-actions,
    .stream-bus-row {
        grid-template-columns: 1fr;
    }

    .stream-console-actions {
        justify-content: stretch;
        flex-direction: column;
    }
}
