/* Marketplace panel — same overlay pattern as sphere */
#marketplace-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(var(--panel-w), 100vw);
  height: 100vh;
  background: var(--bg-white);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  overflow: hidden;
}
#marketplace-panel.open { transform: translateX(0); }

#market-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
#market-close {
  float: right;
  font-size: 1.4rem;
  color: var(--ink-muted);
  line-height: 1;
  padding: .1rem .3rem;
}
#market-close:hover { color: var(--accent); }

#market-search-bar {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
}
#market-search-bar input { flex: 1; }

#market-cat-tabs {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  margin-top: .6rem;
  padding-bottom: .25rem;
}
.mcat-btn {
  font-family: Arial, sans-serif;
  font-size: .75rem;
  padding: .25rem .65rem;
  border-radius: 2px;
  border: 1px solid var(--rule);
  white-space: nowrap;
  transition: all .15s;
}
.mcat-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.mcat-btn:hover:not(.active) { background: var(--bg); }

#market-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

/* Intent search box */
#intent-box {
  background: #fffbe6;
  border: 1px solid #f0d060;
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
}
#intent-box h3 {
  font-family: Arial, sans-serif;
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--ink);
}
#intent-box .intent-row {
  display: flex;
  gap: .5rem;
}
#intent-box input { flex: 1; font-size: .85rem; }

/* Listing cards */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem;
}

.listing-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-white);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.listing-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.listing-card .lc-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 2.5rem;
}
.listing-card .lc-body { padding: .9rem 1rem; }
.listing-card .lc-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: .4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
}
.listing-card .lc-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .35rem;
}
.listing-card .lc-price .neg {
  font-size: .8rem;
  font-weight: 400;
  color: var(--ink-muted);
}
.listing-card .lc-meta {
  font-family: Arial, sans-serif;
  font-size: .82rem;
  color: var(--ink-light);
  display: flex;
  justify-content: space-between;
  margin-top: .25rem;
}

/* Condition badge */
.cond-badge {
  font-family: Arial, sans-serif;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 2px;
  text-transform: uppercase;
}
.cond-new      { background: #d5f5e3; color: #1a7a45; }
.cond-like_new { background: #d6eaf8; color: #1a5276; }
.cond-good     { background: #fef9e7; color: #7d6608; }
.cond-fair     { background: #fce8d4; color: #784212; }

/* Source badge */
.source-fb {
  font-family: Arial, sans-serif;
  font-size: .65rem;
  font-weight: 700;
  background: #e8f0fe;
  color: #1565c0;
  padding: .1rem .4rem;
  border-radius: 2px;
}

/* Listing detail overlay */
#listing-detail {
  position: fixed;
  top: 0; right: 0;
  width: min(var(--panel-w), 100vw);
  height: 100vh;
  background: var(--bg-white);
  z-index: 102;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.18);
  overflow: hidden;
}
#listing-detail.open { transform: translateX(0); }

#ld-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
#ld-close { float: right; font-size: 1.4rem; color: var(--ink-muted); padding: .1rem .3rem; }
#ld-close:hover { color: var(--accent); }
#ld-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }

.ld-images { display: flex; gap: .5rem; overflow-x: auto; margin-bottom: 1rem; }
.ld-images img {
  height: 180px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}
#ld-price { font-size: 1.6rem; font-weight: 700; color: var(--accent); margin-bottom: .5rem; }
#ld-title { font-size: 1.15rem; font-weight: 700; margin-bottom: .5rem; }
#ld-desc  { font-size: .9rem; line-height: 1.6; color: var(--ink-light); margin-bottom: 1rem; }
.ld-detail-row {
  display: flex;
  gap: .5rem;
  font-family: Arial, sans-serif;
  font-size: .82rem;
  margin-bottom: .35rem;
  color: var(--ink-muted);
}
.ld-detail-row strong { color: var(--ink); min-width: 100px; }

.contact-box {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-top: 1rem;
}
.contact-box h3 {
  font-family: Arial, sans-serif;
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: .5rem;
}
.contact-box .contact-item {
  font-family: Arial, sans-serif;
  font-size: .85rem;
  margin-bottom: .3rem;
}
.contact-box .contact-item a { color: var(--accent); }

/* New listing form */
#new-listing-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(var(--panel-w), 100vw);
  height: 100vh;
  background: var(--bg-white);
  z-index: 103;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.18);
  overflow: hidden;
}
#new-listing-panel.open { transform: translateX(0); }
#nl-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
#nl-close { float: right; font-size: 1.4rem; color: var(--ink-muted); padding: .1rem .3rem; }
#nl-close:hover { color: var(--accent); }
#nl-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
#nl-body .field { margin-bottom: 1rem; }
#nl-body label {
  display: block;
  font-family: Arial, sans-serif;
  font-size: .8rem;
  color: var(--ink-muted);
  margin-bottom: .3rem;
}

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

/* Legal panel */
#legal-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(var(--panel-w), 100vw);
  height: 100vh;
  background: var(--bg-white);
  z-index: 104;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.18);
  overflow: hidden;
}
#legal-panel.open { transform: translateX(0); }
#legal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
#legal-close { float: right; font-size: 1.4rem; color: var(--ink-muted); padding: .1rem .3rem; }
#legal-close:hover { color: var(--accent); }
#legal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  font-family: Arial, sans-serif;
  font-size: .88rem;
  line-height: 1.7;
  color: var(--ink-light);
}

.legal-tab {
  font-family: Arial, sans-serif;
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--ink-muted);
}
.legal-tab:first-child { border-radius: 3px 0 0 3px; }
.legal-tab:last-child  { border-radius: 0 3px 3px 0; margin-left: -1px; }
.legal-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

#legal-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .5rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--accent);
}
#legal-body h4 {
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.25rem 0 .4rem;
}
#legal-body p { margin-bottom: .6rem; }
#legal-body ul {
  padding-left: 1.25rem;
  margin-bottom: .6rem;
}
#legal-body li { margin-bottom: .25rem; }
#legal-body a { color: var(--accent); text-decoration: underline; }
.legal-updated {
  font-size: .78rem !important;
  color: var(--ink-muted) !important;
  margin-bottom: 1rem !important;
}

/* Admin panel */
#admin-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(var(--panel-w), 100vw);
  height: 100vh;
  background: var(--bg-white);
  z-index: 104;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,.18);
  overflow: hidden;
}
#admin-panel.open { transform: translateX(0); }
#admin-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
#admin-close { float: right; font-size: 1.4rem; color: var(--ink-muted); padding: .1rem .3rem; }
#admin-close:hover { color: var(--accent); }
#admin-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }

.admin-tab {
  font-family: Arial, sans-serif;
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--ink-muted);
}
.admin-tab:first-child { border-radius: 3px 0 0 3px; }
.admin-tab:last-child  { border-radius: 0 3px 3px 0; margin-left: -1px; }
.admin-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.adm-card {
  padding: .85rem 0;
  border-bottom: 1px solid var(--rule);
}
.adm-card:last-child { border-bottom: none; }
.adm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: baseline;
  font-family: Arial, sans-serif;
  font-size: .82rem;
  margin-bottom: .35rem;
}
.adm-text {
  font-size: .85rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: .5rem;
  white-space: pre-wrap;
}
.adm-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}

@media (max-width: 600px) {
  #market-header { padding: .75rem 1rem; }
  #market-body { padding: .75rem 1rem; }
  #ld-body { padding: .75rem 1rem; }
  #nl-body { padding: .75rem 1rem; }

  /* Stack intent search row */
  #intent-box > div[style*="display:flex"] {
    flex-direction: column;
  }
  #intent-box button { width: 100%; }

  /* Stack notify box contact fields */
  #notify-box div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Wrap language switcher */
  #lang-switcher { flex-wrap: wrap !important; }
}
