.bf-watch {
    --watch-radius: 5px;
    --watch-control-radius: 4px;
    --watch-speed: 170ms;
    --watch-bg: var(--surface, #131a16);
    --watch-bg-soft: var(--surface-2, #19231d);
    --watch-text: var(--text, #eef5f0);
    --watch-muted: var(--muted, #9aaba0);
    --watch-border: var(--border, #28342c);
    --watch-accent: var(--watch_accent, var(--accent, #57c77a));
    --watch-on-accent: var(--watch_accent_font, var(--on-accent, #07100a));
    --watch-screen: #070a08;
    width: 100%;
    color: var(--watch-text);
    font: 500 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-variant-numeric: tabular-nums;
}

.bf-watch *,
.bf-watch *::before,
.bf-watch *::after {
    box-sizing: border-box;
}

.bf-watch button {
    font: inherit;
    font-variant-numeric: inherit;
}

.bf-watch__shell {
    overflow: hidden;
    border: 1px solid var(--watch-border);
    border-radius: var(--watch-radius);
    background: var(--watch-bg);
}

.bf-watch__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 60px;
    min-height: 60px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--watch-border);
    background: var(--watch-bg);
}

.bf-watch__sources {
    position: relative;
    min-width: 0;
    flex: 1 1 auto;
}

.bf-watch__sources-menu {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    color: var(--watch-text);
    border: 1px solid var(--watch-border);
    border-radius: var(--watch-control-radius);
    background: var(--watch-bg-soft);
    cursor: pointer;
}

.bf-watch__sources-list {
    display: flex;
    gap: 2px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.bf-watch__source,
.bf-watch__action,
.bf-watch__queue-toggle,
.bf-watch__queue-row {
    appearance: none;
    border: 0;
    cursor: pointer;
}

.bf-watch__source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    max-width: 220px;
    flex: 0 0 auto;
    padding: 8px 11px;
    overflow: hidden;
    color: var(--watch-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: var(--watch-control-radius);
    background: transparent;
    transition: color var(--watch-speed), background var(--watch-speed);
}

.bf-watch__source:hover,
.bf-watch__source:focus-visible {
    color: var(--watch-text);
    background: var(--watch-bg-soft);
}

.bf-watch__source--active {
    color: var(--watch-on-accent);
    background: var(--watch-accent);
}

.bf-watch__source-icon,
.bf-watch__action-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: currentColor;
}

.bf-watch__actions {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
}

.bf-watch__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 10px;
    color: var(--watch-muted);
    border-radius: var(--watch-control-radius);
    background: transparent;
    transition: color var(--watch-speed), background var(--watch-speed);
}

.bf-watch__action:hover,
.bf-watch__action:focus-visible,
.bf-watch__action--active {
    color: var(--watch-accent);
    background: var(--watch-bg-soft);
}

.bf-watch__stage,
.bf-watch__screen,
.bf-watch__screen-inner,
.bf-watch__viewport {
    position: relative;
    width: 100%;
}

.bf-watch__viewport {
    aspect-ratio: 16 / 9;
    min-height: 0;
    overflow: hidden;
    background: var(--watch-screen);
}

.bf-watch__embed {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--watch-screen);
}

.bf-watch__facade {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    border: 0;
    background-color: var(--watch-screen);
    background-image:
        linear-gradient(rgb(7 10 8 / 38%), rgb(7 10 8 / 74%)),
        var(--bf-watch-poster, linear-gradient(#101712, #070a08));
    background-position: center;
    background-size: cover;
    cursor: pointer;
}

.bf-watch__facade.is-hidden {
    display: none;
}

.bf-watch__facade-icon {
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    color: var(--watch-on-accent);
    border-radius: 50%;
    background: var(--watch-accent);
}

.bf-watch__facade-icon svg {
    fill: currentColor;
}

.bf-watch__facade-text {
    padding: 4px 8px;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--watch-control-radius);
    background: rgb(0 0 0 / 46%);
}

.bf-watch__status {
    position: absolute;
    inset: auto 16px 16px;
    z-index: 3;
    margin: 0;
    padding: 8px 10px;
    color: #fff;
    border-radius: var(--watch-control-radius);
    background: rgb(0 0 0 / 72%);
}

.bf-watch__status:empty {
    display: none;
}

.bf-watch__wait {
    position: absolute;
    inset: 0;
    display: none;
    pointer-events: none;
    background: rgb(7 10 8 / 58%);
}

.bf-watch__wait::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    content: "";
    transform: translate(-50%, -50%);
    border: 3px solid rgb(255 255 255 / 35%);
    border-top-color: var(--watch-accent);
    border-radius: 50%;
    animation: bf-watch-spin 700ms linear infinite;
}

.bf-watch__queue {
    border-top: 1px solid var(--watch-border);
    background: var(--watch-bg);
}

.bf-watch__queue-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 46px;
    padding: 9px 12px;
    color: var(--watch-text);
    background: var(--watch-bg-soft);
    font-weight: 700;
}

.bf-watch__queue-toggle[aria-expanded="false"] span:last-child {
    transform: rotate(180deg);
}

.bf-watch__queue-inner {
    max-height: 264px;
    overflow: auto;
}

.bf-watch__queue--hidden .bf-watch__queue-inner,
.bf-watch__queue--hidden .bf-watch__queue-ad {
    display: none;
}

.bf-watch__queue-stack {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
}

.bf-watch__queue-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 6px 8px;
    color: var(--watch-text);
    text-align: left;
    border: 1px solid var(--watch-border);
    border-radius: var(--watch-control-radius);
    background: var(--watch-bg);
}

.bf-watch__queue-row:hover,
.bf-watch__queue-row--active {
    border-color: var(--watch-muted);
    background: var(--watch-bg-soft);
}

.bf-watch__queue-row--active .bf-watch__queue-num {
    color: var(--watch-on-accent);
    background: var(--watch-accent);
}

.bf-watch__queue-num {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 50%;
    background: var(--watch-bg-soft);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.bf-watch__queue-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bf-watch__queue-ad,
.bf-watch__notice,
.bf-watch__debugbox {
    padding: 14px;
}

.bf-watch__notice {
    min-height: 88px;
    display: grid;
    place-items: center;
    color: var(--watch-muted);
    text-align: center;
}

.bf-watch__debugbox {
    margin-top: 12px;
    border: 1px solid var(--watch-border);
    border-radius: var(--watch-radius);
    background: var(--watch-bg);
}

.bf-watch__debugbox summary {
    cursor: pointer;
}

.bf-watch__debugbox pre {
    max-height: 360px;
    overflow: auto;
    white-space: pre-wrap;
}

.bf-watch--error .bf-watch__shell {
    border-color: #a94343;
}

.bf-watch--error .bf-watch__status {
    background: rgb(124 30 30 / 92%);
}

.bf-watch button:focus-visible,
.bf-watch summary:focus-visible {
    outline: 3px solid var(--watch-accent);
    outline-offset: 2px;
}

body.cinema-mode::before {
    position: fixed;
    inset: 0;
    z-index: 900;
    content: "";
    background: rgb(0 0 0 / 72%);
}

body.cinema-mode .bf-watch {
    position: relative;
    z-index: 901;
}

@keyframes bf-watch-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (max-width: 1024px) {
    .bf-watch__sources--dropdown .bf-watch__sources-menu {
        display: flex;
    }

    .bf-watch__sources--dropdown .bf-watch__sources-list {
        position: absolute;
        top: calc(100% + 6px);
        left: 0;
        z-index: 8;
        display: none;
        width: min(330px, calc(100vw - 32px));
        max-height: 280px;
        padding: 6px;
        overflow-y: auto;
        border: 1px solid var(--watch-border);
        border-radius: var(--watch-radius);
        background: var(--watch-bg);
    }

    .bf-watch__sources--dropdown.is-open .bf-watch__sources-list {
        display: grid;
    }

    .bf-watch__sources--dropdown .bf-watch__source {
        width: 100%;
        max-width: none;
        justify-content: flex-start;
    }

    .bf-watch__queue-stack {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .bf-watch__queue-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .bf-watch__bar {
        align-items: center;
        flex-direction: row;
        gap: 6px;
        height: 58px;
        min-height: 58px;
        padding: 7px 8px;
    }

    .bf-watch__actions {
        display: flex;
        flex: 0 0 auto;
        gap: 2px;
    }

    .bf-watch__action {
        width: 44px;
        min-width: 44px;
        padding: 8px;
    }

    .bf-watch__action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .bf-watch__sources-menu {
        min-width: 0;
    }

    .bf-watch__sources-current {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bf-watch__queue-stack {
        grid-template-columns: 1fr;
        padding: 8px;
    }

    .bf-watch__queue-inner {
        max-height: 230px;
    }

    .bf-watch__status {
        inset: auto 8px 8px;
        font-size: 13px;
    }

    .bf-watch__facade-icon {
        width: 52px;
        height: 52px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bf-watch *,
    .bf-watch *::before,
    .bf-watch *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
