/* Мини-конфигуратор забора: слева сцена (план участка / 3D), справа компактная панель; на мобильных — друг под другом */
.fencecfg {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
    color: var(--color-whte, #fff);
}

/* Сцена: в 3D — небо, на плане — светлая «бумага» с сеткой (рисует SVG) */
/* Липкая колонка, высота сцены и плашка итога — общие (configurator-kit/kit.css: .cfg-view, .cfg-stage, .cfg-deal) */
.fencecfg__stage {
    border-radius: 32px;
    overflow: hidden;
    background: linear-gradient(180deg, #b9d4e6 0%, #dde9ee 60%, #e9f0ef 100%);
    border: 1px solid rgba(0, 0, 0, .06);
}

.fencecfg__stage.is-plan {
    background: #f4f7f0;
}

.fencecfg__stage canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
    cursor: grab;
    touch-action: none;
}

.fencecfg__stage canvas:active {
    cursor: grabbing;
}

.fencecfg__plan {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    touch-action: none;
    user-select: none;
    font-family: inherit;
}

.fencecfg__stage.is-plan .fencecfg__plan {
    display: block;
}

.fencecfg__stage.is-plan canvas {
    visibility: hidden;
}

.fencecfg__v {
    cursor: grab;
    transition: r .15s;
}

.fencecfg__v:hover {
    filter: drop-shadow(0 0 4px rgba(79, 125, 51, .6));
}

.fencecfg__mid {
    cursor: copy;
    opacity: .75;
}

.fencecfg__mid:hover {
    opacity: 1;
}

.fencecfg__gate-hit {
    cursor: ew-resize;
}

.fencecfg__plan.is-dragging,
.fencecfg__plan.is-dragging * {
    cursor: grabbing;
}

/* Курсоры плана — с !important и повышенной специфичностью: сайт глушит курсоры кастомным (site-cursor.css) */
html.has-site-cursor .fencecfg__plan .fencecfg__v,
html.has-site-cursor .fencecfg__plan .fencecfg__v * {
    cursor: grab !important;
}

html.has-site-cursor .fencecfg__plan .fencecfg__mid,
html.has-site-cursor .fencecfg__plan .fencecfg__mid * {
    cursor: copy !important;
}

html.has-site-cursor .fencecfg__plan .fencecfg__gate-hit {
    cursor: ew-resize !important;
}

html.has-site-cursor .fencecfg__plan.is-dragging,
html.has-site-cursor .fencecfg__plan.is-dragging * {
    cursor: grabbing !important;
}

.fencecfg__loader {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    background: #f4f7f0;
    transition: opacity .4s;
}

.fencecfg__loader span {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, .1);
    border-top-color: var(--color-alt, #97bf74);
    animation: fencecfg-spin 1s linear infinite;
}

@keyframes fencecfg-spin {
    to { transform: rotate(360deg); }
}

.fencecfg--ready .fencecfg__loader {
    opacity: 0;
    pointer-events: none;
}

.fencecfg__nogl {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 5;
    place-items: center;
    padding: 24px;
    text-align: center;
    color: #2d3a24;
}

.fencecfg--nogl .fencecfg__nogl {
    display: grid;
}

/* Панель инструментов на сцене */
.fencecfg__tools {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fencecfg--nogl .fencecfg__tools {
    display: none;
}

.fencecfg__tool {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    border: 0;
    background: rgba(29, 31, 29, .78);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background .2s, color .2s, opacity .2s;
}

.fencecfg__tool:hover:not(:disabled) {
    background: #1d1f1d;
}

.fencecfg__tool.is-active,
.fencecfg__tool.is-active:hover:not(:disabled) {
    background: var(--color-alt, #97bf74);
    color: #1d1f1d;
}

.fencecfg__tool:disabled {
    opacity: .3;
    cursor: default;
}

.fencecfg__mode {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(29, 31, 29, .78);
    backdrop-filter: blur(6px);
}

.fencecfg__mode button {
    min-width: 40px;
    padding: 8px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.fencecfg__mode button.is-active {
    background: var(--color-alt, #97bf74);
    color: #1d1f1d;
}

.fencecfg__hint {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 16px;
    z-index: 2;
    font-size: 13px;
    color: rgba(45, 58, 36, .7);
    pointer-events: none;
}

.fencecfg__hint[hidden] {
    display: none;
}

/* Панель */
.fencecfg__panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: #1d1f1d;
}

.fencecfg__group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fencecfg__label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--color-alt, #97bf74);
}

.fencecfg__label output {
    color: var(--color-whte, #fff);
}

.fencecfg__meta {
    font-size: 12px;
    color: rgba(255, 255, 255, .55);
}

.fencecfg__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.fencecfg__split {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: start;
}

.fencecfg__split > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Плитки «иконка + подпись» */
.fencecfg__tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.fencecfg__tiles--4 {
    grid-template-columns: repeat(4, 1fr);
}

.fencecfg__tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 7px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .15);
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: background .2s, border-color .2s, color .2s;
}

.fencecfg__tile svg {
    width: 40px;
    height: 32px;
}

.fencecfg__tile small {
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    opacity: .75;
}

.fencecfg__tile:hover {
    border-color: var(--color-alt, #97bf74);
}

.fencecfg__tile.is-active {
    background: var(--color-alt, #97bf74);
    border-color: var(--color-alt, #97bf74);
    color: #1d1f1d;
}

.fencecfg__tile.is-active small {
    opacity: 1;
}

/* Сегменты */
.fencecfg__seg {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .06);
}

.fencecfg__opt {
    flex: 1 1 auto;
    padding: 7px 11px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.fencecfg__opt:hover {
    background: rgba(255, 255, 255, .08);
}

.fencecfg__opt.is-active {
    background: var(--color-alt, #97bf74);
    color: #1d1f1d;
}

.fencecfg__range {
    width: 100%;
    height: 30px;
    margin: 0;
    accent-color: var(--color-alt, #97bf74);
    cursor: pointer;
}

.fencecfg__area {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Цвета */
.fencecfg__swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fencecfg__swatch {
    width: 26px;
    height: 26px;
    flex: none;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--sw);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), inset -3px -5px 7px rgba(0, 0, 0, .3);
    outline: 2px solid transparent;
    outline-offset: 2px;
    cursor: pointer;
    transition: outline-color .2s, transform .15s;
}

.fencecfg__swatch--wood {
    background:
        repeating-linear-gradient(90deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 4px),
        var(--sw);
}

.fencecfg__swatch:hover {
    transform: scale(1.1);
}

.fencecfg__swatch.is-active {
    outline-color: var(--color-alt, #97bf74);
}

/* Ворота: кнопки «+» и список поставленных */
.fencecfg__addons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fencecfg__addon {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px 5px 5px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .15);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .2s;
}

.fencecfg__addon:hover {
    border-color: var(--color-alt, #97bf74);
}

.fencecfg__addon.is-shake {
    animation: fencecfg-shake .35s;
}

@keyframes fencecfg-shake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.fencecfg__plus {
    position: relative;
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    background: var(--color-alt, #97bf74);
    color: #1d1f1d;
}

.fencecfg__plus::before,
.fencecfg__plus::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 9px;
    height: 2px;
    margin: -1px 0 0 -4.5px;
    border-radius: 1px;
    background: currentColor;
}

.fencecfg__plus::after {
    transform: rotate(90deg);
}

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

.fencecfg__gates:empty {
    display: none;
}

.fencecfg__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    font-size: 12px;
    white-space: nowrap;
}

.fencecfg__chip.is-bad {
    opacity: .5;
    text-decoration: line-through;
}

.fencecfg__chip button {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.fencecfg__chip button:hover {
    background: #c8453b;
}

.fencecfg__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.fencecfg__dot--wicket { background: #e0892b; }
.fencecfg__dot--swing { background: #2f7fd8; }
.fencecfg__dot--sliding { background: #c8453b; }

/* Название выбранного цвета — только в окне на телефоне */
.fencecfg__swatch-name {
    display: none;
}

/* Смета: материалы из той же раскладки, что 3D */
.fencecfg__spec {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    margin: 0;
    font-size: 13px;
}

.fencecfg__spec dt {
    color: rgba(255, 255, 255, .6);
}

.fencecfg__spec dd {
    margin: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Низ широкой сцены занят плашкой итога — подсказка уходит наверх, влево от инструментов */
@container (min-width: 900px) {
    .fencecfg__hint {
        top: 24px;
        bottom: auto;
        right: 330px;
        line-height: 1.35;
    }
}

@media (max-width: 1024px) {
    .fencecfg {
        grid-template-columns: 1fr;
    }
}

/* Телефон: сцена, кнопки разделов и итог — в один экран; панель — окном поверх кнопок (kit.css: .cfg-panel) */
@media (max-width: 600px) {
    .fencecfg__stage {
        border-radius: 20px;
    }

    /* В окне: плитки и кружки — одной строкой от края до края (листаются свайпом), кружки крупнее */
    .fencecfg__panel .fencecfg__tile {
        width: 96px;
    }

    .fencecfg__panel .fencecfg__swatches {
        gap: 12px;
        margin-block: -9px;
        padding-block: 9px;
    }

    .fencecfg__panel .fencecfg__swatch {
        width: 52px;
        height: 52px;
        outline-offset: 3px;
    }

    .fencecfg__tools {
        top: 10px;
        right: 10px;
        gap: 4px;
    }

    .fencecfg__tool {
        width: 36px;
        height: 36px;
    }

    .fencecfg__hint {
        display: none;
    }

    .fencecfg__split {
        grid-template-columns: 1fr;
    }
}
