:root {
  --fond: #f6f3ec;
  --carte: #ffffff;
  --encre: #1d2422;
  --doux: #5f6b67;
  --ligne: #e3ddd0;
  --vert: #1f3d36;
  --vert-clair: #e4eee9;
  --orange: #d9772b;
  --orange-clair: #fbeadb;
  --ok: #2f7d4f;
  --ok-fond: #e1f2e7;
  --moyen: #9a6a00;
  --moyen-fond: #fbf1d6;
  --ko: #b23b2e;
  --ko-fond: #f8e3e0;
  --rayon: 14px;
  --ombre: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 5%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #141917;
    --carte: #1d2421;
    --encre: #e9ece9;
    --doux: #9aa6a1;
    --ligne: #2e3733;
    --vert: #8fc7b3;
    --vert-clair: #1f302a;
    --orange: #f0995a;
    --orange-clair: #3a2a1d;
    --ok: #79c995;
    --ok-fond: #1b3024;
    --moyen: #e2b54a;
    --moyen-fond: #33291a;
    --ko: #f08a7c;
    --ko-fond: #3a201d;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.barre {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--fond);
  border-bottom: 1px solid var(--ligne);
}
.marque { display: flex; gap: 8px; align-items: center; text-decoration: none; font-weight: 700; font-size: 18px; }
.marque img { border-radius: 7px; }
.bouton-ajout {
  text-decoration: none; background: var(--vert); color: var(--fond);
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 15px;
}
@media (prefers-color-scheme: dark) { .bouton-ajout { color: #10201b; } }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }

h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 6px; }
h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--doux); text-transform: uppercase; letter-spacing: .04em; }
.doux { color: var(--doux); }
.petit { font-size: 13.5px; }

.bloc {
  background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 14px; margin: 12px 0;
}

/* ---------- Liste ---------- */
.filtres { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.puce {
  flex: none; border: 1px solid var(--ligne); background: var(--carte);
  padding: 6px 12px; border-radius: 999px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.puce[aria-pressed="true"] { background: var(--vert); color: var(--fond); border-color: var(--vert); }
@media (prefers-color-scheme: dark) { .puce[aria-pressed="true"] { color: #10201b; } }

.annonce {
  display: grid; grid-template-columns: 108px 1fr; gap: 12px;
  text-decoration: none; background: var(--carte); border: 1px solid var(--ligne);
  border-radius: var(--rayon); box-shadow: var(--ombre); overflow: hidden; margin: 10px 0;
}
.annonce .vignette { width: 108px; height: 100%; min-height: 112px; object-fit: cover; background: var(--vert-clair); }
.annonce .vignette.vide { display: grid; place-items: center; font-size: 34px; }
.annonce .corps { padding: 10px 12px 10px 0; min-width: 0; }
.annonce .prix { font-weight: 700; font-size: 18px; }
.annonce .lieu { font-size: 14px; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chiffres { font-size: 14px; margin: 2px 0 6px; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 4px; }
.etiquette { font-size: 12.5px; padding: 2px 8px; border-radius: 999px; background: var(--vert-clair); color: var(--vert); font-weight: 600; }
.etiquette.ok { background: var(--ok-fond); color: var(--ok); }
.etiquette.moyen { background: var(--moyen-fond); color: var(--moyen); }
.etiquette.ko { background: var(--ko-fond); color: var(--ko); }
.etiquette.statut { background: var(--orange-clair); color: var(--orange); }
.vide-liste { text-align: center; padding: 40px 10px; color: var(--doux); }
.vide-liste .grand { font-size: 46px; }

/* ---------- Formulaires ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=url], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--ligne);
  background: var(--fond); font-size: 16px;
}
textarea { min-height: 120px; resize: vertical; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer;
  background: var(--vert); color: var(--fond); text-decoration: none;
}
@media (prefers-color-scheme: dark) { .btn { color: #10201b; } }
.btn.secondaire { background: var(--vert-clair); color: var(--vert); }
.btn.danger { background: var(--ko-fond); color: var(--ko); }
.btn.large { width: 100%; margin-top: 14px; }
.btn[disabled] { opacity: .6; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- Fiche ---------- */
.retour { text-decoration: none; color: var(--doux); font-size: 15px; }
.galerie { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px; }
.galerie img { flex: none; width: 86%; max-width: 520px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; scroll-snap-align: center; background: var(--vert-clair); }
.entete-fiche { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.etoile { font-size: 26px; background: none; border: 0; cursor: pointer; line-height: 1; padding: 4px; color: var(--orange); }
.gros-prix { font-size: 26px; font-weight: 800; }
.tableau { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.case { background: var(--fond); border-radius: 10px; padding: 8px; text-align: center; }
.case b { display: block; font-size: 17px; }
.case span { font-size: 12.5px; color: var(--doux); }

.statuts { display: flex; flex-wrap: wrap; gap: 6px; }
.statuts .puce[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: #fff; }

#carte { height: 300px; border-radius: 12px; margin-top: 8px; z-index: 0; }
.legende { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--doux); margin-top: 6px; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

.liste-lieux { list-style: none; margin: 0; padding: 0; }
.liste-lieux li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--ligne); font-size: 14.5px; }
.liste-lieux li:last-child { border-bottom: 0; }
.liste-lieux .nom { min-width: 0; }
.liste-lieux .nom small { display: block; color: var(--doux); font-size: 12.5px; }
.liste-lieux .temps { flex: none; text-align: right; font-weight: 600; white-space: nowrap; }
.liste-lieux .temps small { display: block; font-weight: 400; color: var(--doux); font-size: 12.5px; }

.alerte { border-radius: 10px; padding: 10px 12px; font-size: 14.5px; margin: 8px 0; }
.alerte.info { background: var(--vert-clair); }
.alerte.attention { background: var(--moyen-fond); }
.alerte.erreur { background: var(--ko-fond); color: var(--ko); }

.chargement { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tourne .8s linear infinite; vertical-align: -2px; }
@keyframes tourne { to { transform: rotate(360deg); } }

.note { padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.note:last-child { border-bottom: 0; }
.note .qui { font-size: 13px; color: var(--doux); display: flex; justify-content: space-between; }
.note p { margin: 4px 0 0; white-space: pre-wrap; }
.lien-supprimer { background: none; border: 0; color: var(--ko); font-size: 13px; cursor: pointer; padding: 0; }

details > summary { cursor: pointer; font-weight: 600; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: " ▾"; color: var(--doux); }
details[open] > summary::after { content: " ▴"; }
.description { white-space: pre-wrap; font-size: 15px; }

#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--encre); color: var(--fond); padding: 10px 16px; border-radius: 10px; font-size: 14.5px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 2000; max-width: calc(100% - 32px);
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  .annonce { grid-template-columns: 160px 1fr; }
  .annonce .vignette { width: 160px; }
  #carte { height: 380px; }
}
