/* =========================================================
   Écran de connexion (maquettes/connexion.html) et petit panneau
   « Réglages » (compte, alertes sur cet appareil, déconnexion).
   Tokens : docs/DESIGN.md (base.css).
   ========================================================= */

/* ---------- Connexion : une carte au centre du fond d'écran ---------- */
.cx-fond {
  position: fixed; inset: 0; z-index: 45;   /* au-dessus de tout, alerte (30) et bandeau (40) compris */
  display: grid; place-items: center; padding: 24px; overflow: auto;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr); /* sinon la colonne prend la largeur de la carte et déborde sur iPhone */
  background: var(--fond); background-attachment: fixed;
}
.cx-carte {
  width: min(460px, 100%);
  background: rgba(255,255,255,.96); color: #1d1d1f;
  border-radius: var(--r-sheet); box-shadow: var(--sh-float);
  padding: 36px 36px 28px; display: grid; gap: 18px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.cx-carte [hidden] { display: none !important; }
.cx-carte button, .cx-carte input { font-family: inherit; }
.cx-logo { width: 64px; height: 64px; border-radius: 16px; background: #1c1c1e;
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 12px; }
.cx-logo i { border-radius: 5px; background: #fff; }
.cx-logo i:nth-child(1) { background: var(--orange); }
.cx-logo i:nth-child(4) { background: var(--green); }
.cx-carte h1 { margin: 0; font: 700 30px/1.15 var(--font); }
.cx-sous { margin: -8px 0 0; font: 400 18px var(--font); color: #6e6e73; }
.cx-champ { display: grid; gap: 6px; }
.cx-champ + .cx-champ { margin-top: 14px; }
.cx-champ label { font: 600 16px var(--font); color: #6e6e73; }
.cx-in-boite { position: relative; display: flex; }
.cx-in {
  width: 100%; min-height: 56px; border: 2px solid transparent; border-radius: var(--r-field);
  background: #f2f2f7; color: #1d1d1f; padding: 0 16px; font: 400 20px var(--font);
}
.cx-in[aria-invalid="true"] { border-color: #d70015; }
.cx-mdp { padding-right: 104px; }
.cx-oeil {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  min-height: 48px; padding: 0 12px; border: 0; background: none; color: #0055d4;
  font: 600 16px var(--font); cursor: pointer; border-radius: 10px;
}
.cx-err { display: flex; gap: 8px; align-items: flex-start; color: #d70015; font: 600 17px var(--font); margin: 0; }
.cx-err .ic { margin-top: 1px; }
.cx-go {
  min-height: 58px; border: 0; border-radius: var(--r-field); background: #0055d4; color: #fff;
  font: 700 20px var(--font); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 12px;
}
.cx-go[disabled] { opacity: .75; cursor: progress; }
.cx-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; }
@media (prefers-reduced-motion: no-preference) { .cx-spin { animation: cx-rot .8s linear infinite; } }
@keyframes cx-rot { to { transform: rotate(360deg); } }
.cx-une-fois { display: flex; gap: 10px; align-items: flex-start; background: #f2f2f7; border-radius: var(--r-field);
  padding: 12px 14px; font: 400 16px var(--font); }
.cx-une-fois .ic { color: #248a3d; margin-top: 1px; }
.cx-aide { margin: 0; font: 400 15px var(--font); color: #6e6e73; text-align: center; }
.cx-sans-compte { justify-self: center; min-height: 44px; border: 0; background: none; color: #6e6e73;
  font: 500 15px var(--font); text-decoration: underline; cursor: pointer; }
.cx-ok { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 10px 0; }
.cx-ok .ic { width: 56px; height: 56px; color: #248a3d; }
.cx-ok b { font: 700 24px var(--font); }

/* ---------- Bouton « Réglages » : discret, en bas à droite ---------- */
.rg-bouton {
  position: fixed; right: 6px; bottom: 6px; z-index: 6;
  /* Plein écran : au-dessus de la barre des gestes (iPhone, Android) */
  right: max(6px, env(safe-area-inset-right)); bottom: max(6px, env(safe-area-inset-bottom));
  width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff; opacity: .7;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.rg-bouton:hover, .rg-bouton:focus-visible { opacity: 1; }
.rg-bouton .ic { width: 22px; height: 22px; }
/* Petit point jaune : des données de cet appareil ne sont pas encore dans la base */
.rg-bouton.a-faire::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 2px rgba(0,0,0,.35);
}

/* ---------- Panneau « Réglages » ---------- */
.rg-fond { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; grid-template-columns: minmax(0, 1fr);
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--scrim); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.rg-carte {
  width: min(520px, 100%); max-height: 100%; overflow: auto;
  background: var(--sheet-bg-plein); color: var(--sheet-ink);
  border-radius: var(--r-sheet); box-shadow: var(--sh-float); padding: 8px 0 20px;
}
.rg-carte [hidden] { display: none !important; }
.rg-carte button { font-family: inherit; }
.rg-barre { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px; min-height: 60px; }
.rg-barre h2 { margin: 0; font: 700 26px var(--font); }
.rg-ok { min-height: 48px; padding: 0 12px; border: 0; background: none; color: var(--blue-ink); font: 700 20px var(--font); cursor: pointer; }
.rg-groupe { margin: 10px 20px 0; padding: 14px 16px; background: var(--w-bg); border-radius: var(--r-field); display: grid; gap: 10px; }
.rg-titre { font: 700 14px var(--font); text-transform: uppercase; letter-spacing: .04em; color: var(--w-muted); margin: 14px 36px 0; }
.rg-texte { margin: 0; font: 500 18px var(--font); color: var(--w-ink); overflow-wrap: anywhere; }
.rg-petit { margin: 0; font: 400 15px var(--font); color: var(--w-muted); }
.rg-petit.rg-alerte { color: var(--red-ink); font-weight: 600; }
.rg-seg { display: flex; background: var(--w-field); border-radius: 14px; padding: 4px; gap: 4px; }
.rg-seg button {
  flex: 1; min-height: 48px; border: 0; border-radius: 10px; background: none; color: var(--w-ink);
  font: 600 17px var(--font); cursor: pointer;
}
.rg-seg button[aria-checked="true"] { background: var(--w-bg); box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.rg-action {
  min-height: 48px; border: 0; border-radius: var(--r-field); background: var(--w-field); color: var(--blue-ink);
  font: 600 18px var(--font); cursor: pointer; padding: 0 16px;
}
.rg-action[disabled] { opacity: .6; cursor: progress; }
.rg-action.danger { color: var(--red-ink); }
.rg-action.confirmer { background: var(--red-ink); color: #fff; }
.rg-source { margin: 16px 36px 0; font: 400 14px var(--font); color: var(--w-muted); }

/* ---------- iPhone ---------- */
@media (max-width: 700px) {
  .cx-fond { place-items: start center; padding: max(60px, calc(20px + env(safe-area-inset-top))) 16px calc(40px + env(safe-area-inset-bottom)); }
  .cx-carte { padding: 28px 22px 22px; gap: 14px; }
  .cx-carte h1 { font-size: 26px; }
  .cx-sous { font-size: 16px; }
  .cx-in { min-height: 50px; font-size: 17px; }
  .cx-go { min-height: 50px; font-size: 17px; }
  .rg-fond { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); place-items: end center; }
  .rg-barre h2 { font-size: 22px; }
  .rg-texte { font-size: 17px; }
  .rg-seg button, .rg-action { font-size: 16px; min-height: 44px; }
}
