html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-body);

    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;

    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-secondary);
}

input,
button,
textarea,
select {
    font-family: inherit;
}

button {
    cursor: pointer;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--main-focus);
    outline-offset: 2px;
}

.container {
    margin: 0 auto;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

main {
    flex: 1;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#budget-modal .modal-content,
.filters-menu,
.facet-container ul {
    overscroll-behavior: contain;
}

.purple-text {
    color: var(--main-purple);
}

.purple-text strong,
.purple-text b {
    color: inherit;
}

.product-top-section {
    position: relative;
    display: block;
    width: 100%;
}

/* --- Performance Optimizations --- */
.product,
.store-card,
.price-drop-item {
    contain: layout style;
    transform: translateZ(0);
}

/* --- Theme Toggle Button --- */
#theme-toggle-btn .moon {
    display: none;
}

#theme-toggle-btn .sun {
    display: block;
    fill: none;
    stroke: currentColor;
}

body.dark-mode #theme-toggle-btn .moon {
    display: block;
    fill: none;
    stroke: currentColor;
}

body.dark-mode #theme-toggle-btn .sun {
    display: none;
}

/* --- Beta Badge Utility --- */
.beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--text-muted);
    color: var(--text-inverse);
    -webkit-text-fill-color: var(--text-inverse);
    font-size: clamp(0.5rem, 1.5vw, 0.58rem);
    font-weight: 600;
    padding: 0.22em 0.5em;
    border-radius: 3px;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 0.4em;
    line-height: 1;
    border: none;
    letter-spacing: 0.03em;
    position: relative;
    top: -1px;
}

body.dark-mode .beta-badge {
    background: color-mix(in srgb, var(--text-muted), transparent 70%);
    color: var(--text-main);
    -webkit-text-fill-color: var(--text-main);
}

/* --- New Badge Utility --- */
.new-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--status-success);
    color: white;
    -webkit-text-fill-color: white;
    font-size: clamp(0.45rem, 1.5vw, 0.55rem);
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    vertical-align: middle;
    line-height: 1;
    border: none;
    letter-spacing: 0.03em;
    margin-right: 2px;
}

/* --- Modal Close Bar (shared across all modals) --- */
.modal-close-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-shrink: 0;
    padding: 6px 18px 0 0;
    position: relative;
    z-index: 10;
}

.modal-close-bar button {
    background: transparent !important;
    border: none !important;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    margin: 0 !important;
    padding: 0;
    flex-shrink: 0;
    box-shadow: none !important;
    opacity: 0.6;
}

.modal-close-bar button:hover {
    color: var(--status-alert);
    opacity: 1;
    transform: scale(1.1) !important;
}

.modal-close-bar button:active {
    transform: scale(0.95) !important;
}

body,
html {
    overflow-anchor: none;
}