/* ============================================================
   iter — Anthropotech Lab
   © 2026 Shams Guettaf. Tous droits réservés.
   Reproduction, modification ou distribution interdites sans
   autorisation écrite préalable. Voir LICENSE.txt.
   ============================================================ */

/* ============================================================
   ITER — Anthropotech Lab N°07
   Direction visuelle dédiée : "architecte futuriste" — fond
   nuit profond, lignes fines, accents lumineux bleu -> vert,
   typographie sans-serif géométrique, glow discret.
   Signature : le tracé qui se dessine, dégradé bleu vers vert.
   ============================================================ */

:root {
  --bg: #0a0e1a;
  --bg-elevated: #0d1220;
  --surface: #11172a;
  --ink: #f3f5f8;
  --ink-dim: #8b93a7;
  --border: rgba(243, 245, 248, 0.10);
  --border-strong: rgba(243, 245, 248, 0.18);

  --blue: #3fb6f5;
  --green: #3ddc97;
  --gradient: linear-gradient(90deg, var(--blue), var(--green));
  --accent: var(--blue);

  --danger: #ef5350;
  --ok: var(--green);

  --radius: 16px;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, 'SF Pro Display', system-ui, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* iter conserve une identité nuit constante, y compris si le
   système est en thème clair — c'est une direction assumée,
   cohérente avec l'og-image et l'icône, pas un oubli. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  background-image:
    radial-gradient(600px 400px at 15% 0%, rgba(63,182,245,0.08), transparent),
    radial-gradient(600px 400px at 100% 30%, rgba(61,220,151,0.06), transparent);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}

h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; margin: 0 0 8px; letter-spacing: -0.01em; }

button {
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  background: none;
  color: inherit;
}

input {
  font-family: var(--font-sans);
  font-size: 16px; /* minimum iOS pour éviter le zoom auto */
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  font-weight: 600;
}

/* ------------------------------------------------------------
   Topbar — wordmark géométrique + icône logo
   ------------------------------------------------------------ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(10,14,26,0.75), transparent);
  pointer-events: none;
}
.topbar * { pointer-events: auto; }
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
}
.topbar-brand img { width: 20px; height: 20px; border-radius: 6px; display: block; flex-shrink: 0; }
.topbar-brand .divider { color: var(--ink-dim); font-weight: 400; }
/* Sur écran étroit, le nom du labo s'efface avant les boutons :
   les actions priment sur l'habillage. */
.topbar-brand .brand-texte { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 460px) {
  .topbar-brand .brand-texte,
  .topbar-brand .divider { display: none; }
}
.topbar-social { display: flex; gap: 8px; flex-shrink: 0; }
.topbar-social button,
.topbar-social .topbar-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(17, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  text-decoration: none;
}
.topbar-social svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------
   Splash screen — signature : tracé au dégradé bleu -> vert
   ------------------------------------------------------------ */
#splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  background-image:
    radial-gradient(700px 500px at 20% 10%, rgba(63,182,245,0.10), transparent),
    radial-gradient(700px 500px at 85% 90%, rgba(61,220,151,0.10), transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.5s ease;
}
#splash svg { width: 160px; height: 100px; }
#splash path.route {
  fill: none;
  stroke: url(#route-gradient);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
  filter: drop-shadow(0 0 6px rgba(63,182,245,0.5));
  animation: draw-route 1.6s ease forwards 0.2s;
}
@keyframes draw-route {
  to { stroke-dashoffset: 0; }
}
#splash .wordmark {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
#splash .citation {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-dim);
  text-align: center;
  max-width: 260px;
  letter-spacing: 0.01em;
}
#splash.hidden { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  #splash path.route { animation: none; stroke-dashoffset: 0; }
}

/* ------------------------------------------------------------
   Boutons de zoom — gros et ronds, utilisables au doigt
   (le contrôle natif de MapLibre fait 29 px de côté)
   ------------------------------------------------------------ */
#zoom-controls {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 44;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#zoom-controls button {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
#zoom-controls button:active { background: rgba(63, 182, 245, 0.25); }
#zoom-controls svg { width: 24px; height: 24px; }

/* ------------------------------------------------------------
   Feuille « Modes Plan »
   ------------------------------------------------------------ */
#modes-plan {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 9, 16, 0.55);
  backdrop-filter: blur(4px);
}
#modes-plan.visible { display: flex; }
.mp-sheet {
  width: 100%;
  max-width: 520px;
  background: rgba(17, 23, 42, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(var(--safe-b) + 24px);
}
.mp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.mp-header h2 { font-size: 22px; margin: 0; }
#mp-close {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
}
#mp-close svg { width: 17px; height: 17px; }

.mp-options { display: flex; gap: 12px; }
.mp-option {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.mp-vignette {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px var(--border);
  background-size: cover;
  background-position: center;
}
.mp-standard {
  background-image:
    linear-gradient(135deg, rgba(63,182,245,0.25), rgba(61,220,151,0.18)),
    repeating-linear-gradient(52deg, #2a3550 0 9px, #202942 9px 20px);
}
.mp-plan {
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.08), rgba(255,255,255,0.08)),
    repeating-linear-gradient(120deg, #d8cfc0 0 8px, #efe8dc 8px 18px);
}
.mp-satellite {
  background-image:
    linear-gradient(150deg, rgba(61,220,151,0.28), transparent),
    repeating-linear-gradient(38deg, #3a4a32 0 11px, #4c5f3f 11px 22px);
}
.mp-option.active .mp-vignette { border-color: var(--blue); }
.mp-label { font-size: 13px; font-weight: 600; color: var(--ink-dim); }
.mp-option.active .mp-label { color: var(--ink); }
.mp-note { font-size: 11px; color: var(--ink-dim); line-height: 1.5; margin: 18px 0 0; }
.mp-erreur {
  font-size: 12px;
  color: var(--danger);
  line-height: 1.5;
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(239, 83, 80, 0.1);
  border: 1px solid rgba(239, 83, 80, 0.3);
}

/* ------------------------------------------------------------
   Point bleu de position — style "GPS live"
   ------------------------------------------------------------ */
.user-dot-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  perspective: 320px;
}
.user-dot-accuracy {
  position: absolute;
  border-radius: 50%;
  background: rgba(63, 182, 245, 0.16);
  border: 1px solid rgba(63, 182, 245, 0.3);
  transition: width 0.3s ease, height 0.3s ease;
}
.user-dot-pulse {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(63, 182, 245, 0.65);
  animation: user-dot-pulse 1.8s ease-out infinite;
}
@keyframes user-dot-pulse {
  0% { transform: scale(0.6); opacity: 0.8; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes user-dot-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.user-dot-core {
  position: relative;
  width: 16px;
  height: 16px;
  animation: user-dot-breathe 1.8s ease-in-out infinite;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  box-shadow: 0 0 8px rgba(63, 182, 245, 0.7);
  z-index: 2;
}
.user-dot-heading {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 26px solid rgba(63, 182, 245, 0.85);
  transform-origin: 50% 100%;
  opacity: 0;
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 0 4px rgba(63,182,245,0.5));
}

/* ------------------------------------------------------------
   Bouton de recentrage — réapparaît quand on quitte le suivi GPS
   ------------------------------------------------------------ */
#btn-recenter {
  position: fixed;
  right: 12px;
  top: calc(50% + 82px);
  z-index: 45;
  width: 56px;
  height: 56px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(17, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
#btn-recenter.visible { display: flex; }
#btn-recenter svg { width: 24px; height: 24px; }


/* ------------------------------------------------------------
   Estompage de l'interface en cas d'inactivité — la carte et
   le point bleu de géolocalisation restent TOUJOURS visibles,
   seuls les éléments d'UI (topbar, contrôles, recentrage)
   s'estompent, comme sur une vraie appli de navigation.
   ------------------------------------------------------------ */
.topbar, #controls, #btn-recenter, #zoom-controls {
  transition: opacity 0.6s ease;
}
body.ui-idle .topbar,
body.ui-idle #controls,
body.ui-idle #btn-recenter,
body.ui-idle #zoom-controls {
  opacity: 0.16;
}
/* La topbar reste cliquable même estompée (pas de pointer-events:none
   dessus) : un bouton comme le sélecteur de style doit répondre au
   premier tap, pas nécessiter un tap de "réveil" avant de fonctionner. */

/* ------------------------------------------------------------
   Signalements terrain
   ------------------------------------------------------------ */
/* Les deux boutons flottants sont regroupés : ils ouvrent
   chacun un panneau, et n'apparaissent que si les droits de la
   personne le justifient. */
#boutons-flottants {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 44;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: opacity 0.6s ease;
}
body.ui-idle #boutons-flottants { opacity: 0.16; }

#boutons-flottants button {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.25);
  transition: transform 0.15s ease, box-shadow 0.25s ease;
}
#boutons-flottants button:active { transform: scale(0.94); }
#boutons-flottants svg { width: 27px; height: 27px; }

#btn-girophare {
  background: rgba(63, 182, 245, 0.92);
  color: #0a0e1a;
  box-shadow: 0 4px 18px rgba(63, 182, 245, 0.4);
}
/* Enregistrement en cours : le girophare pulse, l'information
   reste visible même quand le panneau est replié. */
#btn-girophare.enregistre {
  background: var(--danger);
  animation: girophare-pulse 1.4s ease-in-out infinite;
}
@keyframes girophare-pulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(239, 83, 80, 0.5); }
  50%      { box-shadow: 0 4px 30px rgba(239, 83, 80, 0.95); }
}

#btn-signaler {
  background: rgba(245, 166, 35, 0.92);
  color: #0a0e1a;
  box-shadow: 0 4px 18px rgba(245, 166, 35, 0.4);
}

#feuille-signalement {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 9, 16, 0.55);
  backdrop-filter: blur(4px);
}
#feuille-signalement.visible { display: flex; }
.fs-contenu {
  width: 100%;
  max-width: 520px;
  background: rgba(17, 23, 42, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(var(--safe-b) + 24px);
  max-height: 88vh;
  overflow-y: auto;
}
.fs-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.fs-header h2 { font-size: 22px; margin: 0; flex: 1; }
#fs-close, #fs-retour-etape {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim); background: rgba(255,255,255,0.06); border: 1px solid var(--border);
}
#fs-close svg, #fs-retour-etape svg { width: 17px; height: 17px; }
.fs-position { font-size: 11px; color: var(--ink-dim); margin: 0 0 18px; }
.fs-position.prete { color: var(--green); }
.fs-position.erreur { color: var(--danger); }

.fs-etape { margin-top: 4px; }
.fs-chargement { font-size: 12px; color: var(--ink-dim); padding: 20px 0; text-align: center; }

/* Étape 1 : grille de catégories */
.fs-categories { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.fs-cat-carte {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px; border-radius: 14px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.fs-cat-carte:active { transform: scale(0.96); }
.fs-cat-icone {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #0a0e1a;
}
.fs-cat-nom { font-size: 12px; font-weight: 600; color: var(--ink); text-align: center; line-height: 1.25; }

/* Étape 2 : liste de sous-catégories */
.fs-sous-categories { display: flex; flex-direction: column; gap: 8px; }
.fs-souscat-ligne {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 14px; border-radius: 12px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  text-align: left;
}
.fs-souscat-ligne:active { background: rgba(255,255,255,0.07); }
.fs-souscat-nom { font-size: 13px; font-weight: 600; color: var(--ink); }
.fs-souscat-prio { font-size: 15px; flex-shrink: 0; }


/* Intitulé qui précède les types : le choix vaut envoi, il faut
   que ce soit dit avant que la personne n'appuie. */
.fs-choix-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin: 20px 0 9px;
  font-weight: 700;
}
.fs-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; }
.fs-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.fs-type:active { transform: scale(0.96); }
.fs-type .rond {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #0a0e1a;
}
.fs-type .nom { font-size: 12px; font-weight: 600; color: var(--ink); text-align: center; line-height: 1.25; }

.fs-commentaire { margin-top: 4px; }
.fs-commentaire label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-dim); margin-bottom: 6px;
}
.fs-commentaire input {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-elevated); color: var(--ink);
}
.fs-commentaire input:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63,182,245,0.15);
}
.fs-retour { font-size: 12px; line-height: 1.5; margin: 14px 0 0; min-height: 18px; }
.fs-retour.succes { color: var(--green); }
.fs-retour.erreur { color: var(--danger); }

/* Zone photo de la feuille de signalement */
.fs-photo-zone { margin-top: 14px; }
.fs-photo-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: rgba(255,255,255,0.03);
  color: var(--ink-dim);
  font-size: 13px; font-weight: 600;
}
.fs-photo-btn.remplie { border-style: solid; border-color: var(--green); color: var(--green); }
.fs-photo-btn svg { width: 19px; height: 19px; }
.fs-photo-apercu { margin-top: 10px; position: relative; display: none; }
.fs-photo-apercu.visible { display: block; }
.fs-photo-apercu img {
  width: 100%; max-height: 190px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border);
}
.fs-photo-retirer {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,14,26,0.85); color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
.fs-photo-retirer svg { width: 14px; height: 14px; }

/* Marqueurs de signalement sur la carte */
.marqueur-signalement {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #0a0e1a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  cursor: pointer;
}
.marqueur-signalement.traite { opacity: 0.4; }

/* Bulle d'information : thème sombre, cohérent avec le reste de
   l'interface (le style par défaut de MapLibre est blanc et
   illisible ici). Utilise les variables du thème, pas de valeurs
   figées, pour rester cohérent quand un thème clair est actif
   (page de supervision). */
.maplibregl-popup-content {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--border-strong);
  border-radius: 12px !important;
  padding: 12px 14px !important;
  box-shadow: 0 6px 22px rgba(0,0,0,0.5) !important;
  font-family: var(--font-sans);
}
.maplibregl-popup-tip {
  border-top-color: var(--surface) !important;
  border-bottom-color: var(--surface) !important;
  border-left-color: var(--surface) !important;
  border-right-color: var(--surface) !important;
}
.maplibregl-popup-close-button {
  color: var(--ink-dim) !important;
  font-size: 18px !important;
  padding: 2px 8px !important;
  background: transparent !important;
}
.popup-signalement { font-size: 12px; line-height: 1.55; }
.popup-signalement .ps-titre { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.popup-signalement .ps-meta { color: var(--ink-dim); font-size: 11px; }
.popup-signalement .ps-note { margin-top: 6px; font-style: italic; }
.popup-signalement .ps-statut { margin-top: 6px; color: var(--ink-dim); font-size: 11px; font-weight: 600; }
.popup-signalement .ps-statut-select {
  width: 100%; margin-top: 10px; padding: 8px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  background: var(--bg-elevated); color: var(--ink);
  border: 1px solid var(--border);
}
.popup-signalement .ps-photo img {
  width: 100%; margin-top: 9px; border-radius: 8px; cursor: zoom-in;
  border: 1px solid var(--border);
}
.popup-signalement .ps-supprimer {
  width: 100%; margin-top: 10px; padding: 8px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  background: rgba(239,83,80,0.14);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* ------------------------------------------------------------
   Carte
   ------------------------------------------------------------ */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  filter: saturate(0.9);
}

/* ------------------------------------------------------------
   Panneau d'authentification
   ------------------------------------------------------------ */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--bg);
  background-image:
    radial-gradient(600px 400px at 10% 0%, rgba(63,182,245,0.09), transparent),
    radial-gradient(600px 400px at 100% 100%, rgba(61,220,151,0.08), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}
.auth-card .sub {
  color: var(--ink-dim);
  font-size: 13px;
  margin-bottom: 20px;
}
.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63,182,245,0.15);
}
.btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: var(--gradient);
  color: #06121a;
  font-weight: 700;
  font-size: 15px;
  margin-top: 8px;
}
.btn-primary:focus-visible,
button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.btn-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-dim);
  text-decoration: underline;
}
.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 16px;
}

/* ------------------------------------------------------------
   Onboarding — affiché une fois après la connexion
   ------------------------------------------------------------ */
#onboarding-screen {
  position: fixed;
  inset: 0;
  z-index: 160;
  background: var(--bg);
  background-image:
    radial-gradient(600px 400px at 10% 0%, rgba(63,182,245,0.09), transparent),
    radial-gradient(600px 400px at 100% 100%, rgba(61,220,151,0.08), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.onboarding-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin: 20px 0;
}
.onboarding-card h1 { font-size: 24px; margin: 4px 0 8px; }
.onboarding-intro { font-size: 13px; color: var(--ink-dim); line-height: 1.5; margin-bottom: 20px; }

.onboarding-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 22px; }
.onboarding-item { display: flex; gap: 14px; align-items: flex-start; }
.oi-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--blue);
}
.oi-icon svg { width: 18px; height: 18px; }
.oi-titre { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.oi-desc { font-size: 12px; color: var(--ink-dim); line-height: 1.5; }

.onboarding-strengths {
  background: rgba(61,220,151,0.06);
  border: 1px solid rgba(61,220,151,0.2);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.strength-line {
  font-size: 12px;
  color: var(--green);
  line-height: 1.6;
  padding-left: 14px;
  position: relative;
}
.strength-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

/* ------------------------------------------------------------
   Sélecteur de type de parcours — lignes fines
   ------------------------------------------------------------ */
.type-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 2px;
}
.type-choice {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.type-choice svg { width: 26px; height: 26px; }
.type-choice.active {
  color: var(--ink);
  border-color: var(--border-strong);
  transform: scale(1.08);
}
.type-choice[data-type="voiture"].active {
  background: var(--blue);
  border-color: var(--blue);
  color: #06121a;
  box-shadow: 0 0 0 4px rgba(63,182,245,0.25), 0 0 18px rgba(63,182,245,0.4);
}
.type-choice[data-type="pied"].active {
  background: var(--green);
  border-color: var(--green);
  color: #06121a;
  box-shadow: 0 0 0 4px rgba(61,220,151,0.25), 0 0 18px rgba(61,220,151,0.4);
}

/* ------------------------------------------------------------
   Contrôles d'enregistrement
   ------------------------------------------------------------ */
#controls {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 40;
  padding: 14px 16px calc(var(--safe-b) + 14px);
  background: linear-gradient(to top, rgba(10,14,26,0.9), transparent);
  display: none;
  flex-direction: column;
  gap: 10px;
  animation: controls-apparition 0.22s ease;
}
#controls.visible { display: flex; }
@keyframes controls-apparition {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stats-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 4px;
}
.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stat-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--blue);
}
.stat-circle svg { width: 22px; height: 22px; }
.stat-val {
  font-weight: 700;
  font-size: 13px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.record-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.btn-circle {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}
.btn-record-main {
  width: 76px;
  height: 76px;
  background: rgba(17, 23, 42, 0.85);
  border: 2px solid var(--border-strong);
  box-shadow: 0 0 24px rgba(63,182,245,0.25);
}
.rec-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient);
}
.btn-pause, .btn-stop {
  width: 52px;
  height: 52px;
  background: rgba(17, 23, 42, 0.85);
  border: 1px solid var(--border-strong);
  color: var(--ink);
}
.btn-stop { color: var(--danger); border-color: var(--danger); }
.btn-circle svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------
   Panneau récapitulatif — apparaît après un enregistrement
   terminé : stats détaillées, alternative éventuelle, export
   ------------------------------------------------------------ */
#summary-panel {
  background: rgba(17, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  max-height: 46vh;
  overflow-y: auto;
}
.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.summary-header #summary-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}
.summary-header #summary-close svg { width: 14px; height: 14px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.summary-item {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.summary-val {
  font-weight: 700;
  font-size: 15px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.summary-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  margin-top: 2px;
}
.comparaison-box {
  background: rgba(61, 220, 151, 0.08);
  border: 1px solid rgba(61, 220, 151, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.comparaison-line {
  font-size: 12px;
  color: var(--green);
  line-height: 1.5;
}
.comparaison-box.comparaison-neutre {
  background: rgba(255,255,255,0.03);
  border-color: var(--border);
}
.comparaison-box.comparaison-neutre .comparaison-line {
  color: var(--ink-dim);
}
.export-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.export-label {
  flex: 1;
  font-size: 12px;
  color: var(--ink-dim);
}
.export-row button {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  background: rgba(255,255,255,0.03);
}
.export-row button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ------------------------------------------------------------
   Alerte sécurité conducteur — le rouge réservé à l'urgence
   ------------------------------------------------------------ */
#driver-alert {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(20, 6, 6, 0.96);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  color: #fff;
}
#driver-alert.show { display: flex; }
#driver-alert h2 { font-size: 22px; color: var(--danger); }
#driver-alert p { font-size: 14px; opacity: 0.85; max-width: 320px; }
#driver-alert .choices { display: flex; gap: 12px; margin-top: 8px; }
#driver-alert button {
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 700;
  background: var(--danger);
  color: #fff;
}
#driver-alert button.secondary {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
}


/* ------------------------------------------------------------
   Photos de profil
   ------------------------------------------------------------ */
.pastille-identite {
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: var(--surface);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.pastille-initiales {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}
/* Les initiales disparaissent dès que la photo est chargée */
.pastille-identite.avec-photo .pastille-initiales { display: none; }

/* Pastille dans la barre du haut */
#btn-profil { padding: 0; overflow: hidden; }
#profil-pastille { display: flex; }
#profil-pastille .pastille-identite { border-width: 0; box-shadow: none; }

/* Marqueur de position : le visage remplace le point bleu.
   Inclinaison type "pion de navigation" (Google Maps) : le disque
   est penché en permanence (perspective portée par .user-dot-wrap)
   et pivote sur lui-même selon le cap du téléphone, mis à jour
   dans updateUserMarker() (map.js). Le dégradé en ::after simule
   un reflet lumineux pour l'effet de relief. */
.user-dot-photo {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -17px;
  margin-left: -17px;
  z-index: 3;
  border-radius: 50%;
  border: 3px solid #fff;
  background-size: cover;
  background-position: center;
  box-shadow: 0 6px 14px rgba(6, 9, 16, 0.45), 0 0 10px rgba(63, 182, 245, 0.8);
  transform: rotateX(35deg);
  transform-origin: 50% 65%;
  transition: transform 0.35s ease;
  will-change: transform;
}
.user-dot-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.14) 32%, rgba(255, 255, 255, 0) 58%);
  pointer-events: none;
}

/* Feuille « Mon profil » */
#feuille-profil {
  position: fixed;
  inset: 0;
  z-index: 135;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 9, 16, 0.55);
  backdrop-filter: blur(4px);
}
#feuille-profil.visible { display: flex; }
#fp-close {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim); background: rgba(255,255,255,0.06); border: 1px solid var(--border);
}
#fp-close svg { width: 17px; height: 17px; }

.fp-apercu { display: flex; align-items: center; gap: 18px; margin: 8px 0 20px; }
#fp-pastille .pastille-identite { width: 84px; height: 84px; border-width: 3px; }
#fp-pastille .pastille-initiales { font-size: 30px; }
.fp-actions { display: flex; flex-direction: column; gap: 8px; }
.bt-clair {
  padding: 9px 15px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.04); color: var(--ink);
}
.bt-clair.danger { border-color: rgba(239,83,80,0.4); color: var(--danger); }

/* Auteur d'un signalement dans la bulle */
.popup-signalement .ps-auteur {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 7px;
}
.popup-signalement .ps-auteur .pastille-identite { width: 28px; height: 28px; border-width: 2px; }

/* Bouton de traitement dans la bulle d'un signalement */
.popup-signalement .ps-traiter {
  width: 100%; margin-top: 10px; padding: 8px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  background: rgba(61, 220, 151, 0.14);
  border: 1px solid var(--green);
  color: var(--green);
}

/* ------------------------------------------------------------
   Alerte de géolocalisation — visible sans masquer la carte
   ------------------------------------------------------------ */
/* Deux alertes distinctes : position et fond de carte. Elles
   peuvent survenir ensemble, elles ne doivent donc pas se
   remplacer l'une l'autre. */
#alertes {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 74px);
  transform: translateX(-50%);
  z-index: 46;
  width: calc(100% - 32px);
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#alerte-geoloc, #alerte-carte {
  display: none;
  padding: 12px 15px;
  border-radius: 12px;
  color: #fff;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
#alerte-geoloc { background: rgba(239, 83, 80, 0.95); }
#alerte-carte  { background: rgba(245, 166, 35, 0.95); color: #0a0e1a; }
#alerte-geoloc.visible, #alerte-carte.visible { display: block; }

/* ============================================================
   THÈME CLAIR — opt-in via [data-theme="clair"] sur <html>.
   N'affecte QUE les pages qui l'activent explicitement (la
   supervision) : sans cet attribut, l'identité nuit reste
   inchangée partout ailleurs, y compris sur l'application
   citoyen (index.html).
   ============================================================ */
html[data-theme="clair"] {
  --bg: #f3f5f9;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --ink: #10141f;
  --ink-dim: #5c6579;
  --border: rgba(16, 20, 31, 0.10);
  --border-strong: rgba(16, 20, 31, 0.16);

  --blue: #0d84c9;
  --green: #1a9c6e;
  --gradient: linear-gradient(90deg, var(--blue), var(--green));

  --danger: #d6423d;
}
html[data-theme="clair"] body {
  background-image:
    radial-gradient(600px 400px at 15% 0%, rgba(13,132,201,0.05), transparent),
    radial-gradient(600px 400px at 100% 30%, rgba(26,156,110,0.04), transparent);
}
