.frame-visualizer {
    position: relative;
    z-index: 2;
    isolation: isolate;
    clear: both;
    width: 100%;
    max-width: var(--preview-max-width);
    margin: 1.5rem auto;
    box-sizing: border-box;
}

.frame-visualizer,
.frame-visualizer * {
    box-sizing: border-box;
}

.frame-visualizer h2 {
    margin: 0 0 1rem;
}

.frame-visualizer-tabs,
.frame-scene-options {
    position: relative;
    z-index: 20;
    display: flex;
    gap: .55rem;
    max-width: 100%;
    margin: 0 0 1rem;
    padding: .15rem 0 .45rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

.frame-visualizer-tabs {
    min-height: 48px;
    background: #fff;
}

.frame-visualizer-panel {
    position: relative;
    z-index: 1;
    clear: both;
}

.frame-visualizer-tab,
.frame-scene-option {
    flex: 0 0 auto;
    padding: .65rem 1rem;
    border: 1px solid #c9c9c9;
    border-radius: 999px;
    background: #fff;
    color: inherit;
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
}

.frame-visualizer-tab.selected,
.frame-scene-option.selected {
    border-color: #2271b1;
    background: #2271b1;
    color: #fff;
}

.frame-visualizer-tab:focus-visible,
.frame-scene-option:focus-visible {
    outline: 3px solid rgba(34, 113, 177, .35);
    outline-offset: 2px;
}

.frame-visualizer-panel[hidden] {
    display: none !important;
}

.fv-render-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 300px;
    overflow: hidden;
}

.fv-product-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.fv-render-fallback {
    display: block;
    max-width: 100%;
    max-height: var(--preview-max-height);
    object-fit: contain;
}

.fv-render-loading {
    position: absolute;
    inset: auto 1rem 1rem;
    padding: .55rem .75rem;
    border-radius: .25rem;
    background: rgba(255,255,255,.92);
    color: #8a1f11;
    text-align: center;
}

.fv-room-stage {
    position: relative;
    width: 100%;
    min-height: 260px;
    overflow: hidden;
    background: #ececec;
}

.fv-room-background,
.fv-room-foreground {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.fv-room-background { z-index: 1; }
.fv-room-product-canvas {
    position: absolute;
    z-index: 2;
    transform-origin: center;
    pointer-events: none;
}
.fv-room-foreground { z-index: 3; pointer-events: none; }
.fv-room-stage .fv-render-loading { z-index: 4; }

.frame-preview {
    display: grid;
    place-items: center;
    width: 100%;
    max-height: var(--preview-max-height);
    margin: auto;
}

.frame-border,
.frame-scene-frame {
    position: relative;
    max-width: 100%;
    padding: var(--frame-width, 22px);
    background: var(--frame-color, #111);
    border-image: var(--frame-border-image) 30 fill stretch;
}

.frame-border {
    box-shadow: var(--frame-shadow, 0 12px 28px rgba(0, 0, 0, .22));
}

.frame-mat,
.frame-scene-mat {
    position: relative;
    max-width: 100%;
    padding: var(--mat-width, 28px);
    background: var(--mat-color, #f4f0e8);
}

.frame-product-image {
    display: block;
    max-width: 100%;
    max-height: calc(var(--preview-max-height) - 100px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.frame-overlay,
.frame-scene-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

.frame-scene-preview {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    background: #ececec;
}

.frame-scene-background {
    display: block;
    width: 100%;
    height: auto;
}

.frame-scene-artwork {
    position: absolute;
    left: var(--scene-left, 40%);
    top: var(--scene-top, 20%);
    width: var(--scene-width, 25%);
    height: var(--scene-height, 45%);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: var(--scene-transform, none);
    transform-origin: center;
    filter: drop-shadow(var(--scene-shadow, 0 8px 18px rgba(0, 0, 0, .28)));
    pointer-events: none;
}

.frame-scene-frame,
.frame-scene-mat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}

.frame-scene-product-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

@media (max-width: 600px) {
    .frame-visualizer {
        margin-block: 1rem;
        overflow: hidden;
    }

    .frame-border {
        padding: calc(var(--frame-width, 22px) * .6);
    }

    .frame-mat {
        padding: calc(var(--mat-width, 28px) * .6);
    }

    .frame-visualizer-tab,
    .frame-scene-option {
        padding: .55rem .8rem;
    }
}
