/* Flush tool chrome so CVD owns the full widget width */
.tool-widget:has(.cvd-tool) {
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.cvd-tool {
    --cvd-accent: #22c7f5;
    --cvd-accent-strong: #009fda;
    --cvd-accent-soft: rgba(34, 199, 245, .12);
    --cvd-ink: #eef8ff;
    --cvd-muted: #91a8bc;
    --cvd-panel: #0c1624;
    --cvd-panel-soft: #101d2e;
    --cvd-line: rgba(116, 185, 218, .16);
    --cvd-stage-max: min(56vh, 520px);
    --cvd-stage-min: 220px;
    container-type: inline-size;
    container-name: cvd;
    width: 100%;
    max-width: 100%;
    color: var(--cvd-ink);
    font-family: var(--font, "Plus Jakarta Sans", system-ui, sans-serif);
}

.cvd-tool *,
.cvd-tool *::before,
.cvd-tool *::after {
    box-sizing: border-box;
}

.cvd-tool button:focus-visible,
.cvd-tool select:focus-visible,
.cvd-tool input:focus-visible,
.cvd-tool a:focus-visible {
    outline: 3px solid rgba(34, 199, 245, .4);
    outline-offset: 2px;
}

/* ── Hero ── */
.cvd-hero {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: clamp(1rem, 2.5cqi, 1.75rem);
    overflow: hidden;
    background:
        radial-gradient(circle at 88% 20%, rgba(34, 199, 245, .16), transparent 32%),
        linear-gradient(135deg, #101f32, #0b1421 62%);
    border: 1px solid var(--cvd-line);
    border-radius: 18px 18px 0 0;
}

.cvd-hero:after {
    content: "";
    position: absolute;
    right: -65px;
    bottom: -120px;
    width: 260px;
    height: 260px;
    border: 1px solid rgba(34, 199, 245, .11);
    border-radius: 50%;
    box-shadow: 0 0 0 35px rgba(34, 199, 245, .025), 0 0 0 70px rgba(34, 199, 245, .018);
    pointer-events: none;
}

.cvd-kicker,
.cvd-eyebrow {
    display: block;
    color: var(--cvd-accent);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.cvd-hero h2 {
    margin: .35rem 0 .45rem;
    color: #fff;
    font-size: clamp(1.2rem, 3.2cqi, 1.9rem);
    letter-spacing: -.03em;
    line-height: 1.2;
}

.cvd-hero p {
    max-width: 650px;
    margin: 0;
    color: #9fb2c5;
    font-size: clamp(.78rem, 1.8cqi, .88rem);
    line-height: 1.7;
}

.cvd-privacy {
    position: relative;
    z-index: 1;
    align-self: center;
    display: grid;
    grid-template-columns: auto auto;
    gap: .05rem .65rem;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 240px;
    padding: .85rem 1rem;
    background: rgba(6, 13, 23, .62);
    border: 1px solid rgba(34, 199, 245, .18);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    backdrop-filter: blur(10px);
}

.cvd-privacy span {
    grid-row: 1 / 3;
    font-size: 1.25rem;
}

.cvd-privacy strong {
    color: #eafdff;
    font-size: .8rem;
}

.cvd-privacy small {
    color: var(--cvd-muted);
    font-size: .68rem;
}

/* ── Workspace ── */
.cvd-workspace {
    display: grid;
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
    align-items: stretch;
    overflow: hidden;
    background: var(--cvd-panel);
    border: 1px solid var(--cvd-line);
    border-top: 0;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .18);
}

.cvd-controls {
    min-width: 0;
    padding: clamp(1rem, 2.2cqi, 1.35rem);
    background: linear-gradient(180deg, #101c2c, #0c1624);
    border-right: 1px solid var(--cvd-line);
}

.cvd-upload {
    min-height: 155px !important;
    background: rgba(4, 10, 18, .35) !important;
    border-color: rgba(34, 199, 245, .24) !important;
}

.cvd-upload:hover,
.cvd-upload.dragover {
    background: rgba(34, 199, 245, .07) !important;
    border-color: var(--cvd-accent) !important;
}

.cvd-upload .upload-zone-icon { color: var(--cvd-accent); }
.cvd-upload .upload-zone-title { color: #eaf8ff; }
.cvd-upload .upload-zone-hint { color: #8098ac; }

.cvd-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    margin-top: .65rem;
}

.cvd-quick-actions button {
    padding: .52rem .6rem;
    background: rgba(34, 199, 245, .065);
    border: 1px solid rgba(34, 199, 245, .14);
    border-radius: 8px;
    color: #8fdffa;
    font: 700 .71rem inherit;
    cursor: pointer;
    transition: .2s ease;
}

.cvd-quick-actions button:hover {
    background: rgba(34, 199, 245, .13);
    border-color: rgba(34, 199, 245, .3);
    color: #dff8ff;
    transform: translateY(-1px);
}

.cvd-section {
    margin-top: 1.15rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--cvd-line);
}

.cvd-section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .65rem;
}

.cvd-section-title > span {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(34, 199, 245, .2);
    border-radius: 7px;
    background: var(--cvd-accent-soft);
    color: var(--cvd-accent);
    font-size: .68rem;
    font-weight: 800;
}

.cvd-section-title label {
    color: #dceaf5;
    font-size: .78rem;
    font-weight: 800;
}

.cvd-section-title output {
    margin-left: auto;
    color: var(--cvd-accent);
    font-size: .77rem;
    font-weight: 800;
}

.cvd-controls select.cvd-type-native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.cvd-type-carousel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: stretch;
    gap: .4rem;
}

.cvd-type-nav {
    display: grid;
    place-items: center;
    width: 34px;
    min-height: 100%;
    padding: 0;
    border: 1px solid rgba(34, 199, 245, .22);
    border-radius: 10px;
    background: rgba(34, 199, 245, .08);
    color: #8fdffa;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.cvd-type-nav:hover {
    background: rgba(34, 199, 245, .16);
    border-color: rgba(34, 199, 245, .4);
}

.cvd-type-nav:disabled {
    opacity: .35;
    cursor: default;
}

.cvd-type-viewport {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(116, 185, 218, .16);
    border-radius: 12px;
    background: rgba(4, 10, 18, .35);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.cvd-type-viewport.is-dragging {
    cursor: grabbing;
}

.cvd-type-track {
    display: flex;
    gap: .55rem;
    width: max-content;
    padding: .55rem var(--cvd-type-edge, .55rem);
    will-change: transform;
}

.cvd-type-drag-hint {
    margin: .4rem 0 0;
    color: #6f879b;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.cvd-type-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .45rem;
    flex: 0 0 210px;
    width: 210px;
    min-height: 118px;
    padding: .7rem .75rem;
    border: 1px solid rgba(116, 185, 218, .14);
    border-top: 3px solid var(--type-accent, #22c7f5);
    border-radius: 11px;
    background: rgba(8, 16, 28, .72);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
}

.cvd-type-option:hover {
    background: rgba(34, 199, 245, .08);
    border-color: rgba(34, 199, 245, .28);
}

.cvd-type-option.is-active {
    background: rgba(34, 199, 245, .14);
    border-color: rgba(34, 199, 245, .45);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .22), 0 0 0 1px rgba(34, 199, 245, .12);
    transform: translateY(-1px);
}

.cvd-type-option:focus-visible {
    outline: 3px solid rgba(34, 199, 245, .4);
    outline-offset: 2px;
}

.cvd-type-option.is-open-choice {
    border-style: dashed;
}

.cvd-type-swatches {
    display: flex;
    gap: 3px;
}

.cvd-type-swatches span {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2);
}

.cvd-type-copy {
    min-width: 0;
    width: 100%;
}

.cvd-type-copy strong {
    display: block;
    color: #e7f4fc;
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.25;
}

.cvd-type-copy small {
    display: -webkit-box;
    margin-top: .2rem;
    overflow: hidden;
    color: #7f95a8;
    font-size: .6rem;
    line-height: 1.35;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.cvd-type-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    width: 100%;
    margin-top: auto;
}

.cvd-type-group-chip {
    color: #8098ac;
    font-size: .55rem;
    font-weight: 700;
}

.cvd-type-badge {
    flex: 0 0 auto;
    padding: .22rem .42rem;
    border-radius: 999px;
    background: rgba(34, 199, 245, .12);
    background: color-mix(in srgb, var(--type-accent, #22c7f5) 18%, transparent);
    border: 1px solid rgba(34, 199, 245, .28);
    border-color: color-mix(in srgb, var(--type-accent, #22c7f5) 35%, transparent);
    color: var(--type-accent, #22c7f5);
    font-size: .55rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cvd-open-choice {
    margin-top: .75rem;
    padding: .75rem;
    border: 1px dashed rgba(245, 158, 11, .35);
    border-radius: 12px;
    background: rgba(245, 158, 11, .06);
}

.cvd-open-choice .cvd-section-title {
    margin-bottom: .55rem;
}

.cvd-open-choice .cvd-section-title > span {
    border-color: rgba(245, 158, 11, .35);
    background: rgba(245, 158, 11, .12);
    color: #fbbf24;
}

.cvd-open-choice select {
    width: 100%;
    max-width: 100%;
    height: 42px;
    padding: 0 2.2rem 0 .75rem;
    background: #091321;
    color: #e7f4fc;
    border: 1px solid rgba(245, 158, 11, .28);
    border-radius: 9px;
    font-size: .78rem;
}

.cvd-open-choice-help {
    margin: .45rem 0 0;
    color: #b7a07a;
    font-size: .62rem;
    line-height: 1.45;
}

.cvd-type-help {
    min-height: 2.8em;
    margin: .55rem 0 0;
    color: var(--cvd-muted);
    font-size: .7rem;
    line-height: 1.5;
}

@media (hover: none) and (pointer: coarse) {
    .cvd-type-nav {
        min-width: 40px;
        min-height: 44px;
    }

    .cvd-type-option {
        flex-basis: 210px;
        width: 210px;
    }
}

@container cvd (max-width: 380px) {
    .cvd-type-carousel {
        grid-template-columns: 30px minmax(0, 1fr) 30px;
        gap: .3rem;
    }

    .cvd-type-nav {
        width: 30px;
        min-width: 30px;
    }

    .cvd-type-option {
        flex-basis: 184px;
        width: 184px;
    }
}

.cvd-range {
    width: 100%;
    height: 5px;
    accent-color: var(--cvd-accent);
    cursor: pointer;
}

.cvd-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: .4rem;
    color: #6f879b;
    font-size: .62rem;
}

.cvd-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: .55rem;
    margin-top: 1.15rem;
}

.cvd-actions .btn {
    min-height: 46px;
    padding: .62rem .8rem;
    border-radius: 9px;
    font-size: .75rem;
}

.cvd-auto-badge {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    align-content: center;
    column-gap: .6rem;
    min-height: 46px;
    min-width: 0;
    padding: .55rem .7rem;
    background: rgba(52, 211, 153, .07);
    border: 1px solid rgba(52, 211, 153, .18);
    border-radius: 9px;
}

.cvd-auto-badge > span {
    grid-row: 1 / 3;
    align-self: center;
    width: 9px;
    height: 9px;
    background: #34d399;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, .1), 0 0 12px rgba(52, 211, 153, .5);
}

.cvd-auto-badge strong {
    color: #b9f6dd;
    font-size: .7rem;
    line-height: 1.2;
}

.cvd-auto-badge small {
    color: #6f9d8d;
    font-size: .58rem;
    line-height: 1.25;
}

.cvd-actions .btn-primary,
.cvd-export .btn-primary {
    background: linear-gradient(135deg, var(--cvd-accent), var(--cvd-accent-strong));
    box-shadow: 0 6px 18px rgba(0, 174, 239, .22);
    color: #03111b;
}

.cvd-actions .btn-primary:hover,
.cvd-export .btn-primary:hover {
    box-shadow: 0 8px 24px rgba(0, 174, 239, .34);
}

.cvd-actions .btn-outline,
.cvd-export .btn-outline {
    background: rgba(255, 255, 255, .025);
    border: 1px solid var(--cvd-line);
    color: #b8c8d6;
}

.cvd-actions .btn-outline:hover,
.cvd-export .btn-outline:hover {
    background: var(--cvd-accent-soft);
    border-color: rgba(34, 199, 245, .35);
    color: #dff9ff;
}

.cvd-btn-icon { font-size: 1rem; }

.cvd-controls .tool-status {
    margin-top: .75rem;
    border-radius: 8px;
    font-size: .7rem;
}

/* ── Preview ── */
.cvd-preview {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: 0;
    width: 100%;
    padding: clamp(1rem, 2.2cqi, 1.35rem);
    background: linear-gradient(180deg, #0a1421, #08111d);
}

.cvd-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    flex-wrap: wrap;
}

.cvd-preview-head > div:first-child {
    min-width: 0;
    flex: 1 1 160px;
}

.cvd-preview-head h3 {
    margin: .2rem 0 0;
    color: #f1f9ff;
    font-size: clamp(.95rem, 2.4cqi, 1.05rem);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.cvd-view-tabs {
    display: flex;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    padding: 3px;
    background: #111e2e;
    border: 1px solid var(--cvd-line);
    border-radius: 9px;
}

.cvd-view-tabs button {
    flex: 1 1 auto;
    border: 0;
    padding: .44rem .68rem;
    background: transparent;
    border-radius: 6px;
    color: #7f95a8;
    font: 700 .67rem inherit;
    white-space: nowrap;
    cursor: pointer;
}

.cvd-view-tabs button.is-active {
    background: linear-gradient(135deg, #193044, #152738);
    color: #bdefff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, .25);
}

.cvd-stage {
    --image-ratio: 16 / 10;
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: var(--image-ratio);
    max-height: var(--cvd-stage-max);
    min-height: var(--cvd-stage-min);
    overflow: hidden;
    background-color: #07101b;
    background-image:
        linear-gradient(45deg, #0d1927 25%, transparent 25%),
        linear-gradient(-45deg, #0d1927 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #0d1927 75%),
        linear-gradient(-45deg, transparent 75%, #0d1927 75%);
    background-size: 22px 22px;
    background-position: 0 0, 0 11px, 11px -11px, -11px 0;
    border: 1px solid rgba(116, 185, 218, .2);
    border-radius: 13px;
    box-shadow: inset 0 0 45px rgba(0, 0, 0, .28);
}

.cvd-stage canvas,
.cvd-sim-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.cvd-stage canvas { display: block; }

.cvd-sim-layer canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cvd-sim-layer {
    clip-path: inset(0 0 0 50%);
    -webkit-clip-path: inset(0 0 0 50%);
}

.cvd-divider {
    position: absolute;
    z-index: 4;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: #d9f7ff;
    box-shadow: 0 0 12px rgba(0, 174, 239, .65);
    pointer-events: none;
    will-change: left;
}

.cvd-divider span {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, .85);
    border-radius: 50%;
    background: #092031;
    color: #bff3ff;
    box-shadow: 0 5px 18px rgba(0, 0, 0, .48);
    font-weight: 900;
    font-size: .95rem;
}

.cvd-compare-range {
    position: absolute;
    z-index: 5;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: ew-resize;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    touch-action: none;
    pointer-events: none;
}

.cvd-compare-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 1px;
    height: 1px;
    background: transparent;
    border: 0;
}

.cvd-compare-range::-moz-range-thumb {
    width: 1px;
    height: 1px;
    background: transparent;
    border: 0;
}

.cvd-stage:not(.is-empty)[data-view=compare] {
    cursor: ew-resize;
    user-select: none;
    touch-action: none;
}

.cvd-stage.is-dragging-compare .cvd-divider span {
    transform: translate(-50%, -50%) scale(1.08);
    border-color: #fff;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .55), 0 0 18px rgba(34, 199, 245, .35);
}

.cvd-stage-label {
    position: absolute;
    z-index: 3;
    top: .7rem;
    padding: .34rem .58rem;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 6px;
    background: rgba(3, 10, 18, .75);
    color: #e7f8ff;
    font-size: .62rem;
    font-weight: 800;
    backdrop-filter: blur(7px);
    pointer-events: none;
}

.cvd-label-left { left: .7rem; }
.cvd-label-right { right: .7rem; }

.cvd-empty-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem .65rem;
    margin: 0;
    padding: .65rem .85rem;
    background: rgba(34, 199, 245, .06);
    border: 1px dashed rgba(34, 199, 245, .22);
    border-radius: 10px;
    color: #9bb3c6;
    font-size: .72rem;
    line-height: 1.45;
}

.cvd-empty-hint strong {
    color: #dcebf6;
    font-size: .78rem;
    font-weight: 800;
}

.cvd-empty-hint[hidden] {
    display: none !important;
}

.cvd-stage.is-empty {
    aspect-ratio: 16 / 10;
}

.cvd-stage.is-empty canvas,
.cvd-stage.is-empty .cvd-sim-layer,
.cvd-stage.is-empty .cvd-divider,
.cvd-stage.is-empty .cvd-stage-label,
.cvd-stage.is-empty .cvd-compare-range {
    display: none;
}

.cvd-stage[data-view=original] .cvd-sim-layer,
.cvd-stage[data-view=original] .cvd-divider,
.cvd-stage[data-view=original] .cvd-compare-range,
.cvd-stage[data-view=original] .cvd-label-right {
    display: none;
}

.cvd-stage[data-view=simulated] .cvd-sim-layer {
    clip-path: none !important;
    -webkit-clip-path: none !important;
}

.cvd-stage[data-view=simulated] .cvd-divider,
.cvd-stage[data-view=simulated] .cvd-compare-range,
.cvd-stage[data-view=simulated] .cvd-label-left {
    display: none;
}

.cvd-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}

.cvd-meta div {
    min-width: 0;
    padding: .6rem .75rem;
    background: #0d1927;
    border: 1px solid var(--cvd-line);
    border-radius: 9px;
}

.cvd-meta span {
    display: block;
    color: #698196;
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.cvd-meta strong {
    display: block;
    margin-top: .15rem;
    color: #cfe4f2;
    font-size: .72rem;
    overflow-wrap: anywhere;
}

.cvd-export {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding-top: .8rem;
    border-top: 1px solid var(--cvd-line);
}

.cvd-export > span {
    flex: 1 1 auto;
    margin-right: auto;
    color: #8299ac;
    font-size: .7rem;
    font-weight: 700;
}

.cvd-export .btn {
    flex: 0 1 auto;
    min-height: 38px;
    padding: .52rem .7rem;
    border-radius: 8px;
    font-size: .68rem;
}

/* ── Guide ── */
.cvd-guide {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .8rem;
    margin-top: 1rem;
}

.cvd-guide > div {
    display: flex;
    gap: .8rem;
    min-width: 0;
    padding: 1rem;
    background: linear-gradient(145deg, #101b2b, #0b1421);
    border: 1px solid var(--cvd-line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
}

.cvd-guide-icon {
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(34, 199, 245, .15);
    border-radius: 9px;
    background: var(--cvd-accent-soft);
    color: var(--cvd-accent);
    font-size: .72rem;
    font-weight: 900;
}

.cvd-guide strong {
    color: #dcebf5;
    font-size: .75rem;
}

.cvd-guide p {
    margin: .25rem 0 0;
    color: #7e96a9;
    font-size: .66rem;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════
   Container queries — respond to widget width
   (works inside tool-layout / sidebars)
   ═══════════════════════════════════════════ */

/* Large tablet / narrow desktop column */
@container cvd (max-width: 920px) {
    .cvd-workspace {
        grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
    }

    .cvd-stage {
        --cvd-stage-max: min(48vh, 420px);
        --cvd-stage-min: 200px;
    }

    .cvd-export > span {
        flex-basis: 100%;
        margin-right: 0;
    }
}

/* Stack when the tool column can't fit a usable dual pane (typical tool-layout width) */
@container cvd (max-width: 860px) {
    .cvd-hero {
        flex-direction: column;
        gap: 1rem;
    }

    .cvd-privacy {
        align-self: stretch;
        max-width: none;
    }

    .cvd-workspace {
        grid-template-columns: 1fr;
    }

    .cvd-controls {
        border-right: 0;
        border-bottom: 1px solid var(--cvd-line);
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 1rem;
    }

    .cvd-controls > .cvd-upload,
    .cvd-controls > .cvd-quick-actions,
    .cvd-controls > .cvd-actions,
    .cvd-controls > .tool-status,
    .cvd-controls > .cvd-section {
        grid-column: 1 / -1;
    }

    .cvd-section { margin-top: 1rem; }

    .cvd-upload { min-height: 130px !important; }

    .cvd-preview {
        order: 0;
    }

    .cvd-stage {
        --cvd-stage-max: min(52vh, 480px);
        --cvd-stage-min: 240px;
        width: 100%;
        max-width: 100%;
        aspect-ratio: 16 / 10;
    }

    .cvd-preview-head {
        align-items: flex-start;
    }

    .cvd-view-tabs {
        width: auto;
        max-width: 100%;
    }

    .cvd-guide {
        grid-template-columns: 1fr;
    }
}

/* Phone / small tablet widths */
@container cvd (max-width: 540px) {
    .cvd-controls {
        display: block;
    }

    .cvd-preview-head {
        align-items: stretch;
        flex-direction: column;
    }

    .cvd-view-tabs {
        width: 100%;
    }

    .cvd-view-tabs button {
        flex: 1;
        min-width: 0;
        padding: .5rem .4rem;
        font-size: .64rem;
    }

    .cvd-stage,
    .cvd-stage.is-empty {
        --cvd-stage-max: min(48vh, 360px);
        --cvd-stage-min: 200px;
        aspect-ratio: 4 / 3;
        border-radius: 11px;
    }

    .cvd-meta {
        grid-template-columns: 1fr;
    }

    .cvd-export {
        flex-direction: column;
        align-items: stretch;
    }

    .cvd-export > span { margin: 0; }

    .cvd-export .btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .cvd-actions {
        grid-template-columns: 1fr auto;
    }

    .cvd-divider span {
        width: 32px;
        height: 32px;
    }

    .cvd-stage-label {
        top: .45rem;
        font-size: .58rem;
        padding: .28rem .48rem;
    }

    .cvd-label-left { left: .45rem; }
    .cvd-label-right { right: .45rem; }
}

/* Extra-narrow phones */
@container cvd (max-width: 380px) {
    .cvd-privacy {
        grid-template-columns: auto 1fr;
    }

    .cvd-quick-actions {
        grid-template-columns: 1fr;
    }

    .cvd-actions {
        grid-template-columns: 1fr;
    }

    .cvd-actions .btn {
        width: 100%;
    }

    .cvd-stage,
    .cvd-stage.is-empty {
        --cvd-stage-min: 180px;
        --cvd-stage-max: min(42vh, 300px);
    }

    .cvd-guide > div {
        padding: .85rem;
    }
}

/* Wide desktop — give the comparison stage more room */
@container cvd (min-width: 1100px) {
    .cvd-workspace {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    }

    .cvd-stage {
        --cvd-stage-max: min(62vh, 560px);
        --cvd-stage-min: 320px;
    }
}

/* ═══════════════════════════════════════════
   Viewport fallbacks (browsers without @container)
   ═══════════════════════════════════════════ */
@supports not (container-type: inline-size) {
    @media (max-width: 1180px) {
        .cvd-workspace { grid-template-columns: minmax(245px, 290px) minmax(0, 1fr); }
        .cvd-export { flex-wrap: wrap; }
        .cvd-export > span { flex-basis: 100%; }
        .cvd-stage { min-height: 280px; }
    }

    @media (max-width: 900px) {
        .cvd-workspace { grid-template-columns: 1fr; }
        .cvd-controls {
            border-right: 0;
            border-bottom: 1px solid var(--cvd-line);
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0 1rem;
        }
        .cvd-controls > .cvd-upload,
        .cvd-controls > .cvd-quick-actions,
        .cvd-controls > .cvd-actions,
        .cvd-controls > .tool-status { grid-column: 1 / -1; }
        .cvd-upload { min-height: 135px !important; }
        .cvd-guide { grid-template-columns: 1fr; }
        .cvd-hero { flex-direction: column; gap: 1.25rem; }
        .cvd-privacy { align-self: stretch; max-width: none; }
        .cvd-stage { min-height: 260px; }
        .cvd-section { margin-top: 1rem; }
    }

    @media (max-width: 640px) {
        .cvd-controls { display: block; }
        .cvd-hero,
        .cvd-controls,
        .cvd-preview { padding: 1rem; }
        .cvd-preview-head { align-items: flex-start; flex-direction: column; }
        .cvd-view-tabs { width: 100%; }
        .cvd-view-tabs button { flex: 1; min-width: 78px; }
        .cvd-meta { grid-template-columns: 1fr; }
        .cvd-export { align-items: stretch; flex-direction: column; }
        .cvd-export > span { margin: 0; }
        .cvd-export .btn { width: 100%; min-height: 44px; justify-content: center; }
        .cvd-stage,
        .cvd-stage.is-empty { min-height: 220px; aspect-ratio: 4 / 3; }
        .cvd-actions { grid-template-columns: 1fr auto; }
    }

    @media (max-width: 390px) {
        .cvd-hero h2 { font-size: 1.25rem; }
        .cvd-hero p { font-size: .78rem; }
        .cvd-privacy { grid-template-columns: auto 1fr; }
        .cvd-quick-actions { grid-template-columns: 1fr; }
        .cvd-actions { grid-template-columns: 1fr; }
        .cvd-actions .btn { width: 100%; }
        .cvd-stage,
        .cvd-stage.is-empty { min-height: 195px; }
        .cvd-stage-label { top: .45rem; }
        .cvd-label-left { left: .45rem; }
        .cvd-label-right { right: .45rem; }
        .cvd-meta div { padding: .55rem .65rem; }
    }
}

/* Short landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .cvd-hero { padding: 1rem; }
    .cvd-stage,
    .cvd-stage.is-empty {
        --cvd-stage-min: 180px;
        --cvd-stage-max: 70vh;
        min-height: 180px;
        max-height: 70vh;
    }
    .cvd-preview { padding: 1rem; }
}

/* Touch targets */
@media (hover: none) and (pointer: coarse) {
    .cvd-quick-actions button,
    .cvd-view-tabs button,
    .cvd-export .btn,
    .cvd-actions .btn {
        min-height: 44px;
    }

    .cvd-range { height: 24px; }
    .cvd-compare-range { touch-action: none; }
    .cvd-divider span {
        width: 40px;
        height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cvd-tool * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

.cvd-review-actions {
    margin-top: 1rem;
    padding: .85rem 1rem;
    border: 1px solid var(--cvd-line);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--cvd-panel-soft), rgba(34, 199, 245, .08));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cvd-review-actions > div { display: grid; gap: .18rem; }
.cvd-review-actions strong { color: var(--cvd-ink); font-size: .84rem; }
.cvd-review-actions span { color: var(--cvd-muted); font-size: .72rem; }

.cvd-overview {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--cvd-line);
    border-radius: 14px;
    background: var(--cvd-panel);
}

.cvd-overview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cvd-overview-head h4 { margin: .15rem 0 0; color: var(--cvd-ink); font-size: 1rem; }
.cvd-overview > p { margin: .55rem 0 1rem; color: var(--cvd-muted); font-size: .73rem; }
.cvd-overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }

.cvd-overview-card {
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--cvd-line);
    border-radius: 11px;
    background: var(--cvd-panel-soft);
    color: var(--cvd-ink);
    text-align: left;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.cvd-overview-card:hover,
.cvd-overview-card:focus-visible {
    border-color: var(--cvd-accent);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .13);
    transform: translateY(-2px);
}

.cvd-overview-card canvas { display: block; width: 100%; height: auto; background: #e2e8f0; }
.cvd-overview-card > span { display: grid; gap: .1rem; padding: .65rem .75rem; }
.cvd-overview-card strong { font-size: .78rem; }
.cvd-overview-card small { color: var(--cvd-muted); font-size: .64rem; }

@container cvd (max-width: 540px) {
    .cvd-review-actions,
    .cvd-overview-head { align-items: stretch; flex-direction: column; }
    .cvd-review-actions .btn,
    .cvd-overview-head .btn { width: 100%; justify-content: center; }
    .cvd-overview-grid { grid-template-columns: 1fr; }
}
