.shop-header .shop-legal-back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; margin-left: auto; border: 1px solid #dedede; border-radius: 50%; color: var(--bs-gray-700, #495057); background: var(--bs-gray-100, #f8f9fa); text-decoration: none; }
.shop-header .shop-legal-back:hover { background: var(--bs-gray-200, #e9ecef); }
.shop-header .shop-legal-back:focus-visible { outline: 2px solid var(--tenant-primary-color); outline-offset: 3px; }
body.shop-ui .shop-header .fixed-header > .shop-legal-header { display: flex !important; justify-content: flex-start; gap: 12px; }
.shop-header .shop-legal-header .shop-legal-back { margin-left: 0; }
.shop-header .shop-legal-header :is(.shop-header-accounts, .shop-header-favorites, .shop-header-cart) { display: none !important; }

/* Keep desktop account circles the same size, including their selection border. */
@media (min-width: 768px) {
    body.shop-ui .shop-header .accounts-list { align-items: flex-start !important; }
    body.shop-ui .shop-header .account-btn { position: relative; padding: 6px; transform: none; }
    body.shop-ui .shop-header .account-btn img {
        width: 40px !important; height: 40px !important; box-sizing: border-box;
        border: 1px solid var(--bs-border-color); box-shadow: none; transform: none;
    }
    body.shop-ui .shop-header .account-btn.active img {
        border-color: var(--tenant-primary-color, var(--bs-primary));
    }
    body.shop-ui .shop-header .account-btn.active::before {
        content: ""; position: absolute; right: 5px; top: 31px;
        width: 16px; height: 16px; box-sizing: border-box; border: 2px solid white;
        border-radius: 50%; background: var(--tenant-primary-color, var(--bs-primary));
        z-index: 1; pointer-events: none;
    }
    body.shop-ui .shop-header .account-btn.active::after {
        content: ""; position: absolute; right: 9.5px; top: 36px;
        width: 7px; height: 4.5px; border-left: 1.5px solid white; border-bottom: 1.5px solid white;
        transform: rotate(-45deg); z-index: 2; pointer-events: none;
    }
    body.shop-ui .shop-header .add-code-circle {
        width: 40px !important; height: 40px !important; margin-top: 6px !important;
        box-sizing: border-box; transform: none;
    }
}

/* Cap the mobile logo independently of its intrinsic size; reserve icon space. */
@media (max-width: 767px) {
    body.shop-ui .shop-header .fixed-header > .container {
        padding-inline: 12px !important; width: 100%; max-width: 100%;
    }
    body.shop-ui .shop-header .fixed-header > .container:has(.shop-header-accounts) {
        display: grid; grid-template-columns: minmax(0, 128px) minmax(max-content, 1fr) 44px 44px;
        gap: 0;
    }
    body.shop-ui .shop-header .navbar-brand {
        width: 128px; min-width: 0; max-width: 100%; margin: 0 !important; padding: 0;
        display: flex; align-items: center;
    }
    body.shop-ui .shop-header .navbar-brand .logo-size {
        display: block; width: 100%; max-width: 100%; height: 28px;
        max-height: 28px; object-fit: contain; object-position: left center;
    }
    body.shop-ui .shop-header .shop-legal-header .navbar-brand { width: 160px; }
    body.shop-ui .shop-header .shop-legal-header .logo-size { height: 34px; max-height: 34px; }
    /* Keep a 44px touch target around the smaller visual circle. */
    body.shop-ui .shop-header .shop-legal-back { position: relative; border: 0; background: transparent; }
    body.shop-ui .shop-header .shop-legal-back::before { content: ""; position: absolute; inset: 4px; background: var(--bs-gray-100, #f8f9fa); border: 1px solid #dedede; border-radius: 50%; pointer-events: none; }
    body.shop-ui .shop-header .shop-legal-back:hover::before { background: var(--bs-gray-200, #e9ecef); }
    body.shop-ui .shop-header .shop-legal-back svg { position: relative; width: 18px; height: 18px; }
    body.shop-ui .shop-header #customNavbarContent { display: none !important; }
    body.shop-ui .shop-header .shop-header-accounts,
    body.shop-ui .shop-header .shop-header-favorites,
    body.shop-ui .shop-header .shop-header-cart { margin: 0 !important; min-width: 0; }
    body.shop-ui .shop-header .shop-header-accounts { padding-inline: 8px; justify-self: start; }
    body.shop-ui .shop-header .fixed-header .accounts-list { gap: 4px !important; padding: 0 !important; margin: 0 !important; }
    body.shop-ui .shop-header .accounts-list > * { flex-shrink: 0; }
    /* Include the selection ring in the circle's size, rather than adding an outer shadow. */
    body.shop-ui .shop-header .account-btn {
        width: 38px; height: 38px; padding: 0; justify-content: center;
        transform: none; position: relative;
    }
    body.shop-ui .shop-header .account-btn img {
        width: 38px !important; height: 38px !important; box-sizing: border-box;
        border: 1px solid #e1e3e7; border-radius: 50%; object-fit: cover;
        box-shadow: none; transform: none;
    }
    body.shop-ui .shop-header .account-btn.active img {
        border: 2px solid var(--tenant-primary-color, var(--bs-primary));
    }
    /* A small check identifies the selected account without relying on color alone. */
    body.shop-ui .shop-header .account-btn.active::before {
        content: ""; position: absolute; right: -1px; bottom: -1px;
        width: 16px; height: 16px; box-sizing: border-box; border: 2px solid #fff;
        border-radius: 50%; background: var(--tenant-primary-color, var(--bs-primary));
        z-index: 1; pointer-events: none;
    }
    body.shop-ui .shop-header .account-btn.active::after {
        content: ""; position: absolute; right: 3.5px; bottom: 5px;
        width: 7px; height: 4.5px; border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
        transform: rotate(-45deg); z-index: 2; pointer-events: none;
    }
    body.shop-ui .shop-header .add-code-circle {
        margin: 0 !important; width: 38px !important; height: 38px !important;
        box-sizing: border-box; border: 1px solid #e1e3e7; box-shadow: none; transform: none;
    }
    body.shop-ui .shop-header :is(.shop-header-favorites, .shop-header-cart) .nav-item > .btn {
        display: inline-flex; align-items: center; flex-shrink: 0;
        width: 44px; height: 44px; justify-content: center; transform: translateY(5px);
    }
    body.shop-ui .shop-header :is(.shop-header-favorites, .shop-header-cart) .badge {
        left: auto !important; right: -1px; top: -2px !important; transform: none !important;
        min-width: 20px; height: 20px; padding: 0 4px;
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 11px; line-height: 1; white-space: nowrap;
    }
}
