:root {
    color-scheme: light;
    --bg: #eef2fa;
    --ink: #17223d;
    --muted: #626c79;
    --line: #e0e5eb;
    --accent: #4165ef;
    --channel: #4165ef;
    --channel-soft: #edf1ff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-synthesis: none;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background:
        radial-gradient(ellipse at 10% 0%, #dce7ff 0, transparent 50%),
        radial-gradient(ellipse at 95% 35%, #def4f1 0, transparent 50%),
        var(--bg);
    min-height: 100vh;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
button,
input {
    font: inherit;
}
button {
    cursor: pointer;
}
button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid #6c8bff;
    outline-offset: 3px;
}
a {
    color: inherit;
    text-decoration: none;
}
.page-shell {
    max-width: 1440px;
    margin: auto;
    padding: 0 24px;
}
.app-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 25px;
    font-weight: 750;
    letter-spacing: -0.8px;
}
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(145deg, #557bff, #304ad3);
    box-shadow: 0 4px 12px #4165ef30;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}
.brand-mark i {
    width: 3px;
    border-radius: 3px;
    background: #fff;
    height: 10px;
}
.brand-mark i:nth-child(2) {
    height: 20px;
}
.brand-mark i:nth-child(3) {
    height: 15px;
}
.brand-mark i:nth-child(4) {
    height: 8px;
}
.connection {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--muted);
    max-width: 55%;
    padding: 7px 12px;
    border-radius: 24px;
    background: #ffffffa6;
    border: 1px solid #ffffff;
}
.connection-dot {
    height: 8px;
    width: 8px;
    background: #c99a30;
    border-radius: 50%;
    flex-shrink: 0;
}
.connection[data-state='connected'] .connection-dot {
    background: #079876;
    box-shadow: 0 0 0 4px #07987612;
}
.connection[data-state='error'] .connection-dot {
    background: #c26959;
}
.stream-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}
.stream-card {
    background: #fff;
    border: 1px solid #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 8px 28px #263f7510,
        0 1px 3px #263f7510;
}
.stream-card:nth-child(2) {
    --channel: #087f86;
    --channel-soft: #e4f7f5;
}
.stream-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    min-height: 66px;
    border-top: 3px solid var(--channel);
    background: linear-gradient(110deg, var(--channel-soft), #fff 75%);
}
.stream-name h2 {
    font-size: 22px;
    letter-spacing: -0.5px;
    margin: 0;
    font-weight: 750;
    color: var(--channel);
}
.stream-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    padding: 5px 8px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #e4e8f1;
    color: #626c79;
    white-space: nowrap;
}
.stream-status:before {
    content: '';
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}
.stream-status[data-state='active'] {
    background: #edf5df;
    color: #527422;
}
.stream-status[data-state='transition'] {
    background: #fbf3df;
    color: #946c18;
}
.stream-status[data-state='error'] {
    background: #faeeeb;
    color: #a95142;
}
.controls {
    display: flex;
    gap: 7px;
    margin-left: auto;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 13px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 600;
    transition:
        background 0.15s,
        box-shadow 0.15s,
        transform 0.15s;
}
.button span {
    font-size: 11px;
}
.button-primary {
    background: var(--channel);
    border-color: var(--channel);
    color: #fff;
    box-shadow: 0 3px 7px color-mix(in srgb, var(--channel) 22%, transparent);
}
.button-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--channel) 88%, #000);
    transform: translateY(-1px);
}
.button-stop,
.button-secondary {
    background: #fff;
    border-color: #dce1e7;
    color: #535e6c;
}
.button-stop:hover:not(:disabled) {
    background: #faeeeb;
    border-color: #e9c7bf;
    color: #bc3d53;
}
.button-secondary:hover:not(:disabled) {
    background: #f3f4f6;
}
.video-frame {
    aspect-ratio: 16/9;
    background: #111619;
    overflow: hidden;
}
.video-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}
.captions {
    padding: 14px 16px 16px;
    background: linear-gradient(120deg, #fff, var(--channel-soft));
    border-top: 1px solid #ffffff70;
}
.caption-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 650;
    color: var(--channel);
}
.language {
    font-size: 12px;
    color: var(--channel);
    background: #ffffffb3;
    border: 1px solid color-mix(in srgb, var(--channel) 15%, transparent);
    border-radius: 5px;
    padding: 2px 6px;
}
.caption-text {
    font-size: 20px;
    line-height: 1.45;
    min-height: 29px;
    margin: 8px 0 0;
    overflow-wrap: anywhere;
}
.caption-text[data-empty='true'] {
    font-size: 18px;
    color: #7a8490;
}
.app-footer {
    padding: 12px 0;
    text-align: right;
    font-size: 13px;
    color: #7a8490;
}
dialog {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    width: min(410px, calc(100% - 32px));
    color: var(--ink);
    box-shadow: 0 24px 90px #0003;
}
dialog::backdrop {
    background: #14202e66;
}
.modal-heading {
    display: flex;
    justify-content: flex-end;
}
.close-button {
    border: 0;
    background: transparent;
    font-size: 26px;
    color: #687381;
    padding: 0 3px;
}
dialog h2 {
    font-size: 23px;
    letter-spacing: -0.5px;
    margin: 0 0 22px;
}
dialog label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}
dialog input {
    width: 100%;
    border: 1px solid #dce1e7;
    border-radius: 8px;
    padding: 12px;
    font-size: 16px;
    background: #fafbfc;
}
.form-error {
    color: #ae5142;
    font-size: 14px;
    margin: 9px 0 0;
    min-height: 19px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
@media (max-width: 1000px) and (min-width: 701px) {
    .stream-heading {
        flex-wrap: wrap;
        gap: 8px;
    }
    .controls {
        flex-basis: 100%;
        justify-content: flex-end;
    }
    .stream-status {
        margin-left: auto;
    }
}
@media (max-width: 700px) {
    .page-shell {
        padding: 0 12px;
    }
    .app-header {
        min-height: 68px;
        gap: 10px;
    }
    .brand {
        font-size: 22px;
    }
    .connection {
        font-size: 14px;
    }
    .stream-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .stream-heading {
        padding: 10px 12px;
        gap: 8px;
    }
    .stream-name h2 {
        font-size: 21px;
    }
    .stream-status {
        font-size: 13px;
    }
    .button {
        padding: 8px 11px;
    }
    .captions {
        padding: 12px 14px 14px;
    }
}
@media (max-width: 370px) {
    .stream-heading {
        flex-wrap: wrap;
    }
    .stream-status {
        margin-left: auto;
    }
    .controls {
        flex-basis: 100%;
        justify-content: flex-end;
    }
}
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

[hidden] { display: none !important; }
.player-pending { color: #fff; padding: 24px; font-size: 18px; text-align: center; }

.player-modal {
    width: min(1100px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    padding: 0;
    overflow: auto;
}
.player-modal-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
}
.player-modal-heading h2 { margin: 0; font-size: 20px; }
.player-modal-heading .close-button { min-width: 44px; min-height: 44px; }
.player-modal-video { background: #000; aspect-ratio: 16 / 9; }
.player-modal-video iframe { display: block; width: 100%; height: 100%; border: 0; }

.caption-toggle { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.caption-toggle[aria-pressed='true'] { background: var(--channel); color: #fff; border-color: var(--channel); }
