@layer storefront-header {
    body.storefront-app .store-main-header .store-search-shell {
        --header-search-accent: var(--storefront-accent, #2f6df6);
        grid-template-columns: 44px minmax(0, 1fr) !important;
        align-items: center;
        min-height: 46px !important;
        border: 1px solid #e4ded9 !important;
        border-radius: 6px !important;
        background: #fff !important;
        box-shadow: none !important;
    }

    body.storefront-app .store-main-header .store-search-shell:focus-within {
        border-color: var(--header-search-accent) !important;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--header-search-accent) 12%, transparent) !important;
    }

    body.storefront-app .store-main-header .store-search-input {
        min-height: 44px !important;
        padding-inline: 0 14px !important;
        border: 0 !important;
        background: transparent !important;
        color: var(--storefront-ink, #102a43) !important;
        font-weight: 600;
        box-shadow: none !important;
    }

    .store-main-header .store-search-input::placeholder {
        color: #556579 !important;
        opacity: 1 !important;
    }

    body.storefront-app .store-main-header .store-search-3d-tools:has(.store-tool-search-clear:not([hidden])) .store-search-input {
        padding-inline-end: 40px !important;
    }

    body.storefront-app .store-main-header .store-search-button {
        display: grid !important;
        place-items: center;
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 5px !important;
        background: transparent !important;
        color: var(--header-search-accent) !important;
        font-size: 15px !important;
        line-height: 1;
    }

    body.storefront-app .store-main-header .store-search-button:is(:hover, :focus-visible) {
        background: color-mix(in srgb, var(--header-search-accent) 8%, transparent) !important;
    }

    .store-main-header .store-search-button:focus-visible {
        outline: 2px solid currentColor;
        outline-offset: -4px;
    }

    @media (min-width: 992px) {
        body.storefront-app .store-main-header .store-search-shell {
            justify-self: center;
            max-width: 680px;
        }

        .storefront-app .store-category-menu-bar .store-category-menu-panel {
            left: var(--category-menu-shift, 0px) !important;
            transform: none !important;
        }

        .storefront-app .store-category-menu-bar .store-category-menu-panel.is-mega {
            width: min(700px, calc(100vw - 48px)) !important;
            min-width: 0 !important;
            grid-template-columns: minmax(0, 1fr) min(var(--mega-feature-width, 180px), 164px) !important;
            gap: 20px !important;
            padding: 18px !important;
            border-radius: 8px !important;
        }

        .storefront-app .store-category-menu-bar .store-category-mega-grid {
            min-width: 0;
            grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)) !important;
            overflow-wrap: anywhere;
        }

        .storefront-app .store-category-menu-panel::before {
            left: var(--category-menu-arrow, 36px) !important;
        }
    }

    @media (min-width: 992px) {
        .has-compact-tool-search .store-tool-search-control {
            position: relative;
            display: block !important;
            grid-area: search;
            z-index: 1206;
        }

        .has-compact-tool-search .store-tool-search-toggle {
            display: grid !important;
            place-items: center;
        }

        .has-compact-tool-search .store-tool-search-popover {
            display: none !important;
            position: absolute;
            inset-block-start: calc(100% + 8px);
            inset-inline-end: 0;
            box-sizing: border-box;
            width: 400px;
            padding: 10px;
            border: 1px solid #e3e8ed;
            border-radius: 12px;
            background: #fff;
            box-shadow: 0 14px 32px #17324b24;
        }

        .has-compact-tool-search .store-tool-search-control.is-open .store-tool-search-popover {
            display: block !important;
        }

        .has-compact-tool-search .store-tool-search-control.is-inline .store-tool-search-popover {
            inset-block-start: 0;
            inset-inline-end: calc(100% + 8px);
            width: var(--tool-search-width, 400px);
            padding: 0;
            border: 0;
            border-radius: 0;
            background: transparent;
            box-shadow: none;
        }

        body.storefront-app.has-compact-tool-search .store-tool-search-popover .store-search-shell {
            position: static !important;
            width: 100% !important;
            margin: 0 !important;
        }

        body.storefront-app.has-compact-tool-search .store-tool-search-popover .store-search-shell:focus-within {
            border-color: color-mix(in srgb, var(--header-search-accent) 45%, #e3e8ed) !important;
            box-shadow: none !important;
        }
    }

    @media (max-width: 767px) {
        body.storefront-app .store-main-header .store-logout-form {
            display: none !important;
        }

        body.storefront-app .store-main-header .store-brand {
            max-width: clamp(92px, 26vw, 126px) !important;
        }

        body.storefront-app .store-main-header .store-brand.has-logo img {
            width: clamp(92px, 26vw, 126px) !important;
            max-width: 100% !important;
            height: 44px !important;
            max-height: 44px !important;
            object-fit: contain;
            object-position: left center;
        }

        body.storefront-app.has-3d-tools-header.has-3d-header-search:not(.is-3d-header-hidden) {
            --store-header-height: 64px !important;
        }

        body.storefront-app.has-3d-tools-header.has-3d-header-search .store-main-header-inner.is-3d-tools-header.has-search {
            grid-template-rows: 48px !important;
        }

        body.storefront-app.has-tool-header-search .store-main-header-inner.is-3d-tools-header.has-search {
            position: relative !important;
            box-sizing: border-box;
            width: calc(100% - 2 * var(--market-home-gutter, 12px)) !important;
            padding-inline: 0 !important;
            grid-template-columns: auto minmax(0, 1fr) 44px auto !important;
            grid-template-areas: "brand . search actions" !important;
            column-gap: 0 !important;
        }

        .has-tool-header-search .store-tool-search-control {
            display: block !important;
            grid-area: search;
        }

        .has-tool-header-search .store-tool-search-toggle {
            display: grid !important;
            place-items: center;
            width: 44px !important;
            height: 44px !important;
        }

        .has-tool-header-search .store-tool-search-popover {
            display: none !important;
            position: absolute;
            inset-block-start: calc(100% + 4px);
            inset-inline-start: auto;
            inset-inline-end: 0;
            z-index: 1206;
            box-sizing: border-box;
            width: min(420px, calc(100vw - 24px));
            padding: 8px;
            border: 1px solid #dce4ec;
            border-radius: 10px;
            background: #fff;
            box-shadow: 0 14px 32px #17324b24;
        }

        .has-tool-header-search .store-tool-search-control.is-open .store-tool-search-popover {
            display: block !important;
        }

        body.storefront-app.has-tool-header-search .store-tool-search-popover .store-search-shell {
            position: static !important;
            width: 100% !important;
            margin: 0 !important;
        }

        body.storefront-app.has-tool-header-search .store-tool-search-popover .store-search-input {
            font-size: 16px !important;
        }

        /* Keep the regional currency control out of the narrow delivery ticker.
           The footer picker remains available for customers who want to change it. */
        body.storefront-app .store-topbar .store-currency-picker--mobile {
            display: none !important;
        }
    }
}

.store-tool-search-control,
.store-tool-search-popover { display: contents; }

.store-tool-search-toggle {
    display: none;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid #e4ded9;
    border-radius: 6px;
    background: #fff;
    color: var(--storefront-accent, #2f6df6);
}

.store-tool-search-toggle:is(:hover, [aria-expanded="true"]) {
    border-color: currentColor;
    background: #f3f7ff;
}

.store-tool-search-toggle[aria-expanded="true"]:not(:hover) {
    border-color: #dce4ec;
    background: #f5f8fc;
    color: #53667b;
}

.store-tool-search-toggle[aria-expanded="false"] .fa-xmark,
.store-tool-search-toggle[aria-expanded="true"] .fa-magnifying-glass,
.storefront-header-search-toggle[aria-expanded="false"] .fa-xmark,
.storefront-header-search-toggle[aria-expanded="true"] .fa-magnifying-glass {
    display: none !important;
}

.store-tool-search-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.store-search-3d-tools .store-search-input-wrap { position: relative; }

.store-search-3d-tools input[role="combobox"]::-webkit-search-cancel-button { appearance: none; }

.store-tool-search-clear {
    position: absolute;
    inset-inline-end: 3px;
    inset-block-start: 50%;
    translate: 0 -50%;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #53667b;
}

.store-tool-search-clear[hidden] { display: none; }
.store-tool-search-clear:is(:hover, :focus-visible) { background: #edf5ff; }

.store-tool-search-panel {
    position: fixed;
    z-index: 5050;
    box-sizing: border-box;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 6px;
    border: 1px solid #dce4ec;
    border-radius: 10px;
    background: #fff;
    color: #17324b;
    box-shadow: 0 10px 28px #17324b26;
    font-size: 14px;
}

.store-tool-search-panel [hidden],
.store-tool-search-panel[hidden] {
    display: none;
}

@media (max-width: 767px) {
    .has-tool-header-search .store-tool-search-popover .store-tool-search-panel {
        position: static;
        margin-top: 4px;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
}

@media (min-width: 992px) {
    .has-compact-tool-search .store-tool-search-popover .store-tool-search-panel {
        position: static;
        margin-top: 4px;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .has-compact-tool-search .store-tool-search-control.is-inline .store-tool-search-panel {
        position: absolute;
        inset: calc(100% + 8px) 0 auto;
        margin: 0;
        padding: 6px;
        border: 1px solid #dce4ec;
        border-radius: 10px;
        box-shadow: 0 14px 32px #17324b24;
    }
}

.store-tool-search-caption,
.store-tool-search-empty {
    margin: 0;
    padding: 8px 10px;
    color: #53667b;
    font-size: 12px;
}

.store-tool-search-caption { font-weight: 750; }

.store-tool-search-option {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 6px;
    color: inherit;
    font-weight: 650;
    text-decoration: none;
}

.store-tool-search-preview {
    display: grid;
    place-items: center;
    height: 30px;
    overflow: hidden;
    border-radius: 5px;
    background: #edf5ff;
    color: var(--storefront-accent, #2f6df6);
}

.store-tool-search-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.store-tool-search-option > i:last-child { color: #53667b; font-size: 11px; }

.store-tool-search-option:is(:hover, :focus-visible, [aria-selected="true"]) {
    background: #edf5ff;
    color: #174d9e;
}

.store-tool-search-all {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 4px;
    border-top: 1px solid #e6ebf1;
    color: #174d9e;
}

/* Give the physical shop the same compact, single-row desktop header as 3D Tools. */
.storefront-header-search-control,
.storefront-header-search-popover { display: contents; }

.storefront-header-search-toggle { display: none; }

@layer storefront-header {
    @media (max-width: 767px) {
        body.storefront-app .store-main-header > .has-common-store-header.has-search:has(> .storefront-header-search-control.is-toggle-ready:not(.is-open)) {
            grid-template: "brand search" 48px / minmax(0, 1fr) 44px !important;
            align-content: center !important;
            box-sizing: border-box !important;
            width: calc(100% - 24px) !important;
            min-height: 64px !important;
            gap: 0 !important;
            padding: 8px 0 !important;
        }

        .has-common-store-header:has(> .storefront-header-search-control.is-toggle-ready:not(.is-open)) > .store-brand {
            grid-area: brand !important;
        }

        .has-common-store-header:has(> .storefront-header-search-control.is-toggle-ready:not(.is-open)) > :is(.store-main-actions, .store-category-trigger, .store-category-menu-bar) {
            display: none !important;
        }

        .has-common-store-header > .storefront-header-search-control.is-toggle-ready:not(.is-open) {
            display: block !important;
            grid-area: search;
        }

        .storefront-header-search-control.is-toggle-ready:not(.is-open) > .storefront-header-search-popover {
            display: none !important;
        }

        body.storefront-app .store-main-header > .has-common-store-header.has-search:has(> :is(.store-tool-search-control, .storefront-header-search-control).is-open) {
            display: grid !important;
            grid-template: "field close" 48px / minmax(0, 1fr) 44px !important;
            align-items: center !important;
            align-content: center !important;
            gap: 0 6px !important;
            box-sizing: border-box !important;
            width: calc(100% - 24px) !important;
            min-height: 64px !important;
            padding: 8px 0 !important;
        }

        body.storefront-app .has-common-store-header:has(> :is(.store-tool-search-control, .storefront-header-search-control).is-open) > :is(.store-brand, .store-main-actions, .store-category-trigger, .store-category-menu-bar) {
            display: none !important;
        }

        body.storefront-app .has-common-store-header > :is(.store-tool-search-control, .storefront-header-search-control).is-open {
            display: contents !important;
        }

        body.storefront-app .has-common-store-header > :is(.store-tool-search-control, .storefront-header-search-control).is-open > :is(.store-tool-search-toggle, .storefront-header-search-toggle) {
            grid-area: close !important;
            display: grid !important;
            place-items: center;
            width: 44px !important;
            height: 44px !important;
            padding: 0;
            border: 1px solid #a7befb;
            border-radius: 6px;
            background: #f3f7ff;
            color: var(--storefront-accent, #2f6df6);
        }

        .storefront-header-search-control.is-toggle-ready:not(.is-open) > .storefront-header-search-toggle {
            display: grid !important;
            place-items: center;
            width: 44px;
            height: 44px;
            padding: 0;
            border: 1px solid #e4ded9;
            border-radius: 6px;
            background: #fff;
            color: var(--storefront-accent, #2f6df6);
        }

        body.storefront-app .has-common-store-header > :is(.store-tool-search-control, .storefront-header-search-control).is-open > :is(.store-tool-search-popover, .storefront-header-search-popover) {
            grid-area: field !important;
            display: block !important;
            position: relative !important;
            inset: auto !important;
            width: 100% !important;
            min-width: 0;
            padding: 0 !important;
            border: 0 !important;
            background: transparent !important;
            box-shadow: none !important;
        }

        body.storefront-app .has-common-store-header :is(.store-tool-search-control, .storefront-header-search-control).is-open .store-search-shell {
            position: static !important;
            width: 100% !important;
            margin: 0 !important;
        }

        body.storefront-app .has-common-store-header :is(.store-tool-search-control, .storefront-header-search-control).is-open .store-search-input {
            font-size: 16px !important;
        }

        body.storefront-app .has-common-store-header .store-tool-search-control.is-open .store-tool-search-panel {
            position: absolute !important;
            inset: calc(100% + 8px) -50px auto 0 !important;
            margin: 0 !important;
            padding: 6px !important;
            border: 1px solid #dce4ec !important;
            border-radius: 10px !important;
            box-shadow: 0 14px 32px #17324b24 !important;
        }
    }
}

@media (min-width: 992px) {
    body.storefront-app:not(.has-3d-tools-header) .store-main-header-inner.has-common-store-header .storefront-header-search-toggle {
        display: grid !important;
        width: 46px;
        height: 46px;
        place-items: center;
        padding: 0;
        border: 1px solid #e4ded9;
        border-radius: 8px;
        background: #fff;
        color: var(--storefront-accent, #2f6df6);
        font-size: 16px;
    }

    body.storefront-app:not(.has-3d-tools-header) .store-main-header-inner.has-common-store-header .storefront-header-search-toggle:is(:hover, :focus-visible, [aria-expanded="true"]) {
        border-color: currentColor;
        background: #f3f7ff;
    }

    body.storefront-app:not(.has-3d-tools-header) .store-main-header-inner.has-common-store-header .storefront-header-search-popover {
        display: none !important;
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        width: min(380px, calc(100vw - 32px));
        padding: 8px;
        border: 1px solid #dce4ec;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 14px 32px #17324b24;
    }

    body.storefront-app:not(.has-3d-tools-header) .store-main-header-inner.has-common-store-header .storefront-header-search-control.is-open .storefront-header-search-popover {
        display: block !important;
    }

    body.storefront-app:not(.has-3d-tools-header) .store-main-header-inner.has-common-store-header .storefront-header-search-popover .store-search-shell {
        width: 100% !important;
        margin: 0 !important;
    }
}

@media (width < 992px) {
    body.storefront-app:not(.has-3d-tools-header) .store-main-header-inner.has-centered-store-nav > .is-storefront-inline-nav {
        position: fixed !important;
        top: var(--store-header-stack-height) !important;
        right: 0 !important;
        left: 0 !important;
        z-index: 1020 !important;
    }
}

/* The two storefronts share the same desktop tracks. Keep layout declarations
   in the header layer, where they take precedence over legacy important rules. */
@layer storefront-header {
    @media (min-width: 992px) {
        body.storefront-app:is(.is-3d-tools-app, .has-3d-tools-header) {
            --store-header-height: inherit !important;
            --store-header-stack-height: inherit !important;
            --store-fixed-stack-height: inherit !important;
        }

        body.storefront-app .store-main-header > .has-common-store-header {
            display: grid !important;
            position: relative !important;
            box-sizing: border-box !important;
            width: min(1600px, calc(100% - 48px)) !important;
            max-width: none !important;
            min-height: 64px !important;
            height: auto !important;
            grid-template: "brand nav search actions" auto / auto minmax(0, 1fr) auto auto !important;
            align-items: center !important;
            gap: 0 !important;
            margin-inline: auto !important;
            padding: 6px 0 !important;
        }

        body.storefront-app.is-3d-tools-home .store-main-header > .has-common-store-header {
            width: calc(100% - 2 * var(--market-home-gutter, 24px)) !important;
        }

        body.storefront-app .has-common-store-header > .store-brand {
            grid-area: brand !important;
            justify-self: start !important;
            margin: 0 !important;
        }

        body.storefront-app .has-common-store-header > .store-category-trigger {
            display: none !important;
        }

        body.storefront-app .has-common-store-header > .store-category-menu-bar {
            grid-area: nav !important;
            position: relative !important;
            inset: auto !important;
            transform: none !important;
            width: auto !important;
            min-width: 0 !important;
            margin: 0 !important;
            padding-inline: clamp(8px, 1vw, 16px) !important;
            border: 0 !important;
            background: transparent !important;
            box-shadow: none !important;
            overflow: visible !important;
            z-index: 1205 !important;
        }

        body.storefront-app .has-common-store-header .store-category-menu-inner {
            display: flex !important;
            flex-wrap: wrap !important;
            justify-content: center !important;
            align-items: center !important;
            width: 100% !important;
            max-width: none !important;
            margin: 0 !important;
            padding: 0 !important;
            gap: 0 clamp(8px, 1vw, 18px) !important;
            overflow: visible !important;
        }

        body.storefront-app .has-common-store-header .store-category-menu-inner > .store-category-menu-item {
            max-width: 100%;
        }

        body.storefront-app .has-common-store-header .store-category-menu-link {
            min-height: 34px !important;
            white-space: normal !important;
            overflow-wrap: anywhere;
        }

        body.storefront-app .has-common-store-header > :is(.store-tool-search-control, .storefront-header-search-control) {
            grid-area: search !important;
            display: block !important;
            position: relative !important;
            width: 46px !important;
            margin: 0 !important;
            z-index: 1206 !important;
        }

        body.storefront-app .has-common-store-header > .store-main-actions {
            grid-area: actions !important;
            position: static !important;
            display: flex !important;
            align-items: center !important;
            justify-content: flex-end !important;
            flex-wrap: nowrap !important;
            width: max-content !important;
            max-width: none !important;
            gap: 8px !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
        }

        body.storefront-app .has-common-store-header.has-search > .store-main-actions:has(> :not([hidden])) {
            padding-inline-start: 8px !important;
        }

        /* On both homepages, the open search uses the navigation track. */
        body.storefront-app .has-home-inline-search .has-common-store-header:has(> :is(.store-tool-search-control, .storefront-header-search-control).is-open) > .store-category-menu-bar {
            visibility: hidden !important;
        }

        body.storefront-app .has-home-inline-search .has-common-store-header > :is(.store-tool-search-control, .storefront-header-search-control).is-open {
            display: contents !important;
        }

        .has-home-inline-search :is(.store-tool-search-control, .storefront-header-search-control).is-open > :is(.store-tool-search-toggle, .storefront-header-search-toggle) {
            grid-area: search;
            position: relative;
            z-index: 1206;
        }

        body.storefront-app .has-home-inline-search .has-common-store-header > :is(.store-tool-search-control, .storefront-header-search-control).is-open > :is(.store-tool-search-popover, .storefront-header-search-popover) {
            display: block !important;
            grid-area: nav;
            position: relative !important;
            inset: auto !important;
            justify-self: end;
            width: min(530px, calc(100% - 16px)) !important;
            margin-inline: 8px;
            padding: 0 !important;
            border: 0 !important;
            background: transparent !important;
            box-shadow: none !important;
            z-index: 1206;
        }

        .has-home-inline-search .store-tool-search-control.is-open .store-tool-search-panel {
            position: absolute !important;
            inset: calc(100% + 8px) 0 auto !important;
            margin: 0 !important;
            padding: 6px !important;
            border: 1px solid #dce4ec !important;
            border-radius: 10px !important;
            box-shadow: 0 14px 32px #17324b24 !important;
        }
    }
}
