:root {
  --fond: #0b1020;
  --fond2: #111831;
  --carte: #161f3d;
  --carte2: #1d2850;
  --ligne: #26325e;
  --texte: #e8ecf8;
  --doux: #93a0c6;
  --bleu: #3b82f6;
  --bleu-clair: #7fb0ff;
  --orange: #ff8a1f;
  --orange-clair: #ffb36b;
  --rouge: #ff3b4e;
  --vert: #2ed47a;
  --rayon: 16px;
  --haut: env(safe-area-inset-top, 0px);
  --basz: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fond); color: var(--texte); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--bleu-clair); }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
#app > main { flex: 1; min-height: 0; }

/* --- En-tête --- */
.haut { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--haut)) 14px 10px; background: linear-gradient(180deg, #0e1530, var(--fond)); border-bottom: 1px solid var(--ligne); }
.marque { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .3px; font-size: 18px; user-select: none; }
.logo { width: 28px; height: 28px; color: var(--orange); filter: drop-shadow(0 0 8px #ff8a1f55); }
.etat { margin-left: auto; display: flex; align-items: center; gap: 7px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 999px; padding: 6px 12px 6px 9px; font-size: 13px; }
.etat i { width: 10px; height: 10px; border-radius: 50%; background: var(--doux); box-shadow: 0 0 0 3px #93a0c633; }
.etat.orange i { background: var(--orange); box-shadow: 0 0 0 3px #ff8a1f44, 0 0 12px var(--orange); animation: pouls 2s infinite; }
.etat.bleu i { background: var(--bleu); box-shadow: 0 0 0 3px #3b82f644, 0 0 12px var(--bleu); animation: pouls 2s infinite; }
.etat small { color: var(--doux); }
@keyframes pouls { 50% { box-shadow: 0 0 0 6px transparent, 0 0 4px currentColor; } }
.sos-bouton { background: var(--rouge); border: 0; color: #fff; font-weight: 900; letter-spacing: 1px; border-radius: 12px; padding: 8px 12px; box-shadow: 0 4px 18px #ff3b4e55; }
.sos-bouton.actif { animation: clignote 1s infinite; }
@keyframes clignote { 50% { background: #fff; color: var(--rouge); } }
.bandeau-sos { background: var(--rouge); color: #fff; padding: 10px 14px; display: flex; gap: 10px; align-items: center; font-weight: 600; }
.bandeau-sos button { margin-left: auto; background: #fff; color: var(--rouge); border: 0; border-radius: 10px; padding: 6px 10px; font-weight: 800; }

/* --- Navigation --- */
.bas { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--fond2); border-top: 1px solid var(--ligne); padding-bottom: var(--basz); }
.bas a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; text-decoration: none; color: var(--doux); font-size: 11.5px; }
.bas a svg { width: 23px; height: 23px; }
.bas a.on { color: var(--texte); }
.bas a.on svg { color: var(--orange); }
.pastille { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--orange); color: #111; font: 700 11px/17px system-ui; text-align: center; padding: 0 4px; font-style: normal; }

main { overflow: hidden; position: relative; }
.page { height: 100%; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.titre { font-size: 22px; font-weight: 800; margin: 4px 0 12px; }
.sous { color: var(--doux); margin: -6px 0 14px; }
.carte-bloc { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px; margin-bottom: 12px; }
.carte-bloc h3 { margin: 0 0 6px; font-size: 16px; }
.ligne { display: flex; align-items: center; gap: 10px; }
.ligne > .grand { flex: 1; min-width: 0; }
.doux { color: var(--doux); }
.petit { font-size: 12.5px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--ligne); background: var(--carte2); border-radius: 12px; padding: 10px 14px; font-weight: 600; text-decoration: none; color: var(--texte); }
.btn svg { width: 18px; height: 18px; }
.btn.plein { background: var(--orange); border-color: var(--orange); color: #1a0d00; }
.btn.bleu { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.btn.rouge { background: transparent; border-color: var(--rouge); color: var(--rouge); }
.btn.large { width: 100%; }
.btn:disabled { opacity: .5; }
.champ { width: 100%; background: var(--fond2); border: 1px solid var(--ligne); border-radius: 12px; padding: 12px 14px; outline: none; }
.champ:focus { border-color: var(--orange); }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vide { text-align: center; color: var(--doux); padding: 40px 20px; }
.vide svg { width: 56px; height: 56px; color: var(--ligne); }

/* --- Conversation --- */
.discussion { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.disc-tete { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--ligne); background: var(--fond2); }
.disc-tete .retour { background: none; border: 0; padding: 4px; color: var(--texte); }
.disc-tete .retour svg { width: 22px; height: 22px; }
.disc-tete b { display: block; }
.fil { overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 84%; align-self: flex-start; background: var(--carte); border: 1px solid var(--ligne); border-radius: 16px 16px 16px 6px; padding: 8px 11px 6px; position: relative; }
.msg.anim { animation: arrive .25s ease-out; }
.msg.moi { align-self: flex-end; background: #2a2340; border-color: #4a3a5e; border-radius: 16px 16px 6px 16px; }
.msg.sos { border: 2px solid var(--rouge); background: #3a1020; }
.msg.pin { border-style: dashed; }
@keyframes arrive { from { transform: translateY(6px); opacity: 0; } }
.msg .qui { font-size: 12.5px; font-weight: 700; color: var(--orange-clair); display: flex; gap: 6px; align-items: center; }
.msg .qui .verif { color: var(--vert); font-weight: 900; }
.msg .texte { white-space: pre-wrap; word-wrap: break-word; }
.msg .meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--doux); margin-top: 3px; justify-content: flex-end; }
.msg img, .msg video { display: block; max-width: 100%; border-radius: 10px; margin: 4px 0; background: #000; }
.msg img.mini { image-rendering: auto; filter: saturate(1.05); }
.msg audio { width: 230px; max-width: 100%; height: 36px; margin-top: 4px; }
.chemin { display: inline-flex; gap: 2px; }
.chemin i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.chemin i.ble { background: var(--bleu); }
.chemin i.net { background: var(--orange); }
.chemin i.paquet { background: var(--vert); }
.attente { font-size: 12px; color: var(--orange-clair); }
.raccourcis { display: flex; gap: 8px; padding: 6px 12px; overflow-x: auto; scrollbar-width: none; }
.raccourcis button { flex: none; background: var(--carte); border: 1px solid var(--ligne); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px); border-top: 1px solid var(--ligne); background: var(--fond2); }
.compose textarea { flex: 1; resize: none; max-height: 120px; min-height: 42px; background: var(--fond); border: 1px solid var(--ligne); border-radius: 20px; padding: 10px 14px; outline: none; }
.rond { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--ligne); background: var(--carte); display: grid; place-items: center; color: var(--texte); }
.rond svg { width: 20px; height: 20px; }
.rond.plein { background: var(--orange); border-color: var(--orange); color: #1a0d00; }
.rond.enreg { background: var(--rouge); border-color: var(--rouge); color: #fff; animation: clignote 1s infinite; }
.limite { font-size: 11px; color: var(--doux); padding: 0 14px 4px; }

/* --- Listes --- */
.liste { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; padding: 11px 12px; text-align: left; width: 100%; color: var(--texte); }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; position: relative; }
.avatar.orange { background: linear-gradient(135deg, #ff9a3d, #e5660a); }
.avatar.bleu { background: linear-gradient(135deg, #5b9bff, #2563eb); }
.avatar.gris { background: #3a4570; }
.avatar.salon { background: linear-gradient(135deg, #8b5cf6, #5b21b6); }
.avatar .tag { position: absolute; right: -3px; bottom: -3px; font-size: 13px; }
.item .grand b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .grand span { display: block; color: var(--doux); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--ligne); color: var(--doux); white-space: nowrap; }
.badge.orange { border-color: var(--orange); color: var(--orange-clair); }
.badge.bleu { border-color: var(--bleu); color: var(--bleu-clair); }
.badge.vert { border-color: var(--vert); color: var(--vert); }

/* --- Carte --- */
.carte-vue { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: #0d1428; }
.leaflet-container { background: #0d1428; font: inherit; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.85) contrast(.9) saturate(.6); }
.carte-outils { position: absolute; z-index: 500; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 8px; }
.carte-outils .rond { background: var(--fond2); box-shadow: 0 4px 14px #0008; }
.legende { position: absolute; z-index: 500; left: 12px; bottom: 12px; background: #0b1020e6; border: 1px solid var(--ligne); border-radius: 12px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; backdrop-filter: blur(6px); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.noeud-marq { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 4px #0005; display: grid; place-items: center; font: 800 11px system-ui; color: #fff; }
.noeud-marq.orange { background: var(--orange); box-shadow: 0 0 0 6px #ff8a1f33, 0 0 16px var(--orange); }
.noeud-marq.bleu { background: var(--bleu); box-shadow: 0 0 0 6px #3b82f633, 0 0 16px var(--bleu); }
.noeud-marq.moi { background: #fff; border-color: var(--orange); }
.noeud-marq.sos { background: var(--rouge); animation: clignote 0.8s infinite; }
.noeud-marq.stick { border-radius: 6px; }
.pin-marq { font-size: 26px; filter: drop-shadow(0 2px 4px #000a); }
.lien-maille { stroke-dasharray: 4 6; animation: flux 1.2s linear infinite; }
@keyframes flux { to { stroke-dashoffset: -20; } }
#radar { position: absolute; inset: 0; width: 100%; height: 100%; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--carte); color: var(--texte); border: 1px solid var(--ligne); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-control-attribution { background: #0b1020bb !important; color: var(--doux) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--doux) !important; }

/* --- Modale, toasts --- */
.modale { position: fixed; inset: 0; z-index: 1000; background: #02040ccc; display: grid; align-items: end; justify-items: center; backdrop-filter: blur(3px); }
.modale-boite { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--fond2); border: 1px solid var(--ligne); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--basz)); animation: monte .25s ease-out; }
@keyframes monte { from { transform: translateY(40px); opacity: 0; } }
.modale-boite h2 { margin: 0 0 8px; font-size: 19px; }
.toasts { position: fixed; z-index: 1100; left: 50%; transform: translateX(-50%); top: calc(64px + var(--haut)); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--carte2); border: 1px solid var(--ligne); border-left: 4px solid var(--orange); border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 24px #0009; animation: arrive .2s; pointer-events: auto; }
.toast.bleu { border-left-color: var(--bleu); }
.toast.rouge { border-left-color: var(--rouge); }

/* --- Parcours d'accueil --- */
.accueil { height: 100%; display: flex; flex-direction: column; padding: calc(24px + var(--haut)) 22px calc(22px + var(--basz)); max-width: 560px; margin: 0 auto; }
.accueil .etapes { display: flex; gap: 6px; margin-bottom: 26px; }
.accueil .etapes i { flex: 1; height: 4px; border-radius: 4px; background: var(--ligne); }
.accueil .etapes i.on { background: var(--orange); }
.accueil h1 { font-size: 28px; line-height: 1.15; margin: 0 0 10px; }
.accueil p { color: var(--doux); }
.accueil .bas-acc { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.hero-maille { width: 100%; max-width: 320px; margin: 10px auto 18px; display: block; }
.perm { display: flex; gap: 12px; align-items: center; background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.perm .ico { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--carte2); }
.perm .grand b { display: block; }
.perm .grand span { color: var(--doux); font-size: 13px; }
.perm .btn { padding: 8px 12px; font-size: 13px; }
.perm.ok { border-color: #2ed47a66; }
.perm.ok .btn { background: transparent; border-color: var(--vert); color: var(--vert); }
.points-cles { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; }
.points-cles li { display: flex; gap: 10px; align-items: flex-start; }
.points-cles li b { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; background: var(--carte2); }

/* --- Boussole, alerte SOS, repérage --- */
.boussole { display: grid; place-items: center; padding: 10px 0; }
.boussole .cadran { width: 230px; height: 230px; border-radius: 50%; border: 2px solid var(--ligne); position: relative; background: radial-gradient(circle, var(--carte2), var(--fond2)); }
.boussole .fleche { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .25s ease-out; }
.boussole .fleche svg { width: 120px; height: 120px; }
.boussole .dist { font-size: 34px; font-weight: 900; margin-top: 10px; }
.alerte-sos { position: fixed; inset: 0; z-index: 1200; background: radial-gradient(circle, #8a0f1f, #2a0208); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 12px; animation: fondSos 1s infinite; }
@keyframes fondSos { 50% { background: radial-gradient(circle, #c4162c, #4a0410); } }
.alerte-sos h1 { font-size: 44px; margin: 0; }
.reperage { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; color: #000; font-size: 28px; font-weight: 900; animation: strobo .5s steps(1) infinite; }
@keyframes strobo { 0% { background: #fff; } 50% { background: var(--orange); } }
.qr-boite { background: #fff; border-radius: 16px; padding: 14px; width: max-content; margin: 10px auto; }
.qr-boite img, .qr-boite svg { display: block; width: 230px; height: 230px; }
.scan video { width: 100%; border-radius: 14px; background: #000; }
.interrupteur { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--ligne); position: relative; flex: none; transition: .2s; }
.interrupteur::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.interrupteur:checked { background: var(--orange); }
.interrupteur:checked::after { left: 21px; }
.reglage { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--ligne); }
.reglage:last-child { border-bottom: 0; }
.reglage .grand span { display: block; color: var(--doux); font-size: 12.5px; }
.seg { display: flex; background: var(--fond2); border: 1px solid var(--ligne); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 4px; border-radius: 9px; font-size: 12.5px; color: var(--doux); }
.seg button.on { background: var(--carte2); color: var(--texte); font-weight: 700; }
.stat { text-align: center; }
.stat b { display: block; font-size: 26px; }
.stat span { font-size: 12px; color: var(--doux); }
.schema-maille { width: 100%; height: 190px; display: block; }

/* Mode intégré (IYADOX OS) */
body.integre .haut { padding-top: 10px; }
body.integre #app { max-width: none; }
.carte-bloc .grand > b, .carte-bloc .grand > h3 { display: block; }
.carte-bloc .grand > span { display: block; }
.reglage .grand { flex: 1; min-width: 0; }

/* --- Réseau social --- */
.actions-pub { display: flex; gap: 6px; margin-top: 10px; border-top: 1px solid var(--ligne); padding-top: 8px; }
.actions-pub button { flex: 1; background: none; border: 0; padding: 7px 4px; border-radius: 10px; color: var(--doux); font-size: 13.5px; }
.actions-pub button:hover { background: var(--carte2); }
.actions-pub button.on { color: var(--orange-clair); font-weight: 700; }
.pub a { color: inherit; }
img.avatar { display: block; }
button.carte-bloc { font: inherit; width: 100%; }

/* --- Appels --- */
.ecran-appel { position: fixed; inset: 0; z-index: 1400; background: radial-gradient(circle at 50% 30%, #1d2850, #05070f); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(40px + var(--haut)) 20px calc(34px + var(--basz)); }
.ecran-appel .ap-centre { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 8vh; }
.ecran-appel .ap-centre h2 { margin: 10px 0 0; font-size: 26px; }
.ecran-appel .ap-centre p { margin: 0; color: var(--doux); }
.ecran-appel.en-cours { background: #000; }
#ap-distant { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05070f; }
#ap-local { position: absolute; right: 14px; top: calc(80px + var(--haut)); width: 110px; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; border: 2px solid #fff3; background: #111; z-index: 2; }
.ap-tete { position: relative; z-index: 2; display: flex; gap: 10px; align-items: center; align-self: flex-start; background: #0008; padding: 8px 12px 8px 8px; border-radius: 99px; backdrop-filter: blur(6px); }
.ap-boutons { position: relative; z-index: 2; display: flex; gap: 18px; }
.ap-rond { width: 62px; height: 62px; border-radius: 50%; border: 0; background: #ffffff26; color: #fff; font-size: 24px; backdrop-filter: blur(6px); }
.ap-rond.rouge { background: var(--rouge); }
.ap-rond.vert { background: var(--vert); }
.ap-rond.off { background: #fff; color: #111; }
.ap-rond.on { background: var(--orange); }
