:root {
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --border: #d9d9d9;
  --bg: #ffffff;
  --primary: #c1121f;
  --primary-dark: #8f0d17;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
}
.topnav { display: flex; align-items: center; gap: 12px; }
.topnav a { color: var(--text); font-size: .9rem; white-space: nowrap; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs a {
  flex: 1; padding: 8px 4px; text-align: center; font-size: .9rem; font-weight: 600;
  color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--primary); }
.topbar h1 { margin: 0; font-size: 1rem; line-height: 1.2; }
@media (max-width: 480px) {
  .topbar { padding: 6px 12px; }
  .topbar h1 { font-size: .9rem; }
}
.map-wrap { position: relative; flex: 1; min-height: 0; }
#map { height: 100%; }
body.adding #map { cursor: crosshair; }
.footer { padding: 4px 16px; font-size: .75rem; text-align: center; }
.footer a { color: var(--muted); }

.btn {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font: inherit; font-size: .95rem; cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--primary); border-color: var(--primary); }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-icon { border: 0; background: none; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }

/* Couleurs par type d'action */
.c-manifestation { background: #d62828; }
.c-blocage { background: #f77f00; }
.c-rassemblement { background: #7b2cbf; }
.c-ag { background: #2a9d8f; }
.c-tractage { background: #1d70b8; }
.c-violences_policieres { background: #111111; }
.c-autre { background: #555555; }

.pin { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); }
.pin-new { border-radius: 50%; background: #111; border: 3px solid #ffd60a; box-shadow: 0 0 0 2px #111; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; color: #fff; font-size: .75rem; font-weight: 600; }

.legend {
  position: absolute; left: 8px; bottom: 24px; z-index: 500; max-width: calc(100% - 16px);
  padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, .95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); font-size: .75rem;
}
.legend summary { cursor: pointer; font-weight: 700; font-size: .8rem; }
.legend[open] summary { margin-bottom: 4px; }
#legend { display: flex; flex-wrap: wrap; gap: 4px 10px; }
@media (min-width: 768px) {
  .legend { max-width: calc(100% - 300px); }
  .legend summary { display: none; } /* toujours ouvert sur grand écran */
}

/* Action principale : bouton flottant, à portée de pouce */
.fab {
  position: absolute; right: 12px; bottom: 28px; z-index: 600;
  padding: 12px 18px; border-radius: 999px; font-size: 1rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}
body.adding .fab { display: none; }

.legend label { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: .75rem; cursor: pointer; }
.legend input { display: inline; width: auto; margin: 0; padding: 0; }
.legend label.off { opacity: .45; text-decoration: line-through; }
.legend .swatch { margin-right: 0; }

.witness summary { cursor: pointer; font-weight: 600; font-size: .85rem; }
.witness .note { font-size: .8rem; color: var(--muted); }
.witness label { margin: 6px 0; font-size: .85rem; }
.witness .check { display: flex; gap: 6px; align-items: flex-start; }
.witness .check input { width: auto; margin-top: 3px; }

/* Fiche plus haute que l'écran (formulaire témoin ouvert) : on fait défiler la fiche. */
.popup { max-height: min(60vh, 520px); overflow-y: auto; padding-right: 4px; }

.popup h3 { margin: 6px 0 4px; font-size: 1rem; }
.popup .when { margin: 0 0 6px; color: var(--muted); font-size: .85rem; }
.popup .desc { margin: 0 0 8px; white-space: pre-line; overflow-wrap: anywhere; }
.popup .contact { display: inline-block; margin-bottom: 8px; }
.report summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.report select { margin: 6px 0; }

.panel {
  position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; max-height: 65vh; overflow-y: auto;
  padding: 12px 16px 16px; background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .25);
}
@media (min-width: 768px) {
  .panel { left: auto; top: 60px; right: 16px; bottom: 16px; width: 380px; max-height: none; border-radius: 12px; }
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
fieldset { border: 0; padding: 0; margin: 12px 0; }
legend { font-weight: 700; padding: 0; }
label { display: block; margin: 10px 0; font-size: .9rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 16px; /* 16px : évite le zoom auto sur iPhone */
}
.row { display: flex; gap: 6px; }
.row input { margin-top: 0; }
.hint, .warning { font-size: .85rem; color: var(--muted); }
.warning { color: #8a4b00; }
.place-status { font-weight: 600; color: var(--muted); }
.place-status.ok { color: #1b7f3b; }
.geo-results { list-style: none; padding: 0; margin: 6px 0; }
.geo-result { display: block; width: 100%; text-align: left; padding: 8px; border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; cursor: pointer; }
.form-error { color: var(--primary); font-weight: 600; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.toast {
  position: fixed; z-index: 1100; top: 64px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 8px; background: #1a1a1a; color: #fff;
}

.date-filter {
  position: absolute; top: 10px; right: 8px; z-index: 500; max-width: calc(100% - 70px);
  padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, .95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); font-size: .85rem;
}
.date-filter label { margin: 0; font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.date-filter select, .date-filter input { margin-top: 0; padding: 4px 6px; width: auto; }
.date-custom { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.date-custom[hidden] { display: none !important; }
