/* Entraîneur guitare — thème sombre par défaut, clair en option. */
:root {
  --fond: #16181d;
  --fond2: #1e2128;
  --fond3: #262a33;
  --trait: #333845;
  --texte: #e8eaf0;
  --doux: #9aa1ae;
  --accent: #5eb0ef;
  --ok: #4ade80;
  --ko: #f87171;
  --or: #f5c542;
  --vert: #4ade80;
  --bleu: #60a5fa;
  --violet: #c084fc;
  --rose: #f472b6;
  --gris: #6b7280;
  --bois: #2a2520;
  --corde: #9aa1ae;
  --frette: #4a5160;
  --r: 12px;
}
[data-theme="clair"] {
  --fond: #f6f7f9;
  --fond2: #ffffff;
  --fond3: #eceef2;
  --trait: #d6dae2;
  --texte: #1b1f27;
  --doux: #5b6372;
  --accent: #1d6fb8;
  --ok: #15803d;
  --ko: #b91c1c;
  --or: #b7791f;
  --vert: #15803d;
  --bleu: #1d4ed8;
  --violet: #7c3aed;
  --rose: #be185d;
  --gris: #94a3b8;
  --bois: #e7dcc9;
  --corde: #6b7280;
  --frette: #b8bfcc;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }

/* ---------- barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--fond2); border-bottom: 1px solid var(--trait);
}
.barre h1 { font-size: 17px; margin: 0; font-weight: 600; }
.pousse { flex: 1; }
.icone {
  background: none; border: 1px solid transparent; border-radius: 9px;
  padding: 6px 10px; cursor: pointer; font-size: 17px; line-height: 1;
}
.icone:hover { background: var(--fond3); }
.icone.actif { color: var(--accent); border-color: var(--trait); }
.puce {
  background: var(--fond3); border: 1px solid var(--trait); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: 14px; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- mise en page ---------- */
.ecran {
  max-width: 1040px; margin: 0 auto; padding: 16px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}
.cartes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.carte {
  background: var(--fond2); border: 1px solid var(--trait); border-radius: var(--r);
  padding: 16px; text-align: left; cursor: pointer; width: 100%;
}
.carte:hover { border-color: var(--accent); }
.carte h3 { margin: 0 0 6px; font-size: 16px; }
.carte p { margin: 0; color: var(--doux); font-size: 14px; }
.carte[disabled] { opacity: .5; cursor: not-allowed; }
.bloc {
  background: var(--fond2); border: 1px solid var(--trait);
  border-radius: var(--r); padding: 16px; margin-bottom: 14px;
}
.titre-bloc { margin: 0 0 12px; font-size: 15px; color: var(--doux); font-weight: 600; }
.rangee { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.doux { color: var(--doux); }
.petit { font-size: 13px; }
.centre { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- contrôles ---------- */
.btn {
  background: var(--fond3); border: 1px solid var(--trait); border-radius: 9px;
  padding: 9px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: #0b1016; font-weight: 600; }
.btn.fantome { background: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.choix { display: flex; flex-wrap: wrap; gap: 6px; }
.choix button {
  background: var(--fond3); border: 1px solid var(--trait); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; min-width: 44px;
}
.choix button.sel { background: var(--accent); border-color: var(--accent); color: #0b1016; font-weight: 600; }
.choix button.sel .doux { color: inherit; opacity: .7; }
input[type=text], select {
  background: var(--fond); border: 1px solid var(--trait); border-radius: 9px;
  padding: 10px 12px; min-width: 0;
}
input[type=text]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.champ { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--doux); }

/* ---------- manche ---------- */
.manche-boite { overflow-x: auto; padding: 4px 0 2px; -webkit-overflow-scrolling: touch; }
.manche { display: block; }
.manche .case-clic { fill: transparent; cursor: pointer; }
.manche .case-clic:hover { fill: rgba(127,127,127,.18); }
.pastille { font-size: 11px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.legende { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; margin-top: 8px; }
.legende span::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin-right: 5px; background: currentColor;
}
.c-root { color: var(--or); } .c-third { color: var(--vert); }
.c-fifth { color: var(--bleu); } .c-seventh { color: var(--violet); }
.c-ext { color: var(--rose); } .c-scale { color: var(--gris); }
.c-natural { color: var(--texte); } .c-altered { color: var(--doux); }
.c-ok { color: var(--ok); } .c-ko { color: var(--ko); }

/* ---------- exercices ---------- */
.compteur { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.compteur b { font-size: 22px; }
.jauge { height: 6px; background: var(--fond3); border-radius: 3px; overflow: hidden; margin: 10px 0; }
.jauge > div { height: 100%; background: var(--accent); transition: width .2s; }
.retour-ex { min-height: 24px; font-size: 14px; }
.juste { color: var(--ok); } .faux { color: var(--ko); }
.enonce { font-size: 19px; font-weight: 600; margin: 4px 0 14px; }
.explique { border-left: 3px solid var(--trait); padding-left: 12px; margin-top: 10px; color: var(--doux); font-size: 14px; }
.explique div { margin: 2px 0; }

/* ---------- tableaux ---------- */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--trait); white-space: nowrap; }
th { color: var(--doux); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: none; }
.tableau-boite { overflow-x: auto; }
td.clic { cursor: pointer; color: var(--accent); }

/* ---------- fiches ---------- */
.fiche pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; margin: 0;
  overflow-wrap: anywhere;
}
.fiche .section { color: var(--accent); font-weight: 700; }
.fiche-nav { display: flex; gap: 8px; align-items: center; margin-top: 14px; }

/* ---------- divers ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--fond3); border: 1px solid var(--trait); border-radius: 10px;
  padding: 10px 16px; z-index: 50; max-width: 90vw;
}
.badge {
  display: inline-block; background: var(--fond3); border: 1px solid var(--trait);
  border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--doux);
}
.badge.ok { color: var(--ok); border-color: var(--ok); }
ul.liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
@media (max-width: 560px) {
  .ecran { padding: 12px; }
  .barre h1 { font-size: 15px; }
  .enonce { font-size: 17px; }
}
