:root {
  --green: #1f4d3a; --green-2: #2d6a50; --bg: #f6f4ef; --card: #ffffff; --text: #1d2a24; --muted: #66726b;
  --line: #dcd8cd; --danger: #b3261e; --ok: #2e9e5b; --warn: #e0a800; --off: #8a8f8c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121815; --card: #1c2520; --text: #eceee9; --muted: #9aa8a0; --line: #2f3b35; --green: #3f8c69; --green-2: #4ea37b; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.4; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #5aa6ff; outline-offset: 2px; }

/* Boutons */
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 44px; padding: 0 14px; }
.btn.icon { min-width: 44px; padding: 0; font-size: 22px; line-height: 1; }
.btn:disabled { opacity: .6; cursor: default; }

/* Accueil */
.welcome { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.logo { align-self: center; border-radius: 16px; }
h1 { margin: 4px 0 0; text-align: center; color: var(--green); }
.sub { margin: 0 0 8px; text-align: center; color: var(--muted); }
label { font-weight: 600; font-size: 14px; margin-top: 6px; }
input[type=text], input[type=password], input:not([type]) { min-height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; font-size: 14px; }
.box ul { margin: 6px 0 0; padding-left: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 10px 0; min-height: 44px; }
.check input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--green); }
.error { color: var(--danger); font-weight: 600; margin: 0; }

/* Principal */
#main { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; z-index: 0; }
.topbar { position: absolute; z-index: 500; top: 0; left: 0; right: 0; display: flex; gap: 8px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 8px calc(8px + env(safe-area-inset-left)); pointer-events: none; }
.topbar > * { pointer-events: auto; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.pill { flex: 1; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 22px; background: var(--card); font-weight: 600; font-size: 14px; }
.pill .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--off); flex: none; }
.pill.green .dot { background: var(--ok); }
.pill.yellow .dot { background: var(--warn); }
.pill.grey .dot { background: var(--off); }

.panel { position: absolute; z-index: 500; left: 0; right: 0; bottom: 0; max-height: 45vh; overflow-y: auto; background: var(--card);
  border-radius: 18px 18px 0 0; box-shadow: 0 -2px 12px rgba(0,0,0,.2);
  padding: 8px calc(12px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
#members { list-style: none; margin: 0; padding: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.avatar { position: relative; width: 44px; height: 44px; border-radius: 50%; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.avatar .on { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 2px solid var(--card); }
.info { flex: 1; min-width: 0; }
.info .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info .meta { font-size: 13px; color: var(--muted); }
.member .btn { min-height: 44px; padding: 0 10px; font-size: 14px; }

@media (min-width: 761px) {
  .panel { top: 0; right: auto; bottom: 0; width: 340px; max-height: none; border-radius: 0 18px 18px 0; padding-top: calc(64px + env(safe-area-inset-top)); }
  .topbar { left: 356px; }
}

.banner { position: absolute; z-index: 600; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top)); background: var(--card);
  border: 2px solid var(--green); border-radius: 14px; padding: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 8px; font-weight: 600; }
.banner .row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 761px) { .banner { left: 356px; right: auto; max-width: 420px; } }

.toast { position: absolute; z-index: 700; left: 50%; transform: translateX(-50%); bottom: calc(50vh + 12px); max-width: 90%; background: #1d2a24; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; text-align: center; }
@media (min-width: 761px) { .toast { bottom: 24px; } }

/* Marqueurs */
.mk { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff; color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 6px rgba(0,0,0,.4); }
.mk.old { opacity: .45; }
.leaflet-div-icon.mk-wrap { background: none; border: 0; }

/* Réglages */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--text); padding: 20px; width: min(92vw, 440px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 8px; color: var(--green); }
dialog h3 { margin: 14px 0 4px; font-size: 16px; }
dialog p { margin: 4px 0 8px; font-size: 14px; color: var(--muted); }
dialog .btn.primary { width: 100%; margin-top: 16px; }
