:root {
  --fond: #faf6f2;
  --carte: #ffffff;
  --encre: #2a1d14;
  --doux: #6f5d50;
  --trait: #e4d9cf;
  --accent: #6e1d36;
  --accent-clair: #f3e3e8;
  --ok: #1f6b3a;
  --alerte: #9a3b0c;
  --alerte-fond: #fdf0e3;
  --rayon: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1 { font-size: 1.35rem; line-height: 1.25; margin: .4rem 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: calc(.55rem + env(safe-area-inset-top)) 16px .55rem;
  background: var(--accent); color: #fff;
}
.titre { background: none; border: 0; color: #fff; font-weight: 700; font-size: 1.05rem; padding: .3rem 0; }
.qui { background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 999px; padding: .35rem .8rem; font-size: .9rem; }
main { padding: 12px 16px 48px; max-width: 640px; margin: 0 auto; }

.bandeau { padding: .6rem 16px; background: var(--accent-clair); font-size: .92rem; }
.bandeau.alerte { background: var(--alerte-fond); color: var(--alerte); }

.principal, .secondaire, .choix, .choix-radio {
  min-height: 48px; border-radius: var(--rayon); padding: .7rem 1rem; font-weight: 600;
}
.principal { background: var(--accent); color: #fff; border: 0; width: 100%; }
.principal.grand { min-height: 64px; font-size: 1.15rem; }
.secondaire { background: var(--carte); border: 1.5px solid var(--accent); color: var(--accent); }
.lien { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: .35rem 0; min-height: 44px; }
.actions { display: grid; gap: .6rem; margin: .4rem 0 1rem; }
.pile { display: grid; gap: .9rem; }
.ligne { display: flex; gap: .5rem; align-items: center; }
.ligne input { flex: 1; min-width: 0; }
label { display: grid; gap: .3rem; font-weight: 600; }
input, select {
  width: 100%; min-height: 48px; padding: .6rem .75rem;
  border: 1.5px solid var(--trait); border-radius: var(--rayon); background: var(--carte);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid #c58a9c; outline-offset: 2px; }
fieldset { border: 1.5px solid var(--trait); border-radius: var(--rayon); padding: .6rem .8rem; margin: 0; }
legend { font-weight: 700; padding: 0 .3rem; }
.radio { display: flex; align-items: center; gap: .6rem; font-weight: 500; min-height: 44px; }
.radio input { width: 22px; min-height: 22px; height: 22px; }
.recherche { margin-top: .4rem; }

.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.grille.emp { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.choix { background: var(--carte); border: 1.5px solid var(--trait); text-align: center; display: grid; gap: .1rem; }
.choix small { font-weight: 400; color: var(--doux); font-size: .78rem; }
.choix-radio { display: flex; justify-content: center; align-items: center; gap: .4rem; border: 1.5px solid var(--trait); background: var(--carte); }
.choix-radio:has(input:checked) { border-color: var(--accent); background: var(--accent-clair); }
.choix-radio input { width: 20px; min-height: 20px; height: 20px; }
[hidden] { display: none !important; }

.liste { list-style: none; padding: 0; margin: .3rem 0; display: grid; gap: .4rem; }
.liste li { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .6rem .75rem; }
.liste a { display: grid; color: inherit; text-decoration: none; }
.aide { color: var(--doux); font-size: .88rem; font-weight: 400; }
.liste .aide { display: block; }
.erreur { color: #a3122b; font-weight: 600; margin: 0; min-height: 1em; }
.ecart { font-weight: 700; color: var(--accent); margin: 0; }
.marque { margin: .4rem 0 0; color: var(--doux); text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; }
.puce { display: inline-block; background: var(--accent-clair); color: var(--accent); border-radius: 999px; padding: .15rem .6rem; font-weight: 700; margin: 0 .2rem .3rem 0; }

.tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .6rem 0; }
.tuile { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .6rem; display: grid; gap: .1rem; }
.tuile span { color: var(--doux); font-size: .8rem; }
.tuile b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.tuile.total { background: var(--accent-clair); border-color: transparent; }

.camera { position: relative; overflow: hidden; border-radius: var(--rayon); background: #000; aspect-ratio: 4 / 3; max-height: 45vh; width: 100%; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cadre { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 2px solid rgba(255,255,255,.9); border-radius: 10px; pointer-events: none; }
.cadre span { position: absolute; left: 12px; right: 12px; top: 50%; height: 2px; background: rgba(230,40,60,.85); }
.etat-camera { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.85); margin: 0; font-weight: 600; }
.lampe { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 8px; padding: .3rem .6rem; }

.tableau { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; background: var(--carte); }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--trait); white-space: nowrap; }
th { color: var(--doux); font-weight: 600; }

.pied { margin-top: 2rem; color: var(--doux); font-size: .9rem; }
.pied p { margin: .2rem 0; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10;
  background: var(--ok); color: #fff; padding: .8rem 1rem; border-radius: var(--rayon); font-weight: 600; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.toast.erreur { background: #a3122b; }
