/* ==========================================================================
   1. RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #111111;
    font-size: 14px;
    line-height: 1.4;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ==========================================================================
   2. HEADER, NAVIGATION & FILTERS
   ========================================================================== */
.top-header {
    width: 100%;
    background-color: #ffffff;
    border-bottom: 1px solid #cccccc;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 10px 20px;
}

.header-content,
.header-top-row {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand-logo {
    display: flex;
    align-items: center;
}

.brand-logo-img {
    display: block;
    height: 26px;
    width: auto;
}

/* Search Field */
.search-form {
    flex: 1;
    max-width: 480px;
}

.search-input {
    width: 100%;
    height: 34px;
    border: 1px solid #777777;
    padding: 0 12px;
    font-size: 0.9rem;
    color: #333333;
}

.search-input::placeholder {
    color: #888888;
    font-style: italic;
}

/* Header Icons & Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.icon-link {
    font-size: 1.3rem;
    color: #111111;
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.icon-link .badge {
    font-size: 0.85rem;
    font-weight: 700;
}

.nav-count-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    box-sizing: border-box;
    background-color: #ff522b;
    color: #ffffff;
    border-radius: 50%;
    position: absolute;
    top: -8px;
    right: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
}

/* Sub-header & Filters */
.sub-header {
    max-width: 1200px;
    margin: 5px auto 0 auto;
    /* No horizontal padding here — .sub-header already sits inside
       .top-header, which supplies 20px of left/right padding on its own.
       Adding another 20px here was double-padding the FILTER/SORT/ABOUT
       row relative to the logo row above it, which only gets the one
       20px from .top-header. */
    padding: 5px 0 10px 0;
}

.filter-controls {
    display: flex;
    gap: 20px;
}

.filter-btn {
    background: none;
    border: none;
    font-family: inherit; /* buttons don't inherit the page font by default —
        without this, FILTER/SORT render in the browser's system button font
        instead of the site's real typeface, making their bold weight look
        lighter than plain text (like About) at normal weight. */
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    color: #111111;
    padding: 0;
    margin-right: 15px;
}

/* About reuses .filter-btn for consistent sizing/spacing with FILTER and
   SORT, but isn't a toggle button and doesn't need their bold weight. */
.about-link {
    font-weight: normal;
    text-decoration: none;
}

/* Dropdown Filter Panel */
.filter-dropdown-panel {
    background-color: #f9f9f9;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: start;
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}

.filter-group strong {
    margin-bottom: 6px;
}

.filter-group label {
    margin-bottom: 4px;
    cursor: pointer;
}

.genre-filter-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 16px;
}

.filter-other-groups {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 20px;
}

/* Done Button Styling */
.btn-done {
    border: 1px solid #111111;
    background-color: #111111;
    color: #ffffff !important; /* Force white text over dark background */
    padding: 8px 20px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
}

/* Mobile Layout Fix for Filter Panel Actions */
.filter-actions-panel {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    /* The filter/sort panels live inside the sticky .top-header. Once the
       panel's own content (esp. all the genre checkboxes) is taller than the
       screen, a sticky ancestor can't be "scrolled past" to reach content
       below it — the DONE button ends up permanently off-screen with no way
       to scroll to it. Turning the panel into its own fixed, height-capped,
       internally-scrolling "bottom sheet" fixes that: it no longer depends on
       the page/header scroll position at all, and DONE is pinned to the
       bottom of the sheet so it's always reachable. */
    .filter-dropdown-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-height: 75vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 1001;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
    }

    .filter-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 16px;
    }

    .genre-filter-options {
        display: flex;
        flex-direction: column;
    }

    .filter-other-groups {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .filter-actions-panel {
        justify-content: center;
        /* Sticks to the bottom of the panel's own scroll area (not the page),
           so it stays visible while scrolling through checkboxes above it. */
        position: sticky;
        bottom: 0;
        margin-top: 15px;
        padding: 12px 0;
        background-color: #f9f9f9;
        border-top: 1px solid #ddd;
    }

    .btn-done {
        width: 100%; /* Spans full width on mobile for an easy target */
        padding: 12px;
        text-align: center;
        font-size: 0.95rem;
    }
}
/* ==========================================================================
   3. COMMON UTILITIES & FLASH MESSAGES
   ========================================================================== */
.page-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px 40px 20px;
}

.flash-wrapper {
    margin-bottom: 15px;
}

.flash-banner {
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.flash-success { background-color: #e8f5e9; color: #2e7d32; }
.flash-error   { background-color: #ffebee; color: #c62828; }
.flash-warning { background-color: #fff8e1; color: #8a6100; }

.verify-email-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 15px;
    border-radius: 4px;
    background-color: #fff8e1;
    color: #8a6100;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.verify-email-banner form {
    margin: 0;
}

.verify-email-banner button {
    background: none;
    border: none;
    padding: 0;
    color: #8a6100;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
}

.verify-email-banner button:hover {
    color: #5c4200;
}


/* ==========================================================================
   4. MARKETPLACE GRID & ITEM CARDS
   ========================================================================== */
.market-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 850px) {
    .market-grid {
        grid-template-columns: 1fr;
    }
}

.item-card {
    background-color: #f2f2f2;
    padding: 15px;
    border-radius: 2px;
    position: relative;
}

.profile-card {
    position: relative;
}

.post-overflow {
    position: absolute;
    top: 12px;
    right: 8px;
    z-index: 20;
}

.post-overflow-toggle {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #555555;
    cursor: pointer;
    font-size: 1rem;
}

.post-overflow-toggle:hover,
.post-overflow-toggle:focus-visible {
    background: transparent;
    color: #555555;
    outline: 2px solid #ff522b;
    outline-offset: 1px;
}

.post-overflow-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 155px;
    padding: 6px 0;
    background: #ffffff;
    border: 1px solid #d4d4d4;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.post-overflow-menu a {
    display: block;
    padding: 8px 12px;
    color: #222222;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
}

.post-overflow-menu a:hover,
.post-overflow-menu a:focus-visible {
    background: #fff0eb;
    color: #d84321;
}

.item-title-mobile {
    display: none; /* shown only on mobile, see media query below */
}

.card-body {
    display: flex;
    align-items: flex-start; /* Stops the image column from stretching to match the text height */
    gap: 15px;
}

/* Desktop cards keep the artwork and details in one row. Move that row down
   together so the image/title alignment is preserved; mobile remains as-is. */
@media (min-width: 601px) {
    .card-body {
        margin-top: 4px;
    }
}

.card-image-wrapper {
    width: 180px;
    height: 180px;
    flex-shrink: 0;
    background-color: #f2f2f2;
    overflow: hidden; /* Prevents overflow */
    position: relative;
}

.card-image-wrapper img {
    /* Absolutely-positioned + object-fit (rather than max-width/max-height on a
       flex child) avoids a Safari/iOS bug where percentage sizing breaks once
       the wrapper's height comes from `aspect-ratio` (used below on narrow
       screens) — see the same fix applied to the post-detail image frame. */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Shows full image, letterboxed on gray instead of cropped */
    object-position: center;
    display: block;
}

.placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #888888;
}

.card-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-height: 180px; /* Keeps the metadata column matching the image height */
}



.item-title {
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 6px;
    color: #000000;
}

.item-title a:hover {
    color: #ff522b;
    text-decoration: underline;
}

/* Reserve the card's upper-right corner for its overflow menu so long
   artist/title combinations always wrap before reaching the three dots. */
.item-card .item-title {
    padding-right: 42px;
}

/* On desktop the image and details share a row. Lift the title slightly so
   its visible letterforms align with the image's top edge; mobile uses the
   separate full-width .item-title-mobile and is intentionally unaffected. */
.item-title-desktop {
    margin-top: -5px;
}

/* Format and year read as secondary detail within a post heading, not part
   of the bold title itself. */
.item-title .media-type,
.item-title .item-year,
.post-detail-title .media-type,
.post-detail-title .item-year {
    font-weight: normal;
}

@media (max-width: 600px) {
    /* Mobile-only: title moves above the image+details row instead of
       sitting inside the details column beside the image. Desktop/tablet
       are untouched — they still show .item-title-desktop in its original
       spot and never see .item-title-mobile. */
    .item-title-mobile {
        display: block;
        margin-top: 0;
        margin-bottom: 10px;
    }

    .item-title-desktop {
        display: none;
    }

    .card-image-wrapper {
        width: 42%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .card-details {
        min-height: 0;
    }
}

.item-spec {
    font-size: 0.85rem;
    color: #333333;
    margin-bottom: 2px;
}

.status-spec {
    margin-bottom: 8px;
}

.item-user-caption {
    font-size: 0.82rem;
    color: #222222;
    line-height: 1.35;
    margin-bottom: 10px;
}

.username-link {
    color: #333333;
}

.username-link:hover {
    color: #ff522b;
    text-decoration: underline;
}

/* Generic inline text link (e.g. About page copy) — distinct from
   .username-link above, which is shared with the feed card captions and
   stays black/subtle on purpose. This one is meant to read as a link at
   a glance inside a paragraph. */
.text-link {
    color: #ff522b;
    text-decoration: underline;
}

.text-link:hover {
    color: #cc3f1f;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.action-link {
    background: none;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #333333;
    cursor: pointer;
    padding: 0;
    width: fit-content;
}

.action-link:hover {
    color: #ff522b;
    text-decoration: underline;
}

.like-btn {
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #333333;
}

.like-btn.has-likes {
    color: #ff522b;
}

.like-btn:hover {
    color: #ff522b;
}

.want-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.want-count-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0.95rem;
    color: #333333;
    cursor: pointer;
    text-decoration: none;
}

.want-count-link:hover,
.want-count-link.has-likes {
    color: #ff522b;
}

.want-count-link:hover {
    text-decoration: underline;
}

/* "Want This" modal — mirrors the .lightbox-overlay open/close pattern,
   but shows a white content box instead of a full-bleed image. */
.want-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.want-modal-overlay.active {
    display: flex;
}

.want-modal-box {
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 340px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.want-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #888888;
}

.want-modal-close:hover {
    color: #111111;
}

#want-modal-title {
    margin: 0 0 12px 0;
    padding-right: 20px;
    font-size: 1.1rem;
}

.want-modal-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
}

.want-modal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.want-modal-empty {
    color: #888888;
    font-size: 0.9rem;
    padding: 8px 0;
}

/* ==========================================================================
   5. PROFILE PAGE & GRID
   ========================================================================== */
.profile-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.profile-header {
    display: flex;
    gap: 25px;
    align-items: center;
    margin-bottom: 20px;
}

.profile-avatar img, 
.avatar-placeholder {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.profile-title-row {
    display: flex;
    align-items: baseline;
    gap: 15px;
}

.verified-badge {
    color: #ff522b;
    font-weight: bold;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.profile-stats {
    display: flex;
    gap: 20px;
    margin: 8px 0;
}

.btn-profile {
    display: inline-block;
    padding: 6px 16px;
    border: 1px solid #000;
    color: #000;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85em;
    background: #fff;
    margin-top: 5px;
}

.profile-divider {
    border: 0;
    border-top: 1px solid #ccc;
    margin: 25px 0;
}

.section-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)); /* minmax(0, ...) stops long unbreakable
        card text from forcing columns wider than the viewport — that was the
        cause of the whole page needing a horizontal scroll on mobile. */
    gap: 15px;
}

.profile-card {
    background: #f4f4f4;
    border: 1px solid #e0e0e0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    min-width: 0; /* lets flex/grid children shrink below their text's intrinsic width */
}

.card-header-title {
    font-size: 0.85em;
    margin-bottom: 8px;
    min-height: 36px;
}

.card-subtitle {
    color: #555;
    font-size: 0.9em;
}

.card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f4f4f4;
    margin-bottom: 8px;
}

.card-media img {
    /* Absolutely-positioned + object-fit (rather than max-width/max-height on
       a flex child) avoids the Safari/iOS bug where percentage sizing breaks
       once the container's height comes from `aspect-ratio` — this card grid
       had the same pattern that cropped non-square images on mobile Safari
       elsewhere in the app. */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    font-weight: bold;
}

@media (max-width: 600px) {
    /* The profile header's fixed 110px avatar + a row of stats/username left
       very little room for their text to breathe, which is what forced the
       whole page to scroll horizontally. Stacking and centering it removes
       that squeeze entirely. */
    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }

    .profile-title-row,
    .profile-stats,
    .profile-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    .profile-actions {
        display: flex;
        gap: 8px;
    }

    .profile-details {
        text-align: center;
    }

    /* With 15-20+ items, wrapping into more grid rows makes for a lot of
       scrolling. A horizontally-swipeable shelf keeps each section compact —
       the section title above stays put in normal document flow (it isn't
       part of the scrolling element), so it never moves while you swipe
       through the cards beneath it. */
    .profile-grid {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        gap: 12px;
        padding-bottom: 10px; /* breathing room below the row, clear of any scrollbar */
    }

    .profile-card {
        flex: 0 0 45%; /* ~2 cards visible at a time, with the next peeking in to invite swiping */
        scroll-snap-align: start;
    }
}

/* ==========================================================================
   6. FORMS & INPUTS
   ========================================================================== */
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #111111;
}

.form-group-row {
    display: flex;
    gap: 15px;
}

.form-group-row > div,
.form-group-row .field {
    flex: 1;
}

/* .form-section wraps each field's .form-group (via the render_field
   macro) on the post-creation and edit-profile forms. Neither has ever
   had spacing defined, so fields were stacking with no gap at all. */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-container {
    max-width: 600px;
    margin: 30px auto;
    padding: 30px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.form-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 20px;
    color: #111111;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.about-container {
    line-height: 1.6;
}

.about-subtitle {
    margin-top: 30px;
}

.about-text p {
    margin: 0 0 1rem 0;
    color: #333333;
}

.about-text p:last-child {
    margin-bottom: 0;
}

.post-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-container input[type="text"],
.form-container input[type="email"],
.form-container input[type="password"],
.form-container input[type="number"],
.form-container input[type="file"],
.form-container select,
.form-container textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cccccc;
    border-radius: 2px;
    font-size: 0.9rem;
    font-family: inherit;
    background-color: #ffffff;
    color: #111111;
}

.form-container textarea {
    resize: vertical;
    min-height: 90px;
}

.form-container input:focus,
.form-container select:focus,
.form-container textarea:focus {
    outline: none;
    border-color: #ff522b;
}

.form-actions {
    margin-top: 20px;
}

.btn-submit {
    width: 100%;
    background-color: #ff522b;
    color: #ffffff;
    border: none;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.2s ease;
}

.btn-submit:hover {
    background-color: #e04420;
}

/* Edit-post's Save + Cancel sit side by side — scoped to this row only so
   .btn-submit's full-width default (used by every other form: login,
   register, edit profile, new post) is untouched elsewhere. */
.edit-post-actions-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.edit-post-actions-row .btn-submit {
    width: auto;
    flex: 1;
}

.btn-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 1.2rem;
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    color: #222222;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-cancel:hover {
    background-color: #e2e2e2;
    border-color: #bbb;
    color: #000000;
}


/* ==========================================================================
   7. POST DETAIL PAGE
   ========================================================================== */
.post-detail-container {
    max-width: 950px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.post-detail-heading {
    position: relative;
    padding-right: 42px;
}

.post-detail-heading .post-overflow {
    top: 0;
    right: 0;
}

.post-detail-title {
    font-size: 1.6rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    text-align: left;
}

.post-detail-main {
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 2.5rem;
    align-items: start;
}

.image-slider-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.image-frame {
    width: 350px;
    height: 350px;
    background-color: #f0f0f0;
    overflow: hidden;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}

.image-frame .zoom-hint-icon {
    position: absolute;
    bottom: 10px;
    right: 10px;
    color: #ffffff;
    background: rgba(17, 17, 17, 0.6);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.image-frame:hover .zoom-hint-icon {
    opacity: 1;
}

.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 2.5rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
}

.image-frame img {
    /* Absolutely-positioned + object-fit (rather than max-width/max-height on a
       flex child) sidesteps a Safari/iOS bug where percentage heights inside a
       flex container don't resolve correctly when the container's height comes
       from `aspect-ratio` — that bug was cropping non-square images on mobile
       Safari while Chrome/desktop rendered them fine. */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#next-img-btn {
    position: absolute;
    right: -25px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 10px;
    transition: color 0.15s ease;
}

#next-img-btn:hover {
    color: #000;
}

.post-info {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #111;
}

.post-info p {
    margin: 0 0 0.5rem 0;
}

.post-status {
    margin-bottom: 1rem !important;
}

.seller-caption-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.seller-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.seller-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.caption-text a {
    color: #000;
    text-decoration: none;
}

.post-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.action-trade-link {
    color: #000;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .post-detail-main {
        grid-template-columns: 1fr;
    }

    .image-slider-wrapper {
        width: 100%;
    }

    .image-frame {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    #next-img-btn {
        right: 10px;
        background: rgba(255, 255, 255, 0.85);
        border-radius: 50%;
    }
}

/* Owner edit and delete buttons */
.owner-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Reset the form container */
.owner-delete-form {
    display: inline-flex;
    margin: 0;
    padding: 0;
}

/* Normalize both buttons to share identical height & alignment */
.btn-owner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-sizing: border-box;
    height: 36px;            
    padding: 0 0.8rem;
    font-size: 0.9rem;
    line-height: 1;
    border: 1px solid transparent; 
    border-radius: 8px;      
    text-decoration: none;
    cursor: pointer;
}

/* Secondary Action: Edit Button */
.btn-owner-edit {
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    color: #222222;
}

.btn-owner-edit:hover {
    background-color: #e2e2e2;
    border-color: #bbb;
    color: #000;
}

/* Destructive Action: Delete Button */
.btn-owner-delete {
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    color: #222222;
}

.btn-owner-delete:hover {
    background-color: #ff5a36;
    color: #ffffff;
}

/* ==========================================================================
   8. TRADES DASHBOARD & TRAY
   ========================================================================== */
.trade-circle {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #e2c044;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.selectable-card.selected .trade-circle {
    background-color: #e2c044;
    color: #000;
}

.trade-collection-bg {
    background-color: #e0e0e0;
    padding: 20px;
    border-radius: 8px;
}

.trades-wrapper {
    display: flex;
    gap: 20px;
    max-width: 1100px;
    margin: 30px auto;
}

.trade-viewer {
    flex: 1;
    background: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.carousel-container {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 340px;
}

.carousel-viewport {
    width: 280px;
    overflow-x: auto;
    display: flex;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.carousel-viewport::-webkit-scrollbar {
    display: none;
}

.carousel-item {
    min-width: 280px;
    scroll-snap-align: start;
    box-sizing: border-box;
}

.card-box {
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
    padding: 12px;
    text-align: center;
}

.card-box img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    margin: 8px 0;
}

.nav-arrow {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #aaa;
}

.nav-arrow:hover {
    color: #333;
}

.trade-actions {
    display: flex;
    gap: 20px;
    margin-top: 25px;
}

.action-btn {
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1px solid #333;
    color: #333;
}

/* Floating Trade Tray */
.trade-tray {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ffffff;
    border: 2px solid #333333;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1000;
}

.trade-summary p {
    margin: 2px 0;
    font-size: 14px;
}

#submit-trade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}



.trades-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.trade-sidebar-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid #e0e0e0;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s ease;
}

.trade-sidebar-card:hover,
.trade-sidebar-card.selected {
    background-color: #f7f7f7;
}

.card-thumb {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    background-color: #eee;
    border-radius: 2px;
    overflow: hidden;
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 1.2rem;
}

.card-meta {
    flex: 1;
    min-width: 0; /* Enables text clipping */
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-offers-count {
    font-size: 0.8rem;
    color: #888;
}

.card-chevron {
    font-size: 0.75rem;
    color: #111;
    padding-left: 4px;
}


/* Sidebar Container */
.trades-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    padding: 15px;
    padding-top: 10px;
}

/* Tab Bar with 3 Columns & Bottom Accent Bar */
.trade-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 15px;
}

.tab-link {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #888;
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
}

.tab-link:hover {
    color: #444;
}

.tab-link.active {
    color: #ff5a36; /* Coral orange active state */
    font-weight: 700;
}

.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #ff5a36;
}

/* Search Box Styling */
.trade-search-box {
    position: relative;
    margin: 0 12px 15px 12px;
}

.trade-search-box input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border: 1.5px solid #111;
    border-radius: 2px;
    font-size: 0.85rem;
    outline: none;
}

.trade-search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    /* The sidebar (fixed 320px) sitting beside a viewer with a hard-coded
       340px carousel forced the whole page wider than a phone screen,
       hence the horizontal scroll. Stacking the viewer below the sidebar,
       and letting the carousel shrink to fit instead of holding a fixed
       width, keeps everything within the screen without needing to scroll
       sideways. */
    .trades-wrapper {
        flex-direction: column;
    }

    .trades-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding-bottom: 10px;
    }

    .trade-viewer {
        padding: 20px 15px;
    }

    .trade-search-box input {
        font-size: 16px; /* prevents iOS Safari's zoom-on-focus, same fix as the header search box */
    }

    .carousel-container {
        width: 100%;
        max-width: 340px;
    }

    .carousel-viewport {
        width: 100%;
        max-width: 280px;
    }
}


/* User Header Row in Trade Viewer */
.user-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.user-username {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111;
}

/* Small Profile Avatars */
.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-placeholder-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #eee;
    color: #777;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Central Swap Icon */
.swap-icon-container {
    text-align: center;
    margin: 15px 0;
}

.swap-icon {
    font-size: 1.5rem;
    color: #ff5a36;
    display: inline-block;
    transition: transform 0.3s ease;
}

.swap-icon:hover {
    transform: rotate(180deg);
}

.status-available {
    color: #2e7d32; /* Green */
    font-weight: 600;
}

.status-traded {
    color: #777777; /* Gray */
    font-weight: 600;
}

.traded-card {
    opacity: 0.75;
}

.trade-btn.disabled {
    background-color: #e0e0e0;
    color: #888888;
    cursor: not-allowed;
    pointer-events: none;
    text-decoration: none;
}


/* Show mobile search row only on small screens */
.header-mobile-search {
    display: none;
    padding-top: 8px;
}

.search-form-mobile .search-input {
    width: 100%;
}

@media (max-width: 768px) {
    /* Force-hide squeezed search form inside top row on mobile */
    .desktop-search {
        display: none !important;
    }
    
    /* Reveal full-width search bar underneath top row on mobile */
    .header-mobile-search {
        display: block !important;
        width: 100% !important;
    }

    .header-mobile-search .search-input {
        width: 100% !important;
        /* Below 16px, iOS Safari auto-zooms the page on focus — this keeps
           the tap-in experience from jumping/zooming on phones. */
        font-size: 16px !important;
    }
}

.genre-badge {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

.genre-badge:hover {
    color: #ff522b; /* border-bottom uses currentColor, so the existing
        dotted underline turns orange along with the text automatically —
        no separate text-decoration needed here. */
}

/* ==========================================================================
   9. DIRECT MESSAGES
   ========================================================================== */
.messages-page {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.messages-title {
    margin-bottom: 1rem;
}

.messages-layout {
    display: flex;
    gap: 20px;
    height: 70vh;
    min-height: 500px;
}

.conversations-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conversation-search {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.conversation-search input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border: 1.5px solid #111;
    border-radius: 2px;
    font-size: 0.85rem;
    outline: none;
}

.conversation-search .search-icon {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 0.85rem;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    text-decoration: none;
    color: #111111;
    border-bottom: 1px solid #f1f5f9;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background-color: #f8fafc;
}

.conversation-item.active {
    background-color: #fff4f1;
    border-left: 3px solid #ff522b;
}

.conversation-avatar,
.conversation-header-avatar,
.thread-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.thread-avatar {
    width: 32px;
    height: 32px;
}

.conversation-avatar-placeholder,
.thread-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    flex-shrink: 0;
}

.thread-avatar-placeholder {
    width: 32px;
    height: 32px;
}

.conversation-username {
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-unread-badge {
    background-color: #ff522b;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.no-conversations {
    padding: 1rem;
    color: #64748b;
    font-size: 0.9rem;
}

.conversation-panel {
    flex: 1;
    background: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.conversation-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.conversation-header h3 {
    margin: 0;
}

.conversation-thread {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.conversation-start-note {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.thread-message-group {
    margin-bottom: 1.25rem;
}

.thread-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.thread-timestamp {
    color: #94a3b8;
    font-size: 0.8rem;
}

.thread-message-time {
    color: #94a3b8;
    font-size: 0.75rem;
    margin-left: 6px;
}

.thread-message-text {
    margin: 2px 0 2px 40px;
    line-height: 1.5;
}

.conversation-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.message-input-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}

.message-input-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    max-height: 120px;
    line-height: 1.4;
}

.message-input-form textarea:focus {
    outline: none;
    border-color: #ff522b;
}

.message-send-btn {
    background-color: #ff522b;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-send-btn:hover {
    background-color: #e2431f;
}

@media (max-width: 768px) {
    .messages-layout {
        flex-direction: column;
        height: auto;
        gap: 12px;
    }

    .conversations-sidebar {
        order: 1;
        width: 100%;
        max-height: 260px;
    }

    .conversation-panel {
        order: 2;
        height: 60vh;
    }

    .conversation-search input {
        font-size: 16px; /* prevents iOS Safari's zoom-on-focus */
    }

    .message-input-form textarea {
        font-size: 16px; /* same fix for the actual message-typing box */
    }
}

/* ==========================================================================
   10. ENDORSEMENTS & ADMIN
   ========================================================================== */
.endorsed-note {
    color: #28a745;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.endorse-btn {
    background-color: #ff522b;
    color: #ffffff;
    border: none;
}

.endorse-btn:hover {
    background-color: #e2431f;
}

.admin-users-page {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: #fff;
}

.admin-users-table th,
.admin-users-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.not-verified {
    color: #94a3b8;
}

.admin-toggle-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
}

.admin-toggle-btn:hover {
    background: #e2e8f0;
}

.deactivated-user {
    color: #999999;
    font-style: italic;
}

.danger-zone {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #e2e8f0;
}

.danger-zone h3 {
    color: #c0392b;
    margin-bottom: 8px;
}

.danger-zone p {
    font-size: 0.85rem;
    color: #555555;
    margin-bottom: 12px;
}

.btn-delete-account {
    background-color: #ffffff;
    color: #c0392b;
    border: 1px solid #c0392b;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-delete-account:hover {
    background-color: #c0392b;
    color: #ffffff;
}

/* ==========================================================================
   11. TERMS & CONDITIONS (REGISTRATION)
   ========================================================================== */
.terms-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 14px 16px;
    margin: 1rem 0;
    font-size: 0.85rem;
    color: #475569;
    max-height: 220px;
    overflow-y: auto;
}

.terms-box p {
    margin: 0 0 10px 0;
}

.terms-box p:last-child {
    margin-bottom: 0;
}

.terms-checkbox-group {
    margin-bottom: 1rem;
}

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

.terms-checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

/* Honeypot field for spam-bot filtering on register/message forms.
   Positioned off-screen rather than display:none/visibility:hidden,
   since some bots specifically skip fields hidden that way. */
.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    height: 0;
    width: 0;
    overflow: hidden;
}
