/* ============================================================================
   Tamale Marketplace — public site theme
   Bold, mobile-first, card-based. Distinct from any back-office aesthetic.
   ========================================================================== */

:root {
  /* Brand palette — warm terracotta/orange (market, textiles) + deep teal accent */
  --brand:        #E9601A;
  --brand-dark:   #C24E12;
  --brand-light:  #FFF1E8;
  --teal:         #0E7C7B;
  --teal-dark:    #0A5E5D;

  --ink:          #1B1B1F;
  --ink-2:        #4A4A52;
  --ink-3:        #7A7A84;
  --paper:        #FFFFFF;
  --bg:           #FAF7F4;
  --line:         #ECE4DD;
  --line-2:       #E0D5CB;

  --success:      #1C8A4B;
  --danger:       #D8402F;
  --warning:      #C88A00;

  --radius:       14px;
  --radius-s:     9px;
  --shadow-sm:    0 1px 3px rgba(27,27,31,.06), 0 1px 2px rgba(27,27,31,.04);
  --shadow-md:    0 6px 20px rgba(27,27,31,.08);
  --shadow-lg:    0 14px 40px rgba(27,27,31,.14);

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-head: 'Poppins', var(--font-body);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; margin: 0 0 .5em; color: var(--ink); }
.container { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

/* ---------------------------- Top navigation ------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.nav-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px;
  max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: 19px; color: var(--ink); flex-shrink: 0; }
.brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--teal)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.brand .brand-mark.brand-logo { background: none; object-fit: contain; }
.brand span.accent { color: var(--brand); }

.search-form { flex: 1; display: flex; max-width: 560px; }
.search-form input[type="text"], .search-form input[type="search"] {
  flex: 1; border: 1px solid var(--line-2); border-right: none;
  border-radius: var(--radius-s) 0 0 var(--radius-s);
  padding: 10px 14px; font-size: 14px; font-family: var(--font-body);
  background: var(--bg);
}
.search-form input:focus { outline: none; border-color: var(--brand); }
.search-form button {
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 0 18px; border-radius: 0 var(--radius-s) var(--radius-s) 0; cursor: pointer;
  font-weight: 600;
}
.search-form button:hover { background: var(--brand-dark); }

.nav-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
.nav-link { padding: 8px 12px; border-radius: var(--radius-s); font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.nav-link:hover { background: var(--bg); color: var(--ink); }
.btn-sell { background: var(--teal); color: #fff !important; padding: 9px 16px; border-radius: var(--radius-s); font-weight: 600; font-size: 13.5px; }
.btn-sell:hover { background: var(--teal-dark); }

.notif-bell { position: relative; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; color: var(--ink-2); flex-shrink: 0; }
.notif-bell:hover { background: var(--bg); color: var(--brand); }
.notif-bell svg { width: 21px; height: 21px; }
.notif-badge { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; display: flex; align-items: center; justify-content: center; }

.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 10px; border-radius: 999px; background: var(--bg); }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
/* position:fixed with top/right/bottom set by JS (positionUserDropdown() in
   app.js) right before opening -- this works from anywhere in the DOM and
   for both the top chip and the mobile bottom-nav trigger, regardless of
   any ancestor's own layout or visibility. */
.user-dropdown { display: none; position: fixed; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: var(--shadow-md); min-width: 190px; padding: 6px; z-index: 120; }
.user-dropdown.open { display: block; }
.user-dropdown a { display: block; padding: 9px 12px; border-radius: 7px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.user-dropdown a:hover { background: var(--bg); color: var(--ink); }
.user-dropdown hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }

.category-strip { background: var(--paper); border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.category-strip::-webkit-scrollbar { display: none; }
.category-strip .container { display: flex; gap: 6px; padding: 8px 16px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; background: var(--bg); color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.cat-chip:hover { border-color: var(--brand); color: var(--brand); }
.cat-chip.active { background: var(--brand); color: #fff; }
.cat-chip-icon { width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; }

.mobile-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink); }

/* ---------------------------- Hero ---------------------------------------- */
.hero { background: linear-gradient(135deg, var(--brand) 0%, #F08A3C 55%, var(--teal) 130%); color: #fff; padding: 44px 0 36px; }
.hero h1 { color: #fff; font-size: 30px; margin-bottom: 8px; }
.hero p { font-size: 15.5px; opacity: .95; max-width: 560px; margin: 0 0 20px; }
.hero .search-form { max-width: 620px; }
.hero .search-form input { background: #fff; }

/* ---------------------------- Ad slots ------------------------------------ */
.ad-slot { display: block; position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); margin: 18px 0; }
.ad-slot img { width: 100%; aspect-ratio: 1152 / 252; max-height: 160px; object-fit: cover; display: block; background: var(--bg); }
.ad-slot-tag { position: absolute; top: 8px; right: 8px; background: rgba(27,27,31,.65); color: #fff; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; }
.ad-slot-category_sidebar { max-width: 100%; }

/* Ad carousel — several sponsors sharing one placement rotate through it. */
.ad-carousel { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); margin: 18px 0; }
.ad-carousel-track { display: flex; transition: transform .5s ease; }
.ad-carousel-track .ad-slot { flex: 0 0 100%; margin: 0; border-radius: 0; box-shadow: none; }
.ad-carousel-dots { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; justify-content: center; gap: 6px; }
.ad-carousel-dot { width: 7px; height: 7px; padding: 0; border: none; border-radius: 50%; background: rgba(255,255,255,.55); cursor: pointer; }
.ad-carousel-dot.active { background: #fff; }

/* ---------------------------- Sections / cards ----------------------------- */
.section { padding: 28px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.section-head h2 { font-size: 20px; }
.section-head a.more { font-size: 13px; font-weight: 600; }

/* ---------------------------- Category sidebar (toggled via the "All" chip) - */
.category-sidebar {
  background: var(--paper); border-right: 1px solid var(--line); padding: 14px;
  position: fixed; top: 0; left: -280px; width: 260px; height: 100vh;
  z-index: 90; transition: left .15s; box-shadow: var(--shadow-lg); overflow-y: auto;
}
.category-sidebar.open { left: 0; }
.category-sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.category-sidebar-head h3 { font-size: 15px; margin: 0; }
.category-sidebar-close { display: block; background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-3); padding: 0; }
.category-sidebar-list { display: flex; flex-direction: column; gap: 2px; }
.category-sidebar-list a { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.category-sidebar-list a:hover { background: var(--bg); color: var(--brand); }
.category-sidebar-list .icon-wrap { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.category-sidebar-list .icon-wrap img { width: 100%; height: 100%; object-fit: contain; padding: 5px; box-sizing: border-box; }

.cat-sidebar-group { display: flex; align-items: center; gap: 2px; }
.cat-sidebar-group .cat-sidebar-parent { flex: 1; min-width: 0; }
.cat-sidebar-expand { flex-shrink: 0; width: 30px; height: 30px; border: none; background: none; color: var(--ink-3); font-size: 16px; cursor: pointer; border-radius: 8px; transition: transform .18s ease; }
.cat-sidebar-expand:hover { background: var(--bg); color: var(--brand); }
.cat-sidebar-group.open .cat-sidebar-expand { transform: rotate(90deg); }
.cat-sidebar-children { display: none; flex-direction: column; gap: 1px; margin: 0 0 4px 40px; padding-left: 10px; border-left: 2px solid var(--line); }
.cat-sidebar-group.open + .cat-sidebar-children { display: flex; }
.cat-sidebar-children a { font-size: 12.5px; font-weight: 500; padding: 7px 8px; }
.category-sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(20,20,22,.45); z-index: 85; }
.category-sidebar-backdrop.open { display: block; }

.cat-chip-all { background: var(--brand); color: #fff; border: none; cursor: pointer; }
.cat-chip-all:hover { background: var(--brand-dark); color: #fff; }

/* Pinned to the scroll container's right edge so it's always reachable
   without having to scroll the strip all the way to the end. */
.cat-chip-more { position: sticky; right: 0; border: none; cursor: pointer; background: var(--paper); box-shadow: -10px 0 10px -6px rgba(27,27,31,.14); }
.cat-chip-more:hover { color: var(--brand); }

.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }

/* Category/search pages share the row with a 240px filter sidebar, leaving
   less room than the full-width grids on home/storefront -- use a narrower
   minimum column so they can still reach the same 6-per-row target. Scoped
   to min-width so it can never win a specificity contest against the
   mobile 2-column override below, which must always take priority under 600px. */
@media (min-width: 601px) {
  .browse-layout .listing-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
}
.listing-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s; position: relative; display: flex; flex-direction: column; }
.listing-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.listing-card .thumb { aspect-ratio: 1/1; background: var(--bg) center/cover no-repeat; position: relative; }
.listing-card .thumb .noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-3); font-size: 12px; }
.listing-card .promo-badge { position: absolute; top: 8px; left: 8px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; }
.listing-card .fav-btn { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.9); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-3); box-shadow: var(--shadow-sm); }
.listing-card .fav-btn.active, .listing-card .fav-btn:hover { color: var(--danger); }
.listing-card .body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; }
.listing-card .price { font-weight: 700; color: var(--brand); font-size: 15px; margin-bottom: 2px; }
.listing-card .title { font-size: 13.5px; color: var(--ink); font-weight: 500; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.listing-card .meta { font-size: 11.5px; color: var(--ink-3); margin-top: auto; }
.listing-card .meta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.listing-card .meta-row .meta-loc { display: flex; align-items: center; gap: 3px; min-width: 0; overflow: hidden; }
.listing-card .meta-row .meta-loc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listing-card .meta-row .meta-time { display: flex; align-items: center; gap: 3px; flex-shrink: 0; white-space: nowrap; }
.listing-card .meta-row svg { width: 12px; height: 12px; flex-shrink: 0; }
.listing-card .card-desc { display: none; }

/* ---------------------------- Grid/List view toggle ---------------------------- */
.view-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.view-toggle-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--paper); color: var(--ink-3); cursor: pointer; }
.view-toggle-btn:hover { border-color: var(--brand); color: var(--brand); }
.view-toggle-btn svg { width: 16px; height: 16px; }
.view-toggle-btn.active { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }

.results-toolbar { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.results-toolbar .form-control { width: auto; padding: 7px 10px; font-size: 12.5px; }

/* ---------------------------- Filter sidebar: toggle groups & price range ------ */
.toggle-group { display: flex; border: 1px solid var(--line-2); border-radius: var(--radius-s); overflow: hidden; }
.toggle-btn { flex: 1; padding: 7px 4px; border: none; border-right: 1px solid var(--line-2); background: var(--paper); color: var(--ink-3); font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: center; }
.toggle-btn:last-child { border-right: none; }
.toggle-btn:hover:not(.active) { background: var(--bg); }
.toggle-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.price-range-row { display: flex; align-items: center; gap: 6px; }
.price-range-row input { flex: 1; min-width: 0; }
.price-range-sep { color: var(--ink-3); font-size: 12.5px; flex-shrink: 0; }

.listing-grid.view-list { display: flex; flex-direction: column; gap: 10px; }
.listing-grid.view-list .listing-card { flex-direction: row; }
.listing-grid.view-list .listing-card:hover { transform: none; }
.listing-grid.view-list .listing-card .thumb { width: 160px; height: 160px; flex-shrink: 0; aspect-ratio: auto; }
.listing-grid.view-list .listing-card .body { padding: 12px 16px; }
.listing-grid.view-list .listing-card .title { -webkit-line-clamp: 1; margin-bottom: 6px; }
.listing-grid.view-list .listing-card .card-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; margin-bottom: 8px; }
.listing-grid.view-list .listing-card .meta-row { margin-top: 0; }
@media (max-width: 600px) {
  .listing-grid.view-list .listing-card .thumb { width: 96px; height: 96px; }
  .listing-grid.view-list .listing-card .card-desc { -webkit-line-clamp: 1; }
}

@media (max-width: 600px) {
  .listing-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .listing-card .body { padding: 8px 9px 10px; }
  .listing-card .price { font-size: 13.5px; }
  .listing-card .title { font-size: 12px; margin-bottom: 2px; }
  .listing-card .meta { font-size: 10.5px; }
  .listing-card .fav-btn { width: 26px; height: 26px; }
  .listing-card .promo-badge { font-size: 9px; padding: 2px 6px; }
}

/* ---------------------------- Buttons -------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius-s); font-weight: 600; font-size: 14px; cursor: pointer; border: 1px solid transparent; font-family: var(--font-body); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------------------------- Forms ----------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.form-control, select.form-control, textarea.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  font-family: var(--font-body); font-size: 14px; background: var(--paper); color: var(--ink);
}
.form-control:focus { outline: none; border-color: var(--brand); }
.form-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------------------------- Listing photo slots ------------------------------ */
.photo-slots { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-slot { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.photo-slot-tile { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border: 2px dashed var(--line-2); border-radius: var(--radius-s); cursor: pointer; overflow: hidden; background: var(--bg); }
.photo-slot-tile:hover { border-color: var(--brand); }
.photo-slot-tile.filled { border-style: solid; border-color: var(--line); }
.photo-slot-preview { width: 100%; height: 100%; object-fit: cover; display: none; }
.photo-slot-plus { font-size: 28px; font-weight: 300; color: var(--ink-3); line-height: 1; }
.photo-slot-cover-badge { position: absolute; top: 4px; left: 4px; background: var(--brand); color: #fff; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 6px; border-radius: 999px; pointer-events: none; }
.photo-slot-remove { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; border: 2px solid var(--paper); font-size: 14px; line-height: 1; cursor: pointer; display: none; align-items: center; justify-content: center; padding: 0; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }

.auth-card { max-width: 420px; margin: 48px auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 28px 26px; }
.auth-card h1 { font-size: 21px; }
.auth-card .switch { text-align: center; margin-top: 14px; font-size: 13.5px; color: var(--ink-3); }

/* ---------------------------- Alerts / badges -------------------------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-s); font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: #EAF7EF; color: var(--success); border-color: #CBEBD8; }
.alert-error   { background: #FDECEA; color: var(--danger); border-color: #F7CFC9; }
.alert-info    { background: #E9F6F6; color: var(--teal-dark); border-color: #CFEAEA; }
.alert-warning { background: #FFF6E0; color: var(--warning); border-color: #F5E3AE; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-promoted { background: var(--brand-light); color: var(--brand); }
.badge-verified { background: #E9F6F6; color: var(--teal-dark); text-transform: none; letter-spacing: 0; }
.verified-check { color: var(--teal-dark); font-weight: 700; margin-left: 3px; }
.badge-pending  { background: #FFF6E0; color: var(--warning); }
.badge-active   { background: #EAF7EF; color: var(--success); }
.badge-rejected { background: #FDECEA; color: var(--danger); }

/* ---------------------------- Breadcrumb ------------------------------------ */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12.5px; color: var(--ink-3); margin: 14px 0; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--line-2); margin: 0 2px; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

/* ---------------------------- Listing detail --------------------------------- */
.listing-detail { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; align-items: start; }
.gallery-wrap { display: flex; flex-direction: column; gap: 10px; }

.gallery-slider { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 2/1; background: var(--bg); }
.gallery-slider-track { display: flex; height: 100%; touch-action: pan-y; transition: transform .3s ease; }
.gallery-slide { flex: 0 0 100%; height: 100%; min-width: 0; }
.gallery-slide img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.gallery-slide .noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-3); }
.gallery-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.92); border: none; box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; color: var(--ink-2); cursor: pointer; }
.gallery-arrow-prev { left: 10px; }
.gallery-arrow-next { right: 10px; }
.gallery-dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; }
.gallery-dot { width: 7px; height: 7px; padding: 0; border: none; border-radius: 50%; background: rgba(255,255,255,.65); cursor: pointer; }
.gallery-dot.active { background: #fff; }
.gallery-zoom-btn { position: absolute; right: 10px; top: 10px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.92); border: none; box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; font-size: 15px; cursor: pointer; }

.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.gallery-thumbs img.active { border-color: var(--brand); }

@media (min-width: 700px) {
  .gallery-wrap { flex-direction: row; align-items: flex-start; }
  .gallery-slider { flex: 1; min-width: 0; }
  .gallery-thumbs { order: -1; flex-direction: column; flex-wrap: nowrap; flex-shrink: 0; max-height: 100%; overflow-y: auto; }
}

/* Full-screen zoom overlay -- opened by tapping the main image or the zoom button. */
.gallery-zoom-overlay { display: none; position: fixed; inset: 0; z-index: 250; background: rgba(10,10,12,.92); align-items: center; justify-content: center; }
.gallery-zoom-overlay.open { display: flex; }
.gallery-zoom-overlay img { max-width: 92vw; max-height: 88vh; object-fit: contain; }
.gallery-zoom-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 32px; line-height: 1; cursor: pointer; }
.gallery-zoom-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.gallery-zoom-nav.prev { left: 16px; }
.gallery-zoom-nav.next { right: 16px; }

.listing-price-block { margin-top: 18px; }
.listing-price-block .price { font-size: 24px; font-weight: 700; color: var(--brand); }

.listing-description-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); margin-bottom: 8px; }

.detail-panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.detail-panel .seller-name-line { font-size: 12.5px; color: var(--ink-3); margin-bottom: 2px; }
.detail-panel .seller-name-heading { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
.detail-actions-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.detail-actions-row > * { min-width: 0; }
.detail-actions-row .btn { width: 100%; padding-left: 8px; padding-right: 8px; }
.seller-card { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.seller-card .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; overflow: hidden; }
.seller-card .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------- Storefront ------------------------------------- */
.storefront-cover { height: 180px; background: linear-gradient(135deg, var(--brand), var(--teal)) center/cover no-repeat; border-radius: var(--radius); }
.storefront-head { display: flex; align-items: flex-end; gap: 16px; margin-top: -34px; padding: 0 20px; }
.storefront-head .logo { width: 84px; height: 84px; border-radius: 16px; border: 4px solid var(--paper); background: var(--paper); overflow: hidden; box-shadow: var(--shadow-sm); }
.storefront-head .logo img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------- Modal ---------------------------------------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(27,27,31,.55); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--paper); border-radius: var(--radius); max-width: 560px; width: 100%; max-height: 84vh; overflow-y: auto; padding: 24px; box-shadow: var(--shadow-lg); }
.modal-box h2 { font-size: 18px; margin-bottom: 4px; }
.modal-close-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------------------------- FAQ accordion ------------------------------------ */
.faq-accordion { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.faq-item { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.faq-question { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: none; border: none; text-align: left; font: inherit; font-weight: 600; font-size: 14.5px; color: var(--ink); padding: 15px 18px; cursor: pointer; }
.faq-question:hover { background: var(--brand-light); }
.faq-icon { flex-shrink: 0; font-size: 18px; line-height: 1; color: var(--brand); transition: transform .18s ease; }
.faq-item.open .faq-icon { transform: rotate(45deg); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.faq-item.open .faq-answer { max-height: 600px; }
.faq-answer-inner { padding: 0 18px 16px; color: var(--ink-2); font-size: 13.5px; line-height: 1.7; }

/* ---------------------------- Messages (two-pane chat) ------------------------- */
.msg-shell { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 210px); min-height: 480px; max-height: 760px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); box-shadow: var(--shadow-sm); margin: 18px 0 32px; }

.msg-sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.msg-sidebar-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.msg-sidebar-head h2 { font-size: 17px; margin-bottom: 2px; }
.msg-sidebar-head p { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.msg-search { width: 100%; padding: 8px 14px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13px; font-family: var(--font-body); }
.msg-list { flex: 1; overflow-y: auto; min-height: 0; }
.msg-list-item { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); color: inherit; }
.msg-list-item:hover, .msg-list-item.active { background: var(--brand-light); }
.msg-empty { padding: 24px 18px; color: var(--ink-3); font-size: 13px; text-align: center; }

.msg-avatar-stack { position: relative; flex-shrink: 0; }
.msg-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; overflow: hidden; flex-shrink: 0; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-list-thumb-badge { position: absolute; right: -3px; bottom: -3px; width: 19px; height: 19px; border-radius: 5px; object-fit: cover; border: 2px solid var(--paper); }

.msg-list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msg-list-body strong { font-size: 13.5px; color: var(--ink); }
.msg-list-sub, .msg-list-preview { display: block; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list-time { font-size: 11px; color: var(--ink-3); flex-shrink: 0; align-self: flex-start; }

.msg-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.msg-main-empty { align-items: center; justify-content: center; text-align: center; }
.msg-main-header { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.msg-main-header strong { font-size: 14.5px; }
.msg-icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; color: var(--ink-2); margin-left: auto; flex-shrink: 0; }
.msg-icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.msg-back-link { display: none; color: var(--ink-2); font-size: 18px; flex-shrink: 0; }

.msg-listing-strip { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); color: inherit; }
.msg-listing-strip img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.msg-listing-strip-body { flex: 1; min-width: 0; }
.msg-listing-strip-body strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-listing-strip-body .price { display: block; color: var(--brand); font-weight: 700; font-size: 12px; }
.msg-listing-strip .btn { flex-shrink: 0; }

.msg-safety-banner { display: flex; gap: 10px; align-items: flex-start; background: var(--brand-light); color: var(--ink-2); padding: 10px 18px; font-size: 12px; line-height: 1.5; }
.msg-safety-banner button { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--ink-3); flex-shrink: 0; }

.msg-body { flex: 1; overflow-y: auto; min-height: 0; padding: 18px; display: flex; flex-direction: column; }
.msg-date-divider { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 6px 0 14px; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 75%; margin-bottom: 2px; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar-tiny { width: 24px; height: 24px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.msg-avatar-tiny img { width: 100%; height: 100%; object-fit: cover; }
.msg-bubble { padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.msg-row:not(.mine) .msg-bubble { background: var(--bg); color: var(--ink); border-bottom-left-radius: 4px; }
.msg-row.mine .msg-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg-meta { font-size: 10.5px; color: var(--ink-3); margin: 3px 0 12px 32px; }
.msg-meta.mine { align-self: flex-end; margin: 3px 32px 12px 0; }

.msg-compose { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.msg-attach-icon { font-size: 18px; color: var(--ink-3); opacity: .55; flex-shrink: 0; }
.msg-compose input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13.5px; font-family: var(--font-body); }

@media (max-width: 780px) {
  .msg-shell { grid-template-columns: 1fr; height: calc(100vh - 260px); }
  .msg-shell.has-active .msg-sidebar { display: none; }
  .msg-shell:not(.has-active) .msg-main { display: none; }
  .msg-back-link { display: flex; align-items: center; }
}

/* ---------------------------- Footer ------------------------------------------ */
.site-footer { background: #17181B; color: #C9CACE; padding: 36px 0 22px; margin-top: 40px; }
.site-footer .container { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
.site-footer h4 { color: #fff; font-size: 13.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
.site-footer a { color: #C9CACE; font-size: 13.5px; display: block; margin-bottom: 8px; }
.site-footer a:hover { color: #fff; }
.site-footer .bottom { text-align: center; font-size: 12.5px; color: #83858B; margin-top: 24px; padding-top: 18px; border-top: 1px solid #2A2B2F; }

/* ---------------------------- Bottom nav (mobile) ------------------------------ */
/* Base rule sets display:none; the @media block further down (later in source,
   so it wins the cascade at equal specificity) flips it to flex under 720px. */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--paper); border-top: 1px solid var(--line); height: 58px;
  box-shadow: 0 -2px 10px rgba(27,27,31,.06);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  background: none; border: none; cursor: pointer; padding: 6px 0 4px;
}
.bottom-nav svg { width: 21px; height: 21px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav .bottom-nav-sell { color: var(--brand); margin-top: -14px; }
.bottom-nav .bottom-nav-sell-icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md);
}
.bottom-nav .bottom-nav-sell-icon svg { width: 22px; height: 22px; }
.bottom-nav-icon-wrap { position: relative; display: inline-flex; }
.bottom-nav-icon-wrap .notif-badge { position: absolute; top: -4px; right: -8px; min-width: 14px; height: 14px; font-size: 9px; padding: 0 3px; }
.bottom-nav-avatar { width: 21px; height: 21px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }

/* ---------------------------- Responsive --------------------------------------- */
@media (max-width: 860px) {
  .listing-detail { grid-template-columns: 1fr; }

  /* Reflow the listing-detail page for a natural top-to-bottom mobile read:
     images -> price/meta -> seller details -> description -> safety tips ->
     report, instead of the desktop's left-column/right-column DOM order.
     display:contents unwraps the two column divs so their children become
     direct grid items and can each take their own `order`; margin-top is
     zeroed since the grid's own `gap` now provides spacing between them. */
  .ld-left-col, .ld-right-col { display: contents; }
  .ld-gallery { order: 1; }
  .ld-titlemeta { order: 2; margin-top: 0 !important; }
  .ld-seller { order: 3; margin-top: 0 !important; }
  .ld-description { order: 4; margin-top: 0 !important; }
  .ld-safety { order: 5; margin-top: 0 !important; }
  .ld-report { order: 6; margin-top: 0 !important; }
}
@media (max-width: 720px) {
  .search-form { order: 3; flex-basis: 100%; margin-top: 8px; }
  .nav-row { flex-wrap: wrap; }
  .mobile-toggle { display: block; }
  .hero h1 { font-size: 24px; }

  /* Mobile top bar is just the logo/name + search -- Install App, +Sell, the
     notification bell and the account chip all move to (or are already
     covered by) the bottom tab bar below. */
  .nav-actions { display: none; }

  /* Fixed bottom tab bar (Home/Browse/Sell/Messages/Account), mobile only. */
  body { padding-bottom: 58px; }
  .bottom-nav { display: flex; }
}
