:root {
  --fond: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #efeadf;
  --texte: #1f2622;
  --texte-doux: #5b6660;
  --trait: #ddd6c7;
  --accent: #1f5c4a;
  --accent-doux: #e2eee8;
  --accent-texte: #ffffff;
  --ambre: #b26b12;
  --ambre-doux: #fbf0de;
  --juste: #2c7a4b;
  --juste-doux: #e3f3e8;
  --faux: #b23b2e;
  --faux-doux: #fbe7e4;
  --ombre: 0 1px 2px rgba(31, 38, 34, 0.06), 0 6px 20px rgba(31, 38, 34, 0.06);
  --rayon: 14px;
  --titre: "Fraunces", Georgia, serif;
  --corps: "Source Sans 3", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #141917;
    --surface: #1b2220;
    --surface-2: #232c29;
    --texte: #e9ede9;
    --texte-doux: #a3b0aa;
    --trait: #2f3a36;
    --accent: #6fc2a3;
    --accent-doux: #1f3530;
    --accent-texte: #0f1513;
    --ambre: #e3a552;
    --ambre-doux: #33291b;
    --juste: #6fcf94;
    --juste-doux: #1d3326;
    --faux: #f08a7e;
    --faux-doux: #3a2220;
    --ombre: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--corps);
  font-size: 18px;
  line-height: 1.6;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--titre); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.4em; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); margin: 0 0 0.5em; }
h3 { font-size: 1.2rem; margin: 1.6em 0 0.4em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; font-size: 0.9em; }
button { font: inherit; cursor: pointer; }

/* Bandeau */
.bandeau {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--trait);
}
.bandeau-in {
  max-width: 980px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px;
}
.marque { font-family: var(--titre); font-weight: 600; font-size: 1.1rem; text-decoration: none; color: var(--texte); white-space: nowrap; }
.marque span { color: var(--accent); }
.jauge { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.jauge > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }
.jauge-texte { font-size: 0.85rem; color: var(--texte-doux); white-space: nowrap; }

main { max-width: 980px; margin: 0 auto; padding: 32px 16px 80px; }
.etroit { max-width: 720px; margin: 0 auto; }

/* Accueil */
.hero { padding: 24px 0 8px; }
.hero .surtitre { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; color: var(--accent); font-weight: 700; }
.hero p.intro { font-size: 1.15rem; color: var(--texte-doux); max-width: 640px; }
.carte {
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 22px; box-shadow: var(--ombre);
}
.identite { margin: 24px 0 8px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.identite input {
  font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--trait);
  background: var(--surface); color: var(--texte); min-width: 0; flex: 1 1 200px;
}
.bouton {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-texte); border: 0; border-radius: 10px;
  padding: 12px 20px; font-weight: 600; text-decoration: none;
}
.bouton:hover { filter: brightness(1.08); }
.bouton.secondaire { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.bouton[disabled] { opacity: 0.5; cursor: not-allowed; }

.chapitre { margin-top: 40px; }
.chapitre-tete { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.chapitre-num { font-family: var(--titre); color: var(--accent); font-size: 1rem; font-weight: 600; }
.chapitre-tete p { margin: 0; color: var(--texte-doux); }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 14px; }
.tuile {
  display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: var(--texte);
  background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; padding: 14px 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.tuile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tuile .num {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-weight: 700; font-size: 0.9rem; color: var(--texte-doux);
}
.tuile.vu .num { background: var(--accent-doux); color: var(--accent); }
.tuile.reussi .num { background: var(--accent); color: var(--accent-texte); }
.tuile strong { display: block; line-height: 1.3; }
.tuile small { color: var(--texte-doux); }
.tuile-quiz { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; border-color: var(--accent); }
.tuile-quiz h2 { margin: 0; }

/* Étape */
.fil { font-size: 0.9rem; color: var(--texte-doux); margin-bottom: 6px; }
.fil a { color: var(--texte-doux); }
.dit {
  border-left: 4px solid var(--ambre); background: var(--ambre-doux);
  padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 18px 0 8px; font-style: italic;
}
.dit::before { content: "Ce qu'on s'est dit · "; font-style: normal; font-weight: 700; color: var(--ambre); }
.corps p, .corps li { max-width: 68ch; }
.corps ul, .corps ol { padding-left: 1.3em; }
.corps li { margin: 0.3em 0; }
.tableau { overflow-x: auto; margin: 16px 0; border: 1px solid var(--trait); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; background: var(--surface); }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--trait); }
th { background: var(--surface-2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.note { font-size: 0.88rem; color: var(--texte-doux); }
.exemple { margin: 28px 0; border: 1px solid var(--accent); background: var(--accent-doux); }
.exemple .etiquette { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--accent); }
.exemple h3 { margin-top: 4px; }
.retenir { margin: 28px 0; }
.retenir h3 { margin-top: 0; }
.retenir ul { margin: 0; padding-left: 0; list-style: none; }
.retenir li { padding-left: 28px; position: relative; margin: 8px 0; }
.retenir li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

/* Questions */
.question { margin: 28px 0; }
.question h3 { margin-top: 0; }
.choix { display: grid; gap: 10px; margin: 14px 0; }
.choix button {
  text-align: left; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--trait);
  background: var(--surface); color: var(--texte); line-height: 1.4;
}
.choix button:hover:not([disabled]) { border-color: var(--accent); }
.choix button.choisi { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.choix button.juste { border-color: var(--juste); background: var(--juste-doux); }
.choix button.faux { border-color: var(--faux); background: var(--faux-doux); }
.choix button[disabled] { cursor: default; }
.retour { padding: 12px 16px; border-radius: 10px; margin-top: 8px; }
.retour.juste { background: var(--juste-doux); }
.retour.faux { background: var(--faux-doux); }
.confiance { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.confiance button {
  border: 1px solid var(--trait); background: var(--surface); color: var(--texte);
  border-radius: 99px; padding: 6px 14px; font-size: 0.95rem;
}
.confiance button.choisi { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.libelle { font-size: 0.9rem; color: var(--texte-doux); margin-top: 14px; }
textarea {
  width: 100%; min-height: 110px; font: inherit; padding: 12px; border-radius: 10px;
  border: 1px solid var(--trait); background: var(--surface); color: var(--texte); resize: vertical;
}

.navigation { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 36px; }
.compteur { color: var(--texte-doux); font-size: 0.95rem; }

/* Résultats */
.score { font-family: var(--titre); font-size: clamp(2.5rem, 8vw, 4rem); color: var(--accent); line-height: 1; }
.barres { display: grid; gap: 10px; margin: 16px 0; }
.barre-ligne { display: grid; grid-template-columns: minmax(120px, 200px) 1fr auto; gap: 12px; align-items: center; font-size: 0.95rem; }
.barre { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.barre > div { height: 100%; background: var(--accent); border-radius: 99px; }
.liste-reponses { display: grid; gap: 10px; }
.reponse-ligne { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--trait); background: var(--surface); }
.reponse-ligne.juste { border-left: 4px solid var(--juste); }
.reponse-ligne.faux { border-left: 4px solid var(--faux); }
.reponse-ligne small { color: var(--texte-doux); }
.pastille { display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--texte-doux); margin-left: 6px; }
.pastille.alerte { background: var(--faux-doux); color: var(--faux); }
.pastille.fragile { background: var(--ambre-doux); color: var(--ambre); }

footer { text-align: center; color: var(--texte-doux); font-size: 0.85rem; padding: 24px 16px 40px; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .jauge-texte { display: none; }
  .barre-ligne { grid-template-columns: 1fr auto; }
  .barre-ligne .barre { grid-column: 1 / -1; grid-row: 2; }
}

/* Corrections : pas de cadre de focus sur le conteneur, mots longs coupés sur mobile */
main:focus { outline: none; }
main, .corps, .carte { overflow-wrap: break-word; min-width: 0; }
code { overflow-wrap: anywhere; word-break: break-word; }
.tableau table { min-width: 520px; }

/* Schémas façon Excalidraw */
figure.schema { margin: 28px 0; padding: 16px; background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); }
figure.schema svg { display: block; width: 100%; height: auto; }
figure.schema figcaption { margin-top: 10px; font-size: 0.88rem; color: var(--texte-doux); }
.choix.multi button { padding-left: 44px; position: relative; }
.choix.multi button::before { content: ""; position: absolute; left: 16px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border: 2px solid var(--texte-doux); border-radius: 4px; }
.choix.multi button.choisi::before { background: var(--accent); border-color: var(--accent); }
