/* Model page visual overrides.
 * Loaded last to avoid conflicts with legacy style.css/theme.css rules.
 */

/* Overlay layout: header over viewer, like bottom icon bar */
body.model-configurator-page,
body.page-template-page-model {
    --cn-header-overlay-height: 43px;
    --cn-bottom-overlay-height: 74px;
    --cn-viewer-bg-top: rgb(204, 204, 204);
    --cn-skfb-bottom-mask-color: rgb(207, 207, 205);
    --cn-nav-btn-size: 40px;
    --cn-nav-bottom-offset: clamp(8px, 2.4vh, 24px);
    --cn-mask-bottom-extra: 14px;
    --cn-skfb-bottom-mask-height: calc(
        env(safe-area-inset-bottom, 0px) +
        var(--cn-nav-bottom-offset) +
        var(--cn-nav-btn-size) +
        var(--cn-mask-bottom-extra)
    );
}

/* Match overlay/header color to Sketchfab background */
body.model-configurator-page #cn-header,
body.page-template-page-model #cn-header,
body.model-configurator-page #cn-header .header-rectangle,
body.page-template-page-model #cn-header .header-rectangle {
    background: var(--cn-viewer-bg-top) !important;
    background-color: var(--cn-viewer-bg-top) !important;
    border: 0 !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

body.model-configurator-page #cn-header,
body.page-template-page-model #cn-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1302 !important;
}

/* Disable artificial seam mask under header */
body.model-configurator-page #cn-header::after,
body.page-template-page-model #cn-header::after {
    display: none !important;
}

/* Ensure model host uses same background */
body.model-configurator-page #rec983400361,
body.page-template-page-model #rec983400361 {
    background: var(--cn-viewer-bg-top) !important;
    background-color: var(--cn-viewer-bg-top) !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 1 !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* Hide legacy strips creating false footer/header bands */
body.model-configurator-page #rec983400371,
body.page-template-page-model #rec983400371,
body.model-configurator-page #rec983400366,
body.page-template-page-model #rec983400366,
body.model-configurator-page #rec983400416,
body.page-template-page-model #rec983400416,
#rec983400371,
#rec983400366,
#rec983400416 {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Keep navigation container transparent, preserve glass buttons */
body.model-configurator-page #bottom-section,
body.page-template-page-model #bottom-section,
body.model-configurator-page #section-navigation,
body.page-template-page-model #section-navigation {
    background: transparent !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.model-configurator-page #bottom-section,
body.page-template-page-model #bottom-section {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--cn-nav-bottom-offset)) !important;
    width: auto !important;
    height: auto !important;
    pointer-events: none !important;
    z-index: 1301 !important;
}

body.model-configurator-page #section-navigation,
body.page-template-page-model #section-navigation {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: clamp(18px, 2.4vw, 40px) !important;
    pointer-events: none !important;
}

body.model-configurator-page #section-navigation .control-btn,
body.page-template-page-model #section-navigation .control-btn {
    width: var(--cn-nav-btn-size) !important;
    height: var(--cn-nav-btn-size) !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 1302 !important;
}

/* Mobile: when sidebar is open, nav icons must go behind it */
@media (max-width: 991.9px) {
    body.model-configurator-page #options-sidebar.open,
    body.page-template-page-model #options-sidebar.open {
        z-index: 2002 !important;
        overflow: visible !important;
    }

    body.model-configurator-page.sb-open #bottom-section,
    body.page-template-page-model.sb-open #bottom-section {
        z-index: 50 !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    body.model-configurator-page.sb-open #section-navigation .control-btn,
    body.page-template-page-model.sb-open #section-navigation .control-btn {
        pointer-events: none !important;
    }

    /* Sidebar header cleanup: remove small visual artifacts near title */
    body.model-configurator-page #options-sidebar #sidebar-content,
    body.page-template-page-model #options-sidebar #sidebar-content {
        position: relative !important;
        background: #f5f5f5 !important;
        padding-top: 26px !important;
        scrollbar-gutter: stable both-edges;
    }

    /* Neutralize legacy panel paddings/overflows that create top artifact strip */
    body.model-configurator-page #options-sidebar.open #exterior-panel,
    body.page-template-page-model #options-sidebar.open #exterior-panel,
    body.model-configurator-page #options-sidebar.open #wheels-panel,
    body.page-template-page-model #options-sidebar.open #wheels-panel,
    body.model-configurator-page #options-sidebar.open #colors-panel,
    body.page-template-page-model #options-sidebar.open #colors-panel {
        position: relative !important;
        overflow: visible !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
        background: #f5f5f5 !important;
    }

    body.model-configurator-page #options-sidebar.open .sidebar-panel h2,
    body.page-template-page-model #options-sidebar.open .sidebar-panel h2 {
        margin-top: 0 !important;
        padding-top: 0 !important;
        position: relative !important;
        z-index: 2 !important;
    }

    body.model-configurator-page #options-sidebar #sidebar-content::after,
    body.page-template-page-model #options-sidebar #sidebar-content::after {
        display: none !important;
        content: none !important;
    }

    /* Close button: fixed, straddles top edge (half outside) — override legacy bottom/absolute */
    body.model-configurator-page #options-sidebar.open #exterior-panel #sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open #exterior-panel .sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open #wheels-panel #sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open #wheels-panel .sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open #colors-panel #sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open #colors-panel .sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #exterior-panel #sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #exterior-panel .sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #wheels-panel #sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #wheels-panel .sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #colors-panel #sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #colors-panel .sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open #sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open #sidebar-close-btn,
    body.model-configurator-page #options-sidebar.open .sidebar-close-btn,
    body.page-template-page-model #options-sidebar.open .sidebar-close-btn {
        position: fixed !important;
        top: 18px !important;
        bottom: auto !important;
        right: 20px !important;
        transform: translateY(-50%) !important;
        z-index: 2100 !important;
    }
}

/* Kill any extra lines/pseudo strips near bottom controls */
body.model-configurator-page #bottom-section::before,
body.page-template-page-model #bottom-section::before,
body.model-configurator-page #bottom-section::after,
body.page-template-page-model #bottom-section::after,
body.model-configurator-page #section-navigation::before,
body.page-template-page-model #section-navigation::before,
body.model-configurator-page #section-navigation::after,
body.page-template-page-model #section-navigation::after {
    display: none !important;
    content: none !important;
}

/* Slight overscan removes 1px iframe seam at viewport edges */
body.model-configurator-page .skfb-iframe-wrapper,
body.page-template-page-model .skfb-iframe-wrapper {
    position: absolute !important;
    inset: -1px 0 -1px 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.model-configurator-page #api-frame,
body.page-template-page-model #api-frame {
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
    box-shadow: none !important;
    background: var(--cn-viewer-bg-top) !important;
}

/* Keep viewer fullscreen, but disable legacy masking strips */
body.model-configurator-page #configurator-3d,
body.page-template-page-model #configurator-3d {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1 !important;
}

body.model-configurator-page #configurator-3d::before,
body.page-template-page-model #configurator-3d::before {
    display: none !important;
}

body.model-configurator-page #configurator-3d::after,
body.page-template-page-model #configurator-3d::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--cn-skfb-bottom-mask-height);
    background: linear-gradient(
        to bottom,
        rgba(207, 207, 205, 0) 0%,
        var(--cn-skfb-bottom-mask-color) 38%,
        var(--cn-skfb-bottom-mask-color) 100%
    );
    pointer-events: auto;
    z-index: 1099;
}

/* Critical: neutralize core.css Sketchfab clipping/fallback white bars */
body.model-configurator-page .skfb-iframe-wrapper,
body.page-template-page-model .skfb-iframe-wrapper,
body.model-configurator-page #configurator-3d.skfb-active .skfb-iframe-wrapper,
body.page-template-page-model #configurator-3d.skfb-active .skfb-iframe-wrapper,
body.model-configurator-page .skfb-active .skfb-iframe-wrapper,
body.page-template-page-model .skfb-active .skfb-iframe-wrapper {
    clip-path: none !important;
    -webkit-clip-path: none !important;
}

body.model-configurator-page .skfb-iframe-wrapper::before,
body.page-template-page-model .skfb-iframe-wrapper::before,
body.model-configurator-page .skfb-iframe-wrapper::after,
body.page-template-page-model .skfb-iframe-wrapper::after {
    display: none !important;
    content: none !important;
    background: transparent !important;
    height: 0 !important;
}

/* Remove header separators only on model page */
body.model-configurator-page #cn-header .header-elements__btn,
body.page-template-page-model #cn-header .header-elements__btn,
body.model-configurator-page #cn-header .header-elements__projects,
body.page-template-page-model #cn-header .header-elements__projects,
body.model-configurator-page #cn-header .header-elements__phone,
body.page-template-page-model #cn-header .header-elements__phone,
body.model-configurator-page #cn-header .header-elements__lang,
body.page-template-page-model #cn-header .header-elements__lang {
    border: 0 !important;
}

body.model-configurator-page #cn-header .header-elements__projects::before,
body.page-template-page-model #cn-header .header-elements__projects::before,
body.model-configurator-page #cn-header .header-elements__projects::after,
body.page-template-page-model #cn-header .header-elements__projects::after,
body.model-configurator-page #cn-header .header-elements__phone::before,
body.page-template-page-model #cn-header .header-elements__phone::before,
body.model-configurator-page #cn-header .header-elements__lang::before,
body.page-template-page-model #cn-header .header-elements__lang::before,
body.model-configurator-page #cn-header .header-elements__lang::after,
body.page-template-page-model #cn-header .header-elements__lang::after,
body.model-configurator-page #cn-header .header-elements__btn::after,
body.page-template-page-model #cn-header .header-elements__btn::after {
    display: none !important;
}

/* Режим сравнения: блок вне #configurator-3d (z-index вьюера). fixed слева, поверх шапки. */
body.model-configurator-page #compare-controls.compare-controls,
body.page-template-page-model #compare-controls.compare-controls {
    position: fixed;
    top: calc(var(--cn-header-overlay-height, 43px) + 12px);
    left: 12px;
    z-index: 1310 !important;
    pointer-events: auto !important;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: min(240px, calc(100vw - 24px));
    -webkit-tap-highlight-color: transparent;
}
/* Как нижняя навигация Gallery: стекло без белой карточки (см. #section-navigation .control-btn в style.css) */
body.model-configurator-page #compare-controls .compare-controls__row,
body.page-template-page-model #compare-controls .compare-controls__row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 8px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1) inset;
    transition: background-color 0.3s, box-shadow 0.3s;
}
@media (hover: hover) {
    body.model-configurator-page #compare-controls .compare-controls__row:hover,
    body.page-template-page-model #compare-controls .compare-controls__row:hover {
        background: rgba(255, 255, 255, 0.25);
        box-shadow: 0 0 6px rgba(0, 0, 0, 0.12) inset;
    }
    body.model-configurator-page #compare-controls .compare-controls__row:hover .compare-controls__label,
    body.page-template-page-model #compare-controls .compare-controls__row:hover .compare-controls__label {
        color: rgba(0, 0, 0, 1);
    }
    body.model-configurator-page #compare-controls .compare-controls__row:hover #compare-view-mode-btn:not(.compare-view-mode-btn--baseline-active),
    body.page-template-page-model #compare-controls .compare-controls__row:hover #compare-view-mode-btn:not(.compare-view-mode-btn--baseline-active) {
        color: rgba(0, 0, 0, 1);
    }
    body.model-configurator-page #compare-tuning-only-btn.compare-tuning-only-btn:hover:not(:disabled),
    body.page-template-page-model #compare-tuning-only-btn.compare-tuning-only-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.25);
        color: rgba(0, 0, 0, 1);
    }
}
/* Как #contact-form-btn: stroke #000000 + у .control-btn svg opacity .6 (style.css) */
body.model-configurator-page #compare-controls .compare-controls__label,
body.page-template-page-model #compare-controls .compare-controls__label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    color: rgba(0, 0, 0, 0.6);
    transition: color 0.3s;
}
body.model-configurator-page #compare-view-mode-btn.compare-view-mode-btn,
body.page-template-page-model #compare-view-mode-btn.compare-view-mode-btn {
    flex: 0 0 auto;
    margin: 0;
    padding: 6px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.6);
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s, box-shadow 0.3s, color 0.3s;
}
body.model-configurator-page #compare-view-mode-btn.compare-view-mode-btn:disabled,
body.page-template-page-model #compare-view-mode-btn.compare-view-mode-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
body.model-configurator-page #compare-view-mode-btn.compare-view-mode-btn--pending:disabled,
body.page-template-page-model #compare-view-mode-btn.compare-view-mode-btn--pending:disabled {
    opacity: 0.55;
    cursor: default;
}
body.model-configurator-page #compare-view-mode-btn.compare-view-mode-btn--baseline-active,
body.page-template-page-model #compare-view-mode-btn.compare-view-mode-btn--baseline-active {
    background: rgba(0, 123, 255, 0.25);
    color: #000000;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.12) inset;
}
body.model-configurator-page #compare-tuning-only-btn.compare-tuning-only-btn,
body.page-template-page-model #compare-tuning-only-btn.compare-tuning-only-btn {
    margin: 0 0 0 0;
    padding: 8px 10px;
    width: var(--cn-nav-btn-size);
    height: var(--cn-nav-btn-size);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1) inset;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.6);
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s, color 0.3s;
    box-sizing: border-box;
}
body.model-configurator-page #compare-tuning-only-btn.compare-tuning-only-btn:disabled,
body.page-template-page-model #compare-tuning-only-btn.compare-tuning-only-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
body.model-configurator-page #compare-tuning-only-btn.compare-view-mode-btn--pending:disabled,
body.page-template-page-model #compare-tuning-only-btn.compare-view-mode-btn--pending:disabled {
    opacity: 0.55;
    cursor: default;
}
body.model-configurator-page #compare-tuning-only-btn.compare-tuning-only-btn--active,
body.page-template-page-model #compare-tuning-only-btn.compare-tuning-only-btn--active {
    background: rgba(0, 123, 255, 0.25);
    border-color: rgba(0, 123, 255, 0.7);
    color: #000000;
}
body.model-configurator-page #compare-view-mode-btn .compare-view-mode-btn__icon,
body.page-template-page-model #compare-view-mode-btn .compare-view-mode-btn__icon {
    display: inline-flex;
}
body.model-configurator-page #compare-view-mode-btn .compare-view-mode-btn__icon svg,
body.page-template-page-model #compare-view-mode-btn .compare-view-mode-btn__icon svg,
body.model-configurator-page #compare-tuning-only-btn .compare-tuning-only-btn__icon svg,
body.page-template-page-model #compare-tuning-only-btn .compare-tuning-only-btn__icon svg {
    display: block;
}

/* Доп. ноды к диску (внутри карточки колеса) */
body.model-configurator-page #wheels-panel .wheel-card--has-addons .wheel-addons-container,
body.page-template-page-model #wheels-panel .wheel-card--has-addons .wheel-addons-container {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
/* Legacy: аддоны внутри карточки (без бандла) */
body.model-configurator-page #wheels-panel .wheel-addon-item:not(.option-item--bundle-addon),
body.page-template-page-model #wheels-panel .wheel-addon-item:not(.option-item--bundle-addon) {
    cursor: pointer;
    font-size: 12px;
    line-height: 1.3;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
body.model-configurator-page #wheels-panel .wheel-addon-item:not(.option-item--bundle-addon):hover,
body.page-template-page-model #wheels-panel .wheel-addon-item:not(.option-item--bundle-addon):hover {
    border-color: rgba(0, 123, 255, 0.45);
    background: rgba(0, 123, 255, 0.06);
}
body.model-configurator-page #wheels-panel .wheel-addon-item:not(.option-item--bundle-addon)._active,
body.page-template-page-model #wheels-panel .wheel-addon-item:not(.option-item--bundle-addon)._active {
    border-color: rgba(0, 123, 255, 0.75);
    background: rgba(0, 123, 255, 0.12);
}
body.model-configurator-page #wheels-panel .wheel-addon-item__price,
body.page-template-page-model #wheels-panel .wheel-addon-item__price {
    opacity: 0.85;
    white-space: nowrap;
}

/* Экстерьер: 2 колонки. Селектор #options-sidebar #exterior-panel — без привязки к body (дубль классов на проде/кеш). */
#options-sidebar #exterior-panel .option-group-wrapper .items-scroller.items-scroller--exterior-options {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    gap: 15px !important;
    align-items: stretch !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding-right: 0 !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

#options-sidebar #exterior-panel .option-group-wrapper .items-scroller.items-scroller--exterior-options::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}

/* Ширина в сетке: data-cn-exterior-cols из PHP (перебивает устаревший класс full-row при рассинхроне кеша). */
#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item[data-cn-exterior-cols="1"] {
    grid-column: span 1 !important;
    grid-row: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    justify-self: stretch !important;
    align-self: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    height: 100% !important;
    box-sizing: border-box !important;
}

#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item {
    box-sizing: border-box !important;
    min-width: 0 !important;
}

#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item[data-cn-exterior-cols="2"],
#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item.option-item--exterior-full-row:not([data-cn-exterior-cols="1"]) {
    grid-column: 1 / -1 !important;
}

#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-bundle-row {
    grid-column: 1 / -1 !important;
}

/* Карточки экстерьера: единый визуальный ритм по высоте */
#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item[data-cn-exterior-cols="1"] > img {
    width: 100% !important;
    height: 96px !important;
    max-height: 96px !important;
    object-fit: contain !important;
}

#options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item[data-cn-exterior-cols="1"] .option-label {
    margin-top: 6px !important;
    min-height: 2.5em !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1.2 !important;
}

/* Квадратики пресетов: style.css задаёт flex-wrap: nowrap — в 2 колонки карточка узкая, ряд вылезает в соседнюю */
#options-sidebar #exterior-panel .option-item .option-variants-container {
    flex-wrap: wrap !important;
    justify-content: center;
    align-content: flex-start;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

#options-sidebar #exterior-panel .option-bundle-row {
    width: 100%;
    box-sizing: border-box;
    display: grid;
    /* Как на целевом макете: две равные колонки внутри строки бандла. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: stretch !important;
    align-content: start;
    position: relative;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 2px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#options-sidebar #exterior-panel .option-bundle-row.option-bundle-row--active {
    border-color: #007bff;
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.2);
}

#options-sidebar #exterior-panel .option-bundle-row__main {
    min-width: 0;
    align-self: stretch !important;
    display: flex;
}

#options-sidebar #exterior-panel .option-bundle-row__main > .option-item {
    height: 100% !important;
    min-height: 0 !important;
    min-width: 0 !important;
    box-sizing: border-box;
    align-self: stretch !important;
}

#options-sidebar #exterior-panel .option-bundle-row__addons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    align-self: start !important;
    justify-content: flex-start;
}

#options-sidebar #exterior-panel .option-item--bundle-addon {
    padding: 2px 3px !important;
    flex: 0 0 auto;
    width: 100% !important;
    max-width: 100%;
    align-self: stretch;
    box-sizing: border-box !important;
}

#options-sidebar #exterior-panel .option-item--bundle-addon img {
    max-height: 56px !important;
    width: 100%;
    object-fit: contain;
}

#options-sidebar #exterior-panel .option-item--bundle-addon .option-label {
    font-size: 9px;
    line-height: 1.15;
}

/* Внутри бандла активность показываем одной внешней рамкой, не по каждой карточке. */
#options-sidebar #exterior-panel .option-bundle-row .option-item.active,
#options-sidebar #exterior-panel .option-bundle-row .option-item:hover {
    border-color: transparent !important;
}

@media (max-width: 520px) {
    #options-sidebar #exterior-panel .option-bundle-row {
        grid-template-columns: 1fr;
    }

    #options-sidebar #exterior-panel .items-scroller--exterior-options > .option-item[data-cn-exterior-cols="1"] > img {
        height: 84px !important;
        max-height: 84px !important;
    }

    #options-sidebar #wheels-panel .wheel-bundle-row {
        grid-template-columns: 1fr;
    }
}

/* Узкий сайдбар: чуть меньше свотчи, чтобы чаще умещались в один ряд после wrap */
@media (max-width: 480px) {
    #options-sidebar #exterior-panel .option-item .option-variants-container .variant-item {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
    }
}

/* --- Wheels: фильтр по типу (перебивает display:flex !important у .option-item в style.css) --- */
#options-sidebar #wheels-panel .wheel-card.wheel-card--filter-hidden,
#options-sidebar #wheels-panel .wheel-bundle-row.wheel-card--filter-hidden {
    display: none !important;
}

#options-sidebar #wheels-panel .options-grid--wheels > .wheel-bundle-row {
    grid-column: 1 / -1;
    min-width: 0;
}

#options-sidebar #wheels-panel .options-grid--wheels > .option-item {
    min-width: 0;
}

#options-sidebar #wheels-panel .wheel-bundle-row {
    width: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: stretch !important;
    align-content: start;
    position: relative;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 2px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#options-sidebar #wheels-panel .wheel-bundle-row.option-bundle-row--active {
    border-color: #007bff;
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.2);
}

#options-sidebar #wheels-panel .wheel-bundle-row .option-bundle-row__main {
    min-width: 0;
    align-self: stretch !important;
    display: flex;
}

#options-sidebar #wheels-panel .wheel-bundle-row .option-bundle-row__main > .wheel-card {
    height: 100% !important;
    min-height: 0 !important;
    min-width: 0 !important;
    box-sizing: border-box;
    align-self: stretch !important;
}

/*
 * Глобальный .product-card { overflow: hidden } (style.css, мозаика галереи) наследуется
 * карточками дисков и обрезает раскрывающийся блок пресетов ACF (wheel_variants).
 */
#options-sidebar #wheels-panel .option-item.product-card,
#options-sidebar #wheels-panel .wheel-addon-item.option-item.product-card {
    overflow: visible !important;
}

#options-sidebar #wheels-panel .wheel-bundle-row .option-bundle-row__addons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    align-self: start !important;
    justify-content: flex-start;
}

#options-sidebar #wheels-panel .wheel-bundle-row .wheel-addon-item.option-item--bundle-addon {
    padding: 2px 3px !important;
    flex: 0 0 auto;
    width: 100% !important;
    max-width: 100%;
    align-self: stretch;
    box-sizing: border-box !important;
}

/* Аддоны бандла: прежняя высота блока (56px), изображение вписывается без crop (перебиваем .option-item img { object-fit: cover }) */
#options-sidebar #wheels-panel .wheel-bundle-row .wheel-addon-item.option-item--bundle-addon img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 56px !important;
    object-fit: contain !important;
    object-position: center center;
    display: block !important;
}

#options-sidebar #wheels-panel .wheel-bundle-row .wheel-addon-item.option-item--bundle-addon .option-label {
    font-size: 9px;
    line-height: 1.15;
}

#options-sidebar #wheels-panel .wheel-bundle-row .wheel-card.active,
#options-sidebar #wheels-panel .wheel-bundle-row .wheel-card:hover,
#options-sidebar #wheels-panel .wheel-bundle-row .wheel-addon-item.option-item--bundle-addon:hover,
#options-sidebar #wheels-panel .wheel-bundle-row .wheel-addon-item.option-item--bundle-addon._active {
    border-color: transparent !important;
}

#options-sidebar #wheels-panel .wheel-bundle-row .wheel-card .option-variants-container {
    margin-top: 6px;
}

/* Полоска пресетов = на всю ширину карточки диска; 2 колонки 1fr → два крупных квадрата в ряд (каждый ≈ половина ширины полоски). */
/* #wheels-panel .option-item.product-card задаёт align-items: center — без stretch полоска сжимается по контенту. */
#options-sidebar #wheels-panel .wheel-card .option-variants-container.wheel-color-presets {
    align-self: stretch !important;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Закрытое состояние: глобальный .option-variants-container { display:flex } в style.css
   иначе «пробивает» свернутую полоску; без класса открытия держим display:none. */
#options-sidebar #wheels-panel .wheel-color-presets:not(.cn-wheel-presets--open) {
    display: none !important;
}

/* Один ряд на широкой колонке; при узком сайдбаре/карточке — перенос, иначе 4-й свотч обрезается */
#options-sidebar #wheels-panel .wheel-color-presets.cn-wheel-presets--open {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    row-gap: 6px !important;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* Раскрытое состояние: сетка задаётся только у .cn-wheel-presets--open (выше), без глобального
   display:grid на .wheel-color-presets — иначе :visible / toggle теряют согласованность с классом. */

#options-sidebar #wheels-panel .wheel-color-presets .variant-item {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    flex-shrink: 0 !important;
    aspect-ratio: auto;
    padding: 0;
    border-radius: 6px;
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#options-sidebar #wheels-panel .wheel-color-presets .variant-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#options-sidebar #wheels-panel .wheel-variant-swatch-fill {
    display: block;
    width: 100%;
    height: 100%;
}

/* Сайдбар светлый (style.css: rgba(245,245,245)); белая обводка «теряется» — контрастная кайма */
#options-sidebar #wheels-panel .wheel-variant-preset._active {
    box-shadow:
        inset 0 0 0 2px rgba(24, 24, 26, 0.92),
        0 0 0 1px rgba(0, 0, 0, 0.14);
    border-color: rgba(24, 24, 26, 0.5) !important;
    outline: 2px solid rgba(24, 24, 26, 0.55) !important;
    outline-offset: 0 !important;
    z-index: 1;
    position: relative;
}

#options-sidebar #wheels-panel .wheel-variant-custom {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    position: relative;
}

#options-sidebar #wheels-panel .wheel-variant-custom-icon {
    display: block;
    width: 100%;
    height: 100%;
    background: conic-gradient(
        from 0deg,
        #e53935,
        #fbc02d,
        #43a047,
        #1e88e5,
        #8e24aa,
        #e53935
    );
    mask-image: radial-gradient(circle, transparent 38%, #000 40%);
    -webkit-mask-image: radial-gradient(circle, transparent 38%, #000 40%);
}

/* Пресет «материал» без своей иконки */
#options-sidebar #wheels-panel .wheel-variant-swatch-material {
    display: block;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        -45deg,
        #3a3a3a,
        #3a3a3a 3px,
        #505050 3px,
        #505050 6px
    );
    box-sizing: border-box;
}

#options-sidebar #wheels-panel .wheel-variant-preset--material._active {
    box-shadow:
        inset 0 0 0 2px rgba(160, 118, 18, 0.98),
        0 0 0 1px rgba(0, 0, 0, 0.18);
    border-color: rgba(120, 88, 12, 0.75) !important;
    outline: 2px solid rgba(90, 65, 8, 0.65) !important;
    outline-offset: 0 !important;
    z-index: 1;
    position: relative;
}

#options-sidebar #wheels-panel .wheel-variant-custom._active {
    box-shadow:
        inset 0 0 0 2px rgba(24, 24, 26, 0.92),
        0 0 0 1px rgba(0, 0, 0, 0.14);
    border-color: rgba(24, 24, 26, 0.5) !important;
    outline: 2px solid rgba(24, 24, 26, 0.55) !important;
    outline-offset: 0 !important;
    z-index: 1;
    position: relative;
}

/* Оверлей HEX-пикера дисков: затемнение на весь экран; сама панель position:fixed у якоря (JS) */
.cn-wheel-hex-overlay {
    position: fixed;
    inset: 0;
    z-index: 4500;
    display: none;
    padding: 0;
    box-sizing: border-box;
}

.cn-wheel-hex-overlay.cn-wheel-hex-overlay--open {
    display: block;
}

.cn-wheel-hex-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

/* Панель пикера (внутри оверлея; классы без привязки к #wheels-panel — узел на body) */
.cn-wheel-hex-popup {
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: stretch !important;
    box-sizing: border-box;
    padding: 10px 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(24, 24, 26, 0.96);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 4;
    position: relative;
    overflow: hidden;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay {
    margin-top: 0 !important;
    align-self: auto;
    /* Высота по контенту — без внутреннего скролла; вписывание в viewport — в JS (ширина iro + clamp позиции) */
    width: min(156px, calc(100vw - 24px));
    max-width: min(156px, calc(100vw - 24px));
    max-height: none;
    /*
     * Нельзя сочетать overflow-x: hidden с overflow-y: visible — по CSS overflow-y станет auto и появится скролл + «пустота».
     * Узкая панель: горизонтальный вылет маловероятен; при необходимости клип только через clip-path.
     */
    overflow: visible !important;
    flex-shrink: 0;
    z-index: 1;
    padding: 9px 9px 12px;
    position: fixed;
    box-sizing: border-box;
    height: fit-content;
    min-height: 0;
}

.cn-wheel-hex-popup__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__head {
    margin-bottom: 6px;
}

.cn-wheel-hex-popup__title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.02em;
}

.cn-wheel-hex-popup__close {
    appearance: none;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    border-radius: 4px;
}

.cn-wheel-hex-popup__close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.cn-wheel-hex-popup__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

/* Компактный оверлей: кнопка на всю ширину, ниже — HEX и «Сброс» в один ряд */
.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 9px;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__choose {
    grid-column: 1 / -1;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__hex-input {
    grid-column: 1;
    max-width: none;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__reset {
    grid-column: 2;
    align-self: center;
}

.cn-wheel-hex-popup__choose {
    display: flex;
    align-items: stretch;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border: 1px solid rgba(100, 160, 255, 0.65);
    border-radius: 4px;
    background: rgba(40, 40, 44, 0.95);
    color: rgba(255, 255, 255, 0.88);
    font-size: 11px;
    cursor: pointer;
    overflow: hidden;
}

.cn-wheel-hex-popup__choose-swatch {
    width: 28px;
    min-width: 28px;
    background: #c0c0c0;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__choose-swatch {
    width: 27px;
    min-width: 27px;
}

.cn-wheel-hex-popup__choose-text {
    padding: 6px 6px;
    flex: 1;
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__choose-text {
    padding: 5px 6px;
    font-size: 12px;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__title {
    font-size: 14px;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__close {
    font-size: 1.1rem;
    padding: 1px 6px;
}

.cn-wheel-hex-popup__hex-input {
    width: 100%;
    max-width: 88px;
    min-width: 0;
    flex: 0 0 auto;
    padding: 6px 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: #fff;
    color: #222;
    font-size: 11px;
    font-family: ui-monospace, monospace;
    box-sizing: border-box;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__hex-input {
    font-size: 13px;
    padding: 5px 6px;
}

.cn-wheel-hex-popup__reset {
    flex-shrink: 0;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    background: rgba(55, 55, 58, 0.95);
    color: rgba(255, 255, 255, 0.88);
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__reset {
    padding: 5px 8px;
    font-size: 12px;
}

.cn-wheel-hex-popup__reset:hover {
    background: rgba(70, 70, 74, 0.95);
}

.cn-wheel-hex-popup__picker-wrap {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.22);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup__picker-wrap {
    padding: 6px;
    border-radius: 6px;
    overflow: visible;
    height: fit-content;
    min-height: 0;
}

.cn-wheel-hex-popup-picker-host {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    box-sizing: border-box;
}

.cn-wheel-hex-popup-picker-host .IroColorPicker,
.cn-wheel-hex-popup-picker-host .iroColorPicker {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    justify-content: flex-start !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup-picker-host {
    overflow: visible;
    height: fit-content;
    min-height: 0;
    align-items: center;
}

.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup-picker-host .IroColorPicker,
.cn-wheel-hex-popup.cn-wheel-hex-popup--overlay .cn-wheel-hex-popup-picker-host .iroColorPicker {
    gap: 5px !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    height: auto !important;
    min-height: 0 !important;
}

.cn-wheel-hex-popup-picker-host .IroColorPicker svg,
.cn-wheel-hex-popup-picker-host .iroColorPicker svg {
    max-width: 100% !important;
    height: auto !important;
}

/* Шаблон Wheels Model: те же z-index/стек, что у полного конфигуратора (моб. сайдбар) */
@media (max-width: 991.9px) {
    body.wheels-model-page.model-configurator-page #options-sidebar.open,
    body.wheels-model-page.page-template-page-wheels-model #options-sidebar.open {
        z-index: 2002 !important;
        overflow: visible !important;
    }
}
