/* ======================================
   RESET & DESIGN TOKENS
   ====================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0D9488;
    --primary-dark: #0F766E;
    --primary-light: #CCFBF1;
    --secondary: #5f6368;
    --background: #F8FAFC;
    --surface: #ffffff;
    --text: #202124;
    --text-secondary: #5f6368;
    --text-light: #80868b;
    --border: #dadce0;
    --border-light: #e8eaed;
    --success: #0F766E;
    --success-bg: #CCFBF1;
    --warning: #ea8600;
    --warning-bg: #fef7e0;
    --danger: #d93025;
    --danger-bg: #fce8e6;
    --shadow-sm: 0 1px 2px rgba(60,64,67,.1);
    --shadow-md: 0 1px 3px rgba(60,64,67,.15), 0 1px 2px rgba(60,64,67,.1);
    --shadow-lg: 0 4px 12px rgba(60,64,67,.15);
    --shadow-xl: 0 8px 24px rgba(60,64,67,.2);
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --sidebar-width: 240px;
    --header-height: 56px;
    --search-bar-height: 52px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body.no-scroll {
    overflow: hidden;
}

/* ======================================
   HEADER
   ====================================== */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--header-height);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
}

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

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.tagline {
    font-size: 0.8rem;
    color: var(--text-light);
    display: none;
}

@media (min-width: 768px) {
    .tagline { display: block; }
}

/* Filter toggle visibility is controlled by .btn-filter-toggle's class rules
   (default: hidden; visible at ≤1024px). The previous #filterToggleBtn ID
   override fought the class cascade and forced it hidden on tablets — removed. */

.nav {
    display: flex;
    gap: 2px;
}

.nav-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    position: relative;
    white-space: nowrap;
}

.nav-btn:hover {
    background: var(--background);
    color: var(--text);
}

.nav-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

.badge.hidden { display: none; }

/* ======================================
   SECTION VISIBILITY
   ====================================== */
.section { display: none; }
.section.active { display: block; }

/* ======================================
   SEARCH BAR (sticky below header)
   ====================================== */
.search-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--header-height);
    z-index: 150;
    padding: 8px 16px;
}

.search-bar-inner {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: var(--background);
    transition: border-color 0.15s, background 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.search-category,
.search-sort {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    min-width: 140px;
}

.search-category:focus,
.search-sort:focus {
    outline: none;
    border-color: var(--primary);
}

/* Compound selector raises specificity to (0,0,2) so this beats .btn's display:
   inline-flex regardless of source order. The @media override below uses the
   same compound selector to keep cascade resolution predictable. */
.btn.btn-filter-toggle {
    display: none;
    align-items: center;
    gap: 6px;
}

.filter-count-badge {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.85em;
    opacity: 0.95;
}

.filter-count-badge.hidden {
    display: none;
}

/* Mobile-only sort dropdown (lives in the filter drawer; see L-2) */
.sort-mobile-only {
    display: none;
}

/* L-3: bumped from 900px → 1024px so iPads (portrait + landscape) get the
   touch-friendly drawer + filter button instead of a squeezed sidebar. */
@media (max-width: 1024px) {
    .search-sort {
        display: none !important;
    }
    .btn.btn-filter-toggle {
        display: inline-flex;
    }
    .sort-mobile-only {
        display: block;
    }
}

/* ======================================
   BROWSE LAYOUT: SIDEBAR + GRID
   ====================================== */
.browse-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height) - var(--search-bar-height) - 60px);
}

/* Filter Overlay (mobile) */
.filter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
}

.filter-overlay.open {
    display: block;
}

/* Filter Sidebar */
.filter-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    position: sticky;
    top: calc(var(--header-height) + var(--search-bar-height));
    height: calc(100vh - var(--header-height) - var(--search-bar-height));
}

.filter-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.filter-sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.filter-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.filter-section {
    margin-bottom: 16px;
}

.filter-section label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.filter-section select,
.filter-section input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
}

.filter-section select:focus,
.filter-section input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-divider {
    height: 1px;
    background: var(--border-light);
    margin: 16px 0;
}

.filter-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* Listings Main Area */
.listings-main {
    flex: 1;
    min-width: 0;
    padding: 16px;
}

/* ======================================
   LISTINGS GRID (edge-to-edge)
   ====================================== */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.listing-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.listing-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border);
}

.listing-image-wrap {
    position: relative;
    width: 100%;
}

.listing-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--background);
    display: block;
}

.listing-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.85rem;
    height: 180px;
    background: var(--background);
}

.listing-heart {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-light);
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
    padding: 0;
}

.listing-heart:hover {
    transform: scale(1.08);
    background: #fff;
}

.listing-heart.is-fav {
    color: #e11d48;
    background: #fff;
}

.listing-heart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.listing-content {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.listing-content-top {
    flex: 1;
}

.listing-content-bottom {
    margin-top: 8px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
}

.listing-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: calc(0.9rem * 1.3 * 2);
}

.listing-brand {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.listing-seller-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.listing-seller {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}

.listing-seller:hover {
    text-decoration: underline;
}

.listing-timestamp {
    color: var(--text-light);
    font-size: 0.75rem;
}

.listing-views {
    color: var(--text-light);
    font-size: 0.75rem;
    white-space: nowrap;
}

.modal-views {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.listing-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--text-secondary);
    font-weight: 500;
}

.tag.type-swap,
.tag.type-sale,
.tag.type-free {
    background: #E2E8F0;
    color: #475569;
}

.listing-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.listing-price.free {
    color: var(--success);
}

.listing-price.swap {
    color: var(--primary);
}

.listing-location {
    font-size: 0.78rem;
    color: var(--text-light);
}

.listing-status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.listing-pending,
.listing-sold {
    opacity: 0.6;
}

/* Loading & Empty */
.loading, .empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-light);
    font-size: 0.9rem;
    grid-column: 1 / -1;
}

/* ======================================
   PAGE CONTAINER (forms, messages, account)
   ====================================== */
.page-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

.page-container--wide {
    max-width: 1100px;
}

/* ======================================
   BUTTONS
   ====================================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-large {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
}

.btn-block {
    width: 100%;
}

.btn-status {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-status:hover {
    background: var(--primary);
    color: white;
}

/* ======================================
   FORMS
   ====================================== */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.form-card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
    background: var(--surface);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.form-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.form-section h3 {
    margin-bottom: 12px;
    font-size: 1rem;
    color: var(--text);
}

/* Photo Upload */
.photo-upload-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Contact Options */
.contact-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* Checkbox Groups for Size Selection */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    padding: 8px;
    background: var(--background);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-group .checkbox-label {
    margin: 0;
    font-size: 0.85rem;
}

/* ======================================
   MESSAGES
   ====================================== */
.messages-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    height: 600px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
}

.conversations-list {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
}

.conversations-list h2 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.conversation-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.conversation-item:hover {
    background: var(--background);
}

.conversation-item.active {
    background: var(--primary-light);
}

.conversation-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.conversation-preview {
    font-size: 0.8rem;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item.active .conversation-preview {
    color: var(--primary);
}

.chat-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--background);
}

.message {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    line-height: 1.4;
    font-size: 0.9rem;
}

.message.sent {
    align-self: flex-end;
    background: var(--primary);
    color: white;
}

.message.received {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border-light);
    color: var(--text);
}

.message-time {
    font-size: 0.65rem;
    margin-top: 2px;
    opacity: 0.7;
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    background: var(--surface);
}

.chat-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.chat-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-input.hidden { display: none; }

/* ======================================
   ACCOUNT & AUTH
   ====================================== */
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 440px;
    margin: 0 auto;
}

.auth-card.hidden { display: none; }

.auth-card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.password-requirements {
    list-style: none;
    padding: 8px 0 0 0;
    margin: 0;
    font-size: 0.8rem;
}

.password-requirements li {
    padding: 2px 0 2px 20px;
    position: relative;
    color: var(--text-light);
    transition: color 0.2s;
}

.password-requirements li::before {
    content: '✗';
    position: absolute;
    left: 0;
    color: #e53e3e;
    font-weight: bold;
}

.password-requirements li.met {
    color: #2f855a;
}

.password-requirements li.met::before {
    content: '✓';
    color: #2f855a;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: inherit;
    font-weight: 500;
}

.link-btn:hover {
    text-decoration: underline;
}

.account-dashboard {
    max-width: 1000px;
    margin: 0 auto;
}

.account-dashboard.hidden { display: none; }

.account-dashboard > h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dashboard-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.dashboard-card h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.my-listing-item {
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.my-listing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.my-listing-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.my-listing-brand {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

.my-listing-status {
    font-size: 0.8rem;
    font-weight: 600;
}

.my-listing-info {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.my-listing-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Favorite Listing Thumbnail */
.favorite-listing-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.favorite-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

.favorite-thumbnail:hover {
    opacity: 0.85;
}

.favorite-thumbnail.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    color: var(--text-light);
    font-size: 0.7rem;
    text-align: center;
    padding: 4px;
}

.favorite-details {
    flex: 1;
    min-width: 0;
}

/* Profile Image */
.profile-image-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius-md);
}

.profile-image {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.profile-image-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--border-light);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.75rem;
    text-align: center;
}

.profile-field {
    margin-bottom: 10px;
}

.profile-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.profile-value {
    font-weight: 500;
    font-size: 0.9rem;
}

/* ======================================
   MODAL
   ====================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 24px;
    box-shadow: var(--shadow-xl);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--background);
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.modal-close:hover {
    background: var(--border-light);
    color: var(--text);
}

/* Image Viewer Modal */
.image-modal-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.image-modal-content img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

/* Modal Detail Content */
.modal-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.modal-image {
    width: 100%;
    height: 400px;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.modal-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.status-available {
    color: var(--success);
    background: var(--success-bg);
}

.status-pending {
    color: var(--warning);
    background: var(--warning-bg);
}

.status-sold {
    color: var(--text-light);
    background: var(--background);
}

.modal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.modal-detail {
    padding: 10px 12px;
    background: var(--background);
    border-radius: var(--radius-md);
}

.modal-detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.modal-detail-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* User Profile Modal */
.user-profile-modal {
    max-height: 80vh;
    overflow-y: auto;
}

.user-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.user-profile-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.user-listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

/* ======================================
   FAVORITE BUTTON
   ====================================== */
.favorite-btn {
    background: none;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    transition: background 0.15s, border-color 0.15s;
}

.favorite-btn:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.favorite-btn.favorited {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.favorite-btn.not-favorited {
    color: var(--text-secondary);
}

/* ======================================
   TOAST NOTIFICATIONS
   ====================================== */
.toast-notification {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    right: 16px;
    background: var(--surface);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    animation: toastSlideIn 0.25s ease;
    border-left: 3px solid var(--success);
    max-width: 360px;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-notification.success {
    border-left-color: var(--success);
}

.toast-notification.error {
    border-left-color: var(--danger);
}

/* ======================================
   FOOTER
   ====================================== */
.footer {
    background: var(--surface);
    padding: 16px;
    text-align: center;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    margin-top: 24px;
}

/* ======================================
   UTILITY
   ====================================== */
.hidden { display: none !important; }
.text-center { text-align: center; }

/* Camera button - mobile only */
.mobile-camera-btn {
    display: none;
}

/* ======================================
   RESPONSIVE: MOBILE
   ====================================== */
/* L-1 + L-3: filter-sidebar becomes a drawer at ≤1024px (iPad + smaller).
   Single consolidated block — no transform/left split per breakpoint. */
@media (max-width: 1024px) {
    .filter-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85vw;
        max-width: 320px;
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        z-index: 1001;
        box-shadow: var(--shadow-xl);
        border-right: none;
        padding-top: 16px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .filter-sidebar.open {
        transform: translateX(0);
    }

    .filter-close-btn {
        display: block;
    }
}

@media (max-width: 900px) {
    .mobile-camera-btn {
        display: inline-flex;
    }
    /* Header */
    .header-inner {
        padding: 0 12px;
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Search bar */
    .search-bar {
        padding: 8px 12px;
    }

    /* Listings grid: single column */
    .listings-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .listing-card {
        display: flex;
        flex-direction: row;
        height: auto;
    }

    .listing-card .listing-image {
        width: 120px;
        height: 120px;
        flex-shrink: 0;
    }

    .listing-card .listing-content {
        flex: 1;
        min-width: 0;
    }

    /* Listings main */
    .listings-main {
        padding: 8px 12px;
    }

    /* Messages */
    .messages-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .conversations-list {
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Modal */
    .modal {
        padding: 8px;
    }

    .modal-content {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .modal-detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header-left {
        gap: 8px;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    .nav-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .listing-card .listing-image {
        width: 100px;
        height: 100px;
    }

    .modal-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .search-btn-mobile {
        display: inline-block;
    }
    .search-btn-desktop {
        display: none;
    }
}

@media (min-width: 768px) {
    .search-btn-mobile {
        display: none;
    }
    .search-btn-desktop {
        display: block;
    }
}

/* L-1: filter-sidebar drawer behavior is consolidated into the
   @media (max-width: 900px) block above — no per-breakpoint override needed. */

/* Image Carousel Styles */

.image-carousel {
    width: 100%;
    margin-bottom: 1.5rem;
}

.carousel-main {
    position: relative;
    width: 100%;
    height: 400px;
    background: #f5f5f5;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 12px;
}

.carousel-image-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.carousel-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.carousel-image.active {
    opacity: 1;
    pointer-events: auto;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.carousel-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
}

.carousel-prev {
    left: 12px;
}

.carousel-next {
    right: 12px;
}

.carousel-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: thin;
}

.carousel-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.carousel-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.carousel-thumbnails::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.carousel-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
}

.carousel-thumbnail:hover {
    transform: scale(1.05);
}

.carousel-thumbnail.active {
    border-color: var(--primary);
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .carousel-main {
        height: 300px;
    }
    
    .carousel-arrow {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .carousel-thumbnail {
        width: 60px;
        height: 60px;
    }
}

/* Touch swipe support for mobile */
.carousel-image-container {
    touch-action: pan-y;
}

/* ======================================
   NEW ARRIVALS
   ====================================== */
.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.new-arrivals-container {
    margin-bottom: 20px;
    padding-bottom: 4px;
}

.new-arrivals-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.new-arrivals-scroll::-webkit-scrollbar {
    height: 4px;
}

.new-arrivals-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.new-arrival-card {
    flex-shrink: 0;
    width: 150px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.new-arrival-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

.new-arrival-image {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    background: var(--background);
}

.new-arrival-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.75rem;
}

.new-arrival-content {
    padding: 7px 9px 9px;
}

.new-arrival-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.new-arrival-price {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
}

/* ======================================
   SIMILAR ITEMS
   ====================================== */
.similar-items-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.similar-items-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.similar-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.similar-item-card {
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.similar-item-card:hover {
    box-shadow: var(--shadow-md);
}

.similar-item-image {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
    background: var(--background);
}

.similar-item-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.72rem;
}

.similar-item-content {
    padding: 6px 8px 8px;
}

.similar-item-title {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.similar-item-price {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
}

/* ======================================
   SELLER RATINGS & REVIEWS
   ====================================== */
.avg-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.avg-rating-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.avg-rating-stars {
    color: var(--warning);
    font-size: 1rem;
    letter-spacing: 1px;
}

.avg-rating-count {
    color: var(--text-light);
    font-size: 0.8rem;
}

.reviews-list {
    margin-top: 12px;
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
}

.reviews-list-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.review-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.review-item:last-child {
    border-bottom: none;
}

.review-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.review-stars {
    color: var(--warning);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.review-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

.review-comment {
    font-size: 0.85rem;
    color: var(--text);
    margin: 0;
}

/* Interactive Star Rating */
.interactive-stars {
    display: flex;
    gap: 4px;
    margin: 8px 0;
}

.star-btn {
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--border);
    transition: color 0.1s, transform 0.1s;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
}

.star-btn.selected,
.star-btn:hover {
    color: var(--warning);
    transform: scale(1.1);
}

.review-form-box {
    margin-top: 12px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.review-form-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

/* ======================================
   PRICE DROP BADGE
   ====================================== */
.price-drop-badge {
    display: inline-block;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-left: 6px;
    vertical-align: middle;
}

.price-drop-prev {
    font-size: 0.75rem;
    color: var(--text-light);
    text-decoration: line-through;
    margin-right: 4px;
}

/* ======================================
   CHAT IMAGE MESSAGES
   ====================================== */
.chat-image-btn {
    padding: 8px 10px;
    font-size: 1rem;
    flex-shrink: 0;
}

.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-md);
    display: block;
    cursor: pointer;
    object-fit: cover;
}

/* ======================================
   REPORT BUTTON
   ====================================== */
.report-link-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 8px 4px;
    text-decoration: underline;
    margin-left: auto;
}

.report-link-btn:hover {
    color: var(--danger);
}

/* ======================================
   POST SUCCESS SCREEN
   ====================================== */
.post-success-card {
    max-width: 520px;
    margin: 32px auto;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.post-success-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.8rem;
    line-height: 56px;
    display: inline-block;
    margin-bottom: 12px;
}

.post-success-card h2 {
    margin: 0 0 6px;
    font-size: 1.4rem;
}

.post-success-subtitle {
    color: var(--text-secondary);
    margin: 0 0 20px;
    font-size: 0.92rem;
}

.post-success-preview {
    display: flex;
    gap: 14px;
    align-items: center;
    text-align: left;
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 20px;
}

.post-success-thumb {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--border-light);
    flex-shrink: 0;
}

.post-success-thumb.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.8rem;
}

.post-success-meta {
    flex: 1;
    min-width: 0;
}

.post-success-meta h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.post-success-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 2px;
}

.post-success-location {
    color: var(--text-light);
    font-size: 0.82rem;
}

.post-success-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.post-success-actions .btn {
    flex: 1 1 140px;
    min-width: 0;
}

/* ======================================
   L-4: TOUCH TARGETS — bump small interactive elements to WCAG 2.5.5 (44×44)
   on coarse pointers (touch). Desktop mouse precision is unaffected.
   ====================================== */
@media (pointer: coarse) {
    .nav-btn,
    .modal-close,
    .photo-remove,
    .carousel-arrow,
    .filter-close-btn,
    .listing-heart,
    .chat-image-btn {
        min-width: 44px;
        min-height: 44px;
    }
    .modal-close,
    .photo-remove,
    .filter-close-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* Carousel arrows already use absolute positioning — bump and re-center */
    .carousel-arrow {
        font-size: 1.6rem;
    }
}
