:root {
  --fond: #f6f1e7;
  --carte: #fffdf8;
  --texte: #1f2421;
  --doux: #6b6f68;
  --ligne: #e3dccd;
  --accent: #1f8a7a;
  --accent-fonce: #166b5f;
  --vert: #2f8f5b;
  --rouge: #c0392b;
  --bois: #8a5a33;
  --point: #1f2421;
  --nav: #2b2119;
  --caisse: #d9b48a;
  --caisse-bord: #b58a5c;
  --lame: #dfe4e8;
  --lame-ombre: #a9b2ba;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #141a17;
    --carte: #1e2622;
    --texte: #eef0ea;
    --doux: #a3aaa2;
    --ligne: #33403a;
    --accent: #2fb8a3;
    --accent-fonce: #6fd8c6;
    --vert: #4cc283;
    --rouge: #ef6b5b;
    --bois: #d39a6a;
    --point: #eef0ea;
    --nav: #120d09;
    --caisse: #6e4d2f;
    --caisse-bord: #4f3620;
    --lame: #c9d0d6;
    --lame-ombre: #87919a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 760px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 24px; }
h1 { font-size: 1.7rem; margin: .3em 0 .2em; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.4em 0 .5em; }
h3 { font-size: 1.05rem; margin: 0 0 .6em; }
h3 small, h2 small { color: var(--doux); font-weight: 400; font-size: .8em; }
a { color: var(--accent-fonce); }
.petit-texte { color: var(--doux); font-size: .88rem; }
.surtitre { color: var(--doux); margin: 0; font-size: .9rem; }
.retour { display: inline-block; margin: 4px 0; text-decoration: none; font-weight: 600; }
.gros { font-size: 1.5rem; font-weight: 700; text-align: center; color: var(--accent-fonce); margin: .4em 0; }
.alerte { color: var(--rouge); }

/* navigation */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--nav); padding-bottom: env(safe-area-inset-bottom);
}
nav a {
  flex: 1; text-align: center; color: #c6cfc8; text-decoration: none; font-size: .75rem; padding: 8px 0 10px;
}
nav a span { display: block; font-size: 1.35rem; line-height: 1.2; }
nav a.on { color: #7fe0cf; }

/* cartes, boutons */
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; padding: 16px; margin: 12px 0; }
.carte.texte p:first-child { margin-top: 0; }
.carte.texte p:last-child { margin-bottom: 0; }
.btn {
  appearance: none; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte);
  border-radius: 999px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: .5; }
.btn.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.grand { display: block; text-align: center; padding: 14px 18px; margin: 10px 0; font-size: 1.05rem; }
.btn.bon { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn.faux { background: var(--rouge); border-color: var(--rouge); color: #fff; opacity: .75; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ligne { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.ligne.centre { justify-content: center; align-items: center; }
.defile { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
.options { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; font-size: .92rem; }
.options input { accent-color: var(--accent); }
.tempo, .champ { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: .92rem; }
.tempo input { flex: 1; accent-color: var(--accent); }
.tempo b { min-width: 2.5em; text-align: right; }
select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte); max-width: 100%; }

/* accueil */
.hero { padding: 6px 0; }
.hero h1 { font-size: 2.2rem; margin-bottom: 0; }
.hero p { margin: .2em 0; }
.barre { height: 10px; background: var(--ligne); border-radius: 99px; overflow: hidden; margin: 12px 0 4px; }
.barre div { height: 100%; background: var(--vert); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 1.5rem; }
.stats small { color: var(--doux); font-size: .78rem; }
.seance { padding-left: 1.3em; }
.seance li { margin: 6px 0; }
.seance a { text-decoration: none; color: var(--texte); font-weight: 600; }
.seance small { color: var(--doux); font-weight: 400; }

/* parcours */
.niveau h2 { display: flex; align-items: center; gap: 10px; }
.num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .95rem; }
.lecons { list-style: none; padding: 0; margin: 0; }
.lecons a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--ligne); background: var(--carte); border-radius: 12px; margin: 6px 0; color: var(--texte); text-decoration: none; }
.lecons small { margin-left: auto; color: var(--doux); }
.lecons .etat { width: 22px; text-align: center; color: var(--vert); font-weight: 700; }
.lecons .suiv a { border-color: var(--accent); }
.lecons .suiv .etat { color: var(--accent); }
.lecons .fait a { opacity: .8; }
.fin-lecon { margin: 20px 0; }
.bravo { font-size: 1.2rem; font-weight: 700; color: var(--vert); text-align: center; }

/* accords (petit schéma de kalimba) */
.accord { appearance: none; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte); border-radius: 12px; padding: 6px 6px 4px; display: flex; flex-direction: column; align-items: center; cursor: pointer; font: inherit; min-width: 96px; }
.accord.petit { min-width: 80px; padding: 4px; }
.accord .code { font-weight: 800; font-size: 1.05rem; }
.accord .nom { font-size: .72rem; color: var(--doux); }
.accord:active { transform: scale(.97); }
.diag .caisse { fill: var(--caisse); stroke: var(--caisse-bord); stroke-width: 1.5; }
.diag .chev { fill: #4a4a4a; }
.diag .l { fill: var(--lame); }
.diag .l.on { fill: var(--accent); }

/* kalimba interactif */
.kalimba { position: relative; display: flex; align-items: flex-start; justify-content: center; gap: 3px; height: 150px; padding: 14px 10px 10px; margin: 6px 0 10px;
  background: var(--caisse); border: 2px solid var(--caisse-bord); border-radius: 18px 18px 46% 46% / 18px 18px 26% 26%; }
.kalimba.grand { height: 240px; }
.chevalet { position: absolute; left: 8px; right: 8px; top: 12px; height: 6px; border-radius: 3px; background: #4a4a4a; z-index: 1; }
.lame { appearance: none; flex: 1; max-width: 30px; min-width: 0; border: 0; padding: 0 0 6px; margin: 0; cursor: pointer; font: inherit; font-size: .78rem; color: #1d2328;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  background: linear-gradient(90deg, var(--lame-ombre), var(--lame) 35%, var(--lame) 65%, var(--lame-ombre)); border-radius: 2px 2px 9px 9px; box-shadow: 0 2px 2px rgba(0,0,0,.25); transition: transform .08s; }
.lame.do { background: linear-gradient(90deg, #b9a46b, #f1e2b1 35%, #f1e2b1 65%, #b9a46b); }
.lame.on { background: var(--accent); color: #fff; }
.lame.suiv { outline: 2px dashed var(--accent); outline-offset: 1px; }
.lame.ok { background: var(--vert); color: #fff; }
.lame.frappe { transform: translateY(3px); filter: brightness(1.15); }
.kn { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 800; }
.kn i { font-style: normal; font-size: .6em; letter-spacing: -1px; height: .75em; line-height: .75em; }

/* écoute accord */
.micacc .ligne { align-items: center; }
.micacc-etat { flex: 1; min-width: 160px; }
.pastilles { display: flex; gap: 8px; margin-bottom: 8px; }
.pastilles i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ligne); }
.pastilles i.ok { background: var(--vert); border-color: var(--vert); }
.jauge { height: 8px; background: var(--ligne); border-radius: 99px; overflow: hidden; }
.jauge div { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.entendu { color: var(--doux); font-size: .9rem; min-height: 1.4em; }
.micacc.reussi { border-color: var(--vert); }

/* boucle / rythme */
.motif { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; text-align: center; }
.motif .sub { font-size: 1.4rem; font-weight: 800; border-radius: 8px; padding: 4px 0; background: var(--fond); overflow: hidden; white-space: nowrap; text-overflow: clip; }
.motif .sub.on { background: var(--accent); color: #fff; }
.motif.comptes { color: var(--doux); font-size: .8rem; margin-top: 2px; }
.scene { position: relative; display: flex; align-items: center; justify-content: center; gap: 18px; margin: 12px 0 6px; }
.scene .ensuite { color: var(--doux); font-size: .9rem; text-align: center; }
.scene .ensuite b { font-size: 1.6rem; color: var(--texte); }
.decompte { position: absolute; inset: 0; display: grid; place-items: center; font-size: 4rem; font-weight: 900; color: var(--accent); pointer-events: none; }
.decompte:empty { display: none; }
.temps-points { display: flex; justify-content: center; gap: 10px; margin: 8px 0; }
.temps-points i { width: 14px; height: 14px; border-radius: 50%; background: var(--ligne); }
.temps-points i:first-child { outline: 2px solid var(--ligne); outline-offset: 2px; }
.temps-points i.on { background: var(--accent); }
.temps-points.grands i { width: 26px; height: 26px; }

/* défi minute */
.minute-ecran { display: grid; grid-template-columns: 1fr 1fr; align-items: center; text-align: center; margin: 12px 0; }
.chrono { font-size: 2.6rem; font-weight: 900; }
.score { font-size: 2.6rem; font-weight: 900; color: var(--vert); }
.record { grid-column: 1 / -1; color: var(--doux); }

/* tablature en chiffres */
.ktab { display: flex; flex-wrap: wrap; gap: 6px 2px; align-items: flex-start; margin: 10px 0; font-size: 1.4rem; }
.ktab .tcol { min-width: 32px; padding: 2px 3px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; }
.ktab .kns { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.ktab .tcol.court .kns { border-bottom: 2px solid currentColor; }
.ktab small { font-size: .72rem; color: var(--doux); white-space: nowrap; min-height: 1.1em; }
.ktab .tiret { color: var(--doux); min-width: 16px; text-align: center; padding-top: 10px; }
.tcol.on { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.tcol.joue { background: color-mix(in srgb, var(--vert) 30%, transparent); }
.tcol.ok { color: var(--vert); }

/* lecture rapide */
.cible { text-align: center; margin: 6px 0; }
.gros-chiffre { font-size: 4rem; line-height: 1.1; color: var(--accent-fonce); }
.cible small { color: var(--doux); }
.acc-note small { font-size: 1.2rem; color: var(--doux); font-weight: 600; }

/* quiz */
.choix { display: flex; flex-direction: column; gap: 8px; }
.choix .btn { text-align: left; border-radius: 12px; }
.explication { color: var(--vert); font-weight: 600; }

/* morceaux */
.recherche { width: 100%; font: inherit; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte); }
.filtres { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0; padding-bottom: 4px; }
.puce { appearance: none; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte); border-radius: 99px; padding: 6px 12px; white-space: nowrap; font: inherit; font-size: .88rem; }
.puce.on { background: var(--texte); color: var(--fond); }
.morceau-lien { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: var(--texte); margin: 8px 0; padding: 12px 14px; }
.morceau-lien small { display: block; color: var(--doux); }
.puces { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 45%; }
.puces span { font-size: .75rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--fond); border: 1px solid var(--ligne); }

/* lecteur de morceau */
.reglages .champ select { flex: 1 1 0; min-width: 0; width: 100%; }
.partition { margin: 14px 0 120px; }
.pligne { margin: 0 0 16px; }
.mesures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mesure { border: 1px solid var(--ligne); background: var(--carte); border-radius: 10px; padding: 8px 6px 6px; text-align: center; transition: background .1s; display: flex; flex-direction: column; justify-content: space-between; }
.mesure .acc b { font-size: 1.15rem; margin: 0 3px; }
.mesure .mots { display: block; font-size: .92rem; line-height: 1.25; margin-top: 4px; min-height: 1.2em; }
.pligne .section { margin: 0 2px 4px; }
.karaoke { display: block; font-size: 1.15rem; font-weight: 700; color: var(--accent-fonce); line-height: 1.2; }
.mesure.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tps { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.tps i { width: 6px; height: 6px; border-radius: 50%; background: var(--ligne); }
.mesure.on .tps i { background: rgba(255, 255, 255, .45); }
.mesure.on .tps i.on { background: #fff; }
.paroles { margin: 6px 2px 0; font-size: 1.02rem; }
.section { margin: 6px 2px 0; color: var(--doux); font-style: italic; }
.lecteur {
  position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 8px 16px; background: color-mix(in srgb, var(--fond) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--ligne);
}
.lecteur .decompte { position: absolute; inset: auto 0 100%; height: 80px; font-size: 3.4rem; }
.lect-accord { display: flex; align-items: center; gap: 10px; min-height: 60px; }
.lect-accord b { font-size: 1.6rem; display: block; }
.lect-accord small { color: var(--doux); }
.btn.rond { width: 60px; height: 60px; border-radius: 50%; padding: 0; font-size: 1.4rem; flex: none; }

/* outils */
.grille-outils { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.outil { text-decoration: none; color: var(--texte); margin: 0; }
.outil b { display: block; font-size: 1.05rem; }
.outil small { color: var(--doux); }
.metro-bpm { text-align: center; }
.metro-bpm b { font-size: 3.4rem; font-weight: 900; display: block; line-height: 1; }
.metro input[type=range] { width: 100%; accent-color: var(--accent); }

/* accordeur */
.acc-cordes-inutile { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.acc-cordes button { appearance: none; border: 1px solid var(--ligne); background: var(--fond); color: var(--texte); border-radius: 12px; padding: 10px 0; font: inherit; }
.acc-cordes button b { display: block; font-size: 1.1rem; }
.acc-cordes button small { color: var(--doux); }
.acc-cordes button.actif { border-color: var(--accent); background: var(--accent); color: #fff; }
.acc-cordes button.actif small { color: #fff; }
.acc-ecran { text-align: center; margin: 16px 0; padding: 12px; border-radius: 14px; background: var(--fond); }
.acc-ecran.ok { background: color-mix(in srgb, var(--vert) 22%, var(--fond)); }
.acc-note { font-size: 3.2rem; font-weight: 900; line-height: 1.1; }
.acc-cents { color: var(--doux); }
.acc-jauge { position: relative; height: 34px; margin: 12px 8px 4px; background: linear-gradient(90deg, var(--rouge), var(--ligne) 40%, var(--vert) 50%, var(--ligne) 60%, var(--rouge)); border-radius: 8px; opacity: .9; }
.acc-centre { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; background: var(--texte); }
.acc-aiguille { position: absolute; left: 50%; top: 2px; bottom: 2px; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--texte); transition: left .08s; }
.aide { color: var(--doux); font-size: .85rem; text-align: center; }

@media (max-width: 420px) {
  .kalimba { gap: 2px; padding: 14px 6px 10px; }
  .lame { font-size: .68rem; }
  .ktab { font-size: 1.25rem; }
  .mesures { grid-template-columns: repeat(2, 1fr); }
  .grille-outils { grid-template-columns: 1fr; }
  .motif .sub { font-size: 1.1rem; }
}
