:root {
  --green: #0b6b4f;
  --green-2: #12a37a;
  --green-soft: #e3f4ed;
  --ink: #15201c;
  --muted: #5c6b65;
  --line: #e2e8e5;
  --bg: #f5f7f6;
  --card: #ffffff;
  --amber: #b35c00;
  --amber-soft: #fff1e0;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--green); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand { min-width: 0; flex: 1; }
.brand > div { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 0; font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cross {
  width: 30px; height: 30px; flex: none; background: #fff; border-radius: 8px; position: relative;
}
.cross::before, .cross::after {
  content: ""; position: absolute; background: var(--green-2); border-radius: 2px;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
}
.cross::before { width: 18px; height: 6px; }
.cross::after { width: 6px; height: 18px; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); color: #fff;
  padding: 8px 12px; border-radius: 999px; font: 600 13.5px var(--font); cursor: pointer;
  white-space: nowrap; flex: none;
}
.btn-ghost[aria-pressed="true"] { background: #fff; color: var(--green); }

/* Filtres */
.filters { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; }
.select-ville { display: block; position: relative; }
.select-ville::after {
  content: ""; position: absolute; inset-inline-end: 14px; top: 50%; width: 8px; height: 8px; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg);
}
.select-ville select {
  width: 100%; appearance: none; -webkit-appearance: none; font: 600 15px var(--font); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding-block: 11px; padding-inline: 14px 36px;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
  font: 600 13px var(--font); color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.toggle input { accent-color: var(--green); width: 17px; height: 17px; }

/* Carte + liste */
#map { height: 42vh; min-height: 240px; background: #dfe7e3; }
.sheet {
  position: relative; margin-top: -16px; z-index: 500;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 14px 16px 24px;
  box-shadow: 0 -4px 14px rgba(0,0,0,.06);
}
.sheet::before {
  content: ""; display: block; width: 38px; height: 4px; border-radius: 4px;
  background: #cfd8d4; margin: 0 auto 10px;
}
.count { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; scroll-margin-top: 140px;
}
.card.active { border-color: var(--green-2); box-shadow: 0 0 0 2px var(--green-soft); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card h2 { margin: 0; font-size: 16px; line-height: 1.25; }
.meta { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.ar { margin: 1px 0 0; font-size: 14px; color: var(--ink); }
.adr { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.dist { flex: none; font: 700 13px var(--font); color: var(--green); white-space: nowrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.badge { font: 600 12px var(--font); padding: 3px 8px; border-radius: 6px; background: var(--green-soft); color: var(--green); }
.badge.closed { background: var(--amber-soft); color: var(--amber); }
.badge.unknown { background: var(--amber-soft); color: var(--amber); }
.badge.plain { background: #eef1f0; color: var(--ink); }
.badge.nomap { background: transparent; color: var(--muted); border: 1px dashed #c5cfcb; }
.badge.type-jour { background: #fff6d6; color: #7a5a00; }
.badge.type-nuit { background: #e5e9fb; color: #2c3e91; }
.badge.type-24h { background: var(--green-soft); color: var(--green); }
.card.inconnu { background: #fbfcfb; }
.sep { font-size: 12.5px; font-weight: 700; color: var(--amber); padding: 10px 2px 0; }
.notice { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.4; }
.notice.warn { background: var(--amber-soft); color: #6b3700; }
.notice.info { background: var(--green-soft); color: var(--green); }
.btn-ghost:disabled { opacity: .7; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.act {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; border-radius: 10px; text-decoration: none;
  font: 700 13.5px var(--font); border: 1px solid var(--line); color: var(--ink); background: var(--card);
}
.act.call { background: var(--green); border-color: var(--green); color: #fff; }
.act svg { flex: none; }
.act.disabled { color: var(--muted); background: var(--bg); font-weight: 600; }

.empty { text-align: center; padding: 28px 10px; color: var(--muted); font-size: 14px; }
.foot { margin-top: 20px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.foot p { margin: 0 0 6px; }
/* Compteur de visiteurs : discret, même ton que le bas de page */
.compteur { margin: 10px 0 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.compteur-titre { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.compteur dl { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.compteur dl div { min-width: 0; }
.compteur dt { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compteur dd { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 340px) { .compteur dl { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Marqueurs */
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--green); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font: 800 15px var(--font); line-height: 1; }
.pin.ferme { background: #9aa8a2; }
.me-dot {
  width: 22px; height: 22px; border-radius: 50%; background: #1a73e8; border: 4px solid #fff;
  box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 2px 6px rgba(0,0,0,.35);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(26,115,232,.45), 0 2px 6px rgba(0,0,0,.35); } 100% { box-shadow: 0 0 0 16px rgba(26,115,232,0), 0 2px 6px rgba(0,0,0,.35); } }

@media (max-width: 380px) { .btn-ghost span { display: none; } }
html[lang="zgh"] .btn-ghost span, html[lang="de"] .btn-ghost span { display: none; } /* libellé long : icône seule */

@media (min-width: 900px) {
  main { display: grid; grid-template-columns: 1fr 420px; height: calc(100vh - 120px); }
  #map { height: 100%; }
  .sheet { margin-top: 0; border-radius: 0; overflow-y: auto; box-shadow: none; border-left: 1px solid var(--line); }
  .sheet::before { display: none; }
}

/* ---------- En-tête : bouton langue ---------- */
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.btn-icon {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid rgba(255,255,255,.45);
  background: rgba(255,255,255,.12); color: #fff; padding: 8px 10px; border-radius: 999px;
  font: 700 12.5px var(--font); cursor: pointer;
}
[dir="rtl"] .brand h1, [dir="rtl"] .btn-ghost, [dir="rtl"] body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", var(--font); }
.credits { font-size: 11.5px; opacity: .8; }

/* ---------- Page d'accueil ---------- */
.landing {
  position: fixed; inset: 0; z-index: 3000; overflow-y: auto; color: #fff;
  background: radial-gradient(120% 80% at 20% 0%, #14a37a 0%, #0b6b4f 45%, #073f30 100%);
}
.motif { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: rgba(255,255,255,.13); }
.motif svg { position: absolute; transform: rotate(var(--r)); animation: flotte 14s ease-in-out infinite alternate; }
@keyframes flotte {
  from { transform: translateY(0) rotate(var(--r)); }
  to { transform: translateY(-26px) rotate(calc(var(--r) + 25deg)); }
}
.landing-inner {
  position: relative; min-height: 100%; max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center; gap: 26px;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
}
.landing-brand { text-align: center; }
.cross.big { width: 64px; height: 64px; border-radius: 18px; display: inline-block; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.cross.big::before { width: 38px; height: 12px; }
.cross.big::after { width: 12px; height: 38px; }
.landing h1 { margin: 14px 0 6px; font-size: 27px; line-height: 1.2; letter-spacing: .2px; }
.landing h1 span { display: block; font-size: 22px; opacity: .9; margin-top: 2px; }
.landing-sous-titre { margin: 0 0 8px; font-size: 16px; opacity: .9; }
.tagline { margin: 0 auto; max-width: 30ch; font-size: 15.5px; opacity: .92; line-height: 1.45; }

.slides { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 20px; padding: 18px 0 12px; backdrop-filter: blur(4px); }
.slides-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; text-align: center; padding: 0 22px; }
.slide p { margin: 12px auto 0; max-width: 28ch; font-size: 16px; font-weight: 600; line-height: 1.4; }
.slide-art { position: relative; height: 92px; display: flex; justify-content: center; align-items: center; gap: 14px; }
.slide-art .ico {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px;
  background: #fff; color: var(--green); box-shadow: 0 8px 22px rgba(0,0,0,.18);
}
.slide-art .ico svg { width: 32px; height: 32px; }
.slide-art .i1 { width: 76px; height: 76px; border-radius: 22px; background: #eafff6; transform: translateY(-4px); }
.slide-art .i1 svg { width: 42px; height: 42px; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.dots button { width: 8px; height: 8px; padding: 0; border-radius: 99px; border: 0; background: rgba(255,255,255,.4); cursor: pointer; transition: width .2s; }
.dots button[aria-selected="true"] { width: 22px; background: #fff; }

.langs { text-align: center; }
.langs-title { margin: 0 0 12px; font-weight: 700; font-size: 15px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-btn {
  min-height: 52px; border-radius: 14px; border: 0; cursor: pointer;
  background: #fff; color: var(--green); font: 700 16.5px var(--font);
  box-shadow: 0 6px 16px rgba(0,0,0,.15); transition: transform .12s;
}
.lang-btn:hover, .lang-btn:focus-visible { transform: translateY(-2px); outline: 3px solid rgba(255,255,255,.5); }
.lang-btn[aria-pressed="true"] { background: #eafff6; }
/* Tifinagh : police Noto Sans Tifinagh (Google Fonts), absente de nombreux téléphones */
:lang(zgh), [lang="zgh"] body, html[lang="zgh"] body { font-family: "Noto Sans Tifinagh", var(--font); }
.free { margin: 14px 0 0; font-size: 13px; opacity: .8; }

@media (prefers-reduced-motion: reduce) { .motif svg { animation: none; } }

/* RTL : textes latins (adresses) alignés comme le reste de la carte */
[dir="rtl"] .card-head > div > * { text-align: right; }
[dir="rtl"] .badge.plain, .dist { unicode-bidi: isolate; }

/* ---------- Rappel + urgences ---------- */
.rappel {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  font-size: 14px; font-weight: 600; color: var(--green);
}
.rappel svg { flex: none; }
.urgence {
  margin: 4px 0 14px; padding: 14px; border-radius: 16px;
  background: #1a1420; border: 1px solid #5c1a24; color: #f3f4f6;
}
.urgence h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 16px; color: #ff8a8a; }
.urgence-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.urgence-grid a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px;
  border-radius: 12px; background: #1f2937; border: 1px solid #5c1a24; text-decoration: none; color: #cbd5e1;
  font-size: 12px; text-align: center; line-height: 1.2;
}
.urgence-grid a strong { font-size: 19px; color: #ff8a8a; }
.urgence-grid a:active { transform: scale(.97); }
@media (max-width: 340px) { .urgence-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Signature ---------- */
.signature { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px !important; }
.signature a { color: var(--green); font-weight: 600; }
.btn-signaler { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); text-decoration: none; font-size: 13px; }

.lien-pro {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 12px 14px;
  border: 1px dashed var(--green-2); border-radius: 12px; background: var(--green-soft);
  color: var(--green); font-weight: 700; font-size: 14px; text-decoration: none;
}
.lien-pro svg { flex: none; }
