/* Graille 24/24 · V2
   Direction : carte plein écran la nuit, panneaux en verre dépoli léger, un seul accent (ambre lampadaire).
   Noirs neutres (aucune teinte bleue), typo système Apple. */
:root {
  --bg: #0b0b0c;
  --fg: #f5f5f7;
  --muted: #9a9aa0;
  --faint: #6b6b70;
  --accent: #ffb340;
  --accent-ink: #1d1200;
  --ok: #30d158;
  --ko: #ff453a;
  --stale: #8e8e93;
  --glass: rgba(24, 24, 26, 0.62);
  --glass-strong: rgba(20, 20, 22, 0.82);
  --glass-line: rgba(255, 255, 255, 0.10);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --fill: rgba(255, 255, 255, 0.07);
  --fill-2: rgba(255, 255, 255, 0.12);
  --blur: blur(22px) saturate(170%);
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 var(--glass-hi);
}

/* ---------- carte ---------- */
#map { position: fixed; inset: 0; background: #111; z-index: 0; }
.leaflet-container { background: #111; font-family: var(--font); }
/* OSM en mode nuit : inversion + rotation de teinte pour garder des couleurs crédibles */
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.88) saturate(0.45); }
.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.45) !important; color: var(--faint) !important; font-size: 10px; border-radius: 8px 0 0 0;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: var(--muted) !important; }

.pin {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 20, 22, 0.78); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 2px solid var(--ring, var(--ok)); color: var(--fg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 0 4px color-mix(in srgb, var(--ring, var(--ok)) 18%, transparent);
  transition: transform .18s ease;
}
.pin svg { width: 18px; height: 18px; }
.pin.ok { --ring: var(--ok); }
.pin.ko { --ring: var(--ko); }
.pin.stale { --ring: var(--stale); }
.pin.sel { transform: scale(1.22); color: var(--accent); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(255, 179, 64, 0.22); }

/* ---------- barre du haut ---------- */
.top {
  position: fixed; z-index: 10; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; pointer-events: none;
}
.top > * { pointer-events: auto; }
.searchbar { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px 0 14px; border-radius: 16px; }
.searchbar input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 16px; }
.searchbar input::placeholder { color: var(--muted); }
.brand { font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand span { color: var(--accent); }
.round { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: var(--fg); background: var(--fill); }
.round:active { background: var(--fill-2); }
.avatar-btn { font-size: 18px; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--fg);
}
.chip svg { width: 16px; height: 16px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.side { position: fixed; z-index: 10; right: max(12px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 10px + 48px + 8px + 36px + 12px); display: grid; gap: 8px; }
.side .round { width: 44px; height: 44px; border-radius: 14px; background: var(--glass); }

/* ---------- panneau du bas ---------- */
.sheet {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  border-radius: 26px 26px 0 0; border-bottom: 0;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 14px) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; max-height: 42vh; transition: max-height .28s cubic-bezier(.2,.8,.2,1);
  background: var(--glass-strong);
}
.sheet.open { max-height: 66vh; }
.grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 2px 0 8px; flex: none; }
.grabzone { display: flex; flex-direction: column; flex: none; cursor: grab; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 12px; padding-bottom: 4px; min-height: 0; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; font-weight: 700; }
.head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.add-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }

.list { display: grid; gap: 2px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 14px; text-align: left; width: 100%; }
.row:active { background: var(--fill); }
.tile { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--fill); color: var(--accent); flex: none; position: relative; }
.tile .dot { position: absolute; right: -2px; top: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #1a1a1c; background: var(--ok); }
.tile .dot.ko { background: var(--ko); } .tile .dot.stale { background: var(--stale); }
.row .t { flex: 1; min-width: 0; }
.row .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .d { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.row .chev { color: var(--faint); }

/* ---------- fiche ---------- */
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 600; }
.detail-top { display: flex; gap: 14px; align-items: center; }
.detail-top .tile { width: 56px; height: 56px; border-radius: 16px; }
.detail-top .tile svg { width: 26px; height: 26px; }
.detail-top h2 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--fill); width: fit-content; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); } .pill.ko { color: var(--ko); } .pill.stale { color: var(--stale); }
.actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.act { display: grid; justify-items: center; gap: 4px; padding: 11px 6px; border-radius: 16px; background: var(--fill); font-size: 13px; font-weight: 600; text-decoration: none; color: var(--fg); }
.act svg { width: 22px; height: 22px; }
.act.go { background: var(--accent); color: var(--accent-ink); }
.act.ok svg { color: var(--ok); } .act.ko svg { color: var(--ko); }
.act[aria-pressed="true"] { background: var(--fill-2); }
.group { background: var(--fill); border-radius: 16px; padding: 4px 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--glass-line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; }
.section-t { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 2px -4px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { padding: 8px 12px; border-radius: 12px; background: var(--fill); font-size: 14px; font-weight: 500; }
.opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.opt.ko[aria-pressed="false"] { color: var(--ko); }
.stars { display: flex; gap: 4px; }
.stars button { color: var(--fill-2); }
.stars button svg { width: 30px; height: 30px; }
.stars button.on { color: var(--accent); }
.stars button.on svg { fill: currentColor; }
.rating { display: flex; align-items: baseline; gap: 8px; }
.rating b { font-size: 28px; letter-spacing: -0.02em; }
.avis { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--glass-line); }
.avis:last-child { border-bottom: 0; }
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); font-size: 17px; flex: none; }
.avis .who { font-size: 13px; color: var(--muted); }
.mini-stars { color: var(--accent); letter-spacing: 1px; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.link-danger { color: var(--ko); font-weight: 600; font-size: 14px; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; height: 48px; padding: 0 18px; border-radius: 14px; background: var(--fill); font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--ko); }
.btn:disabled { opacity: .5; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
select.field, input.field { width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--glass-line); background: var(--fill); padding: 0 14px; font-size: 16px; }
select.field option { background: #1c1c1e; }
.lbl { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 2px; }
.field-wrap { display: grid; gap: 6px; }
.err { color: var(--ko); font-size: 14px; }
.note { color: var(--muted); font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.codebox { background: var(--fill); border-radius: 12px; padding: 10px 12px; font-size: 13px; word-break: break-all; user-select: all; }

/* ---------- mode « placer le distrib » ---------- */
.crosshair { position: fixed; z-index: 5; left: 50%; top: 42%; transform: translate(-50%, -100%); color: var(--accent); pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }
.crosshair svg { width: 44px; height: 44px; fill: rgba(255, 179, 64, 0.25); }

/* ---------- écrans d'accueil ---------- */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: radial-gradient(120% 80% at 50% 0%, #2a1d07 0%, var(--bg) 55%); }
.gate .card { width: 100%; max-width: 400px; border-radius: 28px; padding: 26px 22px; display: grid; gap: 16px; text-align: center; }
.gate h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.gate h1 span { color: var(--accent); }
.gate p { margin: 0; color: var(--muted); }
.logo { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto; display: block; box-shadow: 0 12px 30px rgba(255,179,64,.25); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { aspect-ratio: 1; border-radius: 14px; background: var(--fill); font-size: 24px; }
.avatars button[aria-pressed="true"] { background: var(--accent); }

.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 112px); padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) { .sheet, .pin { transition: none; } }
@media (min-width: 900px) {
  .sheet { left: 16px; right: auto; bottom: 16px; width: 400px; border-radius: 26px; border-bottom: 1px solid var(--glass-line); max-height: calc(100vh - 150px); }
  .sheet.open { max-height: calc(100vh - 150px); }
  .grabzone { display: none; }
  .top { right: auto; width: 432px; }
}
