:root {
  --ocean: #0b4ea2; --ocean-fonce: #083a7a; --ocean-pale: #e7effb;
  --soleil: #f5b700; --soleil-pale: #fff4cc; --corail: #e5533d; --corail-pale: #fde8e4;
  --vert: #1e9e62; --vert-pale: #e2f5eb; --violet: #6b4fd3; --violet-pale: #ede8fd;
  --sable: #faf6ee; --carte: #ffffff; --texte: #182033; --doux: #69728a; --bord: #ebe5d8;
  --ombre: 0 1px 2px rgba(24,32,51,.05), 0 6px 18px rgba(24,32,51,.06);
  --rond: 20px;
  --titre: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --sable: #0f131c; --carte: #1a2030; --texte: #eef1f7; --doux: #9aa4ba; --bord: #273049;
          --ocean-pale: #182a4d; --soleil-pale: #3a3012; --corail-pale: #3d1f1a; --vert-pale: #143726; --violet-pale: #271f47;
          --ombre: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--sable); }
body { margin: 0; font: 16.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texte);
       background: var(--sable); padding-bottom: calc(84px + env(safe-area-inset-bottom)); min-height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, .titre { font-family: var(--titre); }
main { max-width: 620px; margin: 0 auto; padding: 0 16px 24px; animation: entree .25s ease; }
@keyframes entree { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- en-tête ---------- */
.hero { background: linear-gradient(160deg, var(--ocean) 0%, var(--ocean-fonce) 100%); color: #fff;
        padding: calc(18px + env(safe-area-inset-top)) 20px 64px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: -10%; right: -10%; bottom: -40px; height: 80px;
               background: var(--sable); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.hero .etoiles { position: absolute; right: -30px; top: -20px; width: 180px; opacity: .14; }
.hero h1 { margin: 0; font-size: 28px; letter-spacing: .2px; }
.hero p { margin: 4px 0 0; opacity: .85; font-size: 15px; }
.hero .rangee { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; z-index: 1; }
.anneau { width: 82px; height: 82px; flex: none; position: relative; }
.anneau svg { transform: rotate(-90deg); }
.anneau .val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-family: var(--titre);
               font-weight: 800; font-size: 20px; line-height: 1; }
.anneau .val small { display: block; font-size: 10.5px; font-weight: 600; opacity: .85; margin-top: 2px; }
.barre-haut { background: var(--ocean); color: #fff; padding: calc(12px + env(safe-area-inset-top)) 12px 14px;
              display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 5; }
.barre-haut h1 { font-size: 19px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre-haut button { background: rgba(255,255,255,.14); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 12px; font-size: 18px; flex: none; }
.remonte { margin-top: -44px; position: relative; z-index: 2; }

/* ---------- cartes ---------- */
.carte { background: var(--carte); border-radius: var(--rond); box-shadow: var(--ombre); padding: 18px; margin-top: 12px; }
.carte h3 { margin: 0; font-size: 18px; }
.carte p { margin: 4px 0 0; color: var(--doux); font-size: 14.5px; }
.cliquable { display: block; width: 100%; text-align: left; border: 0; transition: transform .12s ease; }
.cliquable:active { transform: scale(.985); }
.section { font-family: var(--titre); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px;
           color: var(--doux); margin: 26px 4px 4px; }
.moment { display: flex; gap: 14px; align-items: center; }
.moment .ico { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 25px; flex: none; }
.moment .corps { flex: 1; min-width: 0; }
.moment .etat { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.etat.fait { background: var(--vert-pale); color: var(--vert); }
.etat.afaire { background: var(--soleil-pale); color: #946c00; }
@media (prefers-color-scheme: dark) { .etat.afaire { color: var(--soleil); } }
.i-ocean { background: var(--ocean-pale); } .i-soleil { background: var(--soleil-pale); } .i-corail { background: var(--corail-pale); }
.i-vert { background: var(--vert-pale); } .i-violet { background: var(--violet-pale); }
.mini-barre { height: 6px; border-radius: 3px; background: var(--bord); margin-top: 8px; overflow: hidden; }
.mini-barre i { display: block; height: 100%; border-radius: 3px; background: var(--ocean); transition: width .4s ease; }
.mini-barre.vert i { background: var(--vert); }

.phrase-jour { background: linear-gradient(135deg, var(--soleil-pale), var(--carte) 70%); border: 1px solid var(--bord); }
.phrase-jour .k { font-family: var(--titre); font-size: 22px; font-weight: 800; color: var(--ocean); margin-top: 6px; line-height: 1.3; }
@media (prefers-color-scheme: dark) { .phrase-jour .k, .kriolu, .k-bleu { color: #9fc1ff !important; } }
.etiquette { font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--doux); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--carte); border-radius: 16px; box-shadow: var(--ombre); padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--titre); font-size: 24px; color: var(--ocean); }
.stat span { font-size: 12.5px; color: var(--doux); }

/* ---------- grilles ---------- */
.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tuile { background: var(--carte); border: 0; border-radius: 18px; box-shadow: var(--ombre); padding: 14px; text-align: left; position: relative; }
.tuile .e { font-size: 26px; } .tuile b { display: block; font-family: var(--titre); font-size: 15.5px; line-height: 1.25; margin-top: 6px; }
.tuile small { color: var(--doux); font-size: 12.5px; }
.pastille { position: absolute; top: 10px; right: 10px; background: var(--corail); color: #fff; border-radius: 10px; font-size: 12px;
            padding: 1px 8px; font-weight: 700; }

/* chemin des leçons */
.chemin { position: relative; margin-top: 12px; }
.chemin::before { content: ""; position: absolute; left: 33px; top: 30px; bottom: 30px; width: 3px; background: var(--bord); border-radius: 2px; }
.etape-l { display: flex; gap: 14px; align-items: center; padding: 10px 12px; border-radius: 18px; border: 0; background: none; width: 100%; text-align: left; position: relative; }
.etape-l:active { background: var(--carte); }
.etape-l .num { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 21px;
                background: var(--carte); box-shadow: var(--ombre); border: 3px solid var(--bord); position: relative; z-index: 1; }
.etape-l.fini .num { border-color: var(--vert); background: var(--vert-pale); }
.etape-l.encours .num { border-color: var(--soleil); background: var(--soleil-pale); }
.etape-l.suivante .num { border-color: var(--ocean); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(11,78,162,.35); } 50% { box-shadow: 0 0 0 8px rgba(11,78,162,0); } }
.etape-l b { font-family: var(--titre); display: block; font-size: 16px; }
.etape-l small { color: var(--doux); font-size: 13.5px; }

/* ---------- exercice ---------- */
.progression { height: 8px; background: rgba(255,255,255,.25); border-radius: 4px; overflow: hidden; flex: 1; }
.progression i { display: block; height: 100%; background: var(--soleil); border-radius: 4px; transition: width .3s ease; }
.question { font-family: var(--titre); font-size: 25px; font-weight: 700; line-height: 1.3; margin: 6px 0 0; }
.consigne { color: var(--doux); font-size: 14px; margin: 0; }
.reponse { margin-top: 20px; padding-top: 18px; border-top: 2px dashed var(--bord); animation: entree .2s ease; }
.kriolu { font-family: var(--titre); font-size: 27px; font-weight: 800; color: var(--ocean); line-height: 1.3; margin: 0; }
.sous-titre { color: var(--doux); font-size: 16px; margin: 6px 0 0; }
.note-gram { background: var(--violet-pale); border-radius: 12px; padding: 8px 12px; font-size: 14px; margin-top: 12px; }
.btn { border: 0; border-radius: 16px; padding: 15px 18px; font-weight: 700; font-size: 16.5px; width: 100%; margin-top: 16px;
       background: var(--ocean); color: #fff; box-shadow: 0 4px 0 var(--ocean-fonce); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ocean-fonce); }
.btn.secondaire { background: var(--carte); color: var(--texte); box-shadow: 0 3px 0 var(--bord); border: 1px solid var(--bord); }
.btn.soleil { background: var(--soleil); color: #2a2000; box-shadow: 0 4px 0 #c99500; }
.btn:disabled { opacity: .5; }
.ecouter { border: 0; background: var(--ocean-pale); color: var(--ocean); border-radius: 999px; padding: 9px 16px; font-weight: 700;
           font-size: 14.5px; margin-top: 14px; display: inline-flex; align-items: center; gap: 6px; }
@media (prefers-color-scheme: dark) { .ecouter { color: #9fc1ff; } }
.ecouter.joue { animation: ondes 1s infinite; }
@keyframes ondes { 0%,100% { box-shadow: 0 0 0 0 rgba(11,78,162,.3); } 50% { box-shadow: 0 0 0 6px rgba(11,78,162,0); } }
.notes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.notes button { border: 0; border-radius: 14px; padding: 12px 2px; font-weight: 800; font-size: 14.5px; color: #fff; line-height: 1.2; }
.notes small { display: block; font-weight: 500; font-size: 11px; opacity: .9; margin-top: 2px; }
.n0 { background: var(--corail); } .n1 { background: #e48a1f; } .n2 { background: var(--vert); } .n3 { background: var(--ocean); }
.badge { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; margin-top: 12px;
         background: var(--soleil-pale); color: #7a5a00; }
.badge.ok { background: var(--vert-pale); color: var(--vert); }
@media (prefers-color-scheme: dark) { .badge { color: var(--soleil); } }
.lien { background: none; border: 0; color: var(--doux); font-size: 14px; text-decoration: underline; text-underline-offset: 3px;
        padding: 6px 0; margin: 10px 14px 0 0; }
textarea, input[type=search], input[type=text] { width: 100%; font: inherit; padding: 13px 15px; border-radius: 14px;
        border: 2px solid var(--bord); background: var(--carte); color: inherit; outline: none; }
textarea:focus, input:focus { border-color: var(--ocean); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

/* choix (QCM) */
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.choix button { border: 2px solid var(--bord); background: var(--carte); border-radius: 14px; padding: 14px 8px; font-weight: 700;
                font-family: var(--titre); font-size: 18px; }
.choix button.bon { border-color: var(--vert); background: var(--vert-pale); color: var(--vert); }
.choix button.faux { border-color: var(--corail); background: var(--corail-pale); color: var(--corail); }
.trou { display: inline-block; min-width: 54px; border-bottom: 3px solid var(--soleil); color: var(--soleil); text-align: center; }

/* onglets d'étapes de leçon */
.etapes { display: flex; gap: 6px; margin: 14px 0 4px; }
.etapes button { flex: 1; border: 0; background: var(--carte); box-shadow: var(--ombre); border-radius: 12px; padding: 8px 2px;
                 font-size: 12.5px; font-weight: 700; color: var(--doux); }
.etapes button.actif { background: var(--ocean); color: #fff; }
.etapes button.fait:not(.actif) { color: var(--vert); }
.explication p { color: var(--texte); font-size: 16px; margin: 0 0 12px; }
.explication code, .k-bleu { font-family: var(--titre); font-weight: 800; color: var(--ocean); background: var(--ocean-pale);
                              padding: 1px 6px; border-radius: 6px; font-size: .97em; }
.regle { background: var(--soleil-pale); border-radius: 16px; padding: 14px 16px; font-weight: 600; margin: 4px 0 14px; }
.exemple { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--bord); }
.exemple:first-child { border-top: 0; }
.exemple .t { flex: 1; } .exemple .t b { font-family: var(--titre); color: var(--ocean); font-size: 17px; }
.exemple .t span { display: block; color: var(--doux); font-size: 14.5px; }
.exemple .t em { display: block; color: var(--violet); font-size: 13px; font-style: normal; margin-top: 2px; }
.rond { border: 0; background: var(--ocean-pale); width: 40px; height: 40px; border-radius: 50%; flex: none; font-size: 16px; }
.rond.plus { background: var(--vert-pale); color: var(--vert); font-weight: 800; font-size: 20px; }

/* écoute */
.ligne-ecoute { padding: 14px 0; border-top: 1px solid var(--bord); }
.ligne-ecoute:first-child { border-top: 0; }
.ligne-ecoute.active .mots { color: var(--ocean); }
.mots { font-family: var(--titre); font-size: 19px; font-weight: 700; line-height: 1.55; }
.mots span { cursor: pointer; border-radius: 6px; padding: 0 1px; }
.mots span:hover, .mots span.vu { background: var(--soleil-pale); }
.trad { color: var(--doux); font-size: 15px; margin-top: 4px; }
.trad.cachee { filter: blur(6px); cursor: pointer; user-select: none; }
.outils-ligne { display: flex; gap: 8px; margin-top: 8px; }
.puce { border: 1px solid var(--bord); background: var(--carte); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; }
.puce.actif { background: var(--ocean); color: #fff; border-color: var(--ocean); }
.puces { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.source { font-size: 12.5px; color: var(--doux); margin-top: 6px; }

/* feuille du bas (mot touché) */
.voile { position: fixed; inset: 0; background: rgba(10,15,30,.4); z-index: 20; animation: fondu .15s; }
@keyframes fondu { from { opacity: 0; } }
.feuille { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--carte); border-radius: 24px 24px 0 0;
           padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); max-height: 70vh; overflow: auto; animation: monte .2s ease; max-width: 620px; margin: 0 auto; }
@keyframes monte { from { transform: translateY(100%); } }
.feuille .poignee { width: 42px; height: 5px; background: var(--bord); border-radius: 3px; margin: 0 auto 12px; }

/* fluidité */
.chrono { width: 220px; height: 220px; margin: 18px auto 6px; position: relative; }
.chrono svg { transform: rotate(-90deg); }
.chrono .temps { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--titre); font-size: 46px; font-weight: 800; }
.chrono .temps small { display: block; font-size: 14px; color: var(--doux); font-weight: 600; text-align: center; }
.manche { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.manche span { width: 40px; height: 8px; border-radius: 4px; background: var(--bord); }
.manche span.ok { background: var(--vert); } .manche span.en { background: var(--soleil); }

/* journal */
.correction { padding: 12px 0; border-top: 1px solid var(--bord); }
.correction:first-child { border-top: 0; }
.avant { color: var(--corail); text-decoration: line-through; text-decoration-thickness: 2px; }
.apres { color: var(--vert); font-weight: 700; }
.phrase-corr { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--bord); align-items: flex-start; }
.phrase-corr:first-child { border-top: 0; }
.phrase-corr .ic { font-size: 18px; } .phrase-corr .t { flex: 1; }
.attente { text-align: center; padding: 30px 10px; }
.vague { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.vague i { width: 10px; height: 10px; border-radius: 50%; background: var(--ocean); animation: saut 1s infinite ease-in-out; }
.vague i:nth-child(2) { animation-delay: .15s; background: var(--soleil); } .vague i:nth-child(3) { animation-delay: .3s; background: var(--corail); }
@keyframes saut { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* fin de série */
.fin { text-align: center; padding: 26px 18px; }
.fin .gros { font-family: var(--titre); font-size: 54px; font-weight: 800; color: var(--vert); line-height: 1; margin: 8px 0; }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 30; border-radius: 2px; animation: tombe linear forwards; pointer-events: none; }
@keyframes tombe { to { transform: translateY(105vh) rotate(720deg); opacity: .7; } }

/* navigation */
nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: color-mix(in srgb, var(--carte) 92%, transparent);
      backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--bord);
      display: flex; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
nav button { flex: 1; border: 0; background: none; padding: 6px 0; font-size: 11.5px; font-weight: 700; color: var(--doux);
             border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav button .i { font-size: 22px; line-height: 1.2; filter: grayscale(1); opacity: .65; transition: .15s; }
nav button.actif { color: var(--ocean); background: var(--ocean-pale); }
nav button.actif .i { filter: none; opacity: 1; transform: scale(1.08); }
@media (prefers-color-scheme: dark) { nav button.actif { color: #9fc1ff; } }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
         background: var(--texte); color: var(--sable); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
         animation: entree .2s; box-shadow: var(--ombre); }
.vide { color: var(--doux); text-align: center; padding: 30px 10px; }
.resultat { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--bord); }
.resultat:first-child { border-top: 0; }
.resultat .t { flex: 1; } .resultat b { font-family: var(--titre); color: var(--ocean); font-size: 16.5px; }
.resultat small { display: block; color: var(--doux); font-size: 14px; }
.carte .question, .carte .regle, .carte .explication p { color: var(--texte); }
.carte .kriolu { color: var(--ocean); }
.carte .sous-titre { color: var(--doux); }
.note-gram code, .exemple em code, .regle code { font-family: var(--titre); font-weight: 800; color: var(--ocean);
  background: rgba(255,255,255,.55); padding: 0 5px; border-radius: 5px; }
