@property --theme-viewport-color {
    syntax: "<color>";
    inherits: true;
    initial-value: #ffffff;
}

:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --theme-viewport-color: #ffffff;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #101112;
    --theme-surface: #191b1d;
    --theme-raised: #222528;
    --theme-hover: #292c30;
    --theme-text: #f2f2f0;
    --theme-muted: #b7b8b9;
    --theme-border: #383c40;
    --theme-accent: #ffad68;
    --theme-accent-surface: #37271d;
    --theme-shadow: 0 12px 28px rgba(0, 0, 0, .34);
    --theme-success: #83d6a7;
    --theme-success-surface: #183225;
    --theme-danger: #ff9b98;
    --theme-danger-surface: #3c2224;
    --theme-warning: #ffcb80;
    --theme-warning-surface: #382b1b;
    --theme-info: #9abfff;
    --theme-info-surface: #1d2c44;
    --theme-viewport-color: var(--theme-bg);
    background-color: var(--theme-viewport-color);
}

html[data-theme="light"] {
    color-scheme: light;
    background-color: var(--theme-viewport-color);
}

.theme-viewport-edge {
    display: none;
}

@media (any-pointer: coarse), (max-width: 767px) {
    html[data-theme] body {
        background-color: var(--theme-viewport-color);
    }

    /* Give the browser a solid, live color to sample at each viewport edge. */
    .theme-viewport-edge {
        display: block;
        position: fixed;
        z-index: 2147483646;
        background-color: var(--theme-viewport-color);
        pointer-events: none;
    }

    .theme-viewport-edge--top,
    .theme-viewport-edge--bottom {
        inset-inline: 0;
    }

    .theme-viewport-edge--top {
        top: 0;
        height: max(16px, var(--safe-area-top));
    }

    .theme-viewport-edge--bottom {
        /* Keep a stable layer as the browser's bottom controls move. */
        --edge-bottom-reserve: max(var(--safe-area-bottom), env(safe-area-max-inset-bottom, 36px));
        bottom: calc(var(--safe-area-bottom) - var(--edge-bottom-reserve));
        height: calc(12px + var(--edge-bottom-reserve));
    }

    .theme-viewport-edge--left,
    .theme-viewport-edge--right {
        inset-block: 0;
    }

    .theme-viewport-edge--left {
        left: 0;
        width: var(--safe-area-left);
    }

    .theme-viewport-edge--right {
        right: 0;
        width: var(--safe-area-right);
    }
}

html.theme-live-fade :is(.product-card, .mobile-nav, .cart-sidebar, .filter-panel) {
    transition-property: background-color, border-color, color, transform, visibility;
    transition-duration: var(--theme-live-duration);
    transition-timing-function: ease-in-out;
}

html.theme-crossfade::view-transition {
    pointer-events: none;
}

html.theme-crossfade::view-transition-group(root),
html.theme-crossfade::view-transition-old(root),
html.theme-crossfade::view-transition-new(root) {
    animation-duration: 380ms;
    animation-timing-function: cubic-bezier(.33, 0, .2, 1);
}

.theme-transition-veil {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    opacity: 0;
    pointer-events: none;
}

html.theme-applying,
html.theme-applying *,
html.theme-applying *::before,
html.theme-applying *::after {
    transition: none !important;
}

.theme-toggle {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #e9bd9d;
    border-radius: 50%;
    background: #fff1e3;
    color: #883d0e;
    font-size: .92rem;
    line-height: 1;
    cursor: pointer;
}

.theme-toggle .theme-toggle__icon--light,
html[data-theme="dark"] .theme-toggle .theme-toggle__icon--dark {
    display: none;
}

.theme-toggle:hover {
    background: #ffe5cd;
    border-color: #dca474;
}

.theme-toggle:focus-visible {
    outline: 2px solid #aa4f0d;
    outline-offset: 3px;
}

html[data-theme="dark"] .theme-toggle {
    background: var(--theme-accent);
    border-color: var(--theme-accent);
    color: var(--theme-bg);
}

html[data-theme="dark"] .theme-toggle:hover {
    background: #ffc18e;
    border-color: #ffc18e;
}

html[data-theme="dark"] .theme-toggle:focus-visible {
    outline-color: var(--theme-accent);
}

html[data-theme="dark"] .theme-toggle .theme-toggle__icon--light {
    display: block;
}
