:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #22201c;
  --muted: #6d675d;
  --line: #e2ddd2;
  --accent: #b5562b;
  --accent-text: #ffffff;
  --soft: #f3e6dd;
  --ok: #2f7a4b;
  --ok-soft: #e1f0e6;
  --no: #a33a3a;
  --no-soft: #f6e1e1;
  --mid: #8a6d12;
  --mid-soft: #f5eccd;
  --m1: #f8d7c4; /* formules */
  --m2: #f6e7a9; /* emphase */
  --m3: #d6e4f7; /* typographie */
  --m4: #e3d6f5; /* trois */
  --m5: #d3eedb; /* conclusion */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18; --card: #252320; --text: #ece8e1; --muted: #a39d92; --line: #3a3732;
    --accent: #e07a48; --accent-text: #1b1a18; --soft: #3a2a20;
    --ok: #7fcb98; --ok-soft: #22352a; --no: #e48a8a; --no-soft: #3d2525; --mid: #e0c46a; --mid-soft: #39321c;
    --m1: #5a3624; --m2: #54491c; --m3: #24394f; --m4: #3b2c52; --m5: #23412c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a18; --card: #252320; --text: #ece8e1; --muted: #a39d92; --line: #3a3732;
  --accent: #e07a48; --accent-text: #1b1a18; --soft: #3a2a20;
  --ok: #7fcb98; --ok-soft: #22352a; --no: #e48a8a; --no-soft: #3d2525; --mid: #e0c46a; --mid-soft: #39321c;
  --m1: #5a3624; --m2: #54491c; --m3: #24394f; --m4: #3b2c52; --m5: #23412c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top, .steps, main { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 28px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.01em; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sub { margin: 4px 0 0; color: var(--muted); }
.tag { font-size: 12px; font-weight: 600; vertical-align: middle; background: var(--soft); color: var(--accent); padding: 2px 8px; border-radius: 99px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; margin-bottom: 0; }
.note:empty { display: none; }

.steps { display: flex; gap: 8px; margin-top: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.steps button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 8px 14px; border-radius: 99px; font: inherit; cursor: pointer;
}
.steps button b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--text); font-size: 13px; margin-right: 4px; }
.steps button.on { color: var(--text); border-color: var(--accent); }
.steps button.on b { background: var(--accent); color: var(--accent-text); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.intro p { margin: 10px 0 0; }
.field { display: block; font-weight: 600; }
input[type=text], textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; }
input[type=text]:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button { font: inherit; cursor: pointer; }
.primary, .ghost, .rec { border-radius: 10px; padding: 9px 16px; border: 1px solid transparent; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 18px 0 30px; align-items: center; }
.actions.left { justify-content: flex-start; margin: 12px 0 0; }

/* Consignes */
.consigne-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.consigne-head .num { color: var(--accent); font-weight: 700; margin-right: 6px; }
.consigne-head h2 { margin: 0; }
.consigne-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.rec { background: var(--soft); color: var(--accent); font-weight: 600; border-color: var(--soft); white-space: nowrap; }
.rec.live { background: var(--no); color: #fff; border-color: var(--no); }
.rec.live::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #fff; margin-right: 8px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.consigne-foot { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 8px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.consigne-foot audio { height: 32px; max-width: 100%; }

.vu { display: inline-block; width: 80px; height: 6px; background: var(--line); border-radius: 3px; vertical-align: middle; overflow: hidden; margin-left: 6px; }
.vu i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s; }
.etat { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.etat:empty { display: none; }
.etat.alerte { color: var(--no); }

details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }

/* Profil */
.bilan { display: flex; gap: 10px; flex-wrap: wrap; }
.bilan div { background: var(--bg); border-radius: 10px; padding: 10px 14px; }
.bilan b { display: block; font-size: 22px; }
.warn { background: var(--mid-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; margin-top: 12px; font-size: 14px; }
.trait { border-top: 1px solid var(--line); padding: 14px 0; }
.trait:first-of-type { border-top: 0; padding-top: 4px; }
.trait h4 { margin: 0; font-size: 16px; }
.trait .detail { margin-top: 2px; }
.trait .valeur { font-weight: 500; }
.verdict .question { font-size: 14px; font-weight: 600; margin-right: 4px; align-self: center; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.fiable { color: var(--ok); border-color: var(--ok); }
.badge.oral { color: var(--mid); border-color: var(--mid); }
.valeur { margin: 6px 0 0; }
.detail { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.verdict { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.verdict button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 99px; padding: 3px 12px; font-size: 14px; }
.verdict button.sel[data-v=oui] { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.verdict button.sel[data-v=non] { background: var(--no-soft); color: var(--no); border-color: var(--no); }
.verdict button.sel[data-v=bof] { background: var(--mid-soft); color: var(--mid); border-color: var(--mid); }
.trait.off .valeur { text-decoration: line-through; opacity: .6; }

/* Marques */
.legende { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.legende span { padding: 2px 10px; border-radius: 99px; }
.surligne { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 14px; line-height: 1.7; }
mark { color: inherit; border-radius: 4px; padding: 0 2px; }
.c-formule { background: var(--m1); }
.c-emphase { background: var(--m2); }
.c-typo { background: var(--m3); }
.c-trois { background: var(--m4); }
.c-conclusion { background: var(--m5); }
#prompt { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
