/* Styles de la coquille PWA — DA Léonidas (P0 du 26.10.2026 : jetons, polices, boutons, onglets) */
/* ── Polices auto-hébergées (Fontshare, licence ITF FFL : fonts/LICENSE-NOTE.md).
 * Aucun appel CDN (nLPD). Panchang = titres, Switzer = texte. ── */
@font-face { font-family: "Panchang"; src: url("../fonts/panchang-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Panchang"; src: url("../fonts/panchang-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("../fonts/switzer-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("../fonts/switzer-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("../fonts/switzer-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

/* Jetons DA Léonidas (validée 19.10.2026) — copie de leo-designer/pwa-beta-ios/tokens.css */
:root {
  /* — Couleurs de base — */
  --bg: #0e1013;              /* fond de l'app (= theme_color / background_color) */
  --bg-card: #171a1f;         /* surface : cartes, feuilles */
  --bg-elevated: #1e2126;     /* surface haute : champs, lignes, désactivé */
  --text: #c9ced6;            /* texte acier */
  --text-strong: #eef0f3;     /* titres, valeurs importantes */
  --muted: #8a919c;           /* texte secondaire */
  --muted-2: #5a6069;         /* texte désactivé */
  --border: rgba(201, 206, 214, 0.18);        /* filet acier fin */
  --border-strong: rgba(201, 206, 214, 0.42); /* contour des boutons acier */
  --steel: #c9ced6;

  /* — Accent unique — */
  --accent: #a50f1f;          /* rouge laqué mat, toujours avec texte blanc */
  --accent-press: #8c0d1a;
  --on-accent: #ffffff;
  --bronze: #b08d57;          /* touche rare (puce d'environnement, détails) */

  /* — États — */
  --ok: #3ddc97;              /* PASS / OK uniquement */
  --warn: #b08d57;            /* « à vérifier », reconnexion (bronze, pas d'ambre) */
  --alarm: #a50f1f;
  --info: #c9ced6;            /* ancien cyan → acier */

  /* — Dégradés (acier discret uniquement) — */
  --grad-steel-edge: linear-gradient(135deg, #3a3f47 0%, #c9ced6 32%, #8a919c 52%, #eef0f3 64%, #3a3f47 100%);
  --grad-steel-surface: linear-gradient(180deg, rgba(201, 206, 214, 0.05) 0%, rgba(201, 206, 214, 0) 60%);
  --grad-header: linear-gradient(180deg, rgba(14, 16, 19, 0.96) 0%, rgba(14, 16, 19, 0.88) 100%);

  /* — Rayons — */
  --r-pill: 999px;            /* boutons, champs, puces, onglet actif */
  --r-card: 6px;              /* repli si le chanfrein n'est pas appliqué */
  --chamfer: 14px;            /* pans coupés des cartes (P1) */
  --chamfer-sm: 8px;

  /* — Ombres — */
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.5);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(201, 206, 214, 0.75);

  /* — Mouvement (façon Dynamic Island) — */
  --ease-island: cubic-bezier(0.32, 0.72, 0, 1);  /* morphing / apparition */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 160ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
  --hold-panic: 2000ms;       /* appui maintenu Panique (JS : PANIC_HOLD_MS = 2000) */

  /* — Typographie — */
  --font-title: "Panchang", "Switzer", system-ui, sans-serif;
  --font-text: "Switzer", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* — Gabarit (inchangé) — */
  --app-height: 100dvh;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tabbar-h: 64px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: var(--app-height);
}

#app {
  min-height: var(--app-height);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--grad-header);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-mark {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-title {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-chip {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main.shell-main {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.field input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  min-height: 44px;
}
.field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  min-height: 44px;
}

/* Champs du gate d'authentification (déverrouillage / enrôlement). */
.input {
  box-sizing: border-box;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  min-height: 48px;
  margin: 4px 0;
}
.input:focus {
  outline: none;
  border-color: var(--steel);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

/* Espace client / profil. */
.profile-dl {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px 12px;
  margin: 0 0 12px;
}
.profile-dl dt {
  color: var(--muted);
  font-size: 13px;
}
.profile-dl dd {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  word-break: break-word;
}

/* Onboarding SoftAP. */
.onboard-steps {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
.onboard-steps li {
  margin: 6px 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
}
.field span {
  color: var(--muted);
  font-size: 13px;
}
.onboard-recap {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
}
.onboard-recap h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

/* Historique des tirs (admin). */
.shots-filter {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.shots-filter .field {
  flex: 1 1 120px;
  margin: 0;
}
.shots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}
.shot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 14px;
}
.shot-row .shot-time {
  color: var(--muted);
  font-size: 12px;
}
.shot-row .shot-source {
  font-weight: 600;
}

/* Journal des armements (gérants). */
.armlog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  margin-bottom: 8px;
}
.armlog-row {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 14px;
}
.armlog-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.armlog-action {
  font-weight: 600;
}
.armlog-result[data-kind="warn"] {
  color: var(--warn, #b26a00);
}
.armlog-result[data-kind="err"] {
  color: var(--danger, #c0392b);
}
.armlog-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

button,
.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-panic-silent {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-panic-loud {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-ghost {
  background: transparent;
}

#shell-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}

#shell-status[data-kind="ok"] {
  color: var(--ok);
}
#shell-status[data-kind="err"] {
  color: var(--alarm);
}
#shell-status[data-kind="pending"] {
  color: var(--warn);
}
#shell-status[data-kind="info"] {
  color: var(--info);
}

/* Stitch drop zone — keep empty structure ready */
#stitch-root {
  /* Stitch export HTML/Tailwind goes here */
  min-height: 0;
}

#stitch-root:empty {
  display: none;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 6px 8px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: rgba(14, 16, 19, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.tabbar a {
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  border-radius: 12px;
}

.tabbar a[aria-current="page"],
.tabbar a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tabbar .ico {
  font-size: 16px;
  line-height: 1;
}

.shell-only-note {
  font-size: 12px;
  color: var(--muted);
  border-left: 3px solid var(--info);
  padding-left: 10px;
  margin: 0;
}

/* Utility placeholders for Stitch tokens */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* === audit export / fleet panels === */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#account-type-badge[data-kind="pro"] {
  color: var(--bronze);
  border-color: var(--bronze);
}

.panel[hidden] {
  display: none !important;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-block {
  width: 100%;
  margin-top: 14px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.export-format-row {
  margin-top: 10px;
}

.fleet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.fleet-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  min-height: 48px;
}

.fleet-row input {
  width: 18px;
  height: 18px;
}

.fleet-id {
  font-weight: 650;
  font-size: 14px;
}

.fleet-meta {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* Badge batterie (Phase 4b) — seuils produit : low ≤ 15 %, critical ≤ 5 %. */
.fleet-batt {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.fleet-batt[data-level="ok"] {
  color: var(--ok);
}
.fleet-batt[data-level="low"] {
  color: var(--warn);
  border-color: var(--warn);
}
.fleet-batt[data-level="critical"] {
  color: var(--alarm);
  border-color: var(--alarm);
  animation: batt-blink 1.2s ease-in-out infinite;
}
@keyframes batt-blink {
  50% {
    opacity: 0.45;
  }
}

.status-line {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}
.status-line[data-kind="ok"] { color: var(--ok); }
.status-line[data-kind="err"] { color: var(--alarm); }
.status-line[data-kind="pending"] { color: var(--warn); }
.status-line[data-kind="info"] { color: var(--info); }
.status-line[data-kind="warn"] { color: var(--warn); }

@media (max-width: 380px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ── Mise en service : procédure terrain (2026-09-10) ───────────────────
 * Remplace le scan BLE et l'écriture directe, tous deux impossibles à
 * exécuter (pas de BLE dans le firmware, contenu mixte bloqué). L'écran
 * explique la manipulation réelle au lieu de prétendre l'automatiser. */
.guide-lead {
  margin: 0 0 14px;
  font-size: 0.94rem;
  line-height: 1.45;
  color: var(--text);
}
.field-hint {
  margin: -4px 0 14px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}
.field-hint[data-kind="ok"] { color: var(--ok); }
.field-hint[data-kind="warn"] { color: var(--warn); }
.field-hint code,
.guide-steps code,
.onboard-steps code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  /* Un nom de réseau ne doit jamais être coupé en deux lignes : on le lit
     pour le retrouver à l'identique dans les réglages Wi-Fi. */
  white-space: nowrap;
}
.guide-steps {
  counter-reset: guide;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}
.guide-steps li {
  counter-increment: guide;
  position: relative;
  padding: 0 0 16px 42px;
  border-left: 1px solid var(--border);
  margin-left: 13px;
}
.guide-steps li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}
.guide-steps li::before {
  content: counter(guide);
  position: absolute;
  left: -13px;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--info);
}
/* Enfants DIRECTS seulement : un <strong> de mise en valeur au fil du texte
   (« 3 secondes ») ne doit pas passer en bloc et casser la phrase. */
.guide-steps li > strong {
  display: block;
  font-size: 0.94rem;
  margin: 3px 0 4px;
}
.guide-steps li > span {
  display: block;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--muted);
}
.guide-note {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.guide-note strong {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 6px;
}
.guide-note ul {
  margin: 0;
  padding-left: 18px;
}
.guide-note li {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 5px;
}
.guide-note li:last-child { margin-bottom: 0; }
/* Lien d'action au fil du texte : même cible tactile qu'un bouton. */
.btn-inline-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--info);
  text-decoration: underline;
  cursor: pointer;
}

/* ══ Améliorations 2026-09-10 ═══════════════════════════════════════════ */

/* ── Barre d'onglets ────────────────────────────────────────────────────
 * Les styles .tabbar existaient déjà (grille 5 colonnes, safe-area) mais ne
 * visaient que des <a>. Les onglets sont des <button> — même rendu, sémantique
 * correcte pour une action qui ne navigue pas. */
.tabbar .tab {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.15;
  text-align: center;
  /* Cible tactile confortable au pouce, quelle que soit la longueur du mot. */
  min-height: 48px;
}
.tabbar .tab .ico {
  font-size: 1.05rem;
  line-height: 1;
}
.tabbar .tab[aria-current="page"] {
  color: var(--text);
  background: var(--bg-elevated);
}

/* ── Pastille de flux temps réel ────────────────────────────────────── */
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: var(--muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px 2px 7px;
  white-space: nowrap;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.live-chip[data-state="live"] { color: var(--ok); }
.live-chip[data-state="live"] .live-dot {
  background: var(--ok);
  animation: live-pulse 2s ease-in-out infinite;
}
.live-chip[data-state="connecting"] .live-dot,
.live-chip[data-state="retrying"] .live-dot { background: var(--warn); }
.live-chip[data-state="retrying"] { color: var(--warn); }
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .live-chip[data-state="live"] .live-dot { animation: none; }
}

/* Ligne de flotte qui vient d'être rafraîchie par le flux : un signal bref,
   sinon l'écran change sous les yeux sans qu'on sache d'où ça vient. */
.fleet-row.row-pulse {
  animation: row-pulse 0.9s ease-out;
}
@keyframes row-pulse {
  0% { background: rgba(201, 206, 214, 0.14); }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .fleet-row.row-pulse { animation: none; }
}
.fleet-state {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ── Bandeau réseau ─────────────────────────────────────────────────── */
.net-banner {
  margin: 0 12px 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}
.net-banner[data-mode="offline"] { border-color: var(--warn); }
.net-banner[data-mode="no-api"] { border-color: var(--border-strong); }

/* ── Appui maintenu ─────────────────────────────────────────────────────
 * La jauge est un dégradé piloté par --hold, mis à jour à chaque frame par
 * bindHoldToFire. Pas d'élément supplémentaire : le bouton EST la jauge. */
.hold-btn,
[data-action="panic-loud"] {
  position: relative;
  overflow: hidden;
  touch-action: none; /* le maintien ne doit pas faire défiler la page */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.hold-btn::after,
[data-action="panic-loud"]::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--hold, 0%);
  background: rgba(255, 255, 255, 0.22);
  pointer-events: none;
  transition: width 60ms linear;
}
.hold-btn.holding,
[data-action="panic-loud"].holding {
  transform: scale(0.985);
}
.hold-btn.armed,
[data-action="panic-loud"].armed {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

/* ── Notifications & invitation ─────────────────────────────────────── */
.push-row,
#pin-setup-password-row[hidden] {
  display: none;
}

.pin-row {
  margin: 14px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.push-row h3,
.pin-row h3 {
  margin: 0 0 6px;
  font-size: 0.88rem;
}
.invite-link {
  margin: 0 0 6px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  /* Un lien long doit rester lisible en entier plutôt que déborder. */
  word-break: break-all;
}

/* ── Rappel de cible (écran Commandes) ──────────────────────────────────
 * Depuis que Commandes est une vue à part, la liste des boîtiers n'est plus
 * à l'écran : le nom de la cible doit rester visible en permanence au-dessus
 * des ordres. Non repliable, volontairement. */
.cmd-target {
  margin: -2px 0 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.cmd-target-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cmd-target-label {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
  /* Un nom long ne doit pas repousser le bouton hors de l'écran. */
  min-width: 0;
  overflow-wrap: anywhere;
  /* D2 : appui maintenu sans loupe, sélection ni menu iOS ; le maintien ne
     fait pas défiler (un glissé annule, js/commands.js). Aucun effet visible. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.cmd-target-switch {
  appearance: none;
  flex: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 12px;
  min-height: 36px;
  cursor: pointer;
}
.cmd-target-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 7px;
}
/* Statut de l'alarme : grand, lisible d'un coup d'œil, en français. */
.alarm-status-block {
  margin: 4px 0 14px;
}
.alarm-status {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--text-strong, var(--text));
}
.alarm-status[data-state="ARMED"] {
  color: var(--steel, var(--text-strong));
}
.alarm-status[data-state="DISARMED"] {
  color: var(--text-strong, var(--text));
}
.alarm-status[data-state="FIRING"],
.alarm-status[data-state="TRIGGERED"],
.alarm-status[data-state="ALARM"],
.alarm-status[data-state="PANIC"] {
  color: var(--alarm);
}
/* État jamais reçu : on le dit, sans le déguiser en valeur fraîche. */
.alarm-status[data-known="0"] {
  color: var(--warn);
  font-size: 20px;
  font-weight: 600;
}
/* Mention secondaire : l'ordre est passé, le Blaster n'a pas encore confirmé son état. */
.alarm-status-pending {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}
.alarm-status-pending::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--warn);
  vertical-align: 1px;
}
.cmd-target-id {
  font-size: 11px;
  color: var(--muted);
}

/* ── Boutons pleine largeur dans une rangée à deux colonnes ─────────────
 * .btn-row est une grille 2 colonnes, et chaque commande du bloc Alarme /
 * Dissuasion / Panique est seule dans sa propre .btn-row : `width: 100%` de
 * .btn-block valait donc 100 % d'UNE colonne. Résultat, des boutons à
 * mi-largeur collés à gauche, avec du vide à droite — y compris « PANIQUE
 * SONORE ». Un bouton déclaré pleine largeur occupe désormais les deux
 * colonnes ; les vraies rangées de deux (Fermer / Se déconnecter) ne portent
 * pas .btn-block et gardent leur disposition. */
.btn-row > .btn-block {
  grid-column: 1 / -1;
}

/* Modale générique (passkeys : renommer / supprimer) */
.leo-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.leo-modal[hidden] { display: none; }
.leo-modal-card { width: 100%; max-width: 420px; background: var(--bg-elevated); }
.leo-modal .btn-danger, .leo-modal #leo-modal-ok.danger { background: var(--alarm); color: #fff; }

/* ── Feuille de confirmation Face ID (step-up) ───────────────────────── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; max-width: 480px; }
[data-trigger-action="STOP"] { touch-action: manipulation; }
[data-trigger-action="STOP"].stop-armed { outline: 2px solid var(--alarm); outline-offset: 2px; }

/* ── Retour (sous-écrans) ──────────────────────────────────────────────── */
.btn-back {
  background: none;
  border: 0;
  color: var(--info);
  font: inherit;
  font-size: 16px;
  padding: 8px 8px 8px 0;
  min-height: 44px;
  cursor: pointer;
}
.btn-back[hidden] { display: none; }
.btn-back:disabled { opacity: 0.4; }

/* ── iOS : défilement, zoom et zones sûres ─────────────────────────────── */
html,
body {
  overscroll-behavior: none;
  /* Bloc B (D1) : défilement permis, pinch-zoom et double appui-zoom interdits
     (la valeur précédente autorisait encore le pincement). */
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
}
#app { padding-top: 0; }
.app-header {
  padding-top: calc(12px + var(--safe-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
#main, .shell-main { overscroll-behavior-y: contain; }
#auth-gate {
  /* Bloc B (D1) : l'écran de connexion (mot de passe, inscription) défile
     quand le clavier ou un petit écran le rend plus haut que la fenêtre. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.leo-modal,
.sheet {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.leo-modal {
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
input, select, textarea { font-size: 16px; }
.tabbar { grid-template-columns: repeat(var(--tab-count, 5), 1fr); }
/* « display: grid » de .tabbar l'emportait sur l'attribut hidden : la barre
   d'onglets restait visible (et cliquable) sous l'écran Face ID, sans session. */
.tabbar[hidden], .tabbar .tab[hidden] { display: none !important; }
.cmd-no-target[hidden] { display: none; }
[data-view][hidden], [data-panel][hidden] { display: none !important; }
#shell-env[data-env="beta"] { color: var(--bronze); border-color: rgba(176, 141, 87, 0.55); }
.update-toast {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.update-toast[hidden] { display: none; }

/* ── En-tête compact sur iPhone ────────────────────────────────────────── */
@media (max-width: 480px) {
  #shell-user,
  .app-header .brand-mark { display: none; }
  .app-header .header-right { gap: 6px; flex-wrap: nowrap; min-width: 0; }
  .app-header .meta-chip { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}


/* Bêta.7 — réglages du tir (Délai / Puissance / Durée). */
.fire-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}
.fire-field select {
  width: 100%;
  box-sizing: border-box;
  font-size: 16px; /* < 16 px ⇒ zoom automatique sur iPhone */
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.fire-field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.fire-hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 340px) {
  .fire-settings {
    grid-template-columns: 1fr;
  }
}
.fleet-batt[data-level="unknown"] {
  color: var(--muted);
  font-weight: 500;
}

/* ── Pavé PIN 4 chiffres (ARM / DISARM, option a) ─────────────────────── */
.pin-sheet { z-index: 1150; }
.pin-card { text-align: center; }
.pin-msg { color: var(--alarm); font-weight: 600; margin: 4px 0 0; }
.pin-msg[hidden] { display: none; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 16px 0 20px; }
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.6;
}
.pin-dot.filled { background: currentColor; opacity: 1; }
.pin-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}
.pin-key {
  min-height: 56px;
  font-size: 22px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pin-erase, .pin-cancel { font-size: 15px; }
.pin-lock-reason { color: var(--alarm); }
.pin-lock-reason[hidden] { display: none; }

/* ── Connexion par PIN (écran d'accès) ─────────────────────────────────── */
.pin-access-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}
/* Bloc principal centré (autant d'espace au-dessus qu'en dessous),
   pied de page collé en bas, y compris la zone de sécurité iOS. */
#auth-gate[data-pin-flow] {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}
#auth-gate[data-pin-flow] .gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  gap: 0;
  box-sizing: border-box;
  padding: max(16px, var(--safe-top, env(safe-area-inset-top, 0px)))
    max(16px, env(safe-area-inset-right, 0px))
    0
    max(16px, env(safe-area-inset-left, 0px));
}
#auth-gate[data-pin-flow] .pin-access-block {
  margin-block: auto;
  max-width: 420px;
  flex: 0 0 auto;
  order: 1;
}
#auth-gate[data-pin-flow] #auth-passkey:not([hidden]) {
  order: 2;
  width: 100%;
  max-width: 360px;
}
#auth-gate[data-pin-flow] .pin-login-footer {
  margin-top: 0;
  flex-shrink: 0;
  padding-top: 16px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  order: 3;
}
#auth-pin-login,
#auth-pin-serial {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
  gap: 12px;
}
#auth-pin-login[hidden],
#auth-pin-serial[hidden],
#pin-login-footer[hidden] {
  display: none;
}
.pin-serial-title {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.pin-serial-field {
  width: 100%;
  text-align: left;
}
.pin-login-dots {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 8px 0 6px;
}
.pin-login-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.55;
}
.pin-login-dot.filled {
  background: currentColor;
  opacity: 1;
}
.pin-login-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 320px;
}
.pin-login-key {
  min-height: 56px;
  font-size: 22px;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pin-login-key-spacer {
  min-height: 56px;
}
.pin-login-back {
  font-size: 20px;
}
.pin-login-msg {
  color: var(--alarm);
  font-weight: 600;
  margin: 0;
  min-height: 1.5em;
  line-height: 1.5;
  width: 100%;
  max-width: 320px;
}
/* Réserve la hauteur : l'apparition du message ne doit pas déplacer le pavé. */
.pin-login-msg[hidden] {
  display: block !important;
  visibility: hidden;
}
#pin-login-submit,
#pin-serial-go {
  min-height: 56px;
  font-size: 17px;
  font-weight: 700;
  width: 100%;
  max-width: 320px;
  background: var(--alarm, #a50f1f);
  border-color: var(--alarm, #a50f1f);
  color: #fff;
}
#pin-login-submit.shaking {
  animation: pin-login-shake 0.45s ease-in-out;
}
@keyframes pin-login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}
.pin-login-other {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.85;
  min-height: 40px;
  margin-top: 4px;
}
.pin-login-faceid {
  display: block;
  width: 100%;
  margin-top: 8px;
}
.pin-login-footer {
  margin-top: auto;
  padding-top: 24px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  text-align: center;
  width: 100%;
}
.pin-login-footer p {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: #fff;
  opacity: 0.6;
}
.pin-login-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.empty-blaster {
  margin: 12px 0 20px;
}
#panel-controls .btn-row[hidden],
#panel-controls [data-trigger-action][hidden],
#panel-controls [data-action="panic-loud"][hidden],
#cmd-target[hidden],
#alarm-status-block[hidden],
#controls-empty[hidden],
#panel-controls [data-feature="tirs"][hidden] {
  display: none !important;
}
