.vwd {
    --p-bg: #fff;
    --p-fg: hsl(0 0% 3.9%);
    --p-muted: hsl(0 0% 42%);
    --p-soft: hsl(0 0% 96.1%);
    --p-border: hsl(0 0% 90%);
    --p-chrome: var(--bg-2);
    --p-primary: hsl(204 80% 43%);
    --p-ok: #10b981;
    --p-ok-ink: #047857;
    --p-ok-soft: rgba(16, 185, 129, 0.12);
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin: 0;
    min-width: 0;
}

html.dark .vwd {
    --p-bg: hsl(0 0% 5%);
    --p-fg: hsl(0 0% 98%);
    --p-muted: hsl(0 0% 64%);
    --p-soft: hsl(0 0% 11%);
    --p-border: hsl(0 0% 16%);
    --p-chrome: #141416;
    --p-primary: hsl(202 85% 56%);
    --p-ok-ink: #6ee7b7;
    --p-ok-soft: rgba(16, 185, 129, 0.16);
}

.vwd-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line-2);
    border-radius: 16px;
    background: var(--p-bg);
    color: var(--p-fg);
    box-shadow: 0 2px 4px rgba(45, 30, 15, 0.05), 0 30px 60px -30px rgba(45, 30, 15, 0.35);
}

html.dark .vwd-panel {
    border-color: #26262a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 34px 70px -34px rgba(0, 0, 0, 0.85);
}

.vwd-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-bottom: 1px solid var(--p-border);
    background: var(--p-chrome);
}

.vwd-bar i {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--line-2);
}

html.dark .vwd-bar i {
    background: #2c2c31;
}

.vwd-url {
    min-width: 0;
    margin: 0 auto;
    padding: 1px 14px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--p-bg);
    color: var(--p-muted);
    font: 500 0.74rem/1.5 var(--body);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.vwd-body {
    display: grid;
    gap: 14px;
    padding: 16px;
    font-family: var(--body);
}

.vwd-head {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.vwd-crumb {
    color: var(--p-muted);
    font-size: 0.72rem;
    line-height: 1.3;
}

.vwd-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    line-height: 1.3;
}

.vwd-name {
    min-width: 0;
    overflow: hidden;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.vwd-badge {
    flex: none;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--p-ok-soft);
    color: var(--p-ok-ink);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.6;
}

.vwd-sum {
    color: var(--p-muted);
    font-size: 0.78rem;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}

.vwd-ctrl {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    min-width: 0;
}

.vwd-lbl,
.vwd-sub {
    flex: 1 0 100%;
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.vwd-sub {
    margin-bottom: 6px;
}

.vwd-tabs {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--p-border);
    border-radius: 9px;
    background: var(--p-bg);
}

.vwd-tab {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 1px;
    min-width: 0;
    min-height: 44px;
    padding: 5px 2px 7px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--p-fg);
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.vwd-tab-n {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.vwd-tab-n small {
    font-size: 0.7rem;
    font-weight: 500;
}

.vwd-tab-g {
    color: var(--p-muted);
    font-size: 0.68rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.vwd-tab[aria-selected='true'] {
    background: color-mix(in srgb, var(--p-primary) 11%, transparent);
    color: var(--p-primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p-primary) 40%, transparent);
}

.vwd-tab[aria-selected='true'] .vwd-tab-g {
    color: inherit;
}

@media (hover: hover) and (pointer: fine) {
    .vwd-tab[aria-selected='false']:hover {
        background: var(--p-soft);
    }

    .vwd-pause:hover {
        background: var(--p-soft);
        color: var(--p-fg);
    }
}

.vwd-tab:focus-visible,
.vwd-pause:focus-visible {
    outline: 2px solid var(--p-primary);
    outline-offset: 1px;
    border-radius: 6px;
}

.vwd-tab-bar {
    position: absolute;
    left: 9px;
    right: 9px;
    bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left center;
    pointer-events: none;
}

.vwd.is-manual .vwd-tab-bar,
.vwd.is-paused .vwd-tab-bar {
    visibility: hidden;
}

.vwd-pause {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    padding: 0;
    border: 1px solid var(--p-border);
    border-radius: 9px;
    background: var(--p-bg);
    color: var(--p-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.vwd-pause[hidden] {
    display: none;
}

.vwd-pause svg {
    width: 17px;
    height: 17px;
}

.vwd-i-play,
.vwd.is-paused .vwd-i-pause,
.vwd.is-manual .vwd-i-pause {
    display: none;
}

.vwd.is-paused .vwd-i-play,
.vwd.is-manual .vwd-i-play {
    display: block;
}

.vwd-preview {
    min-width: 0;
}

.vwd-pbox {
    display: grid;
    place-items: center;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    border-radius: 9px;
    background: #0a0a0a;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    container: vwdbox / size;
}

.vwd-pwall {
    position: relative;
    width: min(100cqw, calc(100cqh * var(--ar, 1.78)));
    aspect-ratio: var(--ar, 1.78);
    overflow: hidden;
    background: linear-gradient(180deg, #2b1630 0%, #8f3b2a 42%, #f08a3c 60%, #ffd59a 63%, #6a3020 63.4%, #1c1210 100%);
}

.vwd-pcanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.vwd-cells {
    position: absolute;
    inset: 0;
}

.vwd-cell {
    position: absolute;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2px;
    padding: 3%;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.vwd-cell b {
    padding: 0 3px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font: 600 9px/14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.vwd-cell i {
    flex: none;
    width: 6px;
    height: 6px;
    margin: 4px 1px 0 0;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

@container vwdbox (max-width: 340px) {
    .vwd-pwall[data-n='12'] .vwd-cell b,
    .vwd-pwall[data-n='20'] .vwd-cell b {
        display: none;
    }
}

@container vwdbox (max-width: 230px) {
    .vwd-pwall[data-n='5'] .vwd-cell b,
    .vwd-pwall[data-n='6'] .vwd-cell b {
        display: none;
    }

    .vwd-pwall[data-n='20'] .vwd-cell i {
        width: 4px;
        height: 4px;
        margin-top: 1px;
    }
}

.vwd-set {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
    margin: 0;
}

.vwd-f {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.vwd-f-fit,
.vwd-f-bz,
.vwd-f-src {
    grid-column: 1 / -1;
}

.vwd-flbl {
    display: block;
    float: none;
    margin-bottom: 4px;
    padding: 0;
    color: var(--p-muted);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.3;
}

.vwd-selw {
    position: relative;
    display: block;
}

.vwd-selw::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 11px;
    width: 6px;
    height: 6px;
    margin-top: -5px;
    border-right: 1.5px solid var(--p-muted);
    border-bottom: 1.5px solid var(--p-muted);
    transform: rotate(45deg);
    pointer-events: none;
}

.vwd-sel {
    display: block;
    width: 100%;
    height: 32px;
    margin: 0;
    padding: 0 28px 0 10px;
    border: 1px solid var(--p-border);
    border-radius: 7px;
    background: var(--p-bg);
    color: var(--p-fg);
    font: 500 0.82rem/1 var(--body);
    font-variant-numeric: tabular-nums;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.vwd-sel option {
    background: var(--p-bg);
    color: var(--p-fg);
}

.vwd-sel:disabled,
.vwd-seg input:disabled + span,
.vwd-num:disabled,
.vwd-stb:disabled,
.vwd-src:disabled {
    cursor: default;
}

.vwd-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--p-border);
    border-radius: 7px;
}

.vwd-seg label {
    position: relative;
    display: block;
    margin: 0;
}

.vwd-seg input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.vwd-seg span {
    display: block;
    border-radius: 5px;
    color: var(--p-muted);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 26px;
    text-align: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.vwd-seg input:checked + span {
    background: color-mix(in srgb, var(--p-primary) 11%, transparent);
    color: var(--p-primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p-primary) 40%, transparent);
}

.vwd-seg input:focus-visible + span {
    outline: 2px solid var(--p-primary);
    outline-offset: 1px;
}

.vwd-bz {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.vwd-step {
    display: grid;
    grid-template-columns: 30px 16px minmax(0, 1fr) auto 30px;
    align-items: center;
    gap: 4px;
    height: 32px;
    border: 1px solid var(--p-border);
    border-radius: 7px;
    background: var(--p-bg);
    transition: border-color 0.2s ease;
}

.vwd-step:has(:focus-visible) {
    border-color: var(--p-primary);
    box-shadow: 0 0 0 1px var(--p-primary);
}

.vwd-step.is-bad {
    border-color: #dc2626;
    box-shadow: 0 0 0 1px #dc2626;
}

.vwd-stb {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--p-fg);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.vwd-stb svg {
    width: 14px;
    height: 14px;
}

.vwd-stb:disabled {
    color: var(--p-muted);
    opacity: 0.45;
}

.vwd-stb:focus-visible {
    outline: 2px solid var(--p-primary);
    outline-offset: -2px;
}

.vwd-axis {
    width: 15px;
    height: 15px;
    color: var(--p-muted);
}

.vwd-num {
    width: 100%;
    min-width: 0;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--p-fg);
    font: 600 0.84rem/1 var(--body);
    font-variant-numeric: tabular-nums;
    text-align: right;
    outline: none;
}

.vwd-step em {
    color: var(--p-muted);
    font-size: 0.8rem;
    font-style: normal;
}

.vwd-err {
    margin: 4px 0 0;
    color: #dc2626;
    font-size: 0.72rem;
    line-height: 1.35;
}

html.dark .vwd-err {
    color: #f87171;
}

html.dark .vwd-step.is-bad {
    border-color: #f87171;
    box-shadow: 0 0 0 1px #f87171;
}

.vwd-err:empty {
    display: none;
}

.vwd-src {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 5px 8px 5px 6px;
    border: 1px solid var(--p-border);
    border-radius: 8px;
    background: var(--p-bg);
    color: var(--p-fg);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.vwd-src:focus-visible,
.vwd-sel:focus-visible {
    outline: 2px solid var(--p-primary);
    outline-offset: 1px;
}

.vwd-src-t {
    flex: 1 1 auto;
    min-width: 0;
}

.vwd-thumb {
    flex: none;
    width: 46px;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    background: radial-gradient(40% 70% at 62% 60%, #ffd7a0, transparent 70%), linear-gradient(180deg, #2b1630, #8f3b2a 45%, #f08a3c 62%, #6a3020 64%, #1c1210);
}

.vwd-thumb[data-s='1'] {
    background: radial-gradient(30% 70% at 50% 58%, #eaf4ff, transparent 70%), linear-gradient(180deg, #0a1430, #1d3a6b 40%, #3f73ad 54%, #163056 57%, #060b16);
}

.vwd-thumb[data-s='2'] {
    background: radial-gradient(50% 40% at 50% 56%, #fff0e0, transparent 70%), linear-gradient(180deg, #331a46, #a8476f 40%, #f2916f 54%, #5a2843 57%, #1d0e1a);
}

.vwd-src b,
.vwd-src small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.vwd-src b {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.35;
}

.vwd-src small {
    color: var(--p-muted);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.vwd-src-c {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--p-primary);
    font-size: 0.76rem;
    font-weight: 600;
}

.vwd-src-c svg {
    width: 14px;
    height: 14px;
}

.vwd:not(.is-js) .vwd-src-c {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .vwd-sel:not(:disabled):hover,
    .vwd-src:not(:disabled):hover {
        border-color: color-mix(in srgb, var(--p-primary) 55%, var(--p-border));
    }

    .vwd-seg input:not(:disabled):not(:checked):hover + span,
    .vwd-stb:not(:disabled):hover {
        background: var(--p-soft);
        color: var(--p-fg);
    }
}

.vwd-live {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding-top: 12px;
    border-top: 1px solid var(--p-border);
    font-size: 0.8rem;
    line-height: 1.35;
}

.vwd-dot {
    position: relative;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--p-ok);
}

@media (prefers-reduced-motion: no-preference) {
    .vwd.is-live:not(.is-paused) .vwd-dot::after {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: var(--p-ok);
        animation: vwd-ping 1.8s cubic-bezier(0.23, 1, 0.32, 1) infinite;
    }
}

@keyframes vwd-ping {
    from {
        transform: scale(1);
        opacity: 0.55;
    }
    to {
        transform: scale(2.6);
        opacity: 0;
    }
}

.vwd-live-l {
    color: var(--p-muted);
}

.vwd-live-v {
    color: var(--p-ok-ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.vwd-live-c {
    margin-left: auto;
    color: var(--p-muted);
    white-space: nowrap;
}

.vwd-live-c b {
    color: var(--p-fg);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.vwd-room {
    position: relative;
    isolation: isolate;
    min-width: 0;
    min-height: 320px;
    overflow: hidden;
    border: 1px solid rgba(20, 12, 6, 0.4);
    border-radius: 16px;
    background:
        radial-gradient(70% 55% at 50% 44%, rgba(240, 140, 60, 0.14), transparent 72%),
        linear-gradient(180deg, #241a14 0%, #17110d 86%, #1f1610 86.2%, #0e0a08 100%);
    box-shadow: 0 2px 4px rgba(45, 30, 15, 0.08), 0 30px 60px -30px rgba(45, 30, 15, 0.45);
}

html.dark .vwd-room {
    border-color: #2a211a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 34px 70px -34px rgba(0, 0, 0, 0.85);
}

.vwd-static,
.vwd-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.vwd-canvas {
    opacity: 0;
}

.vwd.is-live .vwd-canvas {
    opacity: 1;
}

.vwd.is-live .vwd-static {
    display: none;
}

.vwd-sr,
.vwd-in .vwd-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 961px) {
    .vwd:not(.is-compact) {
        grid-template-columns: minmax(350px, 400px) minmax(0, 1fr);
        gap: 18px;
        align-items: stretch;
    }

    .vwd:not(.is-compact) .vwd-set {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
    }

    .vwd:not(.is-compact) .vwd-f-fit {
        grid-column: span 2;
    }
}

@media (max-width: 960px) {
    .vwd-room {
        order: -1;
        min-height: 0;
        aspect-ratio: 2 / 1;
    }

    .vwd:not(.is-compact) .vwd-body {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            'head set'
            'ctrl set'
            'prev set'
            'live live';
        align-items: start;
        column-gap: 20px;
    }

    .vwd:not(.is-compact) .vwd-head {
        grid-area: head;
    }

    .vwd:not(.is-compact) .vwd-ctrl {
        grid-area: ctrl;
    }

    .vwd:not(.is-compact) .vwd-preview {
        grid-area: prev;
    }

    .vwd:not(.is-compact) .vwd-set {
        grid-area: set;
    }

    .vwd:not(.is-compact) .vwd-live {
        grid-area: live;
    }
}

@media (max-width: 600px) {
    .vwd {
        gap: 10px;
    }

    .vwd-bar {
        display: none;
    }

    .vwd-body {
        gap: 10px;
        padding: 12px;
    }

    .vwd-head {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 10px;
    }

    .vwd-crumb {
        display: none;
    }

    .vwd-name {
        font-size: 0.95rem;
    }

    .vwd-sum {
        font-size: 0.74rem;
    }

    .vwd-lbl {
        display: none;
    }

    .vwd-tab-n small {
        display: none;
    }

    .vwd-tab {
        min-height: 40px;
    }

    .vwd:not(.is-compact) .vwd-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            'head'
            'ctrl'
            'set'
            'live';
    }

    .vwd-preview,
    .vwd-f-src {
        display: none;
    }

    .vwd-set {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .vwd-f-fit {
        grid-column: span 2;
    }

    .vwd-flbl {
        margin-bottom: 3px;
        font-size: 0.7rem;
    }

    .vwd-sel {
        padding-left: 9px;
    }

    .vwd-seg span {
        line-height: 28px;
    }

    .vwd-sel,
    .vwd-step {
        height: 34px;
    }

    .vwd-live {
        padding-top: 9px;
        font-size: 0.76rem;
    }
}

.vwd.is-compact .vwd-room {
    order: -1;
    min-height: 0;
    aspect-ratio: 16 / 9;
}

.vwd.is-compact .vwd-crumb,
.vwd.is-compact .vwd-bar {
    display: none;
}

.vwd.is-compact .vwd-body {
    gap: 10px;
    padding: 12px;
}
