/* =====================================================================
   Kozh — « carnet de repérage »
   Papier kraft, encre verte, vert forêt en couleur principale. Titres en slab industrielle,
   étiquettes en machine à écrire, traits nets, ombres franches (jamais de flou ni de dégradé).
   Mode nuit automatique (réglage du téléphone).
   ===================================================================== */

/* ---------- Polices (hébergées sur le site, aucune requête externe) ---------- */
@font-face { font-family: "Zilla Slab"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/zilla-slab/files/zilla-slab-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 700; font-style: italic; font-display: swap;
  src: url("/vendor/fonts/zilla-slab/files/zilla-slab-latin-700-italic.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/zilla-slab/files/zilla-slab-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/ibm-plex-mono/files/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("/vendor/fonts/ibm-plex-mono/files/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }

/* ---------- Palette : jour (papier) ---------- */
:root {
  --paper: #efe9d9;          /* fond de page */
  --paper-2: #f8f4e8;        /* fiches, panneaux */
  --paper-3: #e4dcc7;        /* survol, creux */
  --ink: #1a251e;            /* texte et traits */
  --muted: #5a6656;
  --bd: #1a251e;             /* bordures franches */
  --bd-soft: rgba(26, 37, 30, .2);
  --hard: #1a251e;           /* ombres franches */
  --green: #1c7a4a;          /* vert forêt : couleur principale */
  --green-2: #14603a;        /* survol / appui */
  --green-text: #176a41;     /* vert pour texte et liens sur papier */
  --green-3: rgba(28, 122, 74, .14);
  --on-green: #f8f4e8;
  --ok: #2f9d57;
  --warn: #cf920f;
  --danger: #bf3b28;
  --unknown: #8b8672;
  /* versions plus foncées pour le texte et les tampons (contraste suffisant sur le papier) */
  --ok-ink: #1f7a3a;
  --warn-ink: #8f6406;
  --danger-ink: #b23522;
  --unknown-ink: #6b6757;
  --map-bg: #dcd5bf;
  --tape: rgba(222, 201, 120, .9);
  --pin-ring: #1a251e;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .15 0 0 0 0 .1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520' fill='none' stroke='%231a251e' stroke-opacity='.075' stroke-width='1.2'%3E%3Cpath d='M60 250C58 150 150 66 258 78 356 90 430 160 420 256 410 348 326 422 232 410 132 398 62 340 60 250Z'/%3E%3Cpath d='M102 250C102 174 172 112 254 120 332 128 384 184 376 256 368 326 308 372 234 364 160 356 102 306 102 250Z'/%3E%3Cpath d='M146 250C146 198 194 156 254 162 312 168 346 206 340 256 334 304 292 334 236 328 182 322 146 292 146 250Z'/%3E%3Cpath d='M190 250C190 222 216 200 254 204 290 208 306 230 302 256 298 282 274 298 238 294 208 290 190 272 190 250Z'/%3E%3C/svg%3E");

  /* Noms hérités (utilisés par le JS et d'anciens styles) */
  --bg: var(--paper);
  --surface: var(--paper-2);
  --surface-2: var(--paper-3);
  --surface-3: var(--paper-3);
  --line: var(--bd-soft);
  --line-strong: var(--bd);
  --text: var(--ink);
  --accent: var(--green);
  --accent-hover: var(--green-2);
  --accent-text: var(--green-text);
  --accent-soft: var(--green-3);

  --radius: 4px;
  --radius-sm: 3px;
  --topbar-h: 56px;
  --tabbar-h: 54px;
  --sat: env(safe-area-inset-top, 0px);
  /* iOS (app installée) peut donner au site une hauteur plus courte que l'écran : --viewport-gap est cet écart,
     mesuré par app.js (0 partout ailleurs). Le fond est prolongé dans cette bande (voir body::after) et la marge
     du bas est réduite d'autant, car la barre de geste s'y trouve déjà. */
  --viewport-gap: 0px;
  --sab: max(0px, calc(env(safe-area-inset-bottom, 0px) - var(--viewport-gap)));
  --sab-tab: max(4px, calc(var(--sab) * .45));   /* barre d'onglets : on n'occupe qu'une partie de la zone du bas, comme sur iOS */
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --display: "Zilla Slab", "Rockwell", "Roboto Slab", Georgia, serif;
  --serif: var(--display);
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

/* ---------- Palette : nuit (même carnet, éclairé à la lampe) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101811;
    --paper-2: #17211a;
    --paper-3: #223027;
    --ink: #ece7d6;
    --muted: #9aa795;
    --bd: #46594c;
    --bd-soft: rgba(236, 231, 214, .15);
    --hard: #050905;
    --green: #3dbb77;
    --green-2: #62d393;
    --green-text: #5fd293;
    --green-3: rgba(61, 187, 119, .17);
    --on-green: #07140c;
    --ok: #4cc47c;
    --warn: #e8b13a;
    --danger: #e0604a;
    --unknown: #8b9685;
    --ok-ink: #4cc47c;
    --warn-ink: #e8b13a;
    --danger-ink: #e0604a;
    --unknown-ink: #9aa795;
    --map-bg: #0d130f;
    --tape: rgba(200, 180, 96, .8);
    --pin-ring: #050905;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .9 0 0 0 0 .92 0 0 0 0 .85 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520' fill='none' stroke='%23ece7d6' stroke-opacity='.06' stroke-width='1.2'%3E%3Cpath d='M60 250C58 150 150 66 258 78 356 90 430 160 420 256 410 348 326 422 232 410 132 398 62 340 60 250Z'/%3E%3Cpath d='M102 250C102 174 172 112 254 120 332 128 384 184 376 256 368 326 308 372 234 364 160 356 102 306 102 250Z'/%3E%3Cpath d='M146 250C146 198 194 156 254 162 312 168 346 206 340 256 334 304 292 334 236 328 182 322 146 292 146 250Z'/%3E%3Cpath d='M190 250C190 222 216 200 254 204 290 208 306 230 302 256 298 282 274 298 238 294 208 290 190 272 190 250Z'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; background: var(--paper); }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--paper) var(--grain);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
/* Prolonge le fond dans la bande que iOS ne compte pas dans la hauteur de la page (voir --viewport-gap) */
body::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: var(--viewport-gap);
  background: var(--paper-2); pointer-events: none;
}
a { color: var(--green-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.12; margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -.005em; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, select, label, summary { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: square; stroke-linejoin: miter; }
.brand-mark { fill: currentColor; stroke: none; }
.only-mobile { display: none !important; }

/* Étiquettes « machine à écrire » */
.tag, .section h3, .timeline h3, .stat span, .tabs a, .level-badge, .coords code, .spot-count, .kicker, .chip, label,
.footer, .legend, .log-row .when, .visit-card .date, .notif small, .tag-status {
  font-family: var(--mono);
}

/* ---------- Barre du haut ---------- */
.topbar {
  flex: none;
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) max(18px, var(--sar)) 0 max(18px, var(--sal));
  display: flex; align-items: center; gap: 26px;
  background: var(--paper-2);
  border-bottom: 4px double var(--bd);
  z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--green); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; }
.brand-name { color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 29px; letter-spacing: .01em; line-height: 1; }
.brand-name b { color: var(--green-text); font-weight: 700; font-style: normal; margin-left: .03em; }
.tabs { display: flex; gap: 6px; flex: 1; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  padding: 7px 12px; border: 1.5px solid transparent; border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.tabs a svg { display: none; width: 22px; height: 22px; }
.tabs a:hover { color: var(--ink); background: var(--paper-3); text-decoration: none; }
.tabs a.active { background: var(--green); color: var(--on-green); border-color: var(--bd); box-shadow: 2px 2px 0 var(--hard); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.userarea { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 3px 12px 3px 3px;
  border: 1.5px solid var(--bd); border-radius: var(--radius-sm); background: var(--paper-2);
  color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 2px 2px 0 var(--hard);
}
.user-chip:hover { text-decoration: none; background: var(--paper-3); }
.avatar {
  width: 28px; height: 28px; border-radius: 2px; flex: none;
  background: var(--green); color: var(--on-green); border: 1.5px solid var(--bd);
  font-family: var(--display); font-weight: 700; font-size: 16px; display: grid; place-items: center;
}
.avatar.big { width: 84px; height: 84px; font-size: 44px; border-radius: 3px; border-width: 2px; box-shadow: 4px 4px 0 var(--hard); }
.avatar.has-img { background-color: var(--paper-3); background-size: cover; background-position: center; }
.avatar-box { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.avatar-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* ---------- Notifications ---------- */
.icon-btn.bell { position: relative; }
.bell-count {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 2px;
  background: var(--danger); color: #fff; border: 1.5px solid var(--bd); font: 700 10px/15px var(--mono); text-align: center;
}
.notif-list { margin-top: 8px; max-height: 55vh; overflow-y: auto; overscroll-behavior: contain; }
.notif {
  display: block; width: 100%; text-align: left; position: relative; cursor: pointer; color: var(--ink);
  background: none; border: 0; border-bottom: 1.5px dashed var(--bd-soft); padding: 12px 0 12px 20px; font-size: 14.5px; line-height: 1.45;
}
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--paper-3); }
.notif small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.notif.unread::before { content: ""; position: absolute; left: 4px; top: 19px; width: 9px; height: 9px; background: var(--green); border: 1.5px solid var(--bd); border-radius: 50%; }

/* ---------- Boutons & champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--paper-2); border: 1.5px solid var(--bd); color: var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1.1; letter-spacing: .005em;
  box-shadow: 2px 2px 0 var(--hard);
  transition: background .1s, transform .08s, box-shadow .08s;
}
.btn:hover { background: var(--paper-3); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--hard); }
.btn.primary { background: var(--green); color: var(--on-green); }
.btn.primary:hover { background: var(--green-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); box-shadow: 2px 2px 0 var(--danger); }
.btn.danger:hover { background: rgba(191, 59, 40, .1); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--paper-3); }
.btn.ghost:active { transform: none; }
.btn.glass { background: var(--paper-2); }
.btn.small { min-height: 32px; padding: 4px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.active-ok { background: var(--ok); color: #fff; }
.btn.active-bad { background: var(--danger); color: #fff; }
.btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; cursor: pointer;
  background: var(--paper-2); border: 1.5px solid var(--bd); border-radius: var(--radius-sm); color: var(--ink); font-size: 15px;
  box-shadow: 2px 2px 0 var(--hard); transition: transform .08s, box-shadow .08s;
}
.icon-btn:hover { background: var(--paper-3); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn.ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); }
.icon-btn svg { width: 20px; height: 20px; }

input[type="text"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--paper-2); border: 1.5px solid var(--bd); border-radius: var(--radius-sm);
  font-size: 16px; /* évite le zoom automatique d'iOS au focus */
  transition: box-shadow .1s;
  -webkit-appearance: none; appearance: none;
}
select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%237d8977' stroke-width='2'%3E%3Cpath d='M1 1.500l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-3), 3px 3px 0 var(--green); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
label { display: block; font-size: 11.5px; color: var(--muted); margin: 16px 0 6px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14.5px; font-weight: 400; cursor: pointer; font-family: var(--sans); letter-spacing: 0; text-transform: none; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--green); flex: none; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.error { color: var(--danger); font-size: 13.5px; margin-top: 10px; min-height: 1em; font-weight: 500; }

/* ---------- Vue carte ---------- */
.view { flex: 1; min-height: 0; }
.view-map { display: flex; position: relative; }

.sidebar {
  width: 360px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--paper-2); border-right: 2px solid var(--bd);
}
.side-head { padding: 18px 16px 14px; display: grid; gap: 10px; border-bottom: 2px solid var(--bd); }
.side-title { display: flex; align-items: baseline; justify-content: space-between; }
.side-title h2 { font-size: 30px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters select { min-height: 40px; padding-top: 7px; padding-bottom: 7px; font-size: 14.5px; }
.spot-count { padding: 10px 16px 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.spot-list { list-style: none; margin: 0; padding: 0 0 16px; overflow-y: auto; flex: 1; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.spot-item {
  display: flex; gap: 13px; padding: 12px 16px 12px 13px; cursor: pointer;
  border-left: 4px solid transparent; border-bottom: 1.5px dashed var(--bd-soft);
  transition: background .1s;
}
.spot-item:hover { background: var(--paper-3); }
.spot-item.selected { background: var(--green-3); border-left-color: var(--green); }
.thumb {
  width: 56px; height: 56px; flex: none; border-radius: 2px;
  background: var(--paper-3) center / cover no-repeat;
  display: grid; place-items: center; font-size: 22px; color: var(--muted);
  border: 1.5px solid var(--bd); box-shadow: 2px 2px 0 var(--hard);
  transform: rotate(-1.6deg);
}
.spot-item:nth-child(even) .thumb { transform: rotate(1.4deg); }
.thumb:not([style*="url"]) { filter: grayscale(1); opacity: .75; }
.spot-item .meta { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.spot-item .name { font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-item .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

.map-wrap { flex: 1; position: relative; min-width: 0; z-index: 0; isolation: isolate; }
#map { position: absolute; inset: 0; background: var(--map-bg); }
#map.adding, #map.adding .leaflet-grab { cursor: crosshair; }
.leaflet-container { font: inherit; background: var(--map-bg); }
/* Fonds de carte : « Carnet » (OpenStreetMap passé à la teinte papier) et « Nuit » */
.tiles-vintage { filter: sepia(.4) saturate(.8) hue-rotate(-8deg) contrast(.96) brightness(1.03); }
.tiles-dark { filter: invert(1) hue-rotate(165deg) saturate(.6) brightness(.85) contrast(.9); }
.leaflet-control-layers, .leaflet-bar {
  background: var(--paper-2) !important; color: var(--ink) !important;
  border: 1.5px solid var(--bd) !important; border-radius: var(--radius-sm) !important; box-shadow: 2px 2px 0 var(--hard) !important;
}
.leaflet-bar a { background: transparent !important; color: var(--ink) !important; border-color: var(--bd-soft) !important; }
.leaflet-bar a:first-child { border-radius: 2px 2px 0 0 !important; }
.leaflet-bar a:last-child { border-radius: 0 0 2px 2px !important; }
.leaflet-control-layers-toggle { border-radius: 2px; }
.leaflet-control-layers label { font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 13.5px; margin: 2px 0; color: var(--ink); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--paper-2) 85%, transparent) !important; color: var(--muted) !important; font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--muted) !important; }

.legend {
  position: absolute; left: 14px; bottom: calc(22px + var(--sab)); z-index: 500;
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center; padding: 7px 11px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  background: var(--paper-2); border: 1.5px solid var(--bd); border-radius: var(--radius-sm); box-shadow: 2px 2px 0 var(--hard);
}
.legend::before { content: "Légende"; font-weight: 600; color: var(--ink); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; background: var(--unknown); flex: none; border: 1.5px solid var(--pin-ring); }
.s-libre { background: var(--ok); }
.s-surveille { background: var(--danger); }
.s-incertain { background: var(--warn); }
.s-inconnu { background: var(--unknown); }

.fab-list { display: none; position: absolute; top: 12px; left: 12px; z-index: 600; }
.fab-add { display: none; position: absolute; right: 14px; bottom: calc(86px + var(--sab)); z-index: 600; min-height: 48px; padding: 0 20px; font-size: 15px; }
.fab-locate {
  position: absolute; right: 14px; bottom: calc(26px + var(--sab)); z-index: 600;
  width: 46px; height: 46px; min-height: 0; padding: 0;
}
.fab-locate svg { width: 22px; height: 22px; }
.add-banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 700; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 12px; white-space: nowrap;
  background: var(--green); color: var(--on-green); font-weight: 600; font-size: 14px;
  padding: 7px 8px 7px 14px; border: 1.5px solid var(--bd); border-radius: var(--radius-sm); box-shadow: 3px 3px 0 var(--hard);
}
.add-banner .btn { background: var(--paper-2); color: var(--ink); }

/* Marqueurs : punaises. La couleur dit la surveillance ; en pointillés = lieu en attente de validation */
.pin-wrap { background: none; border: none; }
.pin {
  position: relative; display: block; width: 20px; height: 20px; margin: 0; border-radius: 50%;
  border: 2.5px solid var(--pin-ring); background: var(--unknown);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, .35);
  transition: transform .12s;
}
.pin::after { content: ""; position: absolute; left: 3px; top: 2px; width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .55); }
.pin-wrap:hover .pin { transform: scale(1.2); }
.pin.s-libre { background: var(--ok); }
.pin.s-surveille { background: var(--danger); }
.pin.s-incertain { background: var(--warn); }
.pin.s-inconnu { background: var(--unknown); }
.pin.lc-pending, .pin.lc-rejected { background: var(--paper-2) !important; border: 2.5px dashed var(--green); }
.pin.lc-pending::after, .pin.lc-rejected::after { display: none; }
.pin.lc-rejected { border-color: var(--danger); opacity: .85; }
.pin.temp { background: var(--green); animation: ping 1.4s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(28, 122, 74, .6); } 100% { box-shadow: 0 0 0 16px rgba(28, 122, 74, 0); } }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: var(--green-3); border-radius: 6px; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: var(--green); color: var(--on-green); font-family: var(--mono); font-weight: 600; font-size: 12.5px;
  border: 2px solid var(--pin-ring); border-radius: 3px; box-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
}
.tag-status {
  margin-left: 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 0 5px;
  border-radius: 2px; border: 1.5px solid; transform: rotate(-2deg); display: inline-block;
}
.tag-status.pending { color: var(--green-text); }
.tag-status.rejected { color: var(--danger-ink); }
.notice { border: 1.5px solid var(--bd); border-left: 5px solid var(--green); background: var(--green-3); padding: 11px 14px; margin: 14px 0; font-size: 14px; }
.notice.bad { border-left-color: var(--danger); background: rgba(191, 59, 40, .1); }

/* ---------- Fiche d'un lieu ---------- */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--paper-2) var(--grain); border-left: 2px solid var(--bd);
  z-index: 1000; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  animation: slidein .2s ease-out;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { display: none; }
.drawer-inner { padding: 18px 22px calc(48px + var(--sab)); }
.drawer-top {
  display: flex; align-items: flex-start; gap: 10px;
  position: sticky; top: -18px; z-index: 3; margin: -18px -22px 0; padding: 18px 22px 12px;
  background: var(--paper-2); border-bottom: 1.5px dashed var(--bd-soft);
}
.drawer-top .title-wrap { flex: 1; min-width: 0; }
.drawer-top .kicker { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--green-text); margin-bottom: 4px; }
.drawer-top h2 { font-size: 31px; overflow-wrap: anywhere; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; align-items: center; }
/* étiquette de bagage (catégorie) */
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 20px;
  border: 1.5px solid var(--bd); border-radius: 2px 9px 9px 2px; background: var(--paper-3);
  font-size: 11.5px; font-weight: 600; color: var(--ink); text-transform: uppercase; letter-spacing: .06em;
}
.chip::before { content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border: 1.5px solid var(--bd); border-radius: 50%; background: var(--paper-2); }
/* tampon (surveillance) */
.chip.status {
  padding: 3px 10px; border: 2px solid var(--stamp, var(--unknown)); border-radius: 3px; background: transparent;
  color: var(--stamp, var(--unknown)); letter-spacing: .1em; transform: rotate(-2.5deg);
  box-shadow: inset 0 0 0 1.5px var(--paper-2), inset 0 0 0 2.5px var(--stamp, var(--unknown));
}
.chip.status::before, .chip.status .dot { display: none; }
.chip.st-libre { --stamp: var(--ok-ink); }
.chip.st-surveille { --stamp: var(--danger-ink); }
.chip.st-incertain { --stamp: var(--warn-ink); }
.chip.st-inconnu { --stamp: var(--unknown-ink); }
.byline { font-size: 13px; color: var(--muted); }
.desc { white-space: pre-wrap; margin: 14px 0; overflow-wrap: anywhere; color: var(--ink); }
.coords { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.coords code { background: var(--paper-3); border: 1.5px solid var(--bd); padding: 4px 8px; border-radius: 2px; font-size: 12.5px; color: var(--ink); }
.section { margin-top: 26px; padding-top: 18px; border-top: 1.5px dashed var(--bd); }
.section h3 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink); font-weight: 600;
  margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;
}
.rating-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avg { font-family: var(--display); font-size: 46px; font-weight: 700; line-height: 1; }
.avg small { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; font-size: 19px; line-height: 1; }
.stars .star { color: var(--bd-soft); }
.stars .star.on { color: var(--green); }
.stars.input .star { background: none; border: 0; padding: 2px; cursor: pointer; font-size: 31px; color: var(--bd-soft); }
.stars.input .star.on { color: var(--green); }
.stars.sm { font-size: 13px; }
.vote-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.visit-box { background: var(--paper-3); border: 1.5px solid var(--bd); border-radius: var(--radius); padding: 14px; }
.visit-box.done { border-left: 6px solid var(--ok); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 2px 2px 6px; }
/* photos collées façon tirages */
.gallery .ph {
  position: relative; aspect-ratio: 1; padding: 4px; overflow: hidden; background: #fbf9f1; cursor: zoom-in;
  border: 1px solid var(--bd-soft); box-shadow: 2px 3px 0 var(--hard); transform: rotate(-1.4deg);
}
.gallery .ph:nth-child(even) { transform: rotate(1.3deg); }
.gallery .ph:nth-child(3n) { transform: rotate(-.4deg); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comment { padding: 12px 0; border-bottom: 1.5px dashed var(--bd-soft); }
.comment:last-child { border-bottom: 0; }
.comment .head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.comment .head b { color: var(--ink); font-weight: 600; }
.comment .head .del { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12.5px; padding: 4px 2px; }
.comment .head .del + .del { margin-left: 10px; }
.comment .head .del:hover { color: var(--danger); }
.comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.level-badge {
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 2px; text-transform: uppercase; letter-spacing: .08em;
  border: 1.5px solid var(--bd-soft); color: var(--muted);
}
.level-badge.lv-confirme { color: #8a6d12; border-color: #b99a3a; }
.level-badge.lv-expert { color: var(--green-text); border-color: var(--green); }
.level-badge.role-admin { color: var(--danger); border-color: var(--danger); }
.level-badge.role-moderator { color: var(--green-text); border-color: var(--green); background: var(--green-3); }
.level-badge.role-banned { background: var(--danger); border-color: var(--danger); color: #fff; margin-left: 6px; }

/* ---------- Pages (historique, profil, modération) ---------- */
.view-page {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 34px max(16px, var(--sar)) 56px max(16px, var(--sal));
  background-image: var(--topo), var(--grain); background-size: 520px 520px, 180px 180px;
}
.page { max-width: 780px; margin: 0 auto; }
.page > h1 { font-size: 46px; margin-bottom: 10px; }
.page > h1::after { content: ""; display: block; width: 64px; height: 6px; margin-top: 12px; background: var(--green); border: 1.5px solid var(--bd); }
.page .lead { color: var(--muted); margin: 0 0 24px; max-width: 56ch; }
.card { background: var(--paper-2); border: 1.5px solid var(--bd); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: 4px 4px 0 var(--hard); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-bottom: 24px; border: 1.5px solid var(--bd); border-radius: var(--radius); background: var(--paper-2); box-shadow: 4px 4px 0 var(--hard); }
.stat { padding: 14px 16px; border-right: 1.5px dashed var(--bd-soft); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-family: var(--display); font-size: 36px; font-weight: 700; line-height: 1.05; color: var(--green-text); }
.stat span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.timeline h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink); margin: 30px 0 12px; font-weight: 600; padding-bottom: 6px; border-bottom: 2px solid var(--bd); }
.visit-card { display: flex; gap: 14px; padding: 12px; background: var(--paper-2); border: 1.5px solid var(--bd); border-radius: var(--radius); margin-bottom: 12px; box-shadow: 3px 3px 0 var(--hard); }
.visit-card .thumb { width: 76px; height: 76px; }
.visit-card .info { flex: 1; min-width: 0; }
.visit-card .title { font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.15; }
.visit-card .title a { color: var(--ink); }
.visit-card .title a:hover { color: var(--green-text); }
.visit-card .date { color: var(--muted); font-size: 12.5px; }
.visit-card .note { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.visit-card .actions { display: flex; flex-direction: column; gap: 6px; }
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.profile-head h1 { font-size: 38px; }
.gate { text-align: center; padding: 72px 16px; color: var(--muted); }
.gate .btn { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mod-h { font-size: 26px; margin: 34px 0 14px; }
.card.report .note { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.report-img { max-width: 220px; max-height: 160px; border-radius: 2px; margin-top: 8px; display: block; border: 1.5px solid var(--bd); }
.log-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1.5px dashed var(--bd-soft); font-size: 13.5px; }
.log-row:last-child { border-bottom: 0; }
.log-row .when { color: var(--muted); white-space: nowrap; flex: none; font-size: 12px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1.5px dashed var(--bd-soft); flex-wrap: wrap; }
.user-row:last-child { border-bottom: 0; }
.user-row .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 180px; }
.user-row select { width: auto; min-width: 150px; }
.user-row.banned { opacity: .6; }

/* ---------- Fenêtres, messages, visionneuse ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(12, 20, 14, .66); z-index: 3000;
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper-2) var(--grain); border: 2px solid var(--bd); border-radius: 4px; box-shadow: 6px 6px 0 var(--hard);
  width: min(470px, 100%); max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 24px;
}
.modal.wide { width: min(600px, 100%); }
.modal h2 { font-size: 30px; margin-bottom: 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--bd); border-radius: var(--radius-sm); margin: 14px 0 4px; overflow: hidden; box-shadow: 2px 2px 0 var(--hard); }
.seg button { background: var(--paper-2); border: 0; padding: 10px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button + button { border-left: 1.5px solid var(--bd); }
.seg button.on { background: var(--green); color: var(--on-green); }
.rules { padding-left: 20px; }
.rules li { margin: 9px 0; }
.rules .warn-box, .warn-box { border: 1.5px solid var(--bd); border-left: 6px solid var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--paper-2)); padding: 11px 14px; margin: 14px 0; font-size: 14px; }
.toasts {
  position: fixed; bottom: calc(24px + var(--sab)); left: 50%; transform: translateX(-50%); z-index: 4000;
  display: grid; gap: 10px; width: min(400px, calc(100% - 24px)); pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink); border-left: 7px solid var(--green);
  border-radius: 3px; padding: 11px 14px; font-size: 14px; font-weight: 500; box-shadow: 3px 3px 0 rgba(0, 0, 0, .35); animation: fade .2s;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.lightbox {
  position: fixed; inset: 0; background: rgba(8, 12, 9, .95); z-index: 3500; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); gap: 12px; color: #ece7d6;
}
.lightbox img { max-width: 100%; max-height: 74vh; max-height: 74dvh; border: 6px solid #fbf9f1; box-shadow: 6px 6px 0 rgba(0, 0, 0, .5); }
.lightbox .cap { text-align: center; color: #b9c2b4; font-size: 14px; }
.lightbox .row { justify-content: center; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid var(--bd-soft); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 7px max(18px, var(--sar)) calc(7px + var(--sab)) max(18px, var(--sal));
  font-size: 11px; color: var(--muted); background: var(--paper-2); border-top: 2px solid var(--bd);
  text-transform: uppercase; letter-spacing: .08em;
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--ink); }

/* =====================================================================
   Tablette / petit écran : liste en panneau coulissant, fiche en feuille
   ===================================================================== */
@media (max-width: 1000px) {
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: min(380px, 100%); z-index: 900;
    transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  }
  .sidebar.open { transform: none; box-shadow: 8px 0 0 rgba(0, 0, 0, .25); }
  .only-mobile { display: inline-grid !important; }
  .fab-list { display: inline-flex; }
  .fab-add { display: inline-flex; }
  .legend { bottom: calc(86px + var(--sab)); left: 14px; right: 74px; font-size: 10.5px; gap: 10px; }
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: min(80vh, calc(100% - 56px)); height: min(80dvh, calc(100% - 56px));
    border-left: 0; border-top: 2px solid var(--bd); border-radius: 0;
    animation: slideup .26s cubic-bezier(.2, .8, .2, 1); transition: transform .2s;
  }
  @keyframes slideup { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-handle { display: block; position: sticky; top: 0; z-index: 4; height: 26px; background: var(--paper-2); }
  /* poignée : un morceau de ruban adhésif */
  .sheet-handle::after {
    content: ""; position: absolute; left: 50%; top: 5px; width: 76px; height: 17px; margin-left: -38px;
    background: var(--tape); transform: rotate(-2deg);
    clip-path: polygon(0 0, 100% 0, 97% 50%, 100% 100%, 0 100%, 3% 50%);
  }
  .drawer-top { top: 26px; margin-top: -4px; padding-top: 4px; }
  .drawer-inner { padding-top: 4px; }
  .leaflet-control-zoom { display: none; }
}

/* =====================================================================
   Téléphone (iPhone) : barre d'onglets en bas, fenêtres en feuilles
   ===================================================================== */
@media (max-width: 760px) {
  body { padding-bottom: calc(var(--tabbar-h) + var(--sab-tab)); }
  .topbar { gap: 8px; padding-left: max(14px, var(--sal)); padding-right: max(14px, var(--sar)); }
  .topbar-right { margin-left: auto; }
  .brand-name { font-size: 30px; }
  .user-chip { padding: 3px; }
  .user-chip .uname { display: none; }
  .userarea .btn.ghost { display: none; } /* « Déconnexion » est accessible depuis le profil */

  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000; flex: none; gap: 0;
    height: calc(var(--tabbar-h) + var(--sab-tab)); padding: 0 0 var(--sab-tab) 0;
    background: var(--paper-2); border-top: 4px double var(--bd);
  }
  .tabs a {
    flex: 1; flex-direction: column; justify-content: center; gap: 3px; padding: 0 4px; border-radius: 0; border: 0;
    border-right: 1.5px dashed var(--bd-soft);
    font-size: 9.5px; letter-spacing: .1em;
  }
  .tabs a:last-child { border-right: 0; }
  .tabs a svg { display: block; }
  .tabs a:hover { background: transparent; }
  .tabs a.active { background: var(--green); color: var(--on-green); box-shadow: none; }
  .footer { display: none; }

  .side-head { padding-top: 18px; }
  .view-page { padding-top: 22px; }
  .page > h1 { font-size: 36px; }
  .card { padding: 16px; box-shadow: 3px 3px 0 var(--hard); }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .visit-card { flex-wrap: wrap; }
  .visit-card .actions { flex-direction: row; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(3n) { border-right: 0; }
  .stat:nth-child(n+4) { border-top: 1.5px dashed var(--bd-soft); }
  .legend { display: none; }
  .fab-add { bottom: 72px; }      /* la carte s'arrête déjà au-dessus de la barre d'onglets */
  .fab-locate { bottom: 14px; }
  .toasts { bottom: calc(var(--tabbar-h) + var(--sab-tab) + 14px); }

  /* Fenêtres : feuilles qui montent du bas */
  .modal-back { place-items: end center; padding: 0; }
  .modal {
    width: 100%; max-width: none; border-radius: 0; border-width: 2px 0 0 0; box-shadow: none;
    max-height: 92vh; max-height: 92dvh; padding: 22px 18px calc(22px + var(--sab));
    animation: slideup .26s cubic-bezier(.2, .8, .2, 1);
  }
  .modal.wide { width: 100%; }
  .modal .actions .btn { flex: 1; }
  .lightbox img { max-height: 70dvh; }
  .user-row select { flex: 1; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3n) { border-right: 1.5px dashed var(--bd-soft); }
  .stat:nth-child(2n) { border-right: 0; }
  .vote-row .btn { font-size: 13.5px; padding-left: 8px; padding-right: 8px; }
}

@media (hover: none) {
  .pin-wrap:hover .pin { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
