/* ============================================================================
 * GO SOS — style (thème MyCellGo : fond bleuté, encre marine, vert d'action, rouge d'alerte)
 *                                                                   build sos-2026-10-30-1
 * ========================================================================== */
:root {
  --fond: #EEF5FD; --fond2: #E2ECF8; --carte: #FFFFFF; --carte2: #F4F8FD;
  --ink: #0F1D33; --ink2: #4C5D78; --ink3: #7D8BA3; --ligne: rgba(15,29,51,.10);
  --vert: #16A34A; --vert-t: #11743A; --vert-fond: #E3F6EA;
  --rouge: #D93A54; --rouge2: #B4233C; --rouge-fond: #FDE8EC;
  --ambre: #C77D12; --bleu: #1760C7; --indigo: #4F46E5;
  --r: 18px; --r-s: 12px; --ombre: 0 1px 2px rgba(15,29,51,.06), 0 10px 28px rgba(15,29,51,.10);
  --ease: cubic-bezier(.22,1,.36,1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-titre: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #0B1426; --fond2: #101C33; --carte: #16253F; --carte2: #1B2C4A; --ink: #E8EEF9; --ink2: #A9B6CC; --ink3: #7788A3; --ligne: rgba(232,238,249,.10);
    --vert-t: #5BD68A; --vert-fond: rgba(22,163,74,.16); --rouge-fond: rgba(217,58,84,.18); --ombre: 0 10px 28px rgba(0,0,0,.35); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.5 var(--font); color: var(--ink); background: var(--fond); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--bleu); }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.evitement { position: absolute; left: -999px; top: 8px; z-index: 99; background: var(--bleu); color: #fff; padding: 10px 14px; border-radius: 10px; }
.evitement:focus { left: 8px; }
.petit { font-size: 13px; color: var(--ink2); }

/* ─── Boutons ─── */
.bt { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 14px; border: 0;
  background: var(--vert); color: #fff; font-weight: 800; text-decoration: none; text-align: center; transition: transform .12s, filter .15s; }
.bt:active { transform: scale(.98); }
.bt.grand { width: 100%; min-height: 56px; font-size: 17px; }
.bt.rouge { background: linear-gradient(135deg, #EF4E5E, var(--rouge2)); }
.bt.second { background: var(--carte); color: var(--ink); border: 1px solid var(--ligne); }
.bt.blanc { background: #fff; color: var(--rouge2); }
.bt.contour { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.75); }
.bt:disabled { opacity: .6; cursor: default; }
.icb { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--carte); font-size: 18px; }
.rond { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center; font-size: 19px; }

/* ─── Écrans d'accueil ─── */
.ecran { min-height: 100%; display: grid; place-items: start center; padding: max(24px, env(safe-area-inset-top)) 16px 32px; }
.accueil { position: relative; width: 100%; max-width: 440px; display: grid; gap: 14px; text-align: center; padding-top: 14px; }
.accueil h1 { margin: 0; font: 900 34px/1.1 var(--font-titre); letter-spacing: -.6px; }
.logo-sos { justify-self: center; width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 14px 34px rgba(217,58,84,.35); }
.promesse { margin: 0; color: var(--ink2); font-size: 17px; }
.choix { display: grid; gap: 10px; margin-top: 6px; }
.retour { position: absolute; left: 0; top: 0; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--carte); font-size: 20px; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); padding: 16px; box-shadow: var(--ombre); text-align: left; display: grid; gap: 10px; }
.carte label { font-weight: 800; }
input { font: inherit; color: var(--ink); background: var(--carte2); border: 1.5px solid var(--ligne); border-radius: 12px; min-height: 48px; padding: 0 14px; width: 100%; }
input:focus { border-color: var(--bleu); outline: none; }
input.code { font: 800 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; text-align: center; text-transform: uppercase; min-height: 60px; }
.err { margin: 0; color: var(--rouge2); font-weight: 700; font-size: 14px; }
.install-carte { text-align: left; background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--ombre); }
.install-carte h2 { margin: 0 0 6px; font-size: 17px; }
.install-carte ol { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 6px; }
.install-carte .code-grand { display: block; margin: 8px 0 4px; font: 900 30px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; color: var(--rouge2); text-align: center; }

/* ─── Application ─── */
.app { min-height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.entete { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--fond) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--ligne); }
.entete img { border-radius: 10px; }
.titre { display: grid; line-height: 1.15; min-width: 0; margin-right: auto; }
.titre b { font: 900 18px var(--font-titre); }
.titre small { color: var(--ink2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etat { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); font-weight: 700; }
.pt { width: 9px; height: 9px; border-radius: 50%; background: var(--ink3); }
.etat.ok .pt { background: var(--vert); box-shadow: 0 0 0 4px var(--vert-fond); }
.etat.ko .pt { background: var(--rouge); }
main { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; margin: 0 auto; }
.vue { display: none; }
.vue.on { display: block; animation: entre .25s var(--ease); }
@keyframes entre { from { opacity: 0; transform: translateY(6px); } }
.groupe { margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); }

/* Bouton SOS */
.sos-zone { display: grid; justify-items: center; gap: 12px; padding: 12px 0 4px; }
.sos { position: relative; width: min(64vw, 236px); aspect-ratio: 1; border-radius: 50%; border: 0; color: #fff; display: grid; place-items: center; align-content: center; gap: 2px;
  background: radial-gradient(circle at 35% 30%, #FF7684, var(--rouge) 55%, var(--rouge2)); box-shadow: 0 18px 44px rgba(217,58,84,.45), inset 0 -8px 20px rgba(0,0,0,.18);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sos b { font: 900 clamp(46px, 14vw, 64px)/1 var(--font-titre); letter-spacing: 2px; }
.sos small { font-weight: 800; font-size: 13px; letter-spacing: .1em; opacity: .92; }
.sos svg { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); transform: rotate(-90deg); pointer-events: none; }
.sos circle { fill: none; stroke-width: 9; }
.sos .fond-anneau { stroke: rgba(217,58,84,.15); }
#sos-anneau { stroke: var(--rouge2); stroke-linecap: round; stroke-dasharray: 691; stroke-dashoffset: 691; transition: stroke-dashoffset .05s linear; }
.sos.appui { transform: scale(.96); }
.sos.envoye { background: radial-gradient(circle at 35% 30%, #4ADE80, var(--vert) 60%, #0F6E56); box-shadow: 0 18px 44px rgba(22,163,74,.45); }
@media (prefers-reduced-motion: no-preference) { .sos:not(.appui):not(.envoye) { animation: respire 2.6s ease-in-out infinite; } }
@keyframes respire { 50% { box-shadow: 0 18px 54px rgba(217,58,84,.6), 0 0 0 14px rgba(217,58,84,.08), inset 0 -8px 20px rgba(0,0,0,.18); } }
.sos-aide { margin: 0; text-align: center; color: var(--ink2); max-width: 340px; }
.urgences { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.urgences a { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--carte); border: 1px solid var(--ligne); color: var(--ink); font-weight: 800; text-decoration: none; }

.tuiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tuile { display: grid; justify-items: start; gap: 2px; padding: 12px; border-radius: var(--r); border: 1px solid var(--ligne); background: var(--carte); box-shadow: var(--ombre); text-align: left; min-height: 104px; }
.tuile b { font-size: 15px; }
.tuile small { color: var(--ink2); font-size: 12px; line-height: 1.3; }
.tuile.on { border-color: var(--rouge); background: var(--rouge-fond); }
.ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; margin-bottom: 4px; }
.ic.rouge { background: var(--rouge-fond); } .ic.ambre { background: #FEF3C7; } .ic.vert { background: var(--vert-fond); } .ic.gris { background: var(--fond2); } .ic.bleu { background: #DCEBFF; }

/* Fil */
.canaux { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.canaux::-webkit-scrollbar { display: none; }
.puce { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--ligne); background: var(--carte); font-weight: 750; font-size: 14px; }
.puce.on { background: var(--ink); color: var(--fond); }
.puce.ajout { color: var(--bleu); }
.fil-boite { height: calc(100dvh - 300px); min-height: 260px; overflow-y: auto; border-radius: var(--r); background: var(--carte2); border: 1px solid var(--ligne); padding: 10px; }
.fil { display: grid; gap: 8px; }
.vide { text-align: center; color: var(--ink2); margin: 30px 0; }
.jour { justify-self: center; font-size: 12px; font-weight: 700; color: var(--ink2); background: var(--carte); border-radius: 999px; padding: 3px 10px; }
.ligne-m { display: flex; }
.ligne-m.moi { justify-content: flex-end; }
.bulle { max-width: 82%; padding: 8px 12px; border-radius: 16px; background: var(--carte); border: 1px solid var(--ligne); overflow-wrap: anywhere; }
.ligne-m.moi .bulle { background: var(--vert); color: #fff; border-color: transparent; }
.bulle .qui { font-size: 12px; font-weight: 800; color: var(--bleu); }
.bulle .h { font-size: 11px; opacity: .7; text-align: right; margin-top: 2px; }
.bulle img { display: block; max-width: 100%; border-radius: 10px; margin-top: 4px; }
.vocal { display: flex; align-items: center; gap: 8px; }
.vocal button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.12); }
.sys { justify-self: center; font-size: 12.5px; color: var(--ink2); background: var(--carte); border-radius: 999px; padding: 4px 12px; text-align: center; }
.alerte { border: 2px solid var(--rouge); border-radius: var(--r); background: var(--rouge-fond); overflow: hidden; }
.alerte-tete { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--rouge); color: #fff; }
.alerte-tete small { display: block; opacity: .92; font-size: 12.5px; }
.alerte-corps { padding: 10px 12px; display: grid; gap: 8px; }
.geo { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.geo a { min-height: 38px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 10px; background: var(--carte); border: 1px solid var(--ligne); font-weight: 800; text-decoration: none; color: var(--ink); }
.geo a.fort { background: var(--bleu); color: #fff; border-color: transparent; }
.geo .precision { font-size: 12px; color: var(--ink2); }
.actions4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.actions4 button { min-height: 40px; border-radius: 10px; border: 1px solid var(--ligne); background: var(--carte); font-weight: 750; font-size: 13px; }
.position { border: 1px solid var(--ligne); border-radius: var(--r); background: var(--carte); padding: 10px 12px; display: grid; gap: 6px; }
.enreg { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 800; color: var(--rouge2); }
.enreg i { width: 10px; height: 10px; border-radius: 50%; background: var(--rouge); animation: clignote 1s infinite; }
.enreg small { margin-left: auto; color: var(--ink2); font-weight: 600; }
@keyframes clignote { 50% { opacity: .2; } }
.saisie { display: flex; gap: 8px; margin-top: 10px; }
.saisie input { flex: 1; min-width: 0; border-radius: 999px; }
.micro { background: var(--carte); border: 1px solid var(--ligne); touch-action: none; }
.micro.rec { background: var(--rouge); color: #fff; }
.envoyer { background: var(--vert); color: #fff; }

/* Gestes (app intégrée) */
#cadre-gestes { width: 100%; height: calc(100dvh - 190px); min-height: 420px; border: 0; border-radius: var(--r); background: #fff; box-shadow: var(--ombre); }

/* Membres */
.membres-tete h2 { margin: 6px 0 2px; font: 900 22px var(--font-titre); }
.ajout .ligne { display: flex; gap: 8px; }
.ajout .ligne input { flex: 1; min-width: 0; }
.membres { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 8px; }
.membres li { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r); background: var(--carte); border: 1px solid var(--ligne); }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff; background: hsl(var(--h, 210) 60% 46%); }
.membres .infos { flex: 1; min-width: 0; display: grid; }
.membres .infos small { color: var(--ink2); font-size: 12.5px; }
.membres .acts { display: flex; gap: 6px; }
.membres .acts button { min-height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--ligne); background: var(--carte2); font-size: 13px; font-weight: 750; }
.badge-role { font-size: 11px; font-weight: 800; color: var(--vert-t); background: var(--vert-fond); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.invitation { display: grid; gap: 10px; text-align: center; }
.invitation .code-grand { font: 900 34px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; color: var(--rouge2); }
.invitation .qr { justify-self: center; width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: 12px; }
.invitation .qr img, .invitation .qr canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.invitation .rang { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Onglets */
.onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--carte) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--ligne); }
.onglets button { position: relative; display: grid; justify-items: center; gap: 1px; min-height: 52px; border: 0; background: none; border-radius: 12px; font-size: 12px; font-weight: 750; color: var(--ink2); }
.onglets button span { font-size: 21px; line-height: 1.1; }
.onglets button.on { color: var(--rouge2); background: var(--rouge-fond); }
.badge { position: absolute; top: 2px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--rouge); color: #fff; font: 800 11px/18px var(--font); font-style: normal; }

/* Alerte plein écran, flash */
.alerte-ecran { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; color: #fff;
  background: radial-gradient(circle at 50% 30%, #EF4E5E, #8E1630); }
@media (prefers-reduced-motion: no-preference) { .alerte-ecran { animation: pulse-alerte 1s ease-in-out infinite alternate; } }
@keyframes pulse-alerte { to { background: radial-gradient(circle at 50% 30%, #FF6B78, #B4233C); } }
.alerte-ecran .ic { font-size: 72px; }
.alerte-ecran h2 { margin: 0; font: 900 40px var(--font-titre); letter-spacing: 2px; }
.alerte-ecran p { margin: 0; font-size: 19px; max-width: 360px; }
.alerte-ecran .rang { display: grid; gap: 10px; width: min(320px, 100%); }
.flash { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; font: 900 22px var(--font-titre); color: #000; background: #fff; animation: flash .16s steps(1) infinite; }
@keyframes flash { 50% { background: #000; color: #fff; } }
@media (prefers-reduced-motion: reduce) { .flash { animation-duration: .6s; } }

/* Feuille */
.voile { position: fixed; inset: 0; z-index: 60; background: rgba(15,29,51,.45); }
.feuille { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 88dvh; overflow: auto; background: var(--fond); border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: monte .3s var(--ease); }
@media (min-width: 700px) { .feuille { left: 50%; right: auto; width: 520px; transform: translateX(-50%); bottom: 24px; border-radius: 22px; } }
@keyframes monte { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 700px) { @keyframes monte { from { transform: translate(-50%, 30px); opacity: 0; } } }
.feuille-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.feuille-tete h2 { margin: 0; font: 900 20px var(--font-titre); }
.feuille-corps { display: grid; gap: 12px; }
.reglage { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border-radius: 14px; background: var(--carte); border: 1px solid var(--ligne); }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 99; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 420px); padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--fond); font-weight: 700; font-size: 14.5px; transition: .25s var(--ease); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

body.alerte-active .entete { background: color-mix(in srgb, var(--rouge) 18%, var(--fond)); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
h1[tabindex="-1"]:focus { outline: none; }
#ecran-code .accueil h1 { padding: 0 46px; }
