/* ═══════════════════════════════════════════════════════════════════════════
   Responsive system — mobile / tablet polish across app surfaces
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .topbar {
        padding: 16px clamp(16px, 3vw, 32px);
    }

    .car-detail {
        padding-left: clamp(16px, 3vw, 32px);
        padding-right: clamp(16px, 3vw, 32px);
    }

}

@media (max-width: 768px) {
    /* App + marketing nav: logo + account on one row; links scroll horizontally */
    .topbar--marketing {
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 12px;
        padding: 12px 16px;
    }

    .topbar--marketing .logo {
        margin-right: auto;
    }

    .nav-search {
        order: 2;
        flex: 1 1 100%;
        max-width: none;
    }

    .topbar--marketing .nav-links--account {
        flex-shrink: 0;
        gap: 10px;
    }

    .topbar--marketing .nav-links--site {
        order: 3;
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 4px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
        mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 12px), transparent);
    }

    .topbar--marketing .nav-links--site::-webkit-scrollbar {
        display: none;
    }

    .nav-mkt-link {
        flex-shrink: 0;
        min-height: 44px;
        padding: 10px 6px;
        font-size: 13px;
    }

    .nav-link-cta {
        min-height: 44px;
        padding: 10px 0;
    }

    .guest-banner-content {
        flex-wrap: wrap;
        gap: 10px;
    }

    .listings-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .listings-toolbar__start,
    .listings-toolbar__end {
        width: 100%;
        justify-content: space-between;
    }

    .listings-sort-select {
        min-width: 0;
        flex: 1;
    }

    body.listings-page .filter-controls-row .pill-group.pill-select-group {
        grid-column: span 1;
    }

    .listings-pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .db-hero {
        padding: 24px 16px;
    }

    .db-layout {
        padding: 20px 16px 64px;
        gap: 36px;
    }

    .hub-topbar {
        padding: 20px 16px 0;
    }

    .hub-main {
        padding: 20px 16px 56px;
        grid-template-columns: 1fr;
    }

    .find-dealers-section {
        padding: 20px 16px 40px;
    }

    .find-dealers-input,
    .find-dealers-select {
        max-width: none;
    }

    .find-dealers-form {
        padding: 16px 0;
    }

    .auth-section {
        padding: 32px 16px 48px;
    }

    .auth-card {
        width: 100%;
        max-width: none;
    }

    .compare-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 600px) {
    .results-grid,
    body.listings-page .results-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .saved-grid {
        grid-template-columns: 1fr;
    }

    .reco-card {
        flex: 0 0 min(85vw, 280px);
    }

    .dash-hub-stats {
        grid-template-columns: 1fr;
    }

    .listings-active-chips-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .listings-chips-clear {
        align-self: flex-start;
    }

    .car-detail-price-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* M4 (visual review 2026-09-28): the strip overflowed (424 vs 364px) with
       its scrollbar hidden, clipping "Comments". Wrap instead of scrolling. */
    .car-vdp-tabs {
        gap: 0 4px;
        padding: 0;
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .car-vdp-tab {
        flex: 0 1 auto;
        min-height: 44px;
        padding: 8px 10px;
        font-size: 13px;
        text-align: center;
    }

    .car-quick-specs {
        grid-template-columns: 1fr 1fr;
    }

    .primary-button,
    .secondary-button {
        padding: 12px 18px;
    }

    h1 {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }
}

@media (max-width: 480px) {
    .nav-links a.nav-link-cta {
        min-height: 44px;
        padding: 10px 0;
        font-size: 13px;
    }

    .find-dealers-location-modes {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .find-dealers-map {
        height: min(50vh, 320px);
    }

    .find-dealers-list-wrap {
        max-height: 280px;
    }

    .car-quick-specs {
        grid-template-columns: 1fr 1fr;
        column-gap: 20px;
    }

    .car-gallery-arrow {
        width: 40px;
        height: 40px;
    }

    .db-hero__actions {
        flex-direction: column;
        width: 100%;
    }

    .db-hero__actions .primary-button,
    .db-hero__actions .secondary-button {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 960px) {
    body.listings-page .listings-layout {
        padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    }

    body.listings-page .listings-main-column {
        min-height: 0;
    }
}

/* Respect reduced motion for layout transitions */
@media (prefers-reduced-motion: reduce) {
    .listings-sidebar,
    .listings-filter-backdrop {
        transition: none;
    }
}

/* ── VDP back navigation (car detail + compare; isolated from .back-link) ── */
.vdp-back {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 clamp(1rem, 2.5vw, 1.5rem);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.vdp-back:hover {
    color: var(--navy);
}

.vdp-back:hover .vdp-back__label {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.vdp-back .sc-icon {
    display: block;
    flex-shrink: 0;
    color: var(--navy);
    opacity: 0.8;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.vdp-back:hover .sc-icon {
    opacity: 1;
    transform: translateX(-2px);
}

.vdp-back__label {
    display: inline;
}

@media (prefers-reduced-motion: reduce) {
    .vdp-back:hover .sc-icon {
        transform: none;
    }
}

.scan-lab-vdp-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin: 0 0 1rem;
    padding: 0.5rem 0;
    border-radius: 0;
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.scan-lab-vdp-banner a {
    color: var(--navy);
    text-decoration: none;
    font-weight: 600;
}

.scan-lab-vdp-banner a:hover {
    text-decoration: underline;
}

.scan-lab-vdp-banner-user {
    margin-left: auto;
    opacity: 0.85;
}

/* Listings sidebar form controls — final vertical alignment (overrides cascade conflicts) */
body.listings-page .listings-filter-inner input.smart-search-input--carmax {
    min-height: 48px;
    height: auto;
    padding: 14px 16px;
    line-height: 1.25;
    font-size: 15px;
    border-radius: 10px;
    box-sizing: border-box;
    box-shadow: none;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
}

body.listings-page .listings-filter-inner input.smart-search-input--carmax:focus {
    line-height: 1.25;
    box-shadow: 0 0 0 3px rgba(28, 53, 82, 0.12);
}

body.listings-page .listings-filter-inner .pill-zip,
body.listings-page .listings-filter-inner .pill-select {
    min-height: 44px;
    height: 44px;
    width: 100%;
    font-size: 14px;
    line-height: 20px;
    border-radius: 8px;
    box-sizing: border-box;
    padding: 12px 36px 12px 14px;
    background-position: right 12px center;
}

body.listings-page .listings-filter-inner .pill-zip {
    padding: 12px 14px;
    line-height: 20px;
}

body.listings-page .listings-filter-inner .listings-dealer-picker-btn {
    min-height: 44px;
    height: 44px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    box-shadow: none;
}

body.listings-page .listings-filter-inner .listings-dealer-picker-btn-label {
    line-height: 1.25;
}

body.listings-page .listings-filter-inner .listings-acc-trigger {
    min-height: 44px;
    padding: 12px 0;
    box-sizing: border-box;
    align-items: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Premium page (premium.html), rebuilt 2026-09-30.
   Editorial layout: a left-aligned heading, one comparison table ruled with
   hairlines, and a definition list. No cards, no pills, no icons, no boxes.
   ?embed=1 (in-app WebView, body.premium-embed) hides the nav and the table.
   ═══════════════════════════════════════════════════════════════════════════ */

.pp { max-width: 1040px; margin: 0 auto; padding: 64px 24px 96px; color: var(--text-primary); }
.pp-head { max-width: 680px; margin-bottom: 56px; }
.pp-kicker { font-size: 14px; color: var(--text-muted); margin: 0 0 12px; }
.pp-head h1 { font-size: clamp(30px, 4.6vw, 46px); font-weight: 700; letter-spacing: -0.025em; line-height: 1.08; margin: 0 0 18px; }
.pp-lede { font-size: 18px; line-height: 1.6; color: var(--text-secondary); margin: 0 0 14px; }
.pp-status { font-size: 15px; line-height: 1.6; color: var(--text-primary); margin: 0; }
.pp-status a, .pp-link { color: var(--navy); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.pp-status a:hover, .pp-link:hover { text-decoration-thickness: 2px; }

.pp-plans { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 80px; }
.pp-table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 15px; }
.pp-table th, .pp-table td { padding: 13px 12px; border-bottom: 1px solid var(--border-light); text-align: center; vertical-align: middle; }
.pp-table thead th { vertical-align: bottom; font-size: 15px; font-weight: 600; padding-bottom: 18px; border-bottom: 2px solid var(--text-primary); }
.pp-table thead th.pp-table__feature, .pp-table tbody th, .pp-table tfoot th { text-align: left; padding-left: 0; }
.pp-table tbody th { font-weight: 500; }
.pp-price { display: block; margin-top: 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pp-price small { white-space: nowrap; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--text-muted); }
.pp-table__current { color: var(--navy); }
.pp-yes { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--navy); }
.pp-table tfoot td { border-bottom: none; padding-top: 20px; }
.pp-table tfoot td > * { display: block; }
.pp-current { font-weight: 600; color: var(--navy); }
.pp-muted { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.pp-prices-inline { display: none; font-size: 15px; line-height: 1.6; margin: -24px 0 40px; }

.pp-notes h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 20px; }
.pp-notes dl { margin: 0; }
.pp-note { display: grid; grid-template-columns: minmax(200px, 30%) 1fr; gap: 8px 32px; padding: 18px 0; border-top: 1px solid var(--border-light); }
.pp-note dt { font-weight: 600; }
.pp-from { display: block; font-size: 13px; font-weight: 400; color: var(--text-muted); margin-top: 3px; }
.pp-note dd { margin: 0; color: var(--text-secondary); line-height: 1.6; max-width: 620px; }

@media (max-width: 640px) {
    .pp { padding: 72px 16px 64px; }
    .pp-plans { display: none; }
    .pp-prices-inline { display: block; }
    .pp-head { margin-bottom: 40px; }
    .pp-lede { font-size: 16px; }
    .pp-note { grid-template-columns: 1fr; }
}

body.premium-embed { background: var(--bg-page); }
body.premium-embed .topbar { display: none !important; }
body.premium-embed .pp { padding: 12px 16px 32px; }
body.premium-embed .pp-prices-inline { display: block; margin: -8px 0 24px; }
body.premium-embed .pp-head { margin-bottom: 24px; }
body.premium-embed .pp-head h1 { font-size: 24px; }
body.premium-embed .pp-note { grid-template-columns: 1fr; padding: 14px 0; }

