/* ============================================================
   MCHONGO — Design System
   Light + Dark mode via [data-theme]
   ============================================================ */

/* --- LIGHT MODE (default) --- */
:root, [data-theme="light"] {
    --bg-body: #f5f0ec;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f3f4f6;

    --text-primary: #111827;
    --text-secondary: #64748b;
    --text-muted: #9ca3af;

    --border-color: #e5e7eb;
    --border-strong: #d1d5db;

    --nav-active-bg: #eef2f6;
    --nav-active-color: #0f172a;

    --accent: #111827;
    --accent-text: #ffffff;
    --accent-coral: #4f8a6c;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 99px;

    --nav-height-desktop: 80px;
    --nav-height-mobile: 64px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-float: 0 15px 35px -5px rgba(0, 0, 0, 0.1);

    --scrollbar-thumb: #c4c4c4;
    --scrollbar-track: transparent;
}

/* --- DARK MODE --- */
[data-theme="dark"] {
    --bg-body: #0f0f0f;
    --bg-surface: #1a1a1a;
    --bg-surface-hover: #252525;

    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;

    --border-color: #2a2a2a;
    --border-strong: #3a3a3a;

    --nav-active-bg: #252525;
    --nav-active-color: #f0f0f0;

    --accent: #f0f0f0;
    --accent-text: #0f0f0f;
    --accent-coral: #6ba989;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-float: 0 15px 35px -5px rgba(0, 0, 0, 0.5);

    --scrollbar-thumb: #444;
    --scrollbar-track: transparent;
}

/* --- BASE RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.5;
}

button, a {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    text-decoration: none;
}

input, textarea, select {
    font-family: inherit;
    outline: none;
    border: none;
}

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
/* Hide scrollbar on category tabs */
.category-tabs, .map-filters, .search-overlay-cats, .detail-thumbs {
    scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar,
.map-filters::-webkit-scrollbar,
.search-overlay-cats::-webkit-scrollbar,
.detail-thumbs::-webkit-scrollbar {
    display: none;
}

/* --- APP LAYOUT --- */
.app-wrapper {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================================
   PAGE LOADING SPINNER
   ============================================================ */
.page-spinner {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.page-spinner.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner-ring {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- DESKTOP TOP NAV (sticky) --- */
.top-nav {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: var(--nav-height-desktop);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    flex-shrink: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
}

@media (min-width: 1024px) {
    .top-nav { display: flex; }
}

.brand {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-decoration: none;
}
.brand-logo { display: block; border-radius: 50%; }
.brand-logo-text {
    display: block;
    height: 95px;
    width: auto;
    max-width: 420px;
}
@media (max-width: 768px) {
  .brand-logo-text { height: 64px; max-width: 260px; }
}

.desktop-nav-links {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 8px;
}

.d-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0 18px;
    height: 100%;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    line-height: 1.1;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.d-nav-item i { font-size: 20px; line-height: 1; }
.d-nav-item span { font-size: 11px; font-weight: 500; }

.d-nav-item:hover { color: var(--text-primary); }

.d-nav-item.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
    font-weight: 600;
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface-hover);
    color: var(--text-secondary);
    font-size: 18px;
    transition: var(--transition);
    cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); background: var(--border-color); }

.top-nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.top-nav-user img,
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-circle {
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-body); color: var(--text-primary);
    font-size: 14px; font-weight: 600; flex-shrink: 0;
}

/* --- ACCOUNT DROPDOWN --- */
.account-menu { position: relative; }
.account-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 14px; font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, border-color .12s, color .12s;
}
.account-btn:hover { background: var(--bg-surface-hover); }
.account-btn .account-caret { font-size: 12px; opacity: .7; transition: transform .15s; }
.account-menu.open .account-btn .account-caret { transform: rotate(180deg); }

.account-dropdown {
    position: absolute;
    top: calc(100% + 10px); right: 0;
    width: 320px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,.18), 0 6px 14px rgba(0,0,0,.06);
    padding: 8px;
    display: none;
    z-index: 1000;
    overflow: hidden;
}
.account-menu.open .account-dropdown { display: block; }

.account-dropdown-header {
    padding: 14px 14px 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
}
.account-dropdown-name { font-size: 15px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.account-dropdown-sub  { font-size: 13px; color: var(--text-secondary); margin-top: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.account-dropdown-section { padding: 4px 0; }
.account-dropdown-section + .account-dropdown-section {
    border-top: 1px solid var(--border-color);
    margin-top: 4px; padding-top: 8px;
}

.account-dropdown-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    font-size: 14px; font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    background: transparent; border: 0; width: 100%; text-align: left;
    font-family: inherit;
    justify-content: space-between;
}
.account-dropdown-item .ad-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-dropdown-item .ad-left i { font-size: 18px; flex-shrink: 0; opacity: .85; }
.account-dropdown-item:hover { background: var(--bg-surface-hover); text-decoration: none; color: var(--text-primary); }
.account-dropdown-item.danger { color: #e06b5f; }
.account-dropdown-item.danger:hover { background: rgba(224, 107, 95, 0.1); color: #e06b5f; }

.account-dropdown-value { font-size: 13px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 4px; }
.account-dropdown-value i { font-size: 14px; }

.account-lang-pills {
    display: inline-flex; background: var(--bg-body); border-radius: 999px; padding: 3px;
}
.account-lang-pills button {
    border: 0; background: transparent; padding: 4px 10px;
    font-size: 12px; font-weight: 600; border-radius: 999px;
    color: var(--text-secondary); cursor: pointer; font-family: inherit;
}
.account-lang-pills button.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.account-cta-row { display: flex; gap: 8px; padding: 4px; }
.account-cta-row .btn-cta {
    flex: 1;
    padding: 11px 12px;
    border-radius: 10px;
    font-size: 14px; font-weight: 600;
    text-align: center;
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.account-cta-row .btn-cta.primary {
    background: var(--accent); color: var(--accent-text);
}
.account-cta-row .btn-cta.primary:hover { opacity: .9; text-decoration: none; }
.account-cta-row .btn-cta.ghost {
    background: transparent; color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.account-cta-row .btn-cta.ghost:hover { background: var(--bg-surface-hover); text-decoration: none; }

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background-color: var(--bg-body);
    padding-bottom: calc(var(--nav-height-mobile) + 16px);
}

@media (min-width: 1024px) {
    .main-content { padding-bottom: 40px; }
}

.main-content.ai-layout {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
    overflow: hidden;
}

.main-content.map-layout {
    padding-bottom: 0;
    overflow: hidden;
}

.main-content.listings-layout {
    padding-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.main-content.messages-layout {
    padding-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   LISTINGS PAGE — Sticky header, scrollable grid
   ============================================================ */
.listings-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.page-header {
    flex-shrink: 0;
    background: var(--bg-body);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 1024px) {
    .page-header { padding: 24px 48px; }
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search icon button */
.search-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}
.search-icon-btn:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

/* ============================================================
   SEARCH OVERLAY (full screen)
   ============================================================ */
.search-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 600;
    display: none;
    flex-direction: column;
}

.search-overlay.open { display: flex; }

.search-overlay-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.search-overlay-header .search-back {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.search-overlay-header input {
    flex: 1;
    font-size: 16px;
    background: transparent;
    color: var(--text-primary);
    padding: 10px 0;
}
.search-overlay-header input::placeholder { color: var(--text-muted); }

.search-overlay-cats {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.search-overlay-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.search-overlay-results .product-grid {
    padding: 0;
}

/* Search result items (list style) */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    color: inherit;
    text-decoration: none;
}
.search-result-item:hover { background: var(--bg-surface-hover); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }

.search-result-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.search-result-img img { width: 100%; height: 100%; object-fit: cover; }
.search-result-img i { font-size: 20px; color: var(--text-muted); }

.search-result-info { flex: 1; min-width: 0; }
.search-result-title { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.search-result-price { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

.search-empty {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================================
   CATEGORY TABS
   ============================================================ */
.category-tabs-wrapper {
    flex-shrink: 0;
    background: var(--bg-body);
}

.category-tabs {
    display: flex;
    gap: 8px;
    padding: 0 20px 16px 20px;
    overflow-x: auto;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 1024px) { .category-tabs { padding: 0 48px 24px 48px; } }

.cat-tab {
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: var(--transition);
    background-color: transparent;
    border: 1px solid transparent;
}

.cat-tab:hover { color: var(--text-primary); }

.cat-tab.active {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 600;
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   PRODUCT GRID (scrollable area)
   ============================================================ */
.listings-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-bottom: calc(var(--nav-height-mobile) + 16px);
}

@media (min-width: 1024px) {
    .listings-scroll { padding-bottom: 40px; }
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 0 20px 32px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 24px;
    }
}

@media (min-width: 1024px) {
    .product-grid { padding: 0 48px 48px 48px; }
}

.product-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    color: inherit;
}

.product-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.p-image-container {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    background-color: var(--bg-body);
    border-radius: var(--radius-md);
    overflow: hidden;
}

@media (min-width: 768px) { .p-image-container { height: 180px; } }

.p-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.p-image-container img.p-no-image {
    width: 64%; height: 64%;
    opacity: 0.55;
    object-fit: contain;
}

.p-info { display: flex; flex-direction: column; gap: 4px; position: relative; }
.p-title { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 24px; }
.p-price { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
.p-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.p-stats span { display: flex; align-items: center; gap: 4px; }

.p-arrow {
    position: absolute;
    top: -4px;
    right: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    opacity: 0;
    transition: var(--transition);
}

.product-card:hover .p-arrow {
    opacity: 1;
    background-color: var(--accent);
    color: var(--accent-text);
}

@media (max-width: 768px) {
    .p-arrow { opacity: 1; }
}

.btn-add { display: none; }

/* ============================================================
   MAP PAGE — Top search + split view (sidebar + map)
   ============================================================ */
.map-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-height-desktop));
    overflow: hidden;
}

@media (max-width: 1023px) {
    .map-page {
        height: calc(100vh - var(--nav-height-mobile));
    }
}

/* Full-width top search */
.map-top-search {
    position: relative;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    z-index: 30;
}
.map-top-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    transition: var(--transition);
}
.map-top-search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}
.map-top-search-bar i { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }
.map-top-search-bar input {
    flex: 1;
    width: 100%;
    font-size: 15px;
    background: transparent;
    color: var(--text-primary);
}
.map-top-search-bar input::placeholder { color: var(--text-muted); }

.map-top-search .map-search-suggestions {
    position: absolute;
    left: 16px;
    right: 16px;
    top: calc(100% - 2px);
    margin-top: 0;
}

/* Body row: sidebar + canvas */
.map-page-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
@media (max-width: 1023px) {
    .map-page-body { flex-direction: column; }
}

/* --- Map Sidebar --- */
.map-sidebar {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

@media (max-width: 1023px) {
    .map-sidebar {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: auto;
        z-index: 40;
        border-right: none;
    }
    .map-sidebar.open { display: flex; }
}

.map-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.map-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: 10px 16px;
}

.map-search-box i { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }
.map-search-box input { width: 100%; font-size: 14px; background: transparent; color: var(--text-primary); }
.map-search-box input::placeholder { color: var(--text-muted); }

/* Map search suggestions dropdown */
.map-search-suggestions {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
    z-index: 20;
}
.map-search-suggestions.open { display: block; }

.map-suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.map-suggest-item:last-child { border-bottom: none; }
.map-suggest-item:hover { background: var(--bg-surface-hover); }

.map-suggest-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.map-suggest-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.map-suggest-icon { font-size: 18px; color: var(--text-muted); flex-shrink: 0; }

.map-filters {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.map-cat-chip {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.map-cat-chip:hover { color: var(--text-primary); }

.map-cat-chip.active {
    background: var(--text-primary);
    color: var(--bg-surface);
    border-color: var(--text-primary);
}

/* --- Map List --- */
.map-list {
    flex-grow: 1;
    overflow-y: auto;
}

.map-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.map-list-item:hover { background: var(--bg-surface-hover); }
.map-list-item.active { background: var(--bg-surface-hover); }

.map-list-item-img {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-list-item-img img { width: 100%; height: 100%; object-fit: cover; }
.map-list-item-img i { font-size: 22px; color: var(--text-muted); }
.map-list-item-info { flex-grow: 1; min-width: 0; }

.map-list-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-list-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.map-list-item-price { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

.map-list-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* --- Map Canvas --- */
.map-canvas-area {
    flex-grow: 1;
    position: relative;
    min-height: 0;
}

.map-canvas-area #map-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.map-spinner {
    position: absolute;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: opacity 0.3s ease;
}
.map-spinner.hidden { opacity: 0; pointer-events: none; }

.map-mobile-search { display: none !important; }

.map-toggle-view {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 40;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-surface);
    font-size: 20px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border: none;
    cursor: pointer;
}

@media (max-width: 1023px) {
    .map-toggle-view { display: flex; }
}
@media (min-width: 1024px) {
    .map-toggle-view { display: none; }
}

/* --- Map Popup Card — CENTERED --- */
.map-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 380px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    display: none;
    z-index: 15;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.map-card.active {
    display: block;
    animation: cardPop 0.25s ease;
}

@keyframes cardPop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.map-card-inner { display: flex; flex-direction: row; }

.map-card-img {
    width: 120px;
    min-height: 120px;
    object-fit: cover;
    background: var(--bg-body);
    flex-shrink: 0;
}

.map-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    min-width: 0;
}

.map-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.map-card-title {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-card-price {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.map-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--text-primary);
    color: var(--bg-surface);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    text-align: center;
    font-weight: 500;
    font-size: 13px;
}

.map-card-btn:hover { box-shadow: var(--shadow-md); }

.map-card-close { color: var(--text-muted); flex-shrink: 0; margin-left: 8px; }
.map-card-close i { font-size: 18px; }

/* --- Cluster Popup --- */
.cluster-popup {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; max-width: 340px;
    max-height: 70vh;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    border: 1px solid var(--border-color);
    z-index: 20;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: cardPop 0.25s ease;
}
.cluster-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    font-size: 14px; font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}
.cluster-popup-header button {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; display: flex;
}
.cluster-popup-list {
    overflow-y: auto; flex: 1;
}
.cluster-popup-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none; color: inherit;
    transition: background 0.15s;
}
.cluster-popup-item:last-child { border-bottom: none; }
.cluster-popup-item:hover { background: var(--bg-surface-hover); }
.cluster-popup-thumb {
    width: 48px; height: 48px; border-radius: var(--radius-md);
    overflow: hidden; flex-shrink: 0; background: var(--bg-body);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 20px;
}
.cluster-popup-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cluster-popup-title { font-size: 13px; font-weight: 600; }
.cluster-popup-price { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   AI CHAT
   ============================================================ */
.ai-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg-body);
    overflow: hidden;
    position: relative;
}

/* --- Chat History Sidebar --- */
.ai-sidebar {
    position: absolute; top: 0; left: 0; bottom: 0; width: 280px;
    background: var(--bg-surface); z-index: 50;
    display: flex; flex-direction: column;
    transform: translateX(-100%); transition: transform 0.25s ease;
    border-right: 1px solid var(--border-color);
}
.ai-sidebar.open { transform: translateX(0); }
@media (min-width: 768px) { .ai-sidebar { width: 320px; } }

.ai-sidebar-overlay {
    position: absolute; inset: 0; z-index: 40;
    background: rgba(0,0,0,0.3); opacity: 0;
    pointer-events: none; transition: opacity 0.25s ease;
}
.ai-sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.ai-sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px; border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.ai-sidebar-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.ai-sidebar-close {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition); background: none; border: none; cursor: pointer;
}
.ai-sidebar-close:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

.ai-sidebar-new {
    display: flex; align-items: center; gap: 8px;
    margin: 12px; padding: 10px 14px; border-radius: var(--radius-md);
    background: var(--bg-body); border: 1px solid var(--border-color);
    font-size: 13px; font-weight: 500; color: var(--text-primary);
    cursor: pointer; transition: var(--transition);
}
.ai-sidebar-new:hover { background: var(--bg-surface-hover); }
.ai-sidebar-new i { font-size: 16px; }

.ai-sidebar-list {
    flex: 1; overflow-y: auto; padding: 0 8px;
}

.ai-sidebar-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 40px 16px; color: var(--text-muted); font-size: 13px;
}
.ai-sidebar-empty i { font-size: 28px; }

.ai-sidebar-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-radius: var(--radius-md);
    cursor: pointer; transition: var(--transition);
    margin-bottom: 2px;
}
.ai-sidebar-item:hover { background: var(--bg-surface-hover); }
.ai-sidebar-item.active { background: var(--bg-surface-hover); }

.ai-sidebar-item-text {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
}
.ai-sidebar-item-title {
    font-size: 13px; font-weight: 500; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-sidebar-item-time { font-size: 11px; color: var(--text-muted); }

.ai-sidebar-item-del {
    flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; transition: var(--transition); opacity: 0;
}
.ai-sidebar-item:hover .ai-sidebar-item-del { opacity: 1; }
.ai-sidebar-item-del:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.ai-sidebar-item-del i { font-size: 14px; }

.ai-sidebar-clear {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin: 8px 12px 12px; padding: 8px;
    font-size: 12px; color: var(--text-muted);
    background: none; border: none; cursor: pointer; transition: var(--transition);
    border-top: 1px solid var(--border-color); padding-top: 12px;
}
.ai-sidebar-clear:hover { color: #ef4444; }
.ai-sidebar-clear i { font-size: 14px; }

/* --- History button in input row --- */
.chat-history-btn {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.chat-history-btn:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.chat-history-btn i { font-size: 18px; }

.ai-welcome {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    text-align: center;
    gap: 8px;
}

.ai-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}

.ai-welcome-greeting { font-size: 18px; font-weight: 400; color: var(--text-secondary); }

.ai-welcome-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .ai-welcome-title { font-size: 36px; }
    .ai-welcome-greeting { font-size: 22px; }
}

.ai-welcome-sub {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 380px;
    margin-bottom: 24px;
    line-height: 1.6;
}

@media (min-width: 768px) {
    .ai-welcome-sub { font-size: 14px; max-width: 440px; }
}

.ai-suggestion-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 360px;
}

@media (min-width: 768px) {
    .ai-suggestion-cards {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 700px;
    }
}

.ai-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
    .ai-card { min-width: 170px; max-width: 200px; padding: 18px; gap: 12px; }
}

.ai-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.ai-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
}

@media (min-width: 768px) {
    .ai-card-icon { width: 40px; height: 40px; font-size: 20px; }
}

.ai-card-text { display: flex; flex-direction: column; gap: 2px; }
.ai-card-text strong { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.ai-card-text span { font-size: 11px; color: var(--text-muted); }

@media (min-width: 768px) {
    .ai-card-text strong { font-size: 14px; }
    .ai-card-text span { font-size: 12px; }
}

.chat-area {
    flex-grow: 1;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 24px 16px;
    background: var(--bg-body);
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}
@media (min-width: 768px) { .chat-area { padding: 24px 24px; } }
.chat-area.has-messages { display: flex; }

.message {
    max-width: 80%;
    font-size: 14px;
    line-height: 1.7;
    word-wrap: break-word;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
}

@media (min-width: 768px) {
    .message { max-width: 520px; font-size: 15px; padding: 12px 16px; }
}

/* User bubble — right aligned */
.msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-text);
    border-bottom-right-radius: 4px;
}

/* AI message — left aligned, no bg for text-only, transparent */
.msg-ai {
    align-self: flex-start;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    max-width: 90%;
}
@media (min-width: 768px) { .msg-ai { max-width: 580px; } }

/* Labels */
.msg-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    margin-top: 10px;
    padding: 0 4px;
}
.msg-label:first-child { margin-top: 0; }
.msg-label-right { text-align: right; }

/* Typing indicator */
.msg-typing {
    align-self: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    padding: 14px 20px;
}

/* --- AI message rich content --- */
.msg-ai p { margin: 0 0 6px 0; }
.msg-ai p:last-child { margin-bottom: 0; }
.msg-ai strong { font-weight: 700; }
.msg-ai em { font-style: italic; }
.msg-ai ul, .msg-ai ol { margin: 6px 0; padding-left: 18px; }
.msg-ai li { margin-bottom: 3px; }
.msg-ai a:not(.ai-product-card):not(.source-circle) { color: var(--accent-coral); font-weight: 500; text-decoration: underline; }
.msg-ai a:not(.ai-product-card):not(.source-circle):hover { opacity: 0.8; }
.msg-ai .ai-product-card, .msg-ai .source-circle { text-decoration: none; color: inherit; }
.msg-ai table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.msg-ai th, .msg-ai td { padding: 6px 10px; border: 1px solid var(--border-color); text-align: left; }
.msg-ai th { background: var(--bg-surface-hover); font-weight: 600; }
.msg-ai code { background: var(--bg-surface-hover); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg-ai h3, .msg-ai h4 { font-size: 14px; font-weight: 700; margin: 10px 0 4px; }

/* --- AI auth gate (after 3 free guest messages) --- */
.ai-auth-gate { padding: 4px 0; }
.ai-auth-gate-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--text-primary); }
.ai-auth-gate-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-auth-gate-actions .btn-cta {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 10px;
    font-size: 13px; font-weight: 600;
    text-decoration: none; cursor: pointer;
}
.ai-auth-gate-actions .btn-cta.primary { background: var(--accent); color: var(--accent-text); }
.ai-auth-gate-actions .btn-cta.ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.ai-auth-gate-actions .btn-cta:hover { text-decoration: none; opacity: .92; }

/* --- Product cards inside AI messages --- */
.ai-product-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}
.ai-product-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.ai-product-card-img {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    background: var(--bg-surface-hover); overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.ai-product-card-img img { width: 100%; height: 100%; object-fit: cover; }
.ai-product-card-img i { font-size: 18px; color: var(--text-muted); }
.ai-product-card-info { flex: 1; min-width: 0; }
.ai-product-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-product-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.ai-product-card-meta .ai-dist { color: var(--accent-coral); font-weight: 500; }
.ai-product-card-price { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

/* Typing cursor animation */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--text-primary);
    margin-left: 1px;
    animation: blink 0.7s step-end infinite;
    vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

/* --- Source circles --- */
.msg-sources {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}
.msg-sources-label {
    width: 100%;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.source-circle {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-color);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    background: var(--bg-surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}
.source-circle:hover { border-color: var(--accent-coral); transform: scale(1.1); }
.source-circle img { width: 100%; height: 100%; object-fit: cover; }
.source-circle i { font-size: 18px; color: var(--text-muted); }

/* Source popover on hover */
.source-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 20;
    text-decoration: none;
    color: inherit;
}
.source-circle:hover .source-popover { display: block; }
.source-popover-img {
    width: 100%; height: 100px; border-radius: var(--radius-sm);
    object-fit: cover; background: var(--bg-body); margin-bottom: 8px;
}
.source-popover-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.source-popover-price { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 2px; }
.source-popover-meta { font-size: 11px; color: var(--text-muted); }
.source-popover-dist { font-size: 11px; color: var(--accent-coral); font-weight: 500; margin-top: 2px; }

.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.chat-input-area {
    padding: 10px 16px 14px;
    flex-shrink: 0;
    background: var(--bg-body);
}

/* On mobile, lock the input bar in place directly above the bottom nav,
   so it never gets pushed under it (regardless of standalone/browser mode
   or any layout overflow). */
@media (max-width: 1023px) {
    .chat-input-area {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--nav-height-mobile) + env(safe-area-inset-bottom, 0px));
        z-index: 40;
        padding: 8px 12px 10px;
        border-top: 1px solid var(--border-color);
        background: var(--bg-body);
    }
    /* Reserve space at the bottom of the chat scroll area so messages aren't
       hidden under the locked input. */
    .chat-area {
        padding-bottom: 88px;
    }
    /* Welcome state: center vertically in the visible area above the input. */
    .ai-welcome {
        padding-bottom: calc(96px + var(--nav-height-mobile) + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 1024px) {
    .chat-input-area { padding: 16px 20px 24px; }
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 720px;
    margin: 0 auto;
}

.chat-settings-btn {
    display: none;
}

.chat-input-wrapper {
    display: flex; align-items: center; flex-grow: 1;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-pill); padding: 6px 6px 6px 16px;
    transition: var(--transition); gap: 8px;
}
.chat-input-wrapper:focus-within { border-color: var(--text-muted); box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.1); }

.chat-input-icon { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }
.chat-input-wrapper input { flex-grow: 1; background: transparent; font-size: 14px; color: var(--text-primary); min-width: 0; }
.chat-input-wrapper input::placeholder { color: var(--text-muted); }

.btn-send {
    display: flex; align-items: center; gap: 4px;
    padding: 8px 16px; border-radius: var(--radius-pill);
    background: var(--accent-coral); color: #fff;
    font-size: 13px; font-weight: 600; flex-shrink: 0;
    transition: var(--transition); white-space: nowrap;
}
.btn-send i { font-size: 14px; }
.btn-send:hover { opacity: 0.9; transform: scale(1.02); }

/* ============================================================
   FAB + Modal
   ============================================================ */
.fab {
    position: fixed; bottom: 32px; right: 32px;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-surface);
    display: none; align-items: center; justify-content: center;
    font-size: 24px; box-shadow: var(--shadow-lg);
    z-index: 100; transition: var(--transition); cursor: pointer; border: none;
}
.fab:hover { transform: scale(1.08); box-shadow: var(--shadow-float); }
@media (min-width: 1024px) { .fab { display: flex; } }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: flex-end; justify-content: center; z-index: 1100;
}
.modal-overlay.open { display: flex; }
@media (min-width: 768px) { .modal-overlay { align-items: center; } }

.modal-sheet {
    background: var(--bg-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%; max-width: 480px; max-height: 85vh;
    overflow-y: auto; padding: 24px;
    padding-bottom: calc(24px + var(--nav-height-mobile, 56px) + env(safe-area-inset-bottom, 0px));
    animation: sheetUp 0.3s ease;
}
@media (min-width: 768px) { .modal-sheet { border-radius: var(--radius-xl); max-height: 80vh; padding-bottom: 24px; } }

@keyframes sheetUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition);
}
.modal-close:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

.modal-form { display: flex; flex-direction: column; gap: 14px; }

/* --- Image upload area --- */
.upload-area { display: flex; flex-direction: column; gap: 10px; }
.upload-buttons { display: flex; gap: 10px; }
.upload-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 12px; border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color); background: var(--bg-body);
    color: var(--text-secondary); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.upload-btn i { font-size: 20px; }
.upload-btn:hover { border-color: var(--text-primary); color: var(--text-primary); background: var(--bg-surface-hover); }

.image-preview-row { display: flex; gap: 8px; flex-wrap: wrap; }
.image-preview-row .preview-thumb {
    width: 60px; height: 60px; border-radius: var(--radius-md);
    object-fit: cover; border: 1px solid var(--border-color);
    position: relative;
}

/* --- Form fields --- */
.modal-form .form-input {
    background: var(--bg-body); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 12px 16px;
    font-size: 14px; color: var(--text-primary); width: 100%;
    transition: var(--transition);
}
.modal-form .form-input:focus { border-color: var(--text-primary); box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.08); }
.modal-form textarea.form-input { resize: none; min-height: 80px; font-family: inherit; line-height: 1.5; }
.modal-form .form-label {
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: -6px;
}

.price-row { display: flex; gap: 10px; }
.price-row .form-input { flex-grow: 1; }
.currency-select {
    width: 90px !important; flex-shrink: 0; flex-grow: 0 !important;
    appearance: none; cursor: pointer; text-align: center; font-weight: 600;
    background: var(--bg-surface-hover); border-color: var(--border-color);
}

.btn-submit {
    background: var(--text-primary); color: var(--bg-surface);
    padding: 14px; border-radius: var(--radius-pill);
    font-weight: 600; font-size: 15px; transition: var(--transition);
    width: 100%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-submit i { font-size: 18px; }
.btn-submit:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-submit:disabled { opacity: 0.5; pointer-events: none; }

/* ============================================================
   ACCOUNT VIEW
   ============================================================ */
.account-page { max-width: 800px; margin: 0 auto; padding-top: 24px; width: 100%; }
.account-header { padding: 24px 20px; display: flex; align-items: center; gap: 20px; }
.account-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--bg-surface); display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 600; border: 1px solid var(--border-color); flex-shrink: 0;
}
.account-name { font-size: 20px; font-weight: 700; }
.account-email { color: var(--text-secondary); font-size: 14px; }

.settings-list { padding: 0 20px 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.setting-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; background: var(--bg-surface);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    cursor: pointer; transition: var(--transition); color: inherit;
}
.setting-item:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.setting-item-left { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.setting-item-left i { font-size: 20px; color: var(--text-secondary); }
.setting-item-right { color: var(--text-muted); }

/* Toggle switch */
.toggle-switch {
    width: 48px; height: 28px; border-radius: 14px;
    background: var(--border-strong); position: relative;
    transition: background 0.25s ease; flex-shrink: 0;
}
.toggle-switch.active { background: var(--accent); }
.toggle-knob {
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff; position: absolute; top: 3px; left: 3px;
    transition: transform 0.25s ease; box-shadow: var(--shadow-sm);
}
.toggle-switch.active .toggle-knob { transform: translateX(20px); }

.setting-item.danger { border-color: #fca5a5; }
.setting-item.danger .setting-item-left { color: #ef4444; font-weight: 600; }

/* Language select */
.lang-select {
    padding: 6px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); background: var(--bg-surface);
    color: var(--text-primary); font-size: 14px; font-family: inherit;
    cursor: pointer; outline: none; transition: var(--transition);
}
.lang-select:focus { border-color: var(--accent); }

/* ============================================================
   PRODUCT DETAIL PAGE — single-view layout (pdp-v2)
   ============================================================ */
.pdp-v2 {
    max-width: 1280px; margin: 0 auto; width: 100%;
    padding: 14px 14px 100px;
}
@media (min-width: 1024px) { .pdp-v2 { padding: 28px 32px 64px; } }

.pdp-v2 .pdp-back {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-secondary); font-size: 13px; font-weight: 600;
    margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.5px;
}
.pdp-v2 .pdp-back:hover { color: var(--text-primary); }
.pdp-v2 .pdp-back i { font-size: 16px; }

.pdp-top {
    display: grid; grid-template-columns: 1fr; gap: 18px;
    align-items: start;
}
@media (min-width: 1024px) { .pdp-top { grid-template-columns: 1.25fr 1fr; gap: 48px; } }

/* ── Gallery: 2-col grid everywhere; tap any image to open the lightbox ── */
.pdp-gallery {
    display: grid; gap: 8px;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 768px) { .pdp-gallery { gap: 12px; } }
@media (min-width: 1024px) {
    .pdp-gallery { gap: 14px; }
    /* On desktop the first image acts as a hero across both columns */
    .pdp-gallery .pdp-img-cell:first-child { grid-column: 1 / -1; }
}

.pdp-img-cell {
    position: relative; overflow: hidden;
    background: var(--bg-surface);
    border: none; padding: 0; cursor: zoom-in;
    border-radius: var(--radius-md);
    transition: var(--transition);
    aspect-ratio: 1 / 1;
}
@media (min-width: 1024px) {
    .pdp-gallery .pdp-img-cell:first-child { aspect-ratio: 4 / 3; }
}
.pdp-img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.pdp-img-cell:hover img { transform: scale(1.02); }
.pdp-no-img { cursor: default; background: var(--bg-body); }
.pdp-no-img img { object-fit: contain; opacity: 0.55; padding: 18%; }

/* ── Info column ────────────────────────────────────── */
.pdp-info {
    display: flex; flex-direction: column; gap: 18px;
}
@media (min-width: 1024px) { .pdp-info { position: sticky; top: 24px; gap: 22px; } }

.pdp-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--text-muted);
}
.pdp-eyebrow a { color: var(--text-muted); }
.pdp-eyebrow a:hover { color: var(--accent-coral); }
.pdp-eyebrow i { font-size: 14px; color: var(--accent-coral); }
.pdp-eyebrow-pill {
    padding: 3px 10px; background: rgba(255,107,91,0.12); color: var(--accent-coral);
    border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
}

.pdp-title {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-size: 28px; font-weight: 600; line-height: 1.15;
    color: var(--text-primary); margin: 0; letter-spacing: -0.5px;
}
@media (min-width: 1024px) { .pdp-title { font-size: 36px; } }

.pdp-desc {
    font-size: 14.5px; line-height: 1.65; color: var(--text-secondary);
    white-space: pre-wrap; word-wrap: break-word;
}

.pdp-price-block {
    display: flex; flex-direction: column; gap: 10px;
    padding: 16px 18px;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 14px;
}
.pdp-price {
    font-size: 14px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px;
}
.pdp-price span {
    font-size: 28px; font-weight: 800; color: var(--text-primary);
    margin-left: 4px; letter-spacing: -0.5px;
}
@media (min-width: 1024px) { .pdp-price span { font-size: 32px; } }
.pdp-meta-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pdp-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 11px; border-radius: 999px;
    background: var(--bg-body); border: 1px solid var(--border-color);
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.pdp-chip i { font-size: 13px; color: var(--accent-coral); }

/* ── Contact split button ──────────────────────────── */
.pdp-contact-card { display: flex; flex-direction: column; gap: 8px; }
.pdp-contact-label {
    font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--text-muted);
}
.pdp-contact-split {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
}
.pdp-contact-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 14px 6px;
    background: transparent; border: none; cursor: pointer; text-decoration: none;
    color: var(--text-primary); font-family: inherit;
    font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
    border-right: 1px solid var(--border-color);
    transition: background 0.15s ease, color 0.15s ease;
    min-height: 64px;
}
.pdp-contact-btn:last-child { border-right: none; }
.pdp-contact-btn i { font-size: 22px; transition: transform 0.15s ease; }
.pdp-contact-btn:hover:not(:disabled) { background: var(--bg-body); }
.pdp-contact-btn:hover:not(:disabled) i { transform: translateY(-1px); }
.pdp-contact-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pdp-contact-btn.whatsapp i { color: #25d366; }
.pdp-contact-btn.call i { color: #2563eb; }
.pdp-contact-btn.message i { color: var(--accent-coral); }
.pdp-contact-btn.whatsapp:hover:not(:disabled) { background: rgba(37,211,102,0.08); }
.pdp-contact-btn.call:hover:not(:disabled) { background: rgba(37,99,235,0.08); }
.pdp-contact-btn.message:hover:not(:disabled) { background: rgba(255,107,91,0.08); }

/* ── Seller card ───────────────────────────────────── */
.pdp-seller-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; border-radius: 14px;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    position: relative;
}
.pdp-seller-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-coral); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px; flex-shrink: 0;
}
.pdp-seller-meta { flex: 1; min-width: 0; }
.pdp-seller-name {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pdp-seller-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.pdp-verified, .pdp-unverified {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
    padding: 2px 8px; border-radius: 999px; cursor: help;
}
.pdp-verified { background: rgba(37,99,235,0.10); color: #2563eb; }
.pdp-verified i { font-size: 13px; }
.pdp-unverified { background: var(--bg-body); color: var(--text-muted); border: 1px solid var(--border-color); }
.pdp-unverified i { font-size: 12px; }

/* Info tooltip */
.pdp-info-tip {
    position: relative; flex-shrink: 0;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-body); display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: help;
    border: 1px solid var(--border-color);
}
.pdp-info-tip i { font-size: 16px; }
.pdp-info-tip:hover, .pdp-info-tip:focus { color: var(--text-primary); border-color: var(--text-primary); outline: none; }
.pdp-info-tip-bubble {
    position: absolute; right: 0; top: calc(100% + 10px);
    width: min(320px, 88vw); padding: 14px 16px;
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 18px 40px -10px rgba(0,0,0,0.18);
    font-size: 12.5px; line-height: 1.55;
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    z-index: 30; cursor: default;
}
.pdp-info-tip:hover .pdp-info-tip-bubble,
.pdp-info-tip:focus-within .pdp-info-tip-bubble {
    opacity: 1; visibility: visible; transform: translateY(0);
}
.pdp-info-tip-bubble strong {
    display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--accent-coral); margin-bottom: 6px;
}
.pdp-info-tip-bubble p { margin: 0 0 8px; color: var(--text-secondary); }
.pdp-info-tip-bubble ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.pdp-info-tip-bubble li {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 12px; color: var(--text-secondary);
}
.pdp-info-tip-bubble li i { font-size: 14px; color: var(--accent-coral); flex-shrink: 0; margin-top: 1px; }

/* ── Tags + share row ─────────────────────────────── */
.pdp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pdp-tag {
    padding: 4px 10px; font-size: 11px; font-weight: 600;
    background: var(--bg-body); color: var(--text-secondary);
    border-radius: 999px; border: 1px solid var(--border-color);
}

.pdp-share-row { display: flex; gap: 8px; }
.pdp-icon-btn {
    flex: 1; padding: 12px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: transparent; color: var(--text-primary);
    border: 1px solid var(--border-color); cursor: pointer;
    border-radius: 10px; transition: var(--transition);
    font-size: 13px; font-weight: 600; font-family: inherit;
}
.pdp-icon-btn:hover { border-color: var(--text-primary); }
.pdp-icon-btn.active { color: var(--accent-coral); border-color: var(--accent-coral); }
.pdp-icon-btn i { font-size: 17px; }

/* ── Related products ─────────────────────────────── */
.pdp-related { margin-top: 56px; }
.pdp-related-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 16px; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
}
.pdp-related-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 22px; font-weight: 600; letter-spacing: -0.3px; margin: 0;
}
@media (min-width: 1024px) { .pdp-related-title { font-size: 28px; } }
.pdp-related-more {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text-secondary);
}
.pdp-related-more:hover { color: var(--accent-coral); }
.pdp-related-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 768px) { .pdp-related-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; } }
.pdp-related-card {
    display: flex; flex-direction: column;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 14px; overflow: hidden;
    text-decoration: none; color: var(--text-primary);
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}
.pdp-related-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px -14px rgba(0,0,0,0.18);
    border-color: var(--text-primary);
    color: var(--text-primary);
}
.pdp-related-img {
    width: 100%; aspect-ratio: 1 / 1;
    background: var(--bg-body);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.pdp-related-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pdp-related-img .pdp-related-noimg { width: 60%; height: 60%; object-fit: contain; opacity: 0.5; }
.pdp-related-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.pdp-related-cat {
    font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px;
    color: var(--text-muted); text-transform: uppercase;
}
.pdp-related-name {
    font-size: 14px; font-weight: 600; line-height: 1.35;
    color: var(--text-primary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.pdp-related-price {
    font-size: 14px; font-weight: 700; color: var(--accent-coral); margin-top: 2px;
}

/* ── Lightbox ─────────────────────────────────────── */
.pdp-lightbox {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.92);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.pdp-lightbox[hidden] { display: none; }
.pdp-lightbox-img { max-width: 92%; max-height: 92vh; object-fit: contain; border-radius: 4px; }
.pdp-lightbox-close, .pdp-lightbox-nav {
    position: absolute; background: rgba(255,255,255,0.1); color: #fff;
    border: none; cursor: pointer; border-radius: 50%;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.pdp-lightbox-close:hover, .pdp-lightbox-nav:hover { background: rgba(255,255,255,0.2); }
.pdp-lightbox-close { top: 20px; right: 20px; }
.pdp-lightbox-nav i { font-size: 22px; }
.pdp-lightbox-nav.prev { left: 16px; top: 50%; transform: translateY(-50%); }
.pdp-lightbox-nav.next { right: 16px; top: 50%; transform: translateY(-50%); }

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.mobile-nav-wrapper {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 1000; background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 1024px) { .mobile-nav-wrapper { display: none; } }

.mobile-nav {
    display: flex; align-items: center; justify-content: space-around;
    height: var(--nav-height-mobile); max-width: 500px; margin: 0 auto;
}

.m-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; height: 100%; color: var(--text-muted);
    transition: var(--transition); text-decoration: none; gap: 2px;
}
.m-nav-item i { font-size: 22px; }
.m-nav-item span { font-size: 10px; font-weight: 500; }
.m-nav-item.active { color: var(--text-primary); }

.m-nav-fab {
    display: flex; align-items: center; justify-content: center;
    flex: 1; height: 100%;
}
.m-nav-fab-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-surface);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; border: none; cursor: pointer;
    box-shadow: var(--shadow-md); transition: var(--transition);
}
.m-nav-fab-btn:hover { transform: scale(1.05); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-primary); color: var(--bg-surface);
    padding: 12px 24px; border-radius: var(--radius-pill);
    font-size: 14px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
    opacity: 0; pointer-events: none; transition: all 0.3s ease;
    z-index: 9999; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */
.pwa-install-banner {
    position: fixed; bottom: 68px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: calc(100% - 32px); max-width: 420px;
    background: var(--bg-surface); color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    opacity: 0; pointer-events: none;
    transition: all 0.35s cubic-bezier(.4,0,.2,1);
    z-index: 9998;
}
.pwa-install-banner.show {
    opacity: 1; pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.pwa-install-content {
    display: flex; align-items: center; gap: 12px;
    flex: 1; min-width: 0;
}
.pwa-install-icon {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    flex-shrink: 0;
}
.pwa-install-text {
    display: flex; flex-direction: column; min-width: 0;
}
.pwa-install-text strong {
    font-size: 14px; font-weight: 600;
}
.pwa-install-text span {
    font-size: 12px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pwa-install-actions {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.pwa-install-btn {
    background: var(--accent); color: var(--accent-text);
    border: none; border-radius: var(--radius-pill);
    padding: 8px 18px; font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.pwa-install-dismiss {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; padding: 4px;
    display: flex; align-items: center; justify-content: center;
}
@media (min-width: 769px) {
    .pwa-install-banner { bottom: 24px; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.no-listings { grid-column: 1 / -1; text-align: center; padding: 48px 20px; color: var(--text-muted); }
.no-listings i { font-size: 48px; margin-bottom: 16px; display: block; }
.no-listings h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }

/* ============================================================
   MESSAGES PAGE
   ============================================================ */
.messages-page { max-width: 800px; margin: 0 auto; padding: 48px 20px; text-align: center; width: 100%; }
.empty-state { color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ── Top-nav messages icon (desktop) ── */
.nav-msg-btn {
    position: relative; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: var(--transition);
    text-decoration: none;
}
.nav-msg-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-msg-btn.active { color: var(--text-primary); }
.nav-msg-btn i { font-size: 22px; }
.nav-msg-badge {
    position: absolute; top: 4px; right: 4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: #ef4444; color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-surface);
    box-sizing: content-box;
}
.nav-msg-badge[hidden] { display: none; }

/* ── Mobile message FAB (visible everywhere when authenticated) ── */
.msg-fab-mobile {
    position: fixed;
    right: 16px;
    bottom: calc(var(--nav-height-mobile) + env(safe-area-inset-bottom, 0px) + 16px);
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-surface);
    display: none; align-items: center; justify-content: center;
    box-shadow: var(--shadow-lg); z-index: 999;
    text-decoration: none; transition: var(--transition);
}
.msg-fab-mobile i { font-size: 22px; }
.msg-fab-mobile:hover { transform: scale(1.05); }
.msg-fab-mobile.active { background: var(--accent-coral); }
.msg-fab-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: #ef4444; color: #fff;
    font-size: 11px; font-weight: 700; line-height: 18px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-surface);
    box-sizing: content-box;
}
.msg-fab-badge[hidden] { display: none; }
@media (max-width: 1023px) { .msg-fab-mobile { display: flex; } }

/* ── Messages page (full layout) ── */
.messages-page-full {
    display: grid; grid-template-columns: 320px 1fr;
    height: calc(100vh - var(--nav-height-desktop, 64px));
    width: 100%;
    background: var(--bg-body);
}
@media (max-width: 1023px) {
    .messages-page-full {
        grid-template-columns: 1fr;
        height: calc(100vh - var(--nav-height-mobile, 56px));
    }
}

.msg-sidebar {
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    background: var(--bg-surface); min-height: 0;
}
.msg-sidebar-header {
    padding: 16px 18px; border-bottom: 1px solid var(--border-color);
}
.msg-sidebar-header h2 { font-size: 18px; font-weight: 700; }

.msg-conv-list { flex: 1; overflow-y: auto; }
.msg-empty-mini { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }

.msg-conv-item {
    width: 100%; display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px; border: none; background: transparent;
    text-align: left; cursor: pointer; border-bottom: 1px solid var(--border-color);
    transition: var(--transition); color: inherit;
}
.msg-conv-item:hover { background: var(--bg-surface-hover); }
.msg-conv-item.active { background: var(--bg-surface-hover); }
.msg-conv-item.has-unread .msg-conv-name { font-weight: 700; }
.msg-conv-item.has-unread .msg-conv-last { color: var(--text-primary); font-weight: 500; }

.msg-conv-thumb {
    width: 44px; height: 44px; border-radius: var(--radius-md);
    background: var(--bg-body); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; color: var(--text-muted);
}
.msg-conv-thumb img { width: 100%; height: 100%; object-fit: cover; }
.msg-conv-thumb i { font-size: 22px; }

.msg-conv-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-conv-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.msg-conv-name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-conv-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.msg-conv-listing { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.msg-conv-last { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-unread-pill {
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: var(--radius-pill); flex-shrink: 0; line-height: 1.2;
}

/* ── Thread pane ── */
.msg-thread { display: flex; flex-direction: column; min-height: 0; background: var(--bg-body); }
.msg-thread-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px; text-align: center; color: var(--text-muted);
}
.msg-thread-empty i { font-size: 56px; margin-bottom: 12px; }
.msg-thread-empty h3 { font-size: 16px; color: var(--text-primary); margin-bottom: 6px; }
.msg-thread-empty p { font-size: 13px; max-width: 320px; }

.msg-thread-active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.msg-thread-active[hidden] { display: none; }

.msg-thread-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
}
.msg-back {
    width: 36px; height: 36px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: transparent; color: var(--text-primary); border: none; cursor: pointer;
}
.msg-back:hover { background: var(--bg-surface-hover); }
.msg-back i { font-size: 20px; }
.msg-thread-listing {
    display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
    text-decoration: none; color: inherit;
}
.msg-thread-thumb {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: var(--bg-body); flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center; color: var(--text-muted);
}
.msg-thread-thumb img { width: 100%; height: 100%; object-fit: cover; }
.msg-thread-meta { min-width: 0; flex: 1; }
.msg-thread-title { font-size: 14px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-thread-sub { font-size: 12px; color: var(--text-muted); }
.msg-thread-actions { display: flex; gap: 4px; flex-shrink: 0; }
.msg-action-btn {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--text-muted); border: none; cursor: pointer;
}
.msg-action-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.msg-action-btn i { font-size: 18px; }

.msg-thread-body {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 8px;
}
.msg-bubble {
    max-width: 75%; padding: 9px 13px; border-radius: 16px;
    font-size: 14px; line-height: 1.45; word-wrap: break-word;
}
.msg-bubble-body { white-space: pre-wrap; }
.msg-bubble-time { font-size: 10px; opacity: 0.7; margin-top: 4px; text-align: right; }
.msg-mine {
    align-self: flex-end;
    background: var(--text-primary); color: var(--bg-surface);
    border-bottom-right-radius: 4px;
}
.msg-theirs {
    align-self: flex-start;
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.msg-compose {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}
.msg-compose input {
    flex: 1; padding: 11px 16px; border-radius: var(--radius-pill);
    background: var(--bg-body); border: 1px solid var(--border-color);
    font-size: 14px; color: var(--text-primary); outline: none;
}
.msg-compose input:focus { border-color: var(--text-primary); }
.msg-send-btn {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--text-primary); color: var(--bg-surface);
    display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; transition: var(--transition); flex-shrink: 0;
}
.msg-send-btn i { font-size: 18px; }
.msg-send-btn:hover { transform: scale(1.05); }

/* Mobile: toggle list/thread */
@media (max-width: 1023px) {
    .messages-page-full .msg-thread { display: none; }
    .messages-page-full.show-thread .msg-sidebar { display: none; }
    .messages-page-full.show-thread .msg-thread { display: flex; }
    .msg-back { display: flex; }
}

/* ── Compose / contact picker ── */
.msg-fab-mobile.compose { background: var(--accent-coral); }
.compose-contact-list {
    display: flex; flex-direction: column; gap: 6px;
    max-height: 60vh; overflow-y: auto;
    margin: 0 -8px;
}
.compose-contact-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); background: var(--bg-body);
    cursor: pointer; transition: var(--transition);
    text-align: left; color: inherit; width: 100%;
}
.compose-contact-item:hover { background: var(--bg-surface-hover); border-color: var(--text-muted); }
.compose-contact-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--accent-coral); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.compose-contact-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.compose-contact-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.compose-contact-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-contact-item > i { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }

/* ============================================================
   ANIMATIONS & UTILITIES
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeIn 0.3s ease forwards; }

.maplibregl-popup-content {
    border-radius: var(--radius-md) !important; padding: 12px 16px !important;
    box-shadow: var(--shadow-md) !important; border: 1px solid var(--border-color) !important;
    font-family: 'Inter', sans-serif !important;
}
.maplibregl-popup-close-button { font-size: 16px; padding: 4px 8px; }
.maplibregl-ctrl-group {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* Center map controls vertically on mobile */
@media (max-width: 1023px) {
    .map-canvas-area .maplibregl-ctrl-top-right {
        top: 50% !important;
        transform: translateY(-50%);
    }
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ============================================================
   MAP — Custom HTML Markers (Google-style teardrop + cluster)
   ============================================================ */

/* Listing pin — clean SVG teardrop with gradient + icon disc */
.mk-pin {
    position: relative;
    width: 36px;
    height: 48px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 2;
    transform-origin: 50% 100%;
    transition: transform 0.18s ease;
    will-change: transform;
}
.mk-pin > * { pointer-events: none; }
.mk-pin:hover { transform: scale(1.10); z-index: 4; }

.mk-pin-svg {
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 3px 4px rgba(0,0,0,0.18));
}
.mk-pin-icon {
    position: absolute;
    top: 9px;
    left: 50%;
    width: 17px; height: 17px;
    transform: translateX(-50%);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    line-height: 1;
}

/* Cluster — Google-style soft halo + filled disc with count */
.mk-cluster {
    position: relative;
    width: 44px; height: 44px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 3;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.18s ease;
}
.mk-cluster > * { pointer-events: none; }
.mk-cluster.mk-cluster-md { width: 54px; height: 54px; }
.mk-cluster.mk-cluster-lg { width: 64px; height: 64px; }
.mk-cluster:hover { transform: scale(1.06); }

.mk-cluster-halo {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(66, 133, 244, 0.22);
    transition: background 0.2s ease;
}
.mk-cluster.mk-cluster-md .mk-cluster-halo { background: rgba(251, 188, 5, 0.28); }
.mk-cluster.mk-cluster-lg .mk-cluster-halo { background: rgba(234, 67, 53, 0.30); }

.mk-cluster-core {
    position: relative;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    border-radius: 50%;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #4285F4 0%, #1a73e8 100%);
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.35), 0 1px 3px rgba(0,0,0,0.15);
    border: 2px solid #ffffff;
}
.mk-cluster.mk-cluster-md .mk-cluster-core {
    font-size: 16px;
    background: linear-gradient(160deg, #FBBC05 0%, #f29900 100%);
    box-shadow: 0 4px 12px rgba(242, 153, 0, 0.40), 0 1px 3px rgba(0,0,0,0.15);
}
.mk-cluster.mk-cluster-lg .mk-cluster-core {
    font-size: 17px;
    background: linear-gradient(160deg, #EA4335 0%, #c5221f 100%);
    box-shadow: 0 4px 14px rgba(197, 34, 31, 0.45), 0 1px 3px rgba(0,0,0,0.15);
}

/* Cluster sheet — full card of items inside a cluster, with own search */
.map-cluster-sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -18px 50px -10px rgba(0,0,0,0.22);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex; flex-direction: column;
    max-height: 70vh;
    overflow: hidden;
}
.map-cluster-sheet.open { transform: translateY(0); }
@media (min-width: 1024px) {
    .map-cluster-sheet {
        left: auto; right: 16px; bottom: 16px;
        width: 380px;
        max-height: calc(100vh - 140px);
        border-radius: 18px;
        border: 1px solid var(--border-color);
        transform: translateY(calc(100% + 32px));
    }
}
.mcs-grip {
    width: 40px; height: 4px; border-radius: 999px;
    background: var(--border-color);
    margin: 8px auto 4px;
}
@media (min-width: 1024px) { .mcs-grip { display: none; } }
.mcs-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; padding: 8px 18px 10px;
}
.mcs-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px; font-weight: 600; color: var(--text-primary);
    letter-spacing: -0.2px;
}
.mcs-sub {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
    text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
}
.mcs-close {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg-body); border: 1px solid var(--border-color);
    color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.mcs-close:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.mcs-search {
    margin: 0 18px 12px;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}
.mcs-search i { color: var(--text-muted); font-size: 16px; }
.mcs-search input {
    flex: 1; border: none; background: transparent; outline: none;
    font-family: inherit; font-size: 14px; color: var(--text-primary);
}
.mcs-list {
    flex: 1; overflow-y: auto;
    padding: 0 18px 18px;
    display: flex; flex-direction: column; gap: 8px;
}
.mcs-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    cursor: pointer;
    transition: var(--transition);
}
.mcs-item:hover { border-color: var(--text-primary); transform: translateY(-1px); }
.mcs-item-img {
    width: 56px; height: 56px; border-radius: 10px;
    background: var(--bg-surface-hover);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex-shrink: 0;
}
.mcs-item-img img { width: 100%; height: 100%; object-fit: cover; }
.mcs-item-img i { color: var(--text-muted); font-size: 22px; }
.mcs-item-info { flex: 1; min-width: 0; }
.mcs-item-title {
    font-size: 13.5px; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mcs-item-meta {
    font-size: 11.5px; color: var(--text-muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mcs-item-price {
    font-size: 13px; font-weight: 700; color: var(--accent-coral); margin-top: 4px;
}
.mcs-empty {
    padding: 28px 16px; text-align: center;
    color: var(--text-muted); font-size: 13px;
}

/* ============================================================
   ACCOUNT — centered profile + grouped settings
   ============================================================ */
.account-header.centered {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    padding: 32px 20px 20px;
}
.account-header.centered .account-avatar {
    width: 96px; height: 96px;
    font-size: 36px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-hover) 100%);
    box-shadow: var(--shadow-md);
}
.account-header.centered .account-name {
    margin-top: 6px;
    font-size: 22px;
}
.account-header.centered .account-email { font-size: 14px; }

/* Settings group (collapsible) */
.setting-group {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}
.setting-group .setting-group-header {
    width: 100%;
    border: none;
    border-radius: 0;
    background: transparent;
    text-align: left;
}
.setting-group .setting-group-header:hover {
    box-shadow: none; transform: none;
    background: var(--bg-surface-hover);
}
.setting-group-caret {
    transition: transform 0.25s ease;
}
.setting-group.open .setting-group-caret { transform: rotate(180deg); }

.setting-group-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.setting-group.open .setting-group-body { max-height: 400px; }

.setting-item.sub {
    border: none;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    background: transparent;
    padding-left: 28px;
}
.setting-item.sub:hover { box-shadow: none; transform: none; background: var(--bg-surface-hover); }

/* ============================================================
   MAP — Route panel (distance + ETA overlay)
   ============================================================ */
.route-panel {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(20px);
    width: calc(100% - 32px);
    max-width: 420px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    z-index: 18;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s ease;
}
.route-panel.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.route-panel-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}
.route-panel-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--accent-coral);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}
.route-panel-icon.warn { background: #d97706; }
.route-panel-info { flex: 1; min-width: 0; }
.route-panel-eta {
    font-size: 15px; font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.route-panel-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.route-panel-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    color: var(--text-muted);
    background: var(--bg-surface-hover);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.route-panel-close:hover { color: var(--text-primary); }

@media (max-width: 1023px) {
    .route-panel {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}
