:root {
  color-scheme: light dark;
  --fond: #F3F6F5; --carte: #FFFFFF; --texte: #15272B; --discret: #5A6E72; --bord: #D5E0DF;
  --turq: #0F7C80; --turq-doux: #DDEFEE; --safran: #B87618; --safran-doux: #FBEBD3;
  --ok: #217A4B; --ok-doux: #DDF1E5; --ko: #B23A3A; --ko-doux: #F7E1E1; --bleu: #1E4E8C; --bleu-doux: #E0EAF7;
  --fa: "Vazirmatn", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0D1820; --carte: #14232D; --texte: #E7EFEE; --discret: #93A8AB; --bord: #263A45;
    --turq: #4CC2C2; --turq-doux: #133639; --safran: #E8A94A; --safran-doux: #3A2C14;
    --ok: #5FCB8E; --ok-doux: #143424; --ko: #EE8383; --ko-doux: #3D1A1A; --bleu: #7FA8E6; --bleu-doux: #16283F;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100dvh; color: var(--texte); background: var(--fond);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main {
  max-width: 560px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(92px + env(safe-area-inset-bottom, 0px));
}
h1 { font-size: 26px; margin: 8px 0 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--discret); margin: 24px 0 8px; }
.fa { font-family: var(--fa); color: var(--safran); direction: rtl; unicode-bidi: isolate; }
.discret { color: var(--discret); font-size: 14px; margin: 6px 0; }
.erreur { color: var(--ko); }
.centre { text-align: center; }
.gros { font-size: 44px; }

.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 16px; padding: 16px; }
button, input, select { font: inherit; color: inherit; }
button {
  display: block; width: 100%; margin-top: 12px; padding: 14px; border-radius: 12px;
  border: 1px solid var(--bord); background: var(--carte); font-weight: 600; cursor: pointer;
}
button.principal { background: var(--turq); border-color: var(--turq); color: var(--fond); }
button:focus-visible, input:focus-visible, select:focus-visible, .fiche:focus-visible { outline: 3px solid var(--safran); outline-offset: 2px; }
input, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--bord);
  background: var(--carte); margin-top: 8px;
}
label { font-weight: 600; }

/* ---------- révision ---------- */
.compteurs { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--discret); margin-bottom: 12px; }
.compteurs b { color: var(--texte); font-variant-numeric: tabular-nums; }
.fiche {
  position: relative; min-height: 46dvh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 14px; padding: 44px 18px 24px; cursor: pointer;
}
.fiche .etiquette {
  position: absolute; top: 14px; left: 16px; font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--discret);
}
.fiche .etiquette.nouvelle::after { content: " · nouvelle"; color: var(--safran); }
#f-recto, #f-verso { display: grid; gap: 6px; justify-items: center; width: 100%; }
#f-verso { border-top: 1px dashed var(--bord); padding-top: 14px; }
.mot { font-size: clamp(26px, 8vw, 36px); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.mot.fr { font-weight: 600; }
.script { font-family: var(--fa); font-size: 30px; color: var(--safran); direction: rtl; line-height: 1.5; }
.question { color: var(--turq); font-weight: 700; }
.note { color: var(--discret); font-size: 14px; max-width: 40ch; }
.oral { color: var(--safran); font-weight: 600; }
.radicaux { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.radicaux span { background: var(--turq-doux); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.radicaux b { color: var(--turq); }
.radicaux.grand span { font-size: 20px; padding: 8px 16px; }

.notes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.notes button { padding: 10px 2px; font-size: 14px; }
.notes small { display: block; font-weight: 400; font-size: 12px; opacity: .8; }
.n1 { background: var(--ko-doux); border-color: var(--ko); color: var(--ko); }
.n2 { background: var(--safran-doux); border-color: var(--safran); color: var(--safran); }
.n3 { background: var(--ok-doux); border-color: var(--ok); color: var(--ok); }
.n4 { background: var(--bleu-doux); border-color: var(--bleu); color: var(--bleu); }

/* ---------- tables de conjugaison ---------- */
.defile { overflow-x: auto; width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 14px; text-align: left; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--bord); white-space: nowrap; vertical-align: top; }
th { font-size: 12px; color: var(--discret); text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
td small { display: block; color: var(--safran); font-weight: 600; }
tr.vise td { background: var(--turq-doux); font-weight: 700; }

/* ---------- recherche ---------- */
#resultats { display: grid; gap: 8px; margin-top: 8px; }
.ligne { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: 10px 14px; min-width: 0; }
.ligne .haut { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ligne .t { font-weight: 700; overflow-wrap: anywhere; }
.ligne .fa { font-size: 20px; white-space: nowrap; }
.ligne .bas { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.ligne .radicaux { justify-content: flex-start; margin-top: 6px; }
.ligne.verbe { cursor: pointer; }
.ligne.verbe .t::after { content: " ▾"; color: var(--turq); font-weight: 400; }
.ligne .defile { margin-top: 10px; }
.niveau { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--bord); }
.niveau.n1 { background: var(--safran); border: none; }
.niveau.n2 { background: var(--ok); border: none; }

/* ---------- stats ---------- */
.tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tuile { background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 12px 8px; text-align: center; }
.tuile b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.tuile span { font-size: 12px; color: var(--discret); }
.barres { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.barres > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.barres i { display: block; border-radius: 3px 3px 0 0; background: var(--ok); min-height: 0; }
.barres i.ko { background: var(--ko); border-radius: 3px 3px 0 0; }
.barres i.ko + i { border-radius: 0; }
.barres i.vide { background: var(--bord); height: 2px; }
.barres.etiquetees { height: 110px; }
.barres.etiquetees span { font-size: 11px; color: var(--discret); text-align: center; }
.barres.etiquetees b { font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.barres.etiquetees i { background: var(--turq); }
.legende { display: flex; gap: 6px; align-items: center; }
.pastille { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pastille.ok { background: var(--ok); } .pastille.ko { background: var(--ko); margin-left: 10px; }
.pastille.encours { background: var(--safran); margin-left: 10px; }
.theme { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 14px; padding: 7px 0; }
.theme span:nth-child(2) { color: var(--discret); font-variant-numeric: tabular-nums; }
.jauge { grid-column: 1 / -1; display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--bord); }
.jauge i { background: var(--ok); } .jauge i + i { background: var(--safran); }

/* ---------- navigation ---------- */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--carte);
  border-top: 1px solid var(--bord); padding-bottom: env(safe-area-inset-bottom, 0px);
}
nav button {
  flex: 1; margin: 0; border: none; border-radius: 0; background: none; padding: 10px 0 8px;
  font-size: 12px; font-weight: 600; color: var(--discret); display: grid; justify-items: center; gap: 2px;
}
nav button[aria-current="true"] { color: var(--turq); }
nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
