:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1d2b27;
  --muted: #66746f;
  --line: #e6e0d6;
  --brand: #1f6f5c;
  --brand-ink: #ffffff;
  --accent: #f2a541;
  --danger: #b3412f;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121816; --card: #1b2421; --ink: #eef2f0; --muted: #9aa8a3;
    --line: #2c3833; --brand: #3fa58a; --brand-ink: #0d1412; --accent: #f2b45f; --danger: #e07a68;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--brand); }
img { max-width: 100%; display: block; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: baseline; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; font-size: 22px; text-decoration: none; color: var(--brand); letter-spacing: -0.5px; }
.tagline { color: var(--muted); font-size: 13px; }

main { max-width: 960px; margin: 0 auto; padding: 16px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; font-size: 11px; color: var(--muted); text-decoration: none;
}
.tabbar .ico { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--brand); font-weight: 600; }
.tabbar a.vendre .ico {
  background: var(--brand); color: var(--brand-ink); border-radius: 50%;
  width: 34px; height: 34px; display: grid; place-items: center; margin-top: -6px;
}

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbar input { flex: 1; }

input, select, textarea, button { font: inherit; }
input[type=text], input[type=email], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
textarea { min-height: 100px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

details.filters { margin-bottom: 12px; }
details.filters summary { cursor: pointer; color: var(--brand); font-weight: 600; padding: 6px 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip {
  white-space: nowrap; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); }
.item .thumb { aspect-ratio: 1; object-fit: cover; width: 100%; background: var(--line); }
.item .body { padding: 8px 10px 10px; }
.item .price { font-weight: 700; }
.item .title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #2b1d05; }
.badge.grey { background: var(--line); color: var(--ink); }

.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 12px; padding: 0 16px; }
.gallery img { scroll-snap-align: center; width: 85%; max-width: 480px; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); flex: none; }

.specs { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }

.photos-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photos-pick .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.photos-pick .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos-pick .ph button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 26px; height: 26px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.photos-pick .add { display: grid; place-items: center; border: 2px dashed var(--line); background: transparent; font-size: 28px; color: var(--muted); cursor: pointer; }

.mine { display: flex; gap: 12px; align-items: center; }
.mine img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.mine .grow { flex: 1; min-width: 0; }

.notice { background: color-mix(in srgb, var(--accent) 18%, var(--card)); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50;
}
#toast.show { opacity: 1; }

.blocked { min-height: 70vh; display: grid; place-items: center; text-align: center; }

/* ---------- Messagerie ---------- */
.tabbar .ico { position: relative; }
.pastille { position: absolute; top: -2px; right: -8px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); border: 2px solid var(--card); }
.pastille[hidden] { display: none; }
.code-recup { font: 700 20px/1.4 ui-monospace, Menlo, monospace; letter-spacing: 1px; text-align: center; background: var(--bg); border: 2px dashed var(--brand); border-radius: 10px; padding: 14px 8px; word-break: break-all; user-select: all; }
.conv-ligne { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.conv-ligne img, .conv-ligne .ph-vide { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--line); flex: none; }
.conv-ligne .grow, .conv-tete .grow { flex: 1; min-width: 0; }
.conv-tete { display: flex; gap: 12px; align-items: center; position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 5; }
.conv-tete img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.fil { display: flex; flex-direction: column; gap: 6px; padding-bottom: 90px; }
.bulle { max-width: 80%; padding: 8px 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); align-self: flex-start; word-wrap: break-word; }
.bulle.moi { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.bulle .txt { white-space: pre-wrap; }
.bulle img { border-radius: 10px; max-height: 320px; width: auto; margin: 2px 0; }
.bulle .heure { display: block; font-size: 11px; opacity: .7; margin-top: 2px; text-align: right; }
.saisie { position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 15; display: flex; gap: 6px; align-items: flex-end; padding: 8px 10px; background: var(--bg); border-top: 1px solid var(--line); }
.saisie textarea { min-height: 42px; max-height: 140px; padding: 9px 12px; resize: none; }
.saisie .btn { padding: 10px 12px; flex: none; }
