:root {
  --fond: #f7f7f5;
  --surface: #ffffff;
  --texte: #1d1f23;
  --discret: #5f6570;
  --bord: #dcdde0;
  --accent: #3b5bdb;
  --accent-texte: #ffffff;
  --ok: #1f7a3a;
  --ok-fond: #e3f4e7;
  --mid: #8a5a00;
  --mid-fond: #fdf1d8;
  --ko: #b42318;
  --ko-fond: #fde7e5;
  --enreg: #c92a2a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #15171b; --surface: #1f2228; --texte: #e8e9ec; --discret: #a3a8b3; --bord: #343842;
    --accent: #7c95f5; --accent-texte: #0d1020; --ok: #7bd896; --ok-fond: #183522; --mid: #f0c260;
    --mid-fond: #3a2d10; --ko: #ff8f85; --ko-fond: #431b18; --enreg: #ff6b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #15171b; --surface: #1f2228; --texte: #e8e9ec; --discret: #a3a8b3; --bord: #343842;
  --accent: #7c95f5; --accent-texte: #0d1020; --ok: #7bd896; --ok-fond: #183522; --mid: #f0c260;
  --mid-fond: #3a2d10; --ko: #ff8f85; --ko-fond: #431b18; --enreg: #ff6b6b; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 680px; padding: 12px 16px 48px;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  background: var(--fond); color: var(--texte);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0; }
.entete { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.entete nav { display: flex; gap: 12px; flex-wrap: wrap; }
.confidentiel { font-size: .9rem; margin: .5rem 0 1rem; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 6px; }
.discret { color: var(--discret); font-size: .88em; }

fieldset { border: 1px solid var(--bord); border-radius: 10px; margin: 0 0 12px; padding: 8px 12px 12px; background: var(--surface); }
legend { font-weight: 600; padding: 0 4px; }
.choix { display: block; padding: 6px 0; }
.choix input[type="text"] { margin-top: 4px; }
input[type="text"], select, textarea {
  width: 100%; font: inherit; color: var(--texte); background: var(--fond);
  border: 1px solid var(--bord); border-radius: 8px; padding: 10px;
}
textarea { resize: vertical; min-height: 4.5em; }
input[type="radio"], input[type="checkbox"] { width: 1.1em; height: 1.1em; vertical-align: -2px; accent-color: var(--accent); }

button { font: inherit; cursor: pointer; border-radius: 10px; }
.principal, .secondaire { min-height: 48px; padding: 10px 18px; font-weight: 600; }
.principal { background: var(--accent); color: var(--accent-texte); border: 1px solid var(--accent); }
.secondaire { background: var(--surface); color: var(--texte); border: 1px solid var(--bord); }
.lien { background: none; border: none; color: var(--accent); padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.danger { color: var(--ko); margin-top: 24px; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#bouton-commencer { width: 100%; }

.progression { display: flex; justify-content: space-between; font-size: .9rem; color: var(--discret); margin-top: 8px; }
.barre { height: 6px; background: var(--bord); border-radius: 3px; overflow: hidden; margin: 6px 0 12px; }
.barre > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.consigne { margin: 0 0 4px; font-size: .95rem; }
.phrase { margin: 0 0 16px; padding: 14px 16px; font-size: 1.3rem; line-height: 1.4; background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; }

.voie { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.voie-tete { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.micro { width: 100%; }
.micro.actif { background: var(--enreg); border-color: var(--enreg); color: #fff; animation: pulse 1.2s infinite; }
#bouton-web.actif { border-color: var(--enreg); color: var(--enreg); }
@keyframes pulse { 50% { opacity: .75; } }
@media (prefers-reduced-motion: reduce) { .micro.actif { animation: none; } }
.etat { font-size: .9rem; color: var(--discret); margin: 6px 0 0; min-height: 1.2em; }
.hyp { margin: 6px 0 0; font-style: italic; overflow-wrap: anywhere; }
.hyp:empty { display: none; }
audio { width: 100%; margin-top: 8px; height: 36px; }

.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge:empty { display: none; }
.badge.ok { color: var(--ok); background: var(--ok-fond); }
.badge.mid { color: var(--mid); background: var(--mid-fond); }
.badge.ko { color: var(--ko); background: var(--ko-fond); }
.badge.na { color: var(--discret); background: var(--fond); }

.navigation { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; }
.actions button { flex: 1 1 180px; }

.tableau-defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-weight: 600; color: var(--discret); font-size: .8rem; }
td.nombre { font-variant-numeric: tabular-nums; white-space: nowrap; }
details { background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; margin-bottom: 8px; padding: 8px 12px; }
summary { cursor: pointer; font-weight: 600; }
.ligne-phrase { border-top: 1px solid var(--bord); padding: 8px 0; font-size: .9rem; }
.ligne-phrase .ref { font-weight: 600; }
.ligne-phrase .h { display: flex; gap: 8px; align-items: baseline; }
.ligne-phrase .h span:last-child { overflow-wrap: anywhere; }
mark.err { background: var(--ko-fond); color: var(--ko); border-radius: 3px; padding: 0 2px; }
#repli-copie { margin-top: 8px; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
