:root {
  --fond: #f6f0e4;
  --carte: #fffdf8;
  --encre: #2a1d17;
  --doux: #6f6158;
  --bordeaux: #6e1a26;
  --bordeaux-clair: #f3e3e3;
  --or: #b0832a;
  --or-clair: #f5ead2;
  --vert: #2f6b3a;
  --vert-clair: #e2efe0;
  --orange: #b4572a;
  --orange-clair: #f8e4d8;
  --ligne: #e6dccb;
  --ombre: 0 1px 2px rgba(60, 35, 20, .06), 0 4px 14px rgba(60, 35, 20, .07);
  --serif: 'PT Serif', Georgia, serif;
  --sans: 'PT Sans', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--fond); color: var(--encre); font-family: var(--sans); font-size: 17px; line-height: 1.45; }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
.chargement { text-align: center; margin-top: 40vh; color: var(--doux); font-family: var(--serif); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; color: var(--bordeaux); }
h2 { font-size: 1.3rem; }
p { margin: .4em 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }
.ru { font-family: var(--serif); }

/* ---------- Accueil ---------- */
.entete { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; }
.monogramme { width: 52px; height: 52px; border-radius: 50%; background: var(--bordeaux); color: var(--or-clair);
  display: grid; place-items: center; font-family: var(--serif); font-size: 1.5rem; font-weight: 700; flex: none;
  box-shadow: inset 0 0 0 3px var(--or); }
.entete small { color: var(--doux); display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--carte); border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--ombre); }
.stat b { display: block; font-family: var(--serif); font-size: 1.5rem; color: var(--bordeaux); line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--doux); }
.gros-bouton { display: block; width: 100%; background: var(--bordeaux); color: #fff; border-radius: 16px; padding: 20px 18px;
  font-size: 1.2rem; font-weight: 700; text-align: center; box-shadow: var(--ombre); }
.gros-bouton small { display: block; font-weight: 400; font-size: .85rem; opacity: .85; margin-top: 2px; }
.gros-bouton.fait { background: var(--vert); }
.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--carte); border: 1.5px solid var(--ligne);
  border-radius: 12px; padding: 12px 16px; font-weight: 700; min-height: 48px; }
.bouton.principal { background: var(--bordeaux); border-color: var(--bordeaux); color: #fff; }
.bouton.plein { width: 100%; }
.bouton:disabled { opacity: .45; }
.lien { color: var(--bordeaux); text-decoration: underline; padding: 8px 0; }
.bloc { background: var(--carte); border-radius: 16px; padding: 16px; box-shadow: var(--ombre); margin: 14px 0; }
.bloc h3 { font-size: 1.05rem; margin-bottom: 8px; }
.calendrier { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendrier .j { aspect-ratio: 1; border-radius: 8px; background: #efe7d8; display: grid; place-items: center; font-size: .72rem; color: var(--doux); }
.calendrier .j.fait { background: var(--bordeaux); color: #fff; }
.calendrier .j.joker { background: var(--or-clair); color: var(--or); }
.calendrier .j.auj { box-shadow: inset 0 0 0 2px var(--or); }
.calendrier .tete { font-size: .7rem; text-align: center; color: var(--doux); }
.parcours { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.parcours i { width: calc((100% - 76px) / 20); min-width: 10px; height: 10px; border-radius: 3px; background: #e9dfcd; }
.parcours i.ok { background: var(--or); }
.liste-lecons button { display: flex; justify-content: space-between; width: 100%; padding: 12px 4px; border-bottom: 1px solid var(--ligne); text-align: left; }
.liste-lecons button:last-child { border-bottom: 0; }
.liste-lecons .fr { color: var(--doux); font-size: .9rem; }

/* ---------- Séance ---------- */
.barre-seance { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.barre-seance .fermer { font-size: 1.6rem; width: 40px; height: 40px; color: var(--doux); }
.etapes { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.etapes i { height: 7px; border-radius: 4px; background: #e6dccb; }
.etapes i.ok { background: var(--or); }
.etapes i.cours { background: var(--bordeaux); }
.chrono { font-size: .85rem; color: var(--doux); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.titre-etape { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--or); font-weight: 700; margin-bottom: 2px; }
.consigne { color: var(--doux); margin-bottom: 14px; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions .bouton { flex: 1; }

.note { background: var(--or-clair); border-radius: 12px; padding: 12px 14px; font-size: .95rem; margin: 12px 0; }
.mots { display: grid; gap: 6px; }
.mot { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--carte); border: 1px solid var(--ligne);
  border-radius: 12px; padding: 10px 12px; text-align: left; width: 100%; }
.mot .ru { font-size: 1.2rem; }
.mot .fr { color: var(--doux); font-size: .9rem; text-align: right; }

.dialogue { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.bulle { max-width: 88%; border-radius: 16px; padding: 10px 12px; box-shadow: var(--ombre); }
.bulle.N { background: var(--carte); align-self: flex-start; border-top-left-radius: 4px; }
.bulle.T { background: var(--bordeaux-clair); align-self: flex-end; border-top-right-radius: 4px; }
.bulle .qui { font-size: .75rem; color: var(--doux); font-weight: 700; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.bulle .ru { font-size: 1.25rem; line-height: 1.5; }
.bulle .fr { font-size: .9rem; color: var(--doux); margin-top: 2px; }
.ecouter { width: 36px; height: 36px; border-radius: 50%; background: var(--bordeaux); color: #fff; display: inline-grid; place-items: center; flex: none; }
.ecouter svg { width: 16px; height: 16px; fill: currentColor; }
.ecouter.joue { background: var(--or); }

.w { white-space: nowrap; cursor: pointer; border-radius: 4px; padding: 0 1px; transition: background .15s; }
.w:active, .w.actif { background: var(--or-clair); }
.w.ok { color: var(--vert); background: var(--vert-clair); }
.w.ko { color: var(--orange); background: var(--orange-clair); text-decoration: underline wavy; text-decoration-thickness: 1px; }

/* lecture */
.phrase-lecture { font-size: 1.6rem; line-height: 1.6; text-align: center; padding: 22px 8px; }
.phrase-lecture + .fr { text-align: center; color: var(--doux); }
.micro { width: 84px; height: 84px; border-radius: 50%; background: var(--bordeaux); color: #fff; display: grid; place-items: center; margin: 16px auto 6px; box-shadow: var(--ombre); }
.micro svg { width: 34px; height: 34px; fill: currentColor; }
.micro.ecoute { background: var(--orange); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(180, 87, 42, .5); } 100% { box-shadow: 0 0 0 22px rgba(180, 87, 42, 0); } }
.sous-micro { text-align: center; font-size: .9rem; color: var(--doux); min-height: 1.4em; }
.entendu { text-align: center; font-family: var(--serif); color: var(--doux); font-style: italic; min-height: 1.4em; }
.score { text-align: center; font-family: var(--serif); font-size: 1.15rem; margin: 10px 0; }
.score b { color: var(--bordeaux); font-size: 1.6rem; }

/* dictée */
.zone-reponse { min-height: 64px; border: 2px dashed var(--ligne); border-radius: 14px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; background: var(--carte); }
.tuiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; }
.tuile { font-family: var(--serif); font-size: 1.15rem; background: var(--carte); border: 1.5px solid var(--ligne); border-radius: 10px; padding: 8px 12px; box-shadow: var(--ombre); }
.tuile.utilisee { visibility: hidden; }
.saisie { width: 100%; font-family: var(--serif); font-size: 1.2rem; padding: 12px; border-radius: 12px; border: 1.5px solid var(--ligne); background: var(--carte); }
.correction { border-radius: 12px; padding: 12px; margin-top: 12px; }
.correction.bon { background: var(--vert-clair); }
.correction.faux { background: var(--orange-clair); }

/* quiz */
.question { font-size: 1.05rem; margin-bottom: 8px; }
.question .ru { font-size: 1.6rem; display: block; text-align: center; margin: 12px 0; }
.choix { display: grid; gap: 8px; }
.choix button { background: var(--carte); border: 1.5px solid var(--ligne); border-radius: 12px; padding: 14px; text-align: left; font-size: 1rem; }
.choix button.ru { font-size: 1.25rem; }
.choix button.bon { border-color: var(--vert); background: var(--vert-clair); }
.choix button.faux { border-color: var(--orange); background: var(--orange-clair); }

/* carte de révision */
.carte-rev { background: var(--carte); border-radius: 18px; box-shadow: var(--ombre); padding: 26px 16px; text-align: center; min-height: 200px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.carte-rev .ru { font-size: 1.7rem; line-height: 1.5; }
.carte-rev .fr { color: var(--doux); font-size: 1.05rem; }
.compteur { text-align: center; color: var(--doux); font-size: .85rem; margin-bottom: 8px; }

/* fin */
.fin { text-align: center; }
.fin .gros { font-family: var(--serif); font-size: 2.6rem; color: var(--bordeaux); line-height: 1; margin: 6px 0; }
.avis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.avis button { background: var(--carte); border: 1.5px solid var(--ligne); border-radius: 12px; padding: 12px 8px; }
.avis button.choisi { border-color: var(--bordeaux); background: var(--bordeaux-clair); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--encre); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: .9rem; max-width: 90vw; z-index: 10; }
.reglages label { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--ligne); gap: 10px; }
.reglages label:last-child { border-bottom: 0; }
.reglages input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--bordeaux); }

/* prononciation à la française sous chaque mot */
ruby.w { ruby-position: under; ruby-align: center; }
ruby.w rt { font-family: var(--sans); font-size: .62em; color: var(--doux); letter-spacing: .01em; padding-top: 2px; font-weight: 400; }
ruby.w rt b { color: var(--bordeaux); font-weight: 700; }
.bulle .ru, .carte-rev .ru, .phrase-lecture, .question .ru, .correction .ru { line-height: 2.1; }
.mot .ru { line-height: 1.9; }
