/* Le Tiroir — l'appli de poche (lot 2 de outils/TIROIR.md).
 *
 * Pensée pour une seule main, debout dans une cuisine ou au rayon d'un
 * magasin : cibles ≥ 48 px, deux onglets en bas sous le pouce, aucun indice
 * porté par le seul survol — sur un téléphone, le survol n'existe pas.
 *
 * La palette est celle du Cairn, à la variable près. Elle est définie ICI,
 * dans le fichier qui s'en sert : un `var(--x)` inconnu ne vaut pas « rien »,
 * il rend la propriété invalide, donc TRANSPARENTE — et rien ne le signale.
 * C'est ce qui a rendu invisibles un panneau du Cairn et des onglets de
 * l'Admin (cf. outils/tests/couleurs-definies.test.js). */

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

:root {
  --bg:        #0d0f1a;
  --surface:   #181b2e;
  --surface2:  #1f2340;
  --border:    #2a2f52;
  --accent:    #f59e0b;
  --accent-lo: rgba(245,158,11,.12);
  --green:     #4ade80;
  --green-lo:  rgba(74,222,128,.12);
  --red:       #f87171;
  --red-lo:    rgba(248,113,113,.12);
  --text:      #e2e8f0;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --radius:    10px;
  --radius-sm: 6px;
  /* La hauteur de la barre d'onglets, réservée en bas du corps : sans elle, la
     dernière ligne du tiroir passe SOUS le pouce et ne se lit jamais. */
  --barre:     72px;
}

@media (prefers-color-scheme: light) { :root:not([data-theme]) {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #94a3b8;
  --muted2:    #64748b;
}}
:root[data-theme="light"] {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #94a3b8;
  --muted2:    #64748b;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  font-size: 16px;          /* 16 px : en dessous, iOS zoome à chaque champ */
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* `hidden` doit gagner, toujours. Une règle de classe qui pose `display: flex`
   bat l'attribut (qui ne vaut que `display: none` dans la feuille du
   navigateur, à spécificité nulle) — et c'est ainsi que la feuille de ressenti
   s'ouvrait toute seule PAR-DESSUS l'écran de connexion, au premier
   chargement. Vu à l'essai, invisible à la lecture. */
[hidden] { display: none !important; }

.ecran { display: none; }
.ecran.active { display: block; }

/* ── CONNEXION ─────────────────────────────── */
.carte-connexion {
  max-width: 420px;
  margin: 0 auto;
  padding: 40px 20px calc(40px + env(safe-area-inset-bottom));
  text-align: center;
}
.logo-connexion { width: 76px; height: 76px; border-radius: 18px; }
.carte-connexion h1 { font-size: 27px; margin: 14px 0 4px; }
.sous-titre { color: var(--muted2); font-size: 14px; margin-bottom: 26px; }
.champ { display: block; text-align: left; margin-bottom: 14px; }
.champ span {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--muted2); margin-bottom: 6px;
}
.champ input {
  width: 100%; min-height: 52px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: 16px; font-family: inherit;
}
.champ input:focus { outline: none; border-color: var(--accent); }
.btn-principal {
  width: 100%; min-height: 52px;
  background: var(--accent); color: #1b1b1f;
  border: none; border-radius: var(--radius);
  font-size: 17px; font-weight: 800; font-family: inherit;
  cursor: pointer; margin-top: 8px;
}
.btn-principal[disabled] { opacity: .55; }
.erreur { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 10px; }
.note-compte { color: var(--muted); font-size: 13.5px; margin-top: 22px; line-height: 1.7; }
.note-compte a { color: var(--accent); text-decoration: underline; }

/* ── ENTÊTE ────────────────────────────────── */
.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.entete-titre { font-size: 17px; font-weight: 800; }
.btn-sortir {
  min-height: 48px; padding: 8px 16px;   /* comme tout le reste : un doigt, pas un curseur */
  background: var(--surface2); color: var(--muted2);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 13.5px; font-family: inherit; cursor: pointer;
}

/* ── BANDEAU DE FILE ───────────────────────── */
/* Discret, mais toujours visible tant que la file n'est pas vide : c'est la
   seule chose qui distingue « c'est enregistré » de « ça attend le réseau ». */
.bandeau-file {
  background: var(--accent-lo); color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  position: sticky; top: 0; z-index: 15;
}

.corps { padding: 12px 12px calc(var(--barre) + env(safe-area-inset-bottom) + 12px); }
.vue { display: none; }
.vue.active { display: block; }

/* ── LE TIROIR ─────────────────────────────── */
.famille { margin-bottom: 20px; }
.famille-titre {
  font-size: 13px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  padding: 4px 4px 8px;
}
.ligne {
  display: flex; align-items: stretch; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px; overflow: hidden;
}
.ligne.seuil { border-color: var(--accent); background: var(--accent-lo); }
.ligne.vide { opacity: .55; }
/* Le retour de la tape : net et bref. Une classe posée puis retirée par le
   script — pas une transition au survol, qui n'existe pas sous un doigt. */
.ligne.prise { border-color: var(--green); background: var(--green-lo); }

.ligne-tape {
  flex: 1 1 auto; min-height: 68px;
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; color: inherit;
  padding: 10px 6px 10px 12px; font-family: inherit; font-size: 16px;
  text-align: left; cursor: pointer;
  touch-action: manipulation;         /* pas de double-tap qui zoome */
  -webkit-user-select: none; user-select: none;
}
.ligne-icone { flex: 0 0 30px; height: 30px; line-height: 0; }
.ligne-nom { flex: 1 1 auto; min-width: 0; font-size: 15px; line-height: 1.35; }
.ligne-nom b { display: block; font-size: 13px; color: var(--muted2); font-weight: 700; }
.ligne-stock {
  flex: 0 0 auto; text-align: right;
  font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ligne.vide .ligne-stock { color: var(--muted); }
.ligne-unite { flex: 0 0 44px; font-size: 12px; color: var(--muted); line-height: 1.2; }
.ligne-plus {
  flex: 0 0 52px; min-height: 68px;
  background: var(--surface2); border: none; border-left: 1px solid var(--border);
  color: var(--muted2); font-size: 22px; font-family: inherit; cursor: pointer;
  touch-action: manipulation;
}

.vide-etat {
  text-align: center; color: var(--muted2);
  padding: 48px 20px; font-size: 15px; line-height: 1.7;
}
.vide-etat .emoji { display: block; font-size: 40px; margin-bottom: 12px; }

/* ── RÉASSORT ──────────────────────────────── */
.intro { font-size: 17px; font-weight: 800; padding: 4px 4px 14px; }
.r-ligne {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
}
.r-ligne.rupture { border-color: var(--red); background: var(--red-lo); }
.r-nom { font-size: 15px; line-height: 1.35; margin-bottom: 4px; }
.r-nom b { color: var(--muted2); font-size: 13px; font-weight: 700; }
.r-etat { font-size: 12.5px; color: var(--muted2); margin-bottom: 10px; }
.r-ligne.rupture .r-etat { color: var(--red); }
.r-geste { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.r-champ {
  width: 88px; min-height: 48px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 18px; font-weight: 700; font-family: inherit;
  text-align: center;
}
.r-champ:focus { outline: none; border-color: var(--accent); }
.r-unite { font-size: 13px; color: var(--muted); flex: 0 0 auto; }
.r-vite {
  min-width: 52px; min-height: 48px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer;
  touch-action: manipulation;
}
.limite {
  color: var(--muted); font-size: 12.5px; line-height: 1.6;
  padding: 18px 4px 0; border-top: 1px solid var(--border); margin-top: 18px;
}

/* ── BANDE « ANNULER » ─────────────────────── */
/* Elle flotte au-dessus des onglets pendant ~6 s. Le bouton n'apparaît que si
   la conso est encore dans la file : passée au serveur, elle ne se reprend
   plus (aucune action serveur n'efface une conso). */
.bandeau-annuler {
  position: fixed; left: 10px; right: 10px;
  bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 10px);
  z-index: 40;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  font-size: 14px;
}
.bandeau-annuler .b-texte { flex: 1 1 auto; min-width: 0; }
.bandeau-annuler button {
  flex: 0 0 auto; min-height: 44px; padding: 8px 14px;
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
}
.bandeau-annuler button.b-second { color: var(--muted2); border-color: var(--border); }

/* ── ONGLETS DU POUCE ──────────────────────── */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.onglet {
  flex: 1 1 0; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; border-top: 3px solid transparent;
  color: var(--muted); font-size: 22px; font-family: inherit; cursor: pointer;
  touch-action: manipulation;
}
.onglet span { font-size: 12px; font-weight: 700; }
.onglet.active { color: var(--accent); border-top-color: var(--accent); }

/* ── LA FEUILLE ────────────────────────────── */
.feuille-fond {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end;
}
.feuille {
  width: 100%; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.feuille h2 { font-size: 17px; margin-bottom: 2px; }
.feuille .f-marque { font-size: 13px; color: var(--muted2); margin-bottom: 16px; }
.f-titre {
  font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px;
}
.f-rang { display: flex; flex-wrap: wrap; gap: 8px; }
.pastille {
  min-height: 48px; min-width: 48px; padding: 10px 14px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 14.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  touch-action: manipulation;
}
.pastille.on { background: var(--accent-lo); border-color: var(--accent); color: var(--accent); }
.f-note {
  width: 100%; min-height: 72px; resize: vertical;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 16px; font-family: inherit;
}
.f-note:focus { outline: none; border-color: var(--accent); }
.f-prive { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.f-pied { display: flex; gap: 10px; margin-top: 22px; }
.f-pied button { flex: 1 1 0; min-height: 52px; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer; }
.f-annuler { background: var(--surface2); color: var(--muted2); border: 1px solid var(--border); }
.f-valider { background: var(--accent); color: #1b1b1f; border: none; }

/* ── LE MOT QUI PASSE ──────────────────────── */
.mot {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 10px);
  z-index: 70;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px;
  font-size: 14px; line-height: 1.5;
}
.mot.grave { border-left-color: var(--red); }

/* Le numéro de version, sous le titre de la connexion : c'est le seul écran
   où il ne vole pas de place au pouce, et c'est le premier qu'on regarde
   quand on demande « tu es sur quelle version ? ». */
.auth-version {
  display: inline-block; margin-top: 10px; padding: 3px 11px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface2); color: var(--muted2);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
}

/* ── PROGRAMME BÊTA ────────────────────────────────────────────
   La bande « version d'essai », posée par `poserBandeauBeta()` (app.js) sur
   les seules adresses beta.*. Elle vit DANS LE FLUX, en premier enfant du
   <body> : elle pousse le contenu vers le bas au lieu de le recouvrir, et ne
   prend rien en bas d'écran — là se tiennent les deux onglets, qui sont toute
   la navigation de cette appli.

   Discrète mais impossible à manquer : le fond reste celui de l'appli, c'est
   le liseré d'accent qui accroche l'œil. Une bande criarde finit par ne plus
   se voir. */
.bandeau-beta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: calc(9px + env(safe-area-inset-top)) 14px 9px;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}
.bandeau-beta-lien {
  color: var(--accent);
  text-decoration: underline;
  white-space: nowrap;
}

/* L'entête colle en haut (`position: sticky; top: 0`) : sous la bande, elle
   reprend sa place dès qu'on fait défiler, et n'a rien à recouvrir puisque la
   bande, elle, défile avec la page. La marge d'encoche, en revanche, revient à
   la bande — c'est elle qui est désormais tout en haut. */
:root.beta .entete { padding-top: 12px; }

/* Le chemin vers l'inscription, sous le formulaire de connexion. */
.beta-profil {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.beta-profil a { color: var(--accent); text-decoration: underline; }
