:root {
  --fond: #faf7f2;
  --carte: #ffffff;
  --texte: #2a2118;
  --doux: #75685a;
  --ligne: #e8e0d4;
  --brun: #3b2a1a;
  --ambre: #c97d1c;
  --ambre-pale: #fbefdc;
  --vert: #2f7d4a;
  --orange: #c26a0a;
  --rouge: #b3372c;
  --ombre: 0 1px 2px rgba(59, 42, 26, .06), 0 2px 8px rgba(59, 42, 26, .05);
  --rayon: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #17130f; --carte: #221c16; --texte: #f1e9df; --doux: #b2a594; --ligne: #3a3128;
    --brun: #f1e9df; --ambre: #e3a04a; --ambre-pale: #3a2a14; --vert: #5cb87a; --orange: #e49440; --rouge: #e06a5e;
    --ombre: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond); color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.vue { max-width: 720px; margin: 0 auto; padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }

/* En-tête */
.entete { position: sticky; top: 0; z-index: 5; background: var(--fond); border-bottom: 1px solid var(--ligne); }
.entete-in { max-width: 720px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.entete h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete .sous { display: block; font-size: 12px; font-weight: 400; color: var(--doux); }
select.saison { border: 1px solid var(--ligne); background: var(--carte); border-radius: 10px; padding: 6px 8px; }

/* Barre du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--carte); border-top: 1px solid var(--ligne);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.nav-in { display: flex; width: 100%; max-width: 720px; }
.nav a { flex: 1; text-align: center; padding: 10px 2px 8px; font-size: 12px; color: var(--doux); text-decoration: none; }
.nav a svg { display: block; margin: 0 auto 2px; width: 24px; height: 24px; }
.nav a.actif { color: var(--ambre); font-weight: 600; }

/* Tuiles */
.tuiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 6px 0 14px; }
.tuile { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 12px 14px; }
.tuile .v { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.tuile .l { font-size: 13px; color: var(--doux); }
@media (min-width: 560px) { .tuiles { grid-template-columns: repeat(4, 1fr); } }

h2 { font-size: 15px; margin: 18px 2px 8px; color: var(--doux); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 12px 14px; margin-bottom: 8px; }
.vide { color: var(--doux); text-align: center; padding: 28px 8px; }

/* Listes */
.groupe { margin: 16px 2px 6px; font-size: 13px; color: var(--doux); display: flex; justify-content: space-between; }
.item { width: 100%; text-align: left; border: 0; display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 12px 14px; margin-bottom: 8px; }
.item:active { transform: scale(.99); }
.item .princ { flex: 1; min-width: 0; }
.item .titre { font-weight: 600; }
.item .detail { font-size: 14px; color: var(--doux); overflow-wrap: anywhere; }
.item .droite { text-align: right; white-space: nowrap; font-size: 14px; color: var(--doux); }
.pastille { display: inline-block; min-width: 34px; padding: 2px 8px; border-radius: 999px; background: var(--ambre-pale); color: var(--ambre);
  font-weight: 700; font-size: 14px; text-align: center; }
.pct { font-size: 22px; font-weight: 700; }
.bon { color: var(--vert); } .moyen { color: var(--orange); } .faible { color: var(--rouge); }
.ref { font-size: 12px; color: var(--vert); font-weight: 600; }
.texte-long { white-space: pre-wrap; }

/* Graphique barils par jour */
.barres { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding-top: 6px; }
.barres span { flex: 1; background: var(--ambre); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.axe { display: flex; justify-content: space-between; font-size: 12px; color: var(--doux); margin-top: 4px; }
.classes { display: flex; flex-wrap: wrap; gap: 6px; }

/* Bouton + */
.fab { position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6;
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--ambre); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2); cursor: pointer; }

/* Formulaire (feuille) */
.voile { position: fixed; inset: 0; z-index: 20; background: rgba(20, 14, 8, .45); display: flex; align-items: flex-end; justify-content: center; }
.feuille { background: var(--fond); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { .voile { align-items: center; } .feuille { border-radius: 18px; } }
.feuille h3 { margin: 0 0 12px; font-size: 18px; display: flex; justify-content: space-between; align-items: center; }
.fermer { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--doux); cursor: pointer; padding: 4px 8px; }
.champ { display: block; margin-bottom: 14px; }
label.champ > span { display: block; font-size: 13px; color: var(--doux); margin-bottom: 4px; }
input.ctl, textarea.ctl, select.ctl { width: 100%; padding: 11px 12px; border: 1px solid var(--ligne); border-radius: 10px; background: var(--carte); }
textarea.ctl { min-height: 90px; resize: vertical; }
input.ctl:focus, textarea.ctl:focus { outline: 2px solid var(--ambre); outline-offset: -1px; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { border: 1px solid var(--ligne); background: var(--carte); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 15px; }
.puce.choisie { background: var(--ambre); border-color: var(--ambre); color: #fff; }
.calcul { background: var(--ambre-pale); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.case { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.case input { width: 22px; height: 22px; }
.actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { flex: 1; border: 0; border-radius: 12px; padding: 13px; font-weight: 600; cursor: pointer; background: var(--brun); color: var(--fond); }
.btn.secondaire { background: transparent; color: var(--rouge); border: 1px solid var(--ligne); flex: 0 0 auto; padding: 13px 16px; }
.btn.danger { background: var(--rouge); color: #fff; }
.btn:disabled { opacity: .5; }
.erreur { color: var(--rouge); font-size: 14px; margin: 0 0 10px; min-height: 1em; }

/* Plus */
.menu a, .menu button { display: flex; justify-content: space-between; width: 100%; padding: 15px 14px; border: 0; background: var(--carte);
  color: var(--texte); text-decoration: none; text-align: left; cursor: pointer; border-bottom: 1px solid var(--ligne); }
.menu { border-radius: var(--rayon); overflow: hidden; box-shadow: var(--ombre); margin-bottom: 14px; }
.menu > :last-child { border-bottom: 0; }

/* Connexion */
.connexion { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.connexion h1 { font-size: 24px; margin: 12px 0 4px; }
.connexion p { color: var(--doux); margin: 0 0 20px; }

#toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--brun); color: var(--fond); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.visible { opacity: 1; }
table.corr { width: 100%; border-collapse: collapse; font-size: 14px; }
table.corr td { padding: 2px 4px; }
table.corr input { width: 100%; padding: 6px; border: 1px solid var(--ligne); border-radius: 8px; background: var(--carte); }

/* Parler au registre */
.aide { color: var(--doux); font-size: 14px; margin: 4px 2px 12px; }
#fil { padding-bottom: 190px; }
.echange { margin-bottom: 18px; }
.echange.annule { opacity: .55; }
.bulle { max-width: 88%; padding: 10px 13px; border-radius: 16px; margin-bottom: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle.moi { margin-left: auto; background: var(--brun); color: var(--fond); border-bottom-right-radius: 4px; }
.bulle.registre { background: var(--carte); box-shadow: var(--ombre); border-bottom-left-radius: 4px; }
.lien-annuler { border: 0; background: none; color: var(--rouge); font-weight: 600; padding: 4px 2px; cursor: pointer; }
.zone-parler { position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 5;
  background: linear-gradient(to top, var(--fond) 80%, transparent); padding: 18px 16px 8px; text-align: center; }
.zone-parler > * { max-width: 688px; margin-left: auto; margin-right: auto; }
.ecrire { display: flex; gap: 8px; margin-bottom: 10px; }
.ecrire .btn { flex: 0 0 auto; padding: 11px 14px; }
.micro { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--ambre); color: #fff; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2); display: block; }
.micro svg { width: 34px; height: 34px; }
.micro.ecoute { background: var(--rouge); animation: pulse 1.2s infinite; }
.micro:disabled { opacity: .5; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(179, 55, 44, .45); } 50% { box-shadow: 0 0 0 14px rgba(179, 55, 44, 0); } }
.etat-micro { min-height: 20px; font-size: 14px; color: var(--doux); margin-top: 6px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ligne-lien { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ligne); }
.ligne-lien .btn { flex: 0 0 auto; }
