:root {
  --encre: #17324d;
  --encre-douce: #5b6b7a;
  --fond: #eef2f5;
  --surface: #ffffff;
  --filet: #c9d3dc;
  --accent: #0b6e69;
  --accent-texte: #ffffff;
  --alerte: #a3261c;
  --alerte-fond: #fbeceb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --encre: #e4ebf1;
    --encre-douce: #9fb0bf;
    --fond: #101b26;
    --surface: #182837;
    --filet: #2e4357;
    --accent: #3fb3ab;
    --accent-texte: #06201e;
    --alerte: #ff9c92;
    --alerte-fond: #3a1d1b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(env(safe-area-inset-top, 0px) + .75rem) 1rem .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--filet);
  font-size: .9rem;
}
.societe { font-weight: 700; }
.session { display: flex; align-items: center; gap: .75rem; margin: 0; }
.tech { color: var(--encre-douce); }

main { max-width: 36rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

h1 { font-size: 1.5rem; line-height: 1.2; margin: .25rem 0 .5rem; letter-spacing: -.01em; }
.intro, .consigne { color: var(--encre-douce); margin: 0 0 1.25rem; }
.consigne { font-size: 1.05rem; color: var(--encre); }

.entete-bon { margin-bottom: 1.25rem; }
.ticket { margin: 0; font-weight: 600; }
.ticket span { font-weight: 400; color: var(--encre-douce); }

.pile { display: flex; flex-direction: column; gap: 1.1rem; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
label small { font-weight: 400; color: var(--encre-douce); font-size: .85rem; }

input, textarea {
  font: inherit;
  font-weight: 400;
  color: var(--encre);
  background: var(--surface);
  border: 1px solid var(--filet);
  border-radius: 6px;
  padding: .7rem .8rem;
  min-height: 3rem;
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: 600; margin-bottom: .35rem; padding: 0; }
.choix-type { display: flex; flex-direction: column; gap: .5rem; }
.option {
  flex-direction: row;
  align-items: center;
  gap: .75rem;
  font-weight: 400;
  background: var(--surface);
  border: 1px solid var(--filet);
  border-radius: 6px;
  padding: .8rem;
  min-height: 3rem;
}
.option input { width: 1.25rem; min-height: 0; height: 1.25rem; margin: 0; accent-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

button, .bouton {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  min-height: 3.25rem;
  padding: .75rem 1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.principal { background: var(--accent); color: var(--accent-texte); border: 0; width: 100%; }
.principal:disabled { opacity: .6; cursor: progress; }
.secondaire { background: transparent; color: var(--encre); border: 1px solid var(--filet); width: 100%; }
.lien {
  background: none; border: 0; padding: .25rem 0; min-height: 0;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

.alerte {
  background: var(--alerte-fond);
  color: var(--alerte);
  border-left: 4px solid var(--alerte);
  padding: .75rem 1rem;
  border-radius: 0 6px 6px 0;
  margin: 0 0 1rem;
}

.recap { margin: 0; padding: 0; border-top: 1px solid var(--filet); }
.recap dt { font-size: .85rem; color: var(--encre-douce); padding-top: .75rem; }
.recap dd {
  margin: 0;
  padding: .15rem 0 .75rem;
  border-bottom: 1px solid var(--filet);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.empreinte { font-size: .8rem; }

/* Le feuillet de signature reste blanc, même en mode sombre */
.zone-signature { margin-top: .5rem; }
.attestation { margin: 0 0 .75rem; font-size: .95rem; }
.feuillet {
  position: relative;
  background: #ffffff;
  border: 1px solid #9fb0bf;
  border-radius: 6px;
  height: 13rem;
  box-shadow: 0 1px 0 #9fb0bf, 0 3px 0 -1px #ffffff, 0 4px 0 -1px #9fb0bf;
}
#pad {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  border-radius: 6px;
}
.ligne {
  position: absolute;
  left: 2.25rem;
  right: 1.25rem;
  bottom: 2.75rem;
  border-bottom: 1.5px solid #17324d;
  pointer-events: none;
}
.ligne::before {
  content: "×";
  position: absolute;
  left: -1.4rem;
  bottom: -.15rem;
  font-size: 1.4rem;
  line-height: 1;
  color: #17324d;
}
.sous-pad {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: .5rem;
  font-size: .9rem;
  color: var(--encre-douce);
}
.sous-pad .erreur { color: var(--alerte); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* --- Version préparation sur PC --- */
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.note { color: var(--encre-douce); font-size: .9rem; margin: 0; }
main:has(#form-preparer), main:has(.liste-bons) { max-width: 46rem; }

.taches { display: flex; flex-direction: column; gap: .5rem; }
.tache {
  flex-direction: row; align-items: flex-start; gap: .75rem; font-weight: 400;
  background: var(--surface); border: 1px solid var(--filet); border-radius: 6px; padding: .75rem;
}
.tache input { width: 1.2rem; height: 1.2rem; min-height: 0; margin: .2rem 0 0; accent-color: var(--accent); flex: none; }
.tache:has(input:checked) { border-color: var(--accent); }
.tache-corps { display: flex; flex-direction: column; gap: .2rem; }
.tache-meta { font-size: .85rem; color: var(--encre-douce); font-weight: 600; }
.tache-texte { white-space: pre-line; overflow-wrap: anywhere; }

.ajout { background: var(--surface); border: 1px solid var(--filet); border-radius: 6px; padding: .25rem .9rem; }
.ajout[open] { padding-bottom: 1rem; }
.ajout summary { cursor: pointer; font-weight: 600; padding: .6rem 0; min-height: 2.5rem; }
.ajout summary small { font-weight: 400; color: var(--encre-douce); margin-left: .35rem; }
.ajout > * + * { margin-top: .75rem; }

.qr { margin: 0 0 1.25rem; text-align: center; }
.qr img { background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--filet); }
.qr figcaption { color: var(--encre-douce); font-size: .9rem; margin-top: .5rem; }
.duo-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1rem 0; }

.liste-bons { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--filet); }
.liste-bons li { display: flex; flex-direction: column; gap: .15rem; padding: .7rem 0; border-bottom: 1px solid var(--filet); }
.lb-titre { font-weight: 600; }
.statut { font-size: .9rem; color: var(--encre-douce); }
.statut-signe { color: var(--accent); }
.statut-erreur, .lb-alerte { color: var(--alerte); font-size: .9rem; }

.recap-bloc { border-top: 1px solid var(--filet); }
.recap-bloc h2 { font-size: .85rem; color: var(--encre-douce); font-weight: 600; margin: .9rem 0 .3rem; }
.texte-bon { margin: 0 0 .9rem; white-space: pre-line; overflow-wrap: anywhere; }
.recap-taches { list-style: none; margin: 0; padding: 0; }
.recap-taches li { display: flex; flex-direction: column; padding: .45rem 0; border-bottom: 1px dashed var(--filet); }
.total { font-weight: 700; margin: .5rem 0 .9rem; }
.pour-tech { border: 1px dashed var(--alerte); border-radius: 6px; padding: .5rem .9rem; margin-bottom: 1rem; }
.etape { margin: 0; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
