/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-ecommerce: "Inter", "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-price: "Inter", "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --primary: #1358ff;
    --primary-light: #1f67ff;
    --primary-dark: #0f4ee8;
    --primary-bg: #edf3ff;
    --text-dark: #0b1430;
    --text-mid: #263044;
    --text-light: #66758d;
    --text-muted: #96a0b2;
    --border: #e2e8f2;
    --border-strong: #d8e0ec;
    --bg-white: #ffffff;
    --bg-page: #f5f6fa;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --shadow-nav: 0 1px 0 rgba(15, 23, 42, 0.02), 0 10px 24px rgba(15, 23, 42, 0.04);
    --card-bg: #ffffff;
    --primary-soft: #edf3ff;
    --primary-soft-border: #d8e4ff;
    --image-panel: #f1f2f6;
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 14px;
    --shadow-card: 0 8px 18px rgba(18, 24, 40, 0.06);
}

body {
    font-family: var(--font-ecommerce);
    color: var(--text-dark);
    background: var(--bg-page);
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    border: none;
    background: none;
}

h1, h2, h3, h4, h5, h6,
p, a, span, button {
    font-family: var(--font-ecommerce);
}

/* ==================== RESULTS SECTION ==================== */
.results-section {
    max-width: 1440px;
    margin: 0 auto;
    padding: 34px 24px 40px;
}

.section-title {
    font-size: 32px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.045em;
    color: var(--text-dark);
}

.collection-back-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--text-light);
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.collection-back-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* ==================== HEADER ==================== */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 34px;
}

.history-subtitle {
    margin-top: 6px;
    font-size: 16px;
    line-height: 1.3;
    font-weight: 500;
    color: var(--text-light);
    letter-spacing: -0.01em;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 18px;
}

.results-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-white);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease;
}

.results-badge:hover {
    background: var(--surface-alt, #f8fafc);
}

.results-badge svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted, #94a3b8);
}

/* ==================== RESULTS SEARCH BAR ==================== */
.results-search-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-white);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.results-search-bar svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-muted, #94a3b8);
}

.results-search-bar input {
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-dark);
    width: 160px;
}

.results-search-bar input::placeholder {
    color: var(--text-light);
}

.results-search-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    border: 1px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(19, 88, 255, 0.2);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    padding: 0;
}

.results-search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(19, 88, 255, 0.26);
    background: linear-gradient(180deg, var(--primary, #2b72ff) 0%, var(--primary-dark) 100%);
}

.results-search-btn svg {
    width: 14px;
    height: 14px;
}

.filter-dropdown {
    position: relative;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-white);
    color: var(--text-dark, #1e293b);
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
    font-family: inherit;
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--surface-alt, #f8fafc);
    border-color: var(--border-strong, #cbd5e1);
}

.filter-btn svg:first-child {
    width: 16px;
    height: 16px;
    color: var(--text-mid, #475569);
}

.filter-btn svg:last-child {
    width: 14px;
    height: 14px;
    color: var(--text-muted, #94a3b8);
    transition: transform 0.18s ease;
}

.filter-dropdown.open .filter-btn svg:last-child {
    transform: rotate(180deg);
}

.filter-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-white);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

.filter-menu-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-mid);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
    font-family: inherit;
}

.filter-menu-item:hover {
    background: var(--surface-alt, #f1f5f9);
}

.filter-menu-item.active {
    color: var(--primary);
    background: var(--primary-soft);
}

/* ==================== GRID ==================== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    place-items: center;
    gap: 22px;
    align-items: start;
}


.result-card {
    --result-card-width: 332px;
    width: var(--result-card-width);
    background: linear-gradient(180deg, var(--premium-card, #ffffff) 0%, var(--premium-card, #ffffff) 82%, var(--bg-page, #fbfcff) 100%);
    border: 1px solid var(--premium-border, var(--border, #dfe6f1));
    border-radius: 20px;
    padding: 12px;
    box-shadow: var(--premium-shadow-soft, 0 8px 22px rgba(15, 23, 42, 0.07));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Cards are links to the product page (unless no product id). */
.result-card[data-product-id]:not([data-product-id="0"]) {
    cursor: pointer;
}

.result-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong, #d2ddf0);
    box-shadow: var(--premium-shadow, 0 20px 42px -12px rgba(17, 24, 39, 0.12));
}

.image-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 200px;
    padding: 0;
    background: #f2f5fa;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 10px;
    z-index: 2;
}

.icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border, rgba(226, 232, 242, 0.9));
    background: var(--overlay, rgba(255, 255, 255, 0.94));
    color: var(--text-mid, #344056);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: transform 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.icon-circle:hover {
    transform: translateY(-1px);
    color: var(--primary);
    box-shadow: 0 12px 22px rgba(17, 24, 39, 0.12);
}

/* Cheapest price: plain currency text, no icon/label/link (the whole card
   is clickable now). */
.card-price {
    margin-top: 10px;
    font-size: 20px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deal-row {
    margin-top: 10px;
    min-height: 60px;
    border: 1px solid var(--primary-soft-border);
    background: linear-gradient(180deg, var(--deal-grad-top, #f4f8ff) 0%, var(--primary-bg) 100%);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.deal-row:hover {
    border-color: var(--deal-border-hover, #bfd1ff);
    background: linear-gradient(180deg, var(--primary-soft, #f0f5ff) 0%, var(--primary-soft, #e8efff) 100%);
    transform: translateY(-1px);
}

.deal-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(19, 88, 255, 0.22);
}

.deal-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.deal-label {
    font-size: 12px;
    line-height: 1.05;
    font-weight: 750;
    color: var(--text-mid, #30384a);
    letter-spacing: -0.02em;
}

.deal-highlight {
    margin-top: 4px;
    font-size: 20px;
    line-height: 1;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.045em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deal-link-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.median-section {
    margin-top: 12px;
    margin-bottom: 12px;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.median-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-soft, #f0f5ff);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.median-label {
    font-size: 12px;
    line-height: 1.05;
    font-weight: 650;
    color: var(--text-light);
    letter-spacing: -0.015em;
}

.median-price {
    margin-top: 4px;
    font-size: 19px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.045em;
    color: var(--text-dark);
}

.details-btn {
    position: relative;
    margin-top: auto;
    height: 44px;
    min-height: 44px;
    border-radius: 11px;
    background: linear-gradient(180deg, var(--primary, #1b63ff) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 750;
    letter-spacing: -0.015em;
    box-shadow: 0 12px 24px rgba(19, 88, 255, 0.20);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.details-btn::after {
    content: "→";
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    line-height: 1;
    font-weight: 600;
}

.details-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, var(--primary, #2b72ff) 0%, var(--primary-dark) 100%);
    box-shadow: 0 16px 30px rgba(19, 88, 255, 0.26);
}

.results-bottom-divider {
    margin: 56px 10px 0;
    height: 1px;
    background: var(--surface-alt, #e4e8ef);
}

.img-placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 200px;
    color: var(--primary);
    font-size: 48px;
}

/* ==================== LOADING / SKELETON CARDS ==================== */
.loading-card {
    pointer-events: none;
}

.loading-card:hover {
    transform: none;
    border-color: var(--border, #dfe6f1);
    box-shadow: var(--shadow-card, 0 14px 30px rgba(17, 24, 39, 0.07));
}

.loading-image-shell,
.skeleton-line,
.skeleton-action,
.skeleton-status-icon,
.loading-deal-row,
.skeleton-deal-icon,
.skeleton-link-icon,
.skeleton-median-icon,
.skeleton-details-btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(100deg, var(--surface-alt, #F3F5F9) 0%, var(--surface-alt, #edf1f6) 35%, var(--bg-white, #ffffff) 52%, var(--surface-alt, #edf1f6) 68%, var(--surface-alt, #F3F5F9) 100%);
    background-size: 220% 100%;
    animation: shimmer 1.45s ease-in-out infinite;
}

.loading-image-shell {
    border: 1px solid var(--premium-border-soft);
    background-color: var(--surface-alt, #f1f4f8);
}

.loading-actions {
    gap: 10px;
}

.skeleton-action {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.04);
}

.skeleton-action::before,
.skeleton-status-icon::before,
.skeleton-link-icon::before,
.skeleton-deal-icon::before,
.skeleton-median-icon::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.42);
}

.skeleton-lines {
    margin-top: 14px;
    min-height: 46px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.skeleton-line {
    display: block;
    height: 16px;
    border-radius: 999px;
}

.title-line-lg {
    width: 78%;
    height: 18px;
}

.title-line-sm {
    width: 62%;
    height: 18px;
}

.price-line {
    width: 38%;
    height: 20px;
}

.loading-updated-row {
    margin-top: 4px;
    min-height: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.skeleton-status-icon {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.updated-line {
    width: 52%;
    height: 12px;
}

.loading-deal-row {
    margin-top: 10px;
    min-height: 60px;
    border: 1px solid #edf2fb;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.skeleton-deal-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.skeleton-deal-copy,
.skeleton-median-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deal-label-line {
    width: 54%;
    height: 12px;
}

.deal-price-line {
    width: 42%;
    height: 18px;
}

.skeleton-link-icon {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.loading-median-section {
    margin-top: 12px;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.skeleton-median-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.median-label-line {
    width: 44%;
    height: 12px;
}

.median-price-line {
    width: 34%;
    height: 18px;
}

.skeleton-details-btn {
    display: block;
    margin-top: auto;
    height: 44px;
    min-height: 44px;
    border-radius: 11px;
}

@keyframes shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -120% 0; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== LOADING HEADER ==================== */
.loading-header {
    grid-column: 1/-1;
    text-align: center;
    padding: 20px 0 12px;
}

.loading-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

.loading-text {
    color: var(--text-dark, #000000);
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-ecommerce);
    vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
    .loading-image-shell,
    .skeleton-line,
    .skeleton-action,
    .skeleton-status-icon,
    .loading-deal-row,
    .skeleton-deal-icon,
    .skeleton-link-icon,
    .skeleton-median-icon,
    .skeleton-details-btn {
        animation: none;
    }
}

@media (max-width: 1360px) {
    .results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Brand cards are smaller: never fewer than 3 per row. */
    #brands-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .results-section {
        padding: 24px 18px 30px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-controls {
        flex-wrap: wrap;
    }

    .results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ==================== COLLECTIONS POPUP ==================== */
.collections-popup {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collections-popup:not([hidden]) {
    display: flex;
}

.collections-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
}

.collections-card {
    position: relative;
    z-index: 1;
    width: 420px;
    max-width: calc(100vw - 32px);
    max-height: 70vh;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.collections-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.collections-title {
    flex: 1;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-dark);
}

.collections-add-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--primary-soft-border);
    transition: background 0.15s ease, transform 0.15s ease;
}

.collections-add-btn:hover {
    background: var(--primary-soft-border, #dce6ff);
    transform: translateY(-1px);
}

.collections-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.collections-close-btn:hover {
    background: var(--surface-alt, #f1f5f9);
    color: var(--text-dark);
}

.collections-create {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt, #fafbfe);
}

.collections-create input {
    flex: 1;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--bg-white);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.collections-create input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 88, 255, 0.1);
}

.collections-create input::placeholder {
    color: var(--text-light);
}

.collections-create-save {
    height: 38px;
    padding: 0 16px;
    border-radius: 10px;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(19, 88, 255, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.collections-create-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(19, 88, 255, 0.26);
}

.collections-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 12px;
}

.collection-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.12s ease;
    border: 1px solid transparent;
}

.collection-row:hover {
    background: var(--surface-alt, #f8fafc);
}

.collection-row.selected {
    background: var(--primary-soft);
    border-color: var(--primary-soft-border);
}

.collection-row.selected .collection-check {
    opacity: 1;
}

.collection-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--image-panel);
    display: flex;
    align-items: center;
    justify-content: center;
}

.collection-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.collection-thumb .collection-thumb-placeholder {
    font-size: 20px;
    color: var(--primary);
}

.collection-info {
    flex: 1;
    min-width: 0;
}

.collection-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collection-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
    margin-top: 2px;
}

.collection-check {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--bg-white);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.collection-row.selected .collection-check {
    background: var(--primary);
    border-color: var(--primary);
}

.collection-check svg {
    width: 14px;
    height: 14px;
    color: #fff;
}

.collections-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
}

.collections-empty-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.collections-save-btn {
    margin: 0 12px 12px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 750;
    letter-spacing: -0.01em;
    cursor: pointer;
    border: none;
    box-shadow: 0 8px 18px rgba(19, 88, 255, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.collections-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(19, 88, 255, 0.26);
}

.collections-save-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==================== COLLECTIONS GRID ==================== */
.collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 48px;
}

.collection-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.collection-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 40px rgba(18, 24, 40, 0.12);
}

.collection-thumb-single {
    width: 100%;
    aspect-ratio: 1;
    background: var(--image-panel);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collection-thumb-single img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.collection-thumb-placeholder {
    color: #c5cad3;
    font-size: 32px;
}

.collection-info {
    padding: 14px 16px 16px;
}

.collection-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.collection-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--text-dark);
    line-height: 1.2;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collection-meta {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    margin: 0;
    line-height: 1.3;
}

/* Edit and more buttons on collection cards */
.collection-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.collection-edit-btn,
.collection-more-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    opacity: 0;
}

.collection-card:hover .collection-edit-btn,
.collection-card:hover .collection-more-btn {
    opacity: 1;
}

.collection-edit-btn:hover,
.collection-more-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

/* More menu dropdown */
.collection-more-menu {
    position: fixed;
    z-index: 600;
    min-width: 200px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    padding: 6px;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
    cursor: pointer;
    transition: background 0.12s ease;
}

.more-menu-item:hover:not(:disabled) {
    background: var(--primary-soft);
    color: var(--primary);
}

.more-menu-item:disabled {
    opacity: 0.4;
    cursor: default;
}

.more-menu-item svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.more-menu-danger {
    color: var(--danger, #ef4444);
}

.more-menu-danger:hover {
    background: var(--danger-soft, #fef2f2);
    color: var(--danger, #dc2626);
}

/* ==================== EDIT COLLECTION POPUP ==================== */
.edit-collection-popup {
    position: fixed;
    inset: 0;
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-collection-popup:not([hidden]) {
    display: flex;
}

.edit-collection-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
}

.edit-collection-card {
    position: relative;
    z-index: 1;
    width: 420px;
    max-width: calc(100vw - 32px);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
    padding: 24px;
}

.edit-collection-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-dark);
    margin: 0 0 20px;
}

.edit-field {
    display: block;
    margin-bottom: 16px;
}

.edit-field span {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.edit-field input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--bg-white);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.edit-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 88, 255, 0.12);
}

.edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.edit-cancel-btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: background 0.15s ease;
}

.edit-cancel-btn:hover {
    background: var(--image-panel);
}

.edit-save-btn {
    padding: 10px 24px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.edit-save-btn:hover {
    background: var(--primary-dark);
}

/* Skeleton loading for collection cards */
.skeleton-card .collection-thumb-single {
    background: linear-gradient(90deg, var(--image-panel) 25%, #e8eaef 50%, var(--image-panel) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.collection-name-skeleton {
    height: 18px;
    width: 60%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--image-panel) 25%, #e8eaef 50%, var(--image-panel) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 8px;
}

.collection-meta-skeleton {
    height: 14px;
    width: 45%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--image-panel) 25%, #e8eaef 50%, var(--image-panel) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.collections-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
    margin-top: 24px;
    padding-bottom: 24px;
}

.collections-footer svg {
    color: #b0b8c8;
}


/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-ecommerce: "Inter", "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --primary: #1358ff;
    --primary-dark: #0f4ee8;
    --primary-soft: #edf3ff;
    --primary-soft-border: #d8e4ff;
    --text-dark: #0b1430;
    --text-mid: #2f3950;
    --text-light: #68758d;
    --border: #e3e8f2;
    --bg-white: #ffffff;
    --bg-page: #f5f6fa;
    --card-bg: #ffffff;
    --image-panel: #f1f2f6;
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 14px;
    --radius-sm: 12px;
    --shadow-card: 0 8px 18px rgba(18, 24, 40, 0.06);
}

body {
    font-family: var(--font-ecommerce);
    color: var(--text-dark);
    background: var(--bg-page);
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    border: none;
    background: none;
}

h1, h2, h3, h4, h5, h6,
p, a, span, button {
    font-family: var(--font-ecommerce);
}

/* ==================== RESULTS SECTION ==================== */
.results-section {
    max-width: 1440px;
    margin: 0 auto;
    padding: 34px 24px 40px;
}

.section-title {
    font-size: 32px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.045em;
    color: var(--text-dark);
}

/* ==================== HEADER ==================== */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 34px;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 18px;
}

.results-badge,
.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    padding: 0 22px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-white);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
}

.filter-btn {
    color: #20263b;
    font-size: 15px;
    font-weight: 750;
    cursor: pointer;
}

/* ==================== GRID ==================== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px;
    align-items: start;
}

.image-shell {
    position: relative;
    height: 208px;
    min-height: 208px;
    padding: 0;
    background: #f2f5fa;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 10px;
    z-index: 2;
}

.icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border, rgba(226, 232, 242, 0.9));
    background: var(--overlay, rgba(255, 255, 255, 0.94));
    color: var(--text-mid, #344056);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: transform 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.icon-circle:hover {
    transform: translateY(-1px);
    color: var(--primary);
    box-shadow: 0 12px 22px rgba(17, 24, 39, 0.12);
}

.listing-img {
    width: 100%;
    max-width: none;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    transform: scale(1.01);
}

/* Brand eyebrow: small muted line above the product title. Uses
   --text-muted so each theme (light/dark/sepia/contrast) supplies its
   own appropriate equivalent of the muted grey. */
.listing-brand {
    margin-top: 10px;
    font-size: 11.5px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted, #96a0b2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listing-name {
    margin-top: 4px;
    font-size: 16px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Reserve exactly two lines so the price always starts at the
       same height on every card, whatever the name length. */
    min-height: 40px;
}

.deal-row {
    margin-top: 10px;
    min-height: 60px;
    border: 1px solid var(--primary-soft-border);
    background: linear-gradient(180deg, var(--deal-grad-top, #f4f8ff) 0%, var(--primary-bg) 100%);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.deal-row:hover {
    border-color: var(--deal-border-hover, #bfd1ff);
    background: linear-gradient(180deg, var(--primary-soft, #f0f5ff) 0%, var(--primary-soft, #e8efff) 100%);
    transform: translateY(-1px);
}

.deal-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(19, 88, 255, 0.22);
}

.deal-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.deal-label {
    font-size: 12px;
    line-height: 1.05;
    font-weight: 750;
    color: var(--text-mid, #30384a);
    letter-spacing: -0.02em;
}

.deal-highlight {
    margin-top: 4px;
    font-size: 20px;
    line-height: 1;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.045em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deal-link-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.median-section {
    margin-top: 12px;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.median-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-soft, #f0f5ff);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.median-label {
    font-size: 12px;
    line-height: 1.05;
    font-weight: 650;
    color: var(--text-light);
    letter-spacing: -0.015em;
}

.median-price {
    margin-top: 4px;
    font-size: 19px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.045em;
    color: var(--text-dark);
}

.details-btn {
    position: relative;
    margin-top: auto;
    height: 44px;
    min-height: 44px;
    border-radius: 11px;
    background: linear-gradient(180deg, var(--primary, #1b63ff) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 750;
    letter-spacing: -0.015em;
    box-shadow: 0 12px 24px rgba(19, 88, 255, 0.20);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.details-btn::after {
    content: "→";
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    line-height: 1;
    font-weight: 600;
}

.details-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, var(--primary, #2b72ff) 0%, var(--primary-dark) 100%);
    box-shadow: 0 16px 30px rgba(19, 88, 255, 0.26);
}

.results-bottom-divider {
    margin: 56px 10px 0;
    height: 1px;
    background: var(--surface-alt, #e4e8ef);
}

@media (max-width: 1360px) {
    .results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Brand cards are smaller: never fewer than 3 per row. */
    #brands-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .results-section {
        padding: 24px 18px 30px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-controls {
        flex-wrap: wrap;
    }

    .results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ================================================================
   MOBILE PAGE HELPERS
   Formerly stored in history-mobile.css.
   ================================================================ */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

/* ================================================================
   HISTORY HEADER AND CONTROLS
   ================================================================ */

@media (max-width: 760px) {
    .results-section {
        width: 100% !important;
        max-width: none !important;
        padding: 22px 14px 38px !important;
    }

    .results-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 16px !important;
        margin-bottom: 20px !important;
    }

    .history-heading {
        min-width: 0;
    }

    .section-title {
        margin: 0 !important;
        font-size: clamp(28px, 8vw, 34px) !important;
        line-height: 1.05 !important;
        letter-spacing: -0.05em !important;
    }

    .history-subtitle {
        margin-top: 7px !important;
        font-size: 14px !important;
        line-height: 1.45 !important;
        color: var(--text-light) !important;
    }

    /* Search and sort share one compact row. */
    .results-controls {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 48px !important;
        align-items: center !important;
        width: 100% !important;
        gap: 8px !important;
    }

    .results-search-bar {
        display: grid !important;
        grid-template-columns: 20px minmax(0, 1fr) 38px !important;
        align-items: center !important;
        width: 100% !important;
        min-width: 0 !important;
        height: 48px !important;
        padding: 4px 5px 4px 13px !important;
        gap: 8px !important;
        border: 1px solid var(--auth-border) !important;
        border-radius: 14px !important;
        background: var(--bg-white) !important;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04) !important;
    }

    .results-search-bar > svg {
        width: 19px !important;
        height: 19px !important;
        color: var(--text-muted, #94a3b8) !important;
    }

    .results-search-bar input {
        width: 100% !important;
        min-width: 0 !important;
        height: 38px !important;
        padding: 0 !important;
        border: 0 !important;
        outline: 0 !important;
        background: transparent !important;
        color: var(--text-dark) !important;
        font-size: 16px !important;
        font-weight: 550 !important;
    }

    .results-search-bar input::placeholder {
        color: var(--text-muted, #7b8aa3) !important;
        opacity: 1 !important;
    }

    .results-search-btn {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 !important;
        border-radius: 10px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%) !important;
        box-shadow: 0 7px 16px rgba(19, 88, 255, 0.2) !important;
    }

    .filter-dropdown {
        position: relative !important;
        width: 48px !important;
        min-width: 48px !important;
    }

    .filter-btn {
        width: 48px !important;
        min-width: 48px !important;
        height: 48px !important;
        min-height: 48px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
        border-radius: 14px !important;
        border: 1px solid var(--auth-border) !important;
        background: var(--bg-white) !important;
        color: #334155 !important;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04) !important;
    }

    .filter-btn .sort-label,
    .filter-btn svg:last-child {
        display: none !important;
    }

    .filter-btn svg:first-child {
        width: 20px !important;
        height: 20px !important;
    }

    .filter-menu {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        z-index: 120 !important;
        width: min(260px, calc(100vw - 28px)) !important;
        padding: 7px !important;
        border: 1px solid var(--auth-border) !important;
        border-radius: 14px !important;
        background: var(--bg-white) !important;
        box-shadow: 0 16px 38px rgba(15, 23, 42, 0.15) !important;
    }

    .filter-menu-item {
        width: 100% !important;
        min-height: 42px !important;
        padding: 10px 12px !important;
        border-radius: 9px !important;
        text-align: left !important;
        font-size: 14px !important;
        font-weight: 650 !important;
    }

    /* Always at least two product cards per row. */
    .results-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
        width: 100% !important;
    }

    /* Brand cards are smaller still: 3 per row even on phones. */
    #brands-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .brand-card {
        width: 100% !important;
    }

    /* ============================================================
       COMPACT MOBILE RESULT CARD
       ============================================================ */

    .result-card {
        --result-card-height: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 10px !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        column-gap: 8px !important;
        row-gap: 8px !important;
        overflow: hidden !important;
        border: 1px solid var(--premium-border, #dde5f0) !important;
        border-radius: 18px !important;
        background: linear-gradient(180deg, var(--premium-card, #ffffff) 0%, var(--premium-card, #ffffff) 86%, var(--bg-page, #fbfcff) 100%) !important;
        box-shadow: var(--premium-shadow-soft, 0 8px 22px rgba(15, 23, 42, 0.07)) !important;
    }

    .result-card:hover {
        transform: none !important;
        box-shadow: var(--premium-shadow-soft, 0 8px 22px rgba(15, 23, 42, 0.07)) !important;
    }

    /* Every direct child spans the card except the two price panels. */
    .result-card > :not(.deal-row):not(.median-section) {
        grid-column: 1 / -1 !important;
    }

    /* Square images on phones: shorter, narrower cards. */
    .image-shell {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 1 / 1 !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 14px !important;
        background: #f1f4f9 !important;
        overflow: hidden !important;
    }

    /* Space between the image container and the card edges on phones. */
    .brand-card-media-link {
        margin: 12px 12px 4px !important;
    }
    .brand-card .listing-name {
        margin: 4px 2px 4px !important;
        text-align: center !important;
    }

    .listing-img {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        height: 100% !important;
        min-height: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        object-fit: cover !important;
        object-position: center !important;
        transform: none !important;
    }

    .card-actions {
        top: 9px !important;
        right: 9px !important;
        gap: 6px !important;
    }

    .icon-circle {
        width: 36px !important;
        min-width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        border-radius: 11px !important;
        box-shadow: 0 6px 16px rgba(15, 23, 42, 0.09) !important;
    }

    .icon-circle svg {
        width: 17px !important;
        height: 17px !important;
    }

    .listing-name {
        margin: 2px 2px 0 !important;
        min-height: 0 !important;
        font-size: 17px !important;
        line-height: 1.2 !important;
        font-weight: 800 !important;
        letter-spacing: -0.035em !important;
        -webkit-line-clamp: 2 !important;
    }

    .card-price {
        margin: 6px 2px 0 !important;
        font-size: 18px !important;
    }

    /* Supports the current and likely condition class names. */
    .condition-badge,
    .condition-tag,
    .condition-pill,
    .condition-label,
    .condition-row {
        width: fit-content !important;
        max-width: 100% !important;
        margin: 0 2px !important;
        padding: 4px 9px !important;
        border: 1px solid #bcd0ff !important;
        border-radius: 999px !important;
        background: #eff4ff !important;
        color: var(--primary) !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .deal-row,
    .median-section {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 66px !important;
        margin: 0 !important;
        padding: 9px !important;
        gap: 8px !important;
        border-radius: 12px !important;
        display: flex !important;
        align-items: center !important;
        overflow: hidden !important;
    }

    .deal-row {
        grid-column: 1 / -1 !important;
        border: 1px solid var(--primary-soft-border, #cddcff) !important;
        background: linear-gradient(180deg, var(--deal-grad-top, #f4f8ff) 0%, var(--primary-bg) 100%) !important;
    }

    .median-section {
        border: 1px solid #e1e7f0 !important;
        background: var(--surface-alt, #f8fafc) !important;
    }

    .deal-row:hover {
        transform: none !important;
    }

    .deal-icon,
    .median-icon {
        width: 32px !important;
        min-width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        border-radius: 10px !important;
    }

    .deal-icon {
        box-shadow: 0 6px 14px rgba(19, 88, 255, 0.18) !important;
    }

    .deal-icon svg,
    .median-icon svg {
        width: 16px !important;
        height: 16px !important;
    }

    .deal-copy,
    .median-copy {
        min-width: 0 !important;
    }

    .deal-label,
    .median-label {
        font-size: 10.5px !important;
        line-height: 1.1 !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
    }

    .deal-highlight,
    .median-price {
        margin-top: 4px !important;
        font-size: 17px !important;
        line-height: 1 !important;
        font-weight: 800 !important;
        letter-spacing: -0.035em !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .deal-link-icon {
        display: none !important;
    }

    .details-btn {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        height: 44px !important;
        min-height: 44px !important;
        margin: 1px 0 0 !important;
        border-radius: 12px !important;
        font-size: 14px !important;
        box-shadow: 0 8px 18px rgba(19, 88, 255, 0.18) !important;
    }

    .details-btn::after {
        right: 16px !important;
        font-size: 18px !important;
    }

    .results-bottom-divider {
        margin: 28px 0 0 !important;
    }
}

/* Very narrow phones: retain readable prices without overflow. */
@media (max-width: 370px) {

    .results-section {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .image-shell {
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 1 / 1 !important;
    }

    .deal-row,
    .median-section {
        padding: 8px !important;
        gap: 6px !important;
    }

    .deal-icon,
    .median-icon {
        width: 29px !important;
        min-width: 29px !important;
        height: 29px !important;
        min-height: 29px !important;
    }

    .deal-highlight,
    .median-price {
        font-size: 15.5px !important;
    }
}

/* ================================================================
   FOOTER
   ================================================================ */

@media (max-width: 760px) {
    .site-footer {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    .site-footer-inner {
        min-height: 0 !important;
        padding: 22px 16px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 14px !important;
    }

    .site-footer-left,
    .site-footer-center {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 9px 12px !important;
    }

    .site-footer-tagline,
    .site-footer-right {
        display: none !important;
    }

    .site-footer-center {
        font-size: 12px !important;
    }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* ==================== IMAGE SCAN PANEL ==================== */
.image-scan-panel:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 40px 16px;
}

.image-scan-content {
    text-align: center;
    max-width: 640px;
}

.image-scan-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-dark);
    margin: 0 0 6px;
}

.image-scan-subtitle {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    margin: 0 0 24px;
}

.image-scan-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 20px;
}

.image-scan-thumb {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}

.image-scan-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-scan-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.image-scan-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
}

/* Animated horizontal scan line */
.image-scan-thumb::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--primary-light), transparent);
    box-shadow: 0 0 14px rgba(19, 88, 255, 0.75);
    animation: image-scan-line 2s ease-in-out infinite;
}

@keyframes image-scan-line {
    0%   { top: 0; }
    50%  { top: calc(100% - 3px); }
    100% { top: 0; }
}

.image-scan-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-mid);
}

.image-scan-status::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    animation: image-scan-spin 0.8s linear infinite;
}

@keyframes image-scan-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 560px) {
    .image-scan-thumb {
        width: 160px;
        height: 160px;
    }
}

/* ================================================================
   VIEW SLIDER (PRODUCTS / BRANDS) — mirrors the compare page slider
   (.compare-view-toggle / .compare-view-slider / .compare-view-option)
   ================================================================ */

.results-section .compare-view-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    margin: 14px auto 28px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-white);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.results-section .compare-view-slider {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: 999px;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(19, 88, 255, 0.35);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.results-section .compare-view-toggle[data-mode="brands"] .compare-view-slider {
    transform: translateX(100%);
}

.results-section .compare-view-option {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 132px;
    padding: 8px 18px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-light);
    font-family: var(--font-ecommerce);
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: color 0.18s ease;
}

.results-section .compare-view-option.is-active {
    color: #ffffff;
}

@media (max-width: 480px) {
    .results-section .compare-view-option {
        min-width: 104px;
        padding: 7px 12px;
        font-size: 13px;
    }
}

/* ================================================================
   HISTORY BRAND CARDS
   Shown in the Brands view of the history page. Cards reuse the
   result-card grid so both views align column for column, and they
   reuse the result-card component classes (.image-shell,
   .listing-name, .median-section, .details-btn) so a
   brand card is pixel-identical in size and styling to a product
   card.
   ================================================================ */

.brand-card {
    /* Smaller than product cards, same shape (chrome, radius, padding). */
    width: min(200px, 100%);
    background: linear-gradient(180deg, var(--premium-card, #ffffff) 0%, var(--premium-card, #ffffff) 82%, var(--bg-page, #fbfcff) 100%);
    border: 1px solid var(--premium-border, var(--border, #dfe6f1));
    border-radius: 20px;
    padding: 12px;
    box-shadow: var(--premium-shadow-soft, 0 8px 22px rgba(15, 23, 42, 0.07));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.brand-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong, #d2ddf0);
    box-shadow: var(--premium-shadow, 0 20px 42px -12px rgba(17, 24, 39, 0.12));
}

.brand-card-media-link {
    display: block;
    color: inherit;
    text-decoration: none;
    flex-shrink: 0;
}

/* Space between the image container and the card edges; the shell stays
   square and the image fills it like on product cards. */
.brand-card-media-link {
    /* Wide side/top gaps to the card edge; tight to the text below. */
    margin: 16px 16px 4px;
}
.brand-card .image-shell {
    max-height: none;
    height: auto;
    min-height: 0;
    aspect-ratio: 1 / 1;
}
/* Centred name with balanced spacing (no product-card 2-line reserve). */
.brand-card .listing-name {
    margin: 4px 6px 6px;
    min-height: 0;
    text-align: center;
}

/* Letter fallback shown inside the image shell when a brand has no
   images yet (or its image fails to load). */
.brand-card-logo-letter {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--bg-white);
    color: var(--primary);
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.02em;
    box-shadow: inset 0 0 0 2px var(--primary-soft-border), 0 6px 16px rgba(19, 88, 255, 0.12);
    user-select: none;
}



/* ===================== COLLECTION ADD PRODUCTS ===================== */
.collection-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--primary, #1358ff);
    background: var(--primary, #1358ff);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.collection-add-btn:hover {
    filter: brightness(1.08);
}

.collection-add-btn:active {
    transform: scale(0.97);
}

.collection-add-card {
    width: min(480px, 94%);
}

.collection-add-search {
    width: calc(100% - 32px);
    margin: 14px 16px 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e5e9f2;
    background: var(--bg-white, #ffffff);
    color: var(--text-dark, #0b1430);
    font-size: 14px;
    outline: none;
}

.collection-add-search:focus {
    border-color: var(--primary, #1358ff);
}

.collection-add-list {
    max-height: 46vh;
    overflow-y: auto;
    padding: 4px 10px 10px;
}

.collection-add-card .collections-footer {
    padding: 14px 16px 16px;
    border-top: 1px solid #e5e9f2;
    display: flex;
    justify-content: flex-end;
}

.collection-add-card .collections-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

