/* Liquid-glass pill buttons, adapted from the supplied Three.js reference.
   Existing DOM controls keep their behavior; CSS and a delegated click listener
   add only the visual glass and flip effects. */
.btn,
body.dark-mode .btn,
body.storefront .btn,
button.pos-btn-checkout,
button.pos-btn-clear,
#loginPanel button[type="submit"],
body.auth-page button[type="submit"]:not(.otp-resend),
body.auth-page .auth-home-link {
    --liquid-face: rgba(63, 125, 255, .72);
    --liquid-glow: rgba(63, 125, 255, .34);
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45em;
    min-height: 44px;
    padding: 11px 22px;
    overflow: hidden;
    border: 1px solid rgba(238, 247, 255, .78);
    border-radius: 999px;
    color: #f8fbff;
    background-color: rgba(235, 244, 255, .035);
    background-image:
        linear-gradient(100deg, var(--liquid-face), var(--liquid-face)),
        linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .07) 42%, rgba(2, 8, 24, .18)),
        linear-gradient(145deg, rgba(235, 244, 255, .10), rgba(170, 195, 244, .025));
    background-repeat: no-repeat;
    background-size: 0% 100%, 100% 100%, 100% 100%;
    background-position: left center, center, center;
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
    box-shadow:
        0 4px 0 rgba(3, 8, 22, .62),
        0 9px 19px rgba(0, 0, 0, .24),
        inset 0 1px 1px rgba(255, 255, 255, .92),
        inset 0 -3px 7px rgba(0, 0, 0, .24),
        0 0 13px var(--liquid-glow);
    color: #f8fbff !important;
    font-family: Inter, system-ui, sans-serif;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .46);
    cursor: pointer;
    transition:
        transform .28s cubic-bezier(.2, .9, .25, 1.25),
        box-shadow .32s ease,
        background-size .55s cubic-bezier(.2, .75, .25, 1),
        border-color .25s ease,
        filter .25s ease;
}

.btn::before,
body.dark-mode .btn::before,
body.storefront .btn::before,
button.pos-btn-checkout::before,
button.pos-btn-clear::before,
#loginPanel button[type="submit"]::before,
body.auth-page button[type="submit"]:not(.otp-resend)::before,
body.auth-page .auth-home-link::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 1px;
    border: 1px solid rgba(255, 255, 255, .27);
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, .27), transparent 38%, rgba(255, 255, 255, .035));
    pointer-events: none;
}

.btn:hover,
body.dark-mode .btn:hover,
body.storefront .btn:hover,
button.pos-btn-checkout:hover,
button.pos-btn-clear:hover,
.btn:is([aria-pressed="true"], [aria-selected="true"], [data-state="on"], .active),
body.dark-mode .btn:is([aria-pressed="true"], [aria-selected="true"], [data-state="on"], .active),
body.storefront .btn:is([aria-pressed="true"], [aria-selected="true"], [data-state="on"], .active),
#loginPanel button[type="submit"]:hover,
body.auth-page button[type="submit"]:not(.otp-resend):hover,
body.auth-page .auth-home-link:hover {
    transform: translateY(-2px) perspective(700px) rotateX(2deg);
    border-color: rgba(248, 252, 255, .96);
    background-size: 100% 100%, 100% 100%, 100% 100%;
    box-shadow:
        0 6px 0 rgba(3, 8, 22, .43),
        0 14px 25px rgba(0, 0, 0, .34),
        inset 0 1px 1px rgba(255, 255, 255, .88),
        inset 0 -3px 8px rgba(0, 0, 0, .25),
        0 0 20px var(--liquid-glow);
    filter: brightness(1.08);
}

.btn:active,
body.dark-mode .btn:active,
body.storefront .btn:active,
button.pos-btn-checkout:active,
button.pos-btn-clear:active,
#loginPanel button[type="submit"]:active,
body.auth-page button[type="submit"]:not(.otp-resend):active,
body.auth-page .auth-home-link:active {
    transform: translateY(2px) scale(.985);
    background-size: 100% 100%, 100% 100%, 100% 100%;
    box-shadow:
        0 1px 0 rgba(3, 8, 22, .5),
        0 3px 8px rgba(0, 0, 0, .25),
        inset 0 2px 5px rgba(0, 0, 0, .24),
        inset 0 1px 1px rgba(255, 255, 255, .68);
    filter: brightness(1.12);
}

.btn:focus-visible,
body.dark-mode .btn:focus-visible,
body.storefront .btn:focus-visible,
button.pos-btn-checkout:focus-visible,
button.pos-btn-clear:focus-visible,
#loginPanel button[type="submit"]:focus-visible,
body.auth-page button[type="submit"]:not(.otp-resend):focus-visible,
body.auth-page .auth-home-link:focus-visible {
    outline: 3px solid rgba(167, 218, 255, .9);
    outline-offset: 4px;
}

.btn:disabled,
.btn[aria-disabled="true"],
body.dark-mode .btn:disabled,
body.dark-mode .btn[aria-disabled="true"],
body.storefront .btn:disabled,
body.storefront .btn[aria-disabled="true"],
button.pos-btn-checkout:disabled,
button.pos-btn-clear:disabled,
body.auth-page button[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: .58;
    filter: grayscale(.35);
    transform: none;
}

.btn-secondary {
    --liquid-face: rgba(151, 171, 205, .52);
    --liquid-glow: rgba(163, 190, 230, .20);
}

button.pos-btn-clear {
    --liquid-face: rgba(151, 171, 205, .52);
    --liquid-glow: rgba(163, 190, 230, .20);
}

.btn-danger {
    --liquid-face: rgba(255, 48, 58, .77);
    --liquid-glow: rgba(255, 48, 58, .38);
}

.btn-ai {
    --liquid-face: rgba(137, 111, 255, .75);
    --liquid-glow: rgba(137, 111, 255, .34);
}

/* The storefront skin contains legacy !important backgrounds; replace those
   layers explicitly so the liquid reveal is the same in both site sections. */
body.storefront .btn,
body.storefront .btn-secondary,
body.storefront .btn-danger,
body.storefront .btn-ai {
    color: #f8fbff !important;
    background-color: rgba(235, 244, 255, .035) !important;
    background-image:
        linear-gradient(100deg, var(--liquid-face), var(--liquid-face)),
        linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .07) 42%, rgba(2, 8, 24, .18)),
        linear-gradient(145deg, rgba(235, 244, 255, .10), rgba(170, 195, 244, .025)) !important;
    background-repeat: no-repeat !important;
    background-size: 0% 100%, 100% 100%, 100% 100% !important;
    background-position: left center, center, center !important;
}

body.storefront .btn:hover,
body.storefront .btn:is([aria-pressed="true"], [aria-selected="true"], [data-state="on"], .active) {
    background-size: 100% 100%, 100% 100%, 100% 100% !important;
}

body.storefront .btn:active {
    background-size: 100% 100%, 100% 100%, 100% 100% !important;
}

body.storefront .btn.is-liquid-bouncing {
    background-size: 100% 100%, 100% 100%, 100% 100% !important;
}

.btn.is-liquid-bouncing,
button.pos-btn-checkout.is-liquid-bouncing,
button.pos-btn-clear.is-liquid-bouncing,
body.auth-page #loginPanel button[type="submit"].is-liquid-bouncing,
body.auth-page button[type="submit"]:not(.otp-resend).is-liquid-bouncing,
body.auth-page .auth-home-link.is-liquid-bouncing {
    animation: liquid-button-flip 1.1s cubic-bezier(.2, .78, .24, 1) both;
    background-size: 100% 100%, 100% 100%, 100% 100%;
    transform-style: preserve-3d;
}

@keyframes liquid-button-flip {
    0%   { transform: perspective(700px) translateY(0) rotateX(0) scale(1); }
    18%  { transform: perspective(700px) translateY(-8px) rotateX(205deg) scale(.96); }
    42%  { transform: perspective(700px) translateY(-15px) rotateX(388deg) scale(1.04); }
    62%  { transform: perspective(700px) translateY(-4px) rotateX(354deg) scale(.985); }
    82%  { transform: perspective(700px) translateY(-1px) rotateX(363deg) scale(1.008); }
    100% { transform: perspective(700px) translateY(0) rotateX(360deg) scale(1); }
}

.btn-sm {
    min-height: 32px;
    padding: 6px 14px;
    font-size: .78rem;
}

/* Preserve dense table sizing while restoring the glass bevel and pill edge. */
body.dark-mode .data-table .btn {
    min-height: 30px;
    padding: 6px 11px;
    border: 1px solid rgba(238, 247, 255, .55);
    border-radius: 999px;
    background-size: 0% 100%, 100% 100%, 100% 100%;
    box-shadow:
        0 3px 0 rgba(3, 8, 22, .46),
        0 6px 12px rgba(0, 0, 0, .22),
        inset 0 1px 1px rgba(255, 255, 255, .72),
        inset 0 -2px 5px rgba(0, 0, 0, .30),
        0 0 10px var(--liquid-glow);
}

body.dark-mode .data-table .btn:hover,
body.dark-mode .data-table .btn:is([aria-pressed="true"], [aria-selected="true"], [data-state="on"], .active) {
    transform: translateY(-1px);
    background-size: 100% 100%, 100% 100%, 100% 100%;
    box-shadow:
        0 4px 0 rgba(3, 8, 22, .4),
        0 9px 16px rgba(0, 0, 0, .28),
        inset 0 1px 1px rgba(255, 255, 255, .8),
        inset 0 -2px 6px rgba(0, 0, 0, .24),
        0 0 15px var(--liquid-glow);
}

/* Keep the compact product-card actions pill-shaped too. */
.store-product-card--row .store-product-card-actions .btn {
    border-radius: 999px !important;
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    body.dark-mode .btn,
    body.storefront .btn,
    button.pos-btn-checkout,
    button.pos-btn-clear,
    #loginPanel button[type="submit"],
    body.auth-page button[type="submit"]:not(.otp-resend),
    body.auth-page .auth-home-link { transition: none; }
    .btn.is-liquid-bouncing,
    button.pos-btn-checkout.is-liquid-bouncing,
    button.pos-btn-clear.is-liquid-bouncing,
    body.auth-page #loginPanel button[type="submit"].is-liquid-bouncing,
    body.auth-page button[type="submit"]:not(.otp-resend).is-liquid-bouncing,
    body.auth-page .auth-home-link.is-liquid-bouncing { animation: none; }
}
