#custom_savings_popup {
        display: none;
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background-color: rgba(34,37,41,0.9);
        z-index: 9999;
        justify-content: center; align-items: center;
        padding: 10px;
    }
    #custom_savings_popup .custom_popup-content {
        box-sizing: border-box;
        width: 100%; max-width: var(--caatc-popup-width, 500px);
        padding: 20px; border-radius: 10px; text-align: center;
        position: relative; box-shadow: 0 4px 6px rgba(0,0,0,0.1); max-height:90vh; overflow-y:auto;
        background-color: #fff; color: #000;
    }
    #custom_savings_popup #custom_close_popup {
        background: transparent; border: 0; color: inherit;
        position: absolute; top: 10px; right: 15px;
        font-size: 24px; cursor: pointer;
    }
    #custom_savings_popup .custom_popup-content img.main_product_image {
        max-width: 150px; height: auto;
        margin-bottom: 20px; border-radius: 10px; object-fit: contain;
    }
    #custom_savings_popup .custom_popup-buttons {
        display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px;
    }
    #custom_savings_popup .custom_popup-buttons .custom_button {
        color: #fff; padding: 10px 20px;
        text-decoration: none; border-radius: 5px; border: none;
        cursor: pointer; transition: background-color 0.3s ease;
        background-color: #333;
    }
    form.cart .custom_loading {
        position: relative;
    }
    form.cart .custom_loading::after {
        content: '';
        border: 2px solid #fff; border-top: 2px solid #222;
        border-radius: 50%; width: 14px; height: 14px;
        animation: caatc-spin 0.7s linear infinite;
        position: absolute; right: -25px; top: 50%;
        transform: translateY(-50%);
    }

    #custom_savings_popup .caatc-status { font-size: 14px; margin: 10px 0 16px; min-height: 22px; }
    #custom_savings_popup .caatc-status[data-state="pending"]::before { content: ""; display:inline-block; width:13px; height:13px; margin-right:8px; border:2px solid currentColor; border-top-color:transparent; border-radius:50%; animation:caatc-spin .7s linear infinite; vertical-align:-2px; }
    #custom_savings_popup .caatc-status[data-state="success"]::before { content: "✓ "; font-weight:bold; }
    #custom_savings_popup .caatc-status[data-state="error"] { color:#b42318; }
    #custom_savings_popup .caatc-navigation[aria-disabled="true"] { pointer-events:none; opacity:.5; }
    @keyframes caatc-spin { to {transform:rotate(360deg)} }
    .caatc-stock-status p { color: #8e8050; font-weight: 700; }
    #custom_savings_popup .recommended-products h3 { margin-bottom: 10px; }
    #custom_savings_popup .recommended-products .recommended-list {
        display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
    }
    #custom_savings_popup .recommended-products .recommended-item {
        text-align: center; width: 100px; max-width: 100%;
    }
    #custom_savings_popup .recommended-products .recommended-item img {
        max-width: 100%; height: auto; border-radius: 5px;
    }
    #custom_savings_popup .recommended-products .rec-title {
        display: block; margin-top: 5px; font-size: 12px; text-decoration: none;
    }
#custom_savings_popup { box-sizing: border-box; overflow-wrap: anywhere; }
#custom_savings_popup .custom_popup-content { max-height: min(90vh, 90dvh); overscroll-behavior: contain; }
#custom_savings_popup #custom_close_popup { min-width: 44px; min-height: 44px; }
#custom_savings_popup h2 { margin-inline: 32px; }
#custom_savings_popup :focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
@media (max-width: 480px) { #custom_savings_popup .custom_popup-buttons > * { width: 100%; } }
@media (prefers-reduced-motion: reduce) {
    #custom_savings_popup *, #custom_savings_popup *::before, form.cart .custom_loading::after { animation: none; transition: none; }
}

#custom_savings_popup .caatc-amounts {
    display: grid;
    grid-template-columns: 1fr minmax(0, 1.4fr);
    align-items: baseline;
    gap: .35rem 1rem;
    margin: 1rem 0;
    padding: .75rem 0;
    border-block: 1px solid currentColor;
    text-align: start;
}
#custom_savings_popup .caatc-amounts dt, #custom_savings_popup .caatc-amounts dd { margin: 0; }
#custom_savings_popup .caatc-amounts dd { text-align: end; }
#custom_savings_popup .caatc-amounts small { display: block; font-weight: 400; }
#custom_savings_popup .caatc-total { font-weight: 700; }
#custom_savings_popup.caatc-enhanced .custom_popup-buttons { display: grid; gap: .35rem; }
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .custom_button { width: 100%; min-height: 44px; box-sizing: border-box; }
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .button_checkout { font-weight: 700; }
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .button_continue_shopping,
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .button_view_cart { background: transparent; color: inherit; }
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .button_view_cart { text-decoration: underline; }

/* The compact coastal edition and the original A/B comparison share one dialog. */
#custom_savings_popup .caatc-coast,
#custom_savings_popup .caatc-quantity:empty,
#custom_savings_popup .caatc-product-name:empty,
#custom_savings_popup .caatc-cart-summary:empty,
#custom_savings_popup .caatc-item[hidden] { display: none; }
#custom_savings_popup:not(.caatc-enhanced) .custom_popup-content { display: flex; flex-direction: column; align-items: center; }
#custom_savings_popup:not(.caatc-enhanced) :is(.caatc-header,.caatc-item:not([hidden]),.caatc-item-details) { display: contents; }
#custom_savings_popup:not(.caatc-enhanced) .caatc-quantity { display: none; }
#custom_savings_popup:not(.caatc-enhanced) .main_product_image { order: 1; }
#custom_savings_popup:not(.caatc-enhanced) h2 { order: 2; }
#custom_savings_popup:not(.caatc-enhanced) .caatc-product-name { order: 3; }
#custom_savings_popup:not(.caatc-enhanced) .caatc-status { order: 4; }
#custom_savings_popup:not(.caatc-enhanced) .custom_popup-buttons { order: 5; }
#custom_savings_popup:not(.caatc-enhanced) .recommended-products { order: 6; }

#custom_savings_popup.caatc-enhanced {
    --caatc-paper-edge: clamp(16px, 5vw, 28px);
    background: rgba(8, 26, 37, .69);
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
#custom_savings_popup.caatc-enhanced .custom_popup-content {
    isolation: isolate;
    overflow-x: hidden;
    padding: 0 0 8px;
    max-height: min(94vh, 94dvh);
    border-radius: 15px;
    text-align: start;
    line-height: 1.45;
    box-shadow: 0 20px 70px rgba(5, 20, 29, .42);
}
#custom_savings_popup.caatc-enhanced #custom_close_popup {
    z-index: 2; inset: 5px 6px auto auto; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: 50%; color: #fffaed; background: transparent; outline: none;
    font-size: 27px; line-height: 1; box-shadow: none;
}
#custom_savings_popup.caatc-enhanced .caatc-header {
    isolation: isolate; position: relative; overflow: hidden;
    display: grid; align-content: center; gap: 7px; box-sizing: border-box;
    min-height: 148px; padding: 24px min(36%, 166px) 24px var(--caatc-paper-edge);
    color: #fff8e6; background: linear-gradient(111deg,#122e3b 12%,#1d4753 76%,#2c5557);
    border-bottom: 3px solid #be965c;
}
#custom_savings_popup.caatc-enhanced h2.caatc-heading {
    margin: 0; padding: 0; border: 0; color: inherit;
    font-size: clamp(29px, 5vw, 39px); font-weight: 500;
    line-height: 1.08; letter-spacing: -.035em; text-transform: none; overflow-wrap: anywhere;
}
#custom_savings_popup.caatc-enhanced .caatc-status {
    color: #faf2dc; margin: 0; min-height: 0; line-height: 1.45; font-size: 15px;
}
#custom_savings_popup.caatc-enhanced .caatc-status[data-state="success"]::before { content: none; }
#custom_savings_popup.caatc-enhanced .caatc-status[data-state="error"] { color: #ffdfca; }

/* Six flat shapes make a small two-colour lighthouse print. No network assets. */
#custom_savings_popup.caatc-enhanced .caatc-coast {
    position: absolute; display: block; pointer-events: none; z-index: -1;
    right: 0; bottom: 0; width: min(36%, 166px); height: 126px; overflow: hidden;
}
#custom_savings_popup .caatc-coast i { position: absolute; display: block; }
#custom_savings_popup .caatc-sun {
    width: 48px; height: 48px; border-radius: 50%; bottom: 40px; right: 38%;
    background: repeating-linear-gradient(0deg,transparent 0 5px,#1b43503b 5px 6px),#e8be7e;
}
#custom_savings_popup .caatc-beam {
    right: 24%; bottom: 59px; width: 67%; height: 30px;
    background: linear-gradient(90deg,transparent,#f6d58e70); clip-path: polygon(0 0,100% 53%,0 100%);
}
#custom_savings_popup .caatc-shore {
    bottom: 15px; right: -2%; width: 104%; height: 27px; background: #122e3b;
    clip-path: polygon(0 96%,14% 88%,24% 70%,37% 63%,50% 38%,62% 29%,75% 20%,85% 34%,100% 21%,100% 100%,0 100%);
}
#custom_savings_popup .caatc-tower {
    width: 24px; height: 42px; bottom: 35px; right: 19%;
    background: linear-gradient(90deg,#0000 70%,#213c443b 70%),linear-gradient(to top,#f4ddb1 0 32%,#be7557 32% 63%,#f4ddb1 63%);
    clip-path: polygon(27% 0,74% 0,96% 100%,3% 100%);
}
#custom_savings_popup .caatc-tower::after {
    content: ''; position: absolute; bottom: 0; left: 10px; width: 4px; height: 7px;
    background: #213c44; border-radius: 2px 2px 0 0;
}
#custom_savings_popup .caatc-lantern {
    width: 24px; height: 18px; bottom: 76px; right: 19%;
    background: linear-gradient(to bottom,#c88d68 0 36%,#153642 36% 50%,#ffdfa1 50% 78%,#153642 78% 90%,#e5c394 90%);
    clip-path: polygon(50% 0,93% 36%,76% 44%,76% 78%,100% 78%,100% 100%,2% 100%,2% 78%,24% 78%,24% 44%,7% 36%);
}
#custom_savings_popup .caatc-sea {
    bottom: 0; right: 0; width: 100%; height: 25px;
    background: repeating-linear-gradient(to bottom,#517d7b 0 1px,#214951 1px 4px,#315d63 4px 6px);
    clip-path: polygon(0 88%,18% 55%,36% 49%,56% 23%,75% 24%,100% 0,100% 100%,0 100%);
}
#custom_savings_popup.caatc-enhanced .caatc-item {
    display: flex; align-items: center; gap: 16px; margin: 0 var(--caatc-paper-edge);
    padding: 18px 0; border-bottom: 1px solid #a79f8f70;
}
#custom_savings_popup.caatc-enhanced .caatc-item[hidden] { display: none; }
#custom_savings_popup.caatc-enhanced .custom_popup-content img.main_product_image {
    margin: 0; flex: none; width: 64px; height: 64px; max-width: 30%;
    border: 1px solid #b7ad9860; border-radius: 8px; background: #fff; object-fit: contain;
}
#custom_savings_popup.caatc-enhanced .caatc-item-details { min-width: 0; }
#custom_savings_popup.caatc-enhanced .caatc-product-name {
    color: inherit; font-size: 18px; line-height: 1.3; font-weight: 650; margin: 0;
}
#custom_savings_popup.caatc-enhanced .caatc-quantity { font-size: 14px; line-height: 1.5; }
#custom_savings_popup.caatc-enhanced .caatc-cart-summary { margin: 0 var(--caatc-paper-edge); }
#custom_savings_popup.caatc-enhanced .caatc-amounts {
    margin: 0; padding: 16px 0 14px; gap: 9px 12px; border: 0; font-size: 15px; line-height: 1.4;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr); align-items: start;
}
#custom_savings_popup.caatc-enhanced .caatc-amounts dd { font-variant-numeric: tabular-nums; }
#custom_savings_popup.caatc-enhanced .caatc-amounts small { font-size: 13px; }
#custom_savings_popup.caatc-enhanced .caatc-amounts .caatc-total {
    grid-row: 3; padding-top: 3px; align-self: baseline; font-size: 17px; font-weight: 700;
}
#custom_savings_popup.caatc-enhanced .caatc-amounts dd.caatc-total {
    font-size: 24px; line-height: 1.2;
}
#custom_savings_popup.caatc-enhanced .caatc-shipping-hint { margin: 0 0 12px; font-size: 14px; }
#custom_savings_popup.caatc-enhanced .custom_popup-buttons {
    grid-template-columns: repeat(2, minmax(0,1fr)); margin: 4px var(--caatc-paper-edge) 0; gap: 3px 8px;
}
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .custom_button {
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: 44px; border-radius: 7px; padding: 8px 6px; line-height: 1.25; font-size: 15px;
}
#custom_savings_popup.caatc-enhanced .custom_popup-buttons .button_checkout {
    grid-column: 1 / -1; min-height: 49px; gap: 10px; font-size: 17px; border: 1px solid #0002;
}
#custom_savings_popup.caatc-enhanced .button_checkout::after { content: '→'; font-size: 1.25em; line-height: 1; }
#custom_savings_popup.caatc-enhanced .button_checkout[href]:hover { filter: brightness(.95); }
#custom_savings_popup.caatc-enhanced :is(.button_view_cart,.button_continue_shopping):hover { text-decoration: underline; text-underline-offset: 3px; }
#custom_savings_popup.caatc-enhanced .recommended-products {
    margin: 8px var(--caatc-paper-edge) 12px; padding-top: 14px; border-top: 1px solid #a79f8f70;
}
#custom_savings_popup.caatc-enhanced .recommended-products h3 {
    margin: 0 0 12px; font-size: 20px; font-weight: 600; line-height: 1.2; text-transform: none; letter-spacing: -.01em;
}
#custom_savings_popup.caatc-enhanced .recommended-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,100px),1fr)); gap: 14px 10px; }
#custom_savings_popup.caatc-enhanced .recommended-item { width: auto; text-align: start; min-width: 0; }
#custom_savings_popup.caatc-enhanced .recommended-item img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; border-radius: 6px; }
#custom_savings_popup.caatc-enhanced .recommended-item .rec-title { margin-top: 4px; font-size: 14px; line-height: 1.35; }
@media (max-width: 380px) {
    #custom_savings_popup.caatc-enhanced .caatc-header { min-height: 136px; padding-right: 31%; }
    #custom_savings_popup.caatc-enhanced .caatc-coast { width: 30%; }
}

#custom_savings_popup.caatc-enhanced #custom_close_popup::before {
    content: ''; position: absolute; inset: 7px; border: 1px solid #e9dec580; border-radius: 50%;
}
#custom_savings_popup.caatc-enhanced #custom_close_popup:focus-visible {
    outline: 2px solid #f6d59b; outline-offset: -5px;
}
#custom_savings_popup.caatc-enhanced #custom_close_popup:hover::before { background: #fff2; }
#custom_savings_popup.caatc-enhanced .caatc-amounts::after {
    content: ''; grid-column: 1 / -1; grid-row: 2; border-top: 1px dashed #a79f8f90;
}
@media (max-width: 380px) {
    #custom_savings_popup.caatc-enhanced .caatc-coast { height: 102px; }
    #custom_savings_popup .caatc-tower, #custom_savings_popup .caatc-lantern { right: 34%; }
    #custom_savings_popup .caatc-beam { right: 41%; }
    #custom_savings_popup .caatc-sun { right: 50%; width: 39px; height: 39px; }
}


/* The dialog is attached to the body. Carry scoped product-page typography into it. */
#custom_savings_popup,
#custom_savings_popup :is(.custom_popup-content, .caatc-status, .caatc-product-name, .caatc-quantity, .caatc-shipping-hint, .caatc-amounts dt, .caatc-amounts small, .rec-title) {
    font-family: var(--caatc-text-font, inherit);
}
#custom_savings_popup .caatc-amounts dd {
    font-family: var(--caatc-price-font, var(--caatc-text-font, inherit));
}
#custom_savings_popup :is(.custom_button, #custom_close_popup) {
    font-family: var(--caatc-button-font, var(--caatc-text-font, inherit));
}
