/* =====================================================================================
   «قاب و پیش‌نمایش در اتاق» — room-preview configurator (only loaded on that page).
   Phones: the stage fills the screen above a compact panel (tabs + one row of cards +
   price bar). Wide screens: stage and a scrolling options column side by side.
   Scene geometry is in photo pixels (the JS sets --f frame, --m mat, --d depth and
   --u = one centimetre on the wall); overlays are in screen pixels.
   ===================================================================================== */

.page-configure .site-footer .footer-features {
    display: none;
}

.cfg {
    --cfg-ink: #0D0D0D;
    --cfg-pill: rgba(250, 246, 240, 0.86);
    --cfg-guide: rgba(13, 13, 13, 0.78);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    height: calc(100svh - var(--header-h));
    min-height: 540px;
}

.cfg > * {
    min-width: 0;
}

[data-theme="dark"] .cfg {
    --cfg-pill: rgba(23, 24, 28, 0.84);
}

/* ---- Stage --------------------------------------------------------------------------- */

.cfg__stage {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.cfg__note {
    display: none;
}

.cfg-stage {
    position: relative;
    flex: 1;
    min-height: 260px;
    overflow: hidden;
    isolation: isolate;
    direction: ltr;
    background: var(--room-tone, #CFC6BA);
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Beyond the photo (the whole-wall view of a wide wall): the room, softly blurred. */
.cfg-stage::before {
    content: "";
    position: absolute;
    inset: -60px;
    z-index: -1;
    background: var(--room-image, none) center / cover no-repeat;
    filter: blur(30px) saturate(0.9) brightness(0.9);
    opacity: 0.85;
}

.cfg-scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 2048px;
    height: 2048px;
    transform-origin: 0 0;
}

.cfg-scene__room {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: opacity 0.45s var(--ease);
    -webkit-user-drag: none;
}

.cfg-stage.is-switching .cfg-scene__room {
    opacity: 0.25;
}

/* A wall taller than the photographed one (whole-wall view): the clean wall under the photo's
   ceiling, stretched up to the customer's ceiling and faded into the real wall at the bottom. */
.cfg-scene__rise {
    position: absolute;
    top: 0;
    left: 0;
    width: 2048px;
    height: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease);
    -webkit-mask-image: linear-gradient(to top, transparent, #000 40px);
    mask-image: linear-gradient(to top, transparent, #000 40px);
}

.cfg-stage[data-view="wall"] .cfg-scene__rise.is-on {
    opacity: 1;
}

/* The customer's wall (whole-wall view): everything outside it is dimmed. */
.cfg-scene__wall {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    outline: calc(2px * var(--iz, 1)) dashed rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 6000px rgba(16, 12, 8, 0.52);
    transition: opacity 0.4s var(--ease);
}

.cfg-stage[data-view="wall"] .cfg-scene__wall {
    opacity: 1;
}

/* ---- The framed piece (scene pixels) ------------------------------------------------- */

.cfg-piece {
    --frame-color: #1C1C1C;
    --mat-color: #FFFFFF;
    --f: 0px;
    --m: 0px;
    --d: 2px;
    --u: 4px;
    position: absolute;
    perspective: calc(var(--u) * 260);
    touch-action: none;
    cursor: grab;
}

.cfg-stage.is-dragging .cfg-piece {
    cursor: grabbing;
}

.cfg-piece__shadow {
    position: absolute;
    inset: 0;
    z-index: 0;
    transform: translate(var(--sx, 0px), var(--sy, 0px));
    background: rgba(34, 22, 10, 0.36);
    filter: blur(calc(var(--u) * 1.3));
    pointer-events: none;
}

/* A wider, fainter ambient shadow under the contact shadow. */
.cfg-piece__shadow::after {
    content: "";
    position: absolute;
    inset: calc(var(--u) * -1);
    background: rgba(34, 22, 10, 0.18);
    filter: blur(calc(var(--u) * 5));
    transform: translate(calc(var(--u) * 1.2), calc(var(--u) * 3));
}

.cfg-piece[data-finish="none"] .cfg-piece__shadow {
    background: rgba(34, 22, 10, 0.24);
    filter: blur(calc(var(--u) * 0.7));
}

.cfg-piece__body {
    position: absolute;
    inset: 0;
    z-index: 1;
    transform-style: preserve-3d;
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}

/* Depth: the moulding's outer faces, folded back toward the wall. */
.cfg-side {
    position: absolute;
    background: color-mix(in srgb, var(--frame-color) 72%, #000);
    backface-visibility: hidden;
}

.cfg-side--top {
    top: 0;
    left: 0;
    width: 100%;
    height: var(--d);
    transform-origin: 50% 0;
    transform: rotateX(90deg);
    background: color-mix(in srgb, var(--frame-color) 88%, #fff);
}

.cfg-side--bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--d);
    transform-origin: 50% 100%;
    transform: rotateX(-90deg);
}

.cfg-side--left {
    top: 0;
    left: 0;
    width: var(--d);
    height: 100%;
    transform-origin: 0 50%;
    transform: rotateY(-90deg);
    background: color-mix(in srgb, var(--frame-color) 85%, #fff);
}

.cfg-side--right {
    top: 0;
    right: 0;
    width: var(--d);
    height: 100%;
    transform-origin: 100% 50%;
    transform: rotateY(90deg);
}

.cfg-piece[data-finish="none"] .cfg-side {
    background: #E9E4DA;
}

.cfg-front {
    position: absolute;
    inset: 0;
}

/* Mitred moulding: four trapezoids, lit from the window side. */
.cfg-moulding {
    position: absolute;
    inset: 0;
    background-color: var(--frame-color);
    transition: background-color 0.35s;
}

.cfg-piece[data-finish="none"] .cfg-moulding {
    display: none;
}

.cfg-moulding--top {
    clip-path: polygon(0 0, 100% 0, calc(100% - var(--f)) var(--f), var(--f) var(--f));
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0, rgba(255, 255, 255, 0.05) calc(var(--f) * 0.5), rgba(0, 0, 0, 0.16) var(--f), transparent var(--f));
}

.cfg-moulding--bottom {
    clip-path: polygon(var(--f) calc(100% - var(--f)), calc(100% - var(--f)) calc(100% - var(--f)), 100% 100%, 0 100%);
    background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.32) 0, rgba(0, 0, 0, 0.16) calc(var(--f) * 0.55), rgba(255, 255, 255, 0.05) var(--f), transparent var(--f));
}

.cfg-moulding--left {
    clip-path: polygon(0 0, var(--f) var(--f), var(--f) calc(100% - var(--f)), 0 100%);
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0, rgba(255, 255, 255, 0.03) calc(var(--f) * 0.5), rgba(0, 0, 0, 0.12) var(--f), transparent var(--f));
}

.cfg-moulding--right {
    clip-path: polygon(100% 0, 100% 100%, calc(100% - var(--f)) calc(100% - var(--f)), calc(100% - var(--f)) var(--f));
    background-image: linear-gradient(270deg, rgba(0, 0, 0, 0.26) 0, rgba(0, 0, 0, 0.12) calc(var(--f) * 0.5), rgba(255, 255, 255, 0.04) var(--f), transparent var(--f));
}

.cfg-piece[data-finish="metallic"] .cfg-moulding--top {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0, rgba(255, 255, 255, 0.12) calc(var(--f) * 0.35), rgba(0, 0, 0, 0.2) calc(var(--f) * 0.7), rgba(255, 255, 255, 0.32) var(--f), transparent var(--f));
}

.cfg-piece[data-finish="metallic"] .cfg-moulding--bottom {
    background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.36) 0, rgba(255, 255, 255, 0.18) calc(var(--f) * 0.4), rgba(0, 0, 0, 0.12) calc(var(--f) * 0.75), rgba(255, 255, 255, 0.2) var(--f), transparent var(--f));
}

.cfg-piece[data-finish="metallic"] .cfg-moulding--left {
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0, rgba(255, 255, 255, 0.1) calc(var(--f) * 0.4), rgba(0, 0, 0, 0.16) calc(var(--f) * 0.75), rgba(255, 255, 255, 0.24) var(--f), transparent var(--f));
}

.cfg-piece[data-finish="metallic"] .cfg-moulding--right {
    background-image: linear-gradient(270deg, rgba(0, 0, 0, 0.32) 0, rgba(255, 255, 255, 0.16) calc(var(--f) * 0.4), rgba(0, 0, 0, 0.1) calc(var(--f) * 0.75), rgba(255, 255, 255, 0.18) var(--f), transparent var(--f));
}

.cfg-piece[data-finish="woodgrain"] .cfg-moulding--top,
.cfg-piece[data-finish="woodgrain"] .cfg-moulding--bottom {
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0, rgba(0, 0, 0, 0.1) var(--f), transparent var(--f)),
        repeating-linear-gradient(178.5deg, rgba(0, 0, 0, 0.12) 0 calc(var(--u) * 0.07), transparent calc(var(--u) * 0.07) calc(var(--u) * 0.3), rgba(255, 255, 255, 0.07) calc(var(--u) * 0.3) calc(var(--u) * 0.36), transparent calc(var(--u) * 0.36) calc(var(--u) * 0.7));
}

.cfg-piece[data-finish="woodgrain"] .cfg-moulding--bottom {
    filter: brightness(0.8);
}

.cfg-piece[data-finish="woodgrain"] .cfg-moulding--left,
.cfg-piece[data-finish="woodgrain"] .cfg-moulding--right {
    background-image:
        linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0, rgba(0, 0, 0, 0.1) var(--f), transparent var(--f)),
        repeating-linear-gradient(88.5deg, rgba(0, 0, 0, 0.12) 0 calc(var(--u) * 0.07), transparent calc(var(--u) * 0.07) calc(var(--u) * 0.3), rgba(255, 255, 255, 0.07) calc(var(--u) * 0.3) calc(var(--u) * 0.36), transparent calc(var(--u) * 0.36) calc(var(--u) * 0.7));
}

.cfg-piece[data-finish="woodgrain"] .cfg-moulding--right {
    filter: brightness(0.86);
}

/* Paper border / passe-partout, then the picture itself. */
.cfg-mat {
    position: absolute;
    inset: var(--f);
    padding: var(--m);
    background: var(--mat-color);
    transition: background-color 0.35s;
}

.cfg-piece[data-mat="none"] .cfg-mat {
    background: transparent;
}

.cfg-piece[data-mat="print_border"] .cfg-mat {
    background:
        radial-gradient(120% 80% at 30% 20%, rgba(255, 255, 255, 0.5), transparent 60%),
        var(--mat-color);
}

/* The moulding casts a soft shadow onto whatever sits under it. */
.cfg-mat::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset calc(var(--u) * 0.18) calc(var(--u) * 0.28) calc(var(--u) * 0.55) rgba(0, 0, 0, 0.32);
}

.cfg-piece[data-finish="none"] .cfg-mat::after {
    box-shadow: none;
}

.cfg-art {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #D7CFC3;
}

.cfg-art.has-lqip {
    background: var(--lqip) center / cover no-repeat, #D7CFC3;
}

.cfg-art__canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s var(--ease) 0.1s;
}

.cfg-art.is-ready .cfg-art__canvas {
    opacity: 1;
}

/* Passe-partout: a white bevel round the window and the board's own small shadow on the print. */
.cfg-piece[data-mat="passepartout"] .cfg-art {
    box-shadow: 0 0 0 calc(var(--u) * 0.22) #FCFBF7, 0 0 0 calc(var(--u) * 0.27) rgba(0, 0, 0, 0.1);
}

.cfg-art::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.cfg-piece[data-mat="passepartout"] .cfg-art::after {
    box-shadow: inset calc(var(--u) * 0.1) calc(var(--u) * 0.16) calc(var(--u) * 0.32) rgba(0, 0, 0, 0.3);
}

/* Glazing: a moving glare band and a faint sheen; anti-reflective glass keeps a whisper of it. */
.cfg-glass {
    position: absolute;
    inset: var(--f);
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s;
}

.cfg-piece[data-glazing="acrylic"] .cfg-glass,
.cfg-piece[data-glazing="glass"] .cfg-glass {
    opacity: 1;
}

.cfg-piece[data-glazing="anti_reflective"] .cfg-glass {
    opacity: 0.28;
}

.cfg-glass::before {
    content: "";
    position: absolute;
    top: -30%;
    bottom: -30%;
    left: -80%;
    width: 160%;
    background: linear-gradient(112deg, transparent 40%, rgba(255, 255, 255, 0.28) 47%, rgba(255, 255, 255, 0.08) 52%, transparent 58%);
    transform: translateX(calc(var(--gx, 50%) - 50%));
}

.cfg-glass::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(152deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 28%, transparent 52%),
        linear-gradient(330deg, rgba(255, 255, 255, 0.06), transparent 40%);
}

.cfg-piece[data-glazing="glass"] .cfg-glass {
    box-shadow: inset 0 0 0 calc(var(--u) * 0.16) rgba(150, 196, 178, 0.35);
}

/* Gallery light: a brass picture light and its warm beam (night mode). */
.cfg-piece__beam {
    position: absolute;
    left: -40%;
    right: -40%;
    top: calc(var(--u) * -12);
    height: 100%;
    z-index: 2;
    background: radial-gradient(ellipse 46% 72% at 50% 0%, rgba(255, 228, 172, 0.55), rgba(255, 214, 150, 0.16) 46%, transparent 74%);
    mix-blend-mode: screen;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s var(--ease);
}

.cfg-piece__lamp {
    position: absolute;
    left: 50%;
    top: calc(var(--u) * -8);
    z-index: 3;
    width: min(48%, calc(var(--u) * 44));
    height: calc(var(--u) * 3.2);
    translate: -50% 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #F6E0AC 0%, #CFA154 45%, #8C6425 100%);
    box-shadow: 0 calc(var(--u) * 0.6) calc(var(--u) * 1.4) rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.cfg-piece__lamp::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 62%;
    height: 90%;
    background: radial-gradient(ellipse at 50% 0, rgba(255, 244, 210, 0.95), transparent 70%);
}

.cfg-piece__lamp-arm {
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: calc(var(--u) * 0.7);
    height: calc(var(--u) * 5);
    translate: -50% 0;
    background: linear-gradient(90deg, #8C6425, #E8C67F, #8C6425);
}

.cfg-piece__lamp-arm::before {
    content: "";
    position: absolute;
    left: 50%;
    top: calc(var(--u) * -1.2);
    width: calc(var(--u) * 4);
    height: calc(var(--u) * 1.6);
    translate: -50% 0;
    border-radius: calc(var(--u) * 0.4);
    background: linear-gradient(180deg, #ECCD8D, #9A7231);
}

.cfg-stage[data-night="1"] .cfg-piece__beam,
.cfg-stage[data-night="1"] .cfg-piece__lamp {
    opacity: 1;
}

.cfg-stage__night {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s var(--ease);
    background: radial-gradient(circle var(--lr, 220px) at var(--lx, 50%) var(--ly, 40%), rgba(255, 208, 140, 0.06) 0%, rgba(14, 10, 16, 0.36) 58%, rgba(7, 5, 9, 0.76) 100%);
}

.cfg-stage[data-night="1"] .cfg-stage__night {
    opacity: 1;
}

/* ---- Screen-space overlays ---------------------------------------------------------- */

.cfg-guides {
    position: absolute;
    inset: 0;
    direction: rtl;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.cfg-stage[data-guides="1"].is-ready .cfg-guides {
    opacity: 1;
}

.cfg-guide {
    position: absolute;
    display: none;
    color: var(--cfg-guide);
    filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.85));
}

.cfg-stage[data-view="room"] .cfg-guide--w,
.cfg-stage[data-view="room"] .cfg-guide--h,
.cfg-stage[data-view="room"] .cfg-guide--floor,
.cfg-stage[data-view="closeup"] .cfg-guide--w,
.cfg-stage[data-view="closeup"] .cfg-guide--h,
.cfg-stage[data-view="wall"] .cfg-guide--wallw,
.cfg-stage[data-view="wall"] .cfg-guide--wallh,
.cfg-stage[data-view="wall"] .cfg-guide--floor {
    display: block;
}

.cfg-stage.is-dragging .cfg-guide--w,
.cfg-stage.is-dragging .cfg-guide--h {
    display: none;
}

.cfg-guide--w,
.cfg-guide--wallw {
    border-top: 1.5px solid currentColor;
}

.cfg-guide--h,
.cfg-guide--floor,
.cfg-guide--wallh {
    border-left: 1.5px solid currentColor;
}

.cfg-guide--floor {
    border-left-style: dashed;
}

.cfg-guide::before,
.cfg-guide::after {
    content: "";
    position: absolute;
    background: currentColor;
}

.cfg-guide--w::before,
.cfg-guide--w::after,
.cfg-guide--wallw::before,
.cfg-guide--wallw::after {
    top: -5px;
    width: 1.5px;
    height: 9px;
}

.cfg-guide--w::before,
.cfg-guide--wallw::before {
    left: 0;
}

.cfg-guide--w::after,
.cfg-guide--wallw::after {
    right: 0;
}

.cfg-guide--h::before,
.cfg-guide--h::after,
.cfg-guide--floor::before,
.cfg-guide--floor::after,
.cfg-guide--wallh::before,
.cfg-guide--wallh::after {
    left: -5px;
    width: 9px;
    height: 1.5px;
}

.cfg-guide--h::before,
.cfg-guide--floor::before,
.cfg-guide--wallh::before {
    top: 0;
}

.cfg-guide--h::after,
.cfg-guide--floor::after,
.cfg-guide--wallh::after {
    bottom: 0;
}

.cfg-guide__label {
    position: absolute;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(13, 13, 13, 0.72);
    color: #FAF6F0;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.cfg-guide--w .cfg-guide__label,
.cfg-guide--wallw .cfg-guide__label {
    left: 50%;
    top: 0;
    transform: translate(-50%, calc(-100% - 6px));
}

.cfg-guide--wallw .cfg-guide__label,
.cfg-guide--w.is-below .cfg-guide__label {
    transform: translate(-50%, 6px);
}

.cfg-guide--h .cfg-guide__label,
.cfg-guide--wallh .cfg-guide__label {
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
}

/* Near the top of the line: the floor itself is often under the panel on phones. */
.cfg-guide--floor .cfg-guide__label {
    top: min(50%, 36px);
    left: 8px;
    transform: translateY(-50%);
}

.cfg-guide--h.is-flipped .cfg-guide__label {
    left: auto;
    right: 8px;
}

.cfg-stage__top {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    direction: rtl;
    pointer-events: none;
}

.cfg-back,
.cfg-stage__title {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 13px;
    border-radius: 999px;
    background: var(--cfg-pill);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.cfg-stage__title {
    font-size: 14px;
    font-weight: 800;
}

.cfg-back__icon {
    transform: scaleX(-1);
}

.cfg-stage__hint {
    position: absolute;
    bottom: 58px;
    left: 50%;
    max-width: calc(100% - 32px);
    margin: 0;
    padding: 6px 13px;
    border-radius: 999px;
    background: rgba(13, 13, 13, 0.72);
    color: #FAF6F0;
    direction: rtl;
    font-size: 12.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 6px);
    transition: opacity 0.35s, transform 0.35s var(--ease);
}

.cfg-stage__hint.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.cfg-stage__loading {
    position: absolute;
    left: 50%;
    bottom: 64px;
    margin: 0;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--cfg-pill);
    direction: rtl;
    font-size: 12px;
    transform: translateX(-50%);
    transition: opacity 0.4s;
}

.cfg-stage.is-ready .cfg-stage__loading {
    opacity: 0;
    pointer-events: none;
}

.cfg-stage__tools {
    position: absolute;
    left: 50%;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: calc(100% - 20px);
    padding: 4px;
    border-radius: 999px;
    background: var(--cfg-pill);
    box-shadow: var(--shadow-sm);
    direction: rtl;
    transform: translateX(-50%);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.cfg-views {
    display: flex;
    gap: 2px;
}

.cfg-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.cfg-tool--icon {
    width: 36px;
    padding: 0;
}

.cfg-tool[aria-pressed="true"] {
    background: var(--text);
    color: var(--bg);
}

.cfg-stage[data-night="1"] .cfg-tool[data-cfg-light] {
    background: var(--gold);
    color: var(--cfg-ink);
}

@media (max-width: 440px) {
    .cfg-tool:not([aria-pressed="true"]) span:not(.visually-hidden) {
        display: none;
    }

    .cfg-tool {
        padding: 0 10px;
    }
}

/* ---- Panel (phones: tabs, one row of cards, price bar) -------------------------------- */

.cfg__panel {
    position: relative;
    z-index: 2;
    border-top: 1px solid var(--line);
    background: var(--bg);
    box-shadow: 0 -12px 30px rgba(44, 32, 14, 0.08);
}

.cfg-form {
    display: flex;
    flex-direction: column;
}

.cfg-tabs {
    display: flex;
    gap: 2px;
    padding: 4px 8px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.cfg-tabs::-webkit-scrollbar {
    display: none;
}

.cfg-tab {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 56px;
    padding: 7px 8px 8px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.cfg-tab[aria-selected="true"] {
    border-bottom-color: var(--gold);
    color: var(--text);
}

.cfg-sections {
    padding: 10px 14px 2px;
}

.cfg-section {
    display: none;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.cfg-sections[data-active="frame"] [data-cfg-section="frame"],
.cfg-sections[data-active="mat"] [data-cfg-section="mat"],
.cfg-sections[data-active="glass"] [data-cfg-section="glass"],
.cfg-sections[data-active="size"] [data-cfg-section="size"],
.cfg-sections[data-active="pieces"] [data-cfg-section="pieces"],
.cfg-sections[data-active="room"] [data-cfg-section="room"],
.cfg-sections[data-active="wall"] [data-cfg-section="wall"] {
    display: block;
}

.cfg-section__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.cfg-options {
    display: flex;
    gap: 9px;
    padding: 2px 2px 8px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}

.cfg-options::-webkit-scrollbar {
    display: none;
}

.cfg-option {
    position: relative;
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.cfg-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cfg-option__card {
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 5px;
    width: 98px;
    min-height: 122px;
    padding: 10px 6px 8px;
    border: 1.5px solid transparent;
    border-radius: 14px;
    background: var(--bg-elev);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.cfg-option input:checked + .cfg-option__card {
    border-color: var(--text);
    background: var(--bg);
    box-shadow: var(--shadow-sm);
}

.cfg-option input:focus-visible + .cfg-option__card {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

.cfg-option.is-disabled .cfg-option__card {
    opacity: 0.42;
    cursor: not-allowed;
}

.cfg-option__name {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.55;
}

.cfg-option__meta {
    margin-top: -3px;
    color: var(--muted);
    font-size: 11px;
}

.cfg-option__price {
    color: var(--text-2);
    font-size: 11.5px;
}

.cfg-section__hint,
.cfg-fit {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

.cfg-section__hint:empty {
    display: none;
}

/* Card swatches (CSS-drawn) */
.cfg-swatch {
    --frame-color: #1C1C1C;
    --mat-color: #F6F4EF;
    position: relative;
    display: block;
    width: 38px;
    aspect-ratio: 2 / 3;
    padding: 4px;
    background: var(--frame-color);
    box-shadow: var(--shadow-sm);
}

.cfg-swatch__art {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--ambient) 0%, color-mix(in srgb, var(--ambient) 40%, #FAF6F0) 100%);
}

.cfg-swatch[data-finish="metallic"] {
    background: linear-gradient(135deg, color-mix(in srgb, var(--frame-color) 55%, #fff) 0%, var(--frame-color) 30%, color-mix(in srgb, var(--frame-color) 70%, #000) 55%, var(--frame-color) 75%, color-mix(in srgb, var(--frame-color) 50%, #fff) 100%);
}

.cfg-swatch[data-finish="woodgrain"] {
    background: repeating-linear-gradient(97deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 4px, rgba(255, 255, 255, 0.06) 4px 5px, transparent 5px 9px), var(--frame-color);
}

.cfg-swatch[data-finish="none"] {
    padding: 2px;
    background: #FFFFFF;
}

.cfg-swatch[data-mat="print_border"] .cfg-swatch__art,
.cfg-swatch[data-mat="passepartout"] .cfg-swatch__art {
    border: 5px solid var(--mat-color);
}

.cfg-swatch[data-mat="passepartout"] .cfg-swatch__art {
    box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.18);
}

.cfg-swatch[data-glazing]:not([data-glazing="none"])::after {
    content: "";
    position: absolute;
    inset: 4px;
    background: linear-gradient(120deg, transparent 25%, rgba(255, 255, 255, 0.6) 42%, rgba(255, 255, 255, 0.12) 50%, transparent 62%);
}

.cfg-swatch[data-glazing="anti_reflective"]::after {
    opacity: 0.3;
}

.cfg-size-shape {
    display: block;
    width: calc(var(--w) * 0.55px);
    height: calc(var(--h) * 0.55px);
    margin-block: auto;
    border: 2px solid var(--text);
    background: linear-gradient(135deg, var(--ambient), color-mix(in srgb, var(--ambient) 40%, #FAF6F0));
}

.cfg-options--sizes .cfg-option__card {
    align-content: end;
    width: 84px;
}

.cfg-option--room .cfg-option__card {
    width: 112px;
    min-height: 0;
    padding: 6px 6px 8px;
}

.cfg-room-thumb {
    display: block;
    width: 98px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
}

/* Wall size */
.cfg-ranges {
    display: grid;
    gap: 6px;
}

.cfg-range {
    display: grid;
    gap: 2px;
}

.cfg-range__label {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 700;
}

.cfg-range__value {
    color: var(--text-2);
    font-weight: 800;
}

.cfg-range input {
    width: 100%;
    accent-color: var(--gold);
}

.cfg-fit {
    margin-top: 6px;
    color: var(--text-2);
}

.cfg-suggest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    font-size: 12.5px;
}

.cfg-suggest[hidden] {
    display: none;
}

.cfg-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

/* Price bar */
.cfg-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
}

.cfg-ai {
    display: flex;
    flex-basis: 100%;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
}

.cfg-ai > span {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.cfg-ai__note {
    flex-basis: 100%;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.7;
}

.cfg-bar__details {
    position: relative;
    flex: 1;
    min-width: 0;
}

.cfg-bar__summary {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    column-gap: 8px;
    list-style: none;
    cursor: pointer;
}

.cfg-bar__summary::-webkit-details-marker {
    display: none;
}

.cfg-bar__label {
    color: var(--muted);
    font-size: 11.5px;
}

.cfg-bar__total {
    font-size: 18px;
    font-weight: 900;
    white-space: nowrap;
}

.cfg-bar__more {
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
}

.cfg-bar__details[open] .cfg-bar__more .icon {
    transform: rotate(180deg);
}

.cfg-bar__lines {
    position: absolute;
    bottom: calc(100% + 14px);
    inset-inline-start: -4px;
    z-index: 5;
    width: min(330px, calc(100vw - 28px));
    margin: 0;
    padding: 8px 14px;
    border-radius: 14px;
    background: var(--bg);
    box-shadow: var(--shadow-md);
    list-style: none;
    font-size: 13px;
}

.cfg-bar__lines li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line);
}

.cfg-bar__lines li:last-child {
    border-bottom: 0;
}

.cfg-bar__add {
    flex: 0 0 auto;
}

.cfg-bar__add.is-busy {
    opacity: 0.7;
}

/* Added-to-cart dialog */
.cfg-added {
    text-align: center;
}

.cfg-added__icon {
    display: inline-grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 10px;
    border-radius: 50%;
    background: var(--gold-soft);
    color: var(--text);
}

.cfg-added__actions {
    display: grid;
    gap: 8px;
}

/* ---- Gallery wall: several pieces on one wall ---------------------------------------- */

/* The piece the panel edits, when there are several (scene pixels; --iz keeps it a hairline). */
.cfg-piece.is-selected::after {
    content: "";
    position: absolute;
    inset: calc(-6px * var(--iz, 1));
    z-index: 6;
    border: calc(2px * var(--iz, 1)) dashed rgba(239, 177, 39, 0.95);
    border-radius: calc(3px * var(--iz, 1));
    pointer-events: none;
}

.cfg-stage[data-view="closeup"] .cfg-piece.is-selected::after,
.cfg-stage.is-dragging .cfg-piece.is-selected::after {
    opacity: 0.35;
}

.cfg-selected {
    margin: 6px 14px 0;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--gold-soft);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.cfg-selected[hidden] {
    display: none;
}

.cfg-tab {
    position: relative;
}

.cfg-tab__count {
    position: absolute;
    top: 3px;
    inset-inline-end: 6px;
    display: grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--gold);
    color: var(--ink);
    font-size: 10.5px;
    line-height: 1;
}

.cfg-tab__count[hidden] {
    display: none;
}

.cfg-pieces {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.cfg-piece-chip {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius-s);
    background: var(--bg);
    overflow: hidden;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.cfg-piece-chip.is-selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.cfg-piece-chip__pick {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 6px 8px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.cfg-piece-chip__pick img {
    flex: none;
    width: 30px;
    height: 45px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.cfg-piece-chip__text {
    display: grid;
    min-width: 0;
    line-height: 1.5;
}

.cfg-piece-chip__text strong {
    font-size: 13px;
}

.cfg-piece-chip__text small {
    color: var(--muted);
    font-size: 11.5px;
}

.cfg-piece-chip__remove {
    flex: none;
    width: 40px;
    border: 0;
    border-inline-start: 1px solid var(--line);
    background: none;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.cfg-piece-chip__remove:hover {
    color: #C0392B;
}

.cfg-pieces__add {
    width: 100%;
}

.cfg-arrange {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.cfg-arrange__title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.cfg-arrange__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cfg-chip {
    padding: 6px 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.cfg-chip[aria-pressed="true"] {
    border-color: var(--gold);
    background: var(--gold-soft);
}

.cfg-chip:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Picker of other works */
.cfg-picker {
    width: min(100% - 20px, 720px);
    max-height: min(86dvh, 760px);
    padding: 18px 16px 16px;
}

.cfg-picker__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cfg-picker__close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
}

.cfg-picker__search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 12px;
    padding: 0 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 999px;
    background: var(--bg-elev);
}

.cfg-picker__search:focus-within {
    border-color: var(--gold);
}

.cfg-picker__search input {
    flex: 1;
    min-width: 0;
    height: 42px;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    outline: none;
}

.cfg-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}

.cfg-picker__item {
    display: grid;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 12px;
    text-align: center;
    cursor: pointer;
}

.cfg-picker__item img {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: 3px;
    object-fit: cover;
    background: var(--bg-elev-2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.cfg-picker__item:hover img,
.cfg-picker__item:focus-visible img {
    transform: translateY(-3px);
    box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0, 0, 0, 0.22);
}

.cfg-picker__status {
    margin: 10px 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.cfg-picker__status:empty {
    display: none;
}

/* ---- Phones: the stage keeps at least half the screen ----------------------------------
   A long tab (the wall's list of works, the wall sliders) scrolls inside the panel instead of
   growing the panel over the stage, which hid the tool bar and the floor guide. */

@media (max-width: 959px) {
    .cfg {
        grid-template-rows: minmax(clamp(260px, 50%, 460px), 1fr) minmax(0, auto);
    }

    .cfg__panel {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .cfg-form {
        flex: 1;
        min-height: 0;
    }

    .cfg-tabs,
    .cfg-bar {
        flex: none;
    }

    .cfg-sections {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

/* ---- Wide screens: stage + options column ------------------------------------------- */

@media (min-width: 960px) {
    .cfg {
        grid-template-columns: minmax(0, 1fr) 400px;
        grid-template-rows: minmax(0, 1fr);
        gap: 16px;
        max-width: 1680px;
        height: calc(100vh - var(--header-h));
        min-height: 620px;
        margin: 0 auto;
        padding: 14px 16px 16px;
    }

    .cfg-stage {
        border-radius: var(--radius-l);
    }

    .cfg__note {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 8px 4px 0;
        color: var(--muted);
        font-size: 12px;
    }

    .cfg__panel {
        display: flex;
        min-height: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .cfg-form {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        border-radius: var(--radius-l);
        background: var(--bg-elev);
    }

    .cfg-tabs {
        display: none;
    }

    .cfg-sections {
        flex: 1;
        overflow-y: auto;
        padding: 18px 18px 6px;
    }

    .cfg-section {
        display: block;
        margin-bottom: 20px;
    }

    .cfg-section__title {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
        margin-bottom: 10px;
        font-size: 15px;
        font-weight: 800;
    }

    .cfg-options {
        flex-wrap: wrap;
        overflow: visible;
    }

    .cfg-option__card {
        width: 109px;
        background: var(--bg);
    }

    .cfg-options--sizes .cfg-option__card {
        width: 109px;
    }

    .cfg-bar {
        padding: 12px 18px 16px;
        background: var(--bg);
    }

    .cfg-bar__lines {
        width: 330px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cfg-scene__room,
    .cfg-stage__night,
    .cfg-piece__beam,
    .cfg-art__canvas {
        transition: none;
    }
}
