/* ===== Base ===== */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f3f5f9;
    color: #1f2937;
    line-height: 1.5;
}
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 1.6rem; margin-bottom: .5rem; }
h2 { margin-top: 2rem; font-size: 1.25rem; }
.consigne { color: #4b5563; }

/* ===== Messages ===== */
.message { padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.message.succes { background: #dcfce7; color: #166534; }
.message.erreur { background: #fee2e2; color: #991b1b; }

/* ===== Questions ===== */
.question {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 18px;
    margin: 0 0 16px;
}
fieldset.question legend { width: 100%; padding: 0; }
.question header, fieldset.question legend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.numero { font-weight: 700; color: #1d4ed8; }
.theme {
    font-size: .8rem; background: #eef2ff; color: #3730a3;
    padding: 2px 8px; border-radius: 999px;
}
.enonce { font-size: 1.15rem; margin: 10px 0; }

.choix { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; padding: 0; margin: 0; list-style: none; }
.choix .option, .choix li {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid #d1d5db; border-radius: 8px;
    padding: 8px 10px; background: #fafafa;
}
.choix .option { cursor: pointer; font: inherit; color: inherit; width: 100%; }
.choix .option:hover { border-color: #1d4ed8; }
.choix .option.choisie { border-color: #1d4ed8; background: #eff6ff; }
.choix .option:disabled { cursor: default; }

/* ===== Notation mathématique ===== */
sup { font-size: .7em; }
.rad { border-top: 1.5px solid currentColor; padding: 0 2px; margin-left: 1px; }
.frac {
    display: inline-flex; flex-direction: column; vertical-align: middle;
    text-align: center; font-size: .9em; margin: 0 2px;
}
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }
.frac > span:last-child { padding: 0 3px; }

/* ===== Boutons ===== */
.bouton {
    background: #1d4ed8; color: #fff; border: 0; border-radius: 8px;
    padding: 12px 22px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.bouton:hover { background: #1e40af; }
.bouton.secondaire { background: #6b7280; padding: 8px 14px; }

/* ===== Résultats ===== */
.bilan { background: #fff; border-radius: 12px; padding: 16px; text-align: center; border: 1px solid #e5e7eb; }
.note { font-size: 2.6rem; font-weight: 800; margin: 0; color: #1d4ed8; }

.themes { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.themes th, .themes td { padding: 8px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; }
.themes th { font-weight: 600; width: 40%; }
.barre { width: 45%; }
.barre span { display: block; height: 12px; border-radius: 6px; min-width: 2px; }
.barre .ok { background: #16a34a; }
.barre .ko { background: #dc2626; }
.chiffre { text-align: right; white-space: nowrap; font-weight: 600; }

.question.juste { border-left: 6px solid #16a34a; }
.question.faux  { border-left: 6px solid #dc2626; }
.verdict { margin-left: auto; font-weight: 700; }
.juste .verdict { color: #15803d; }
.faux .verdict  { color: #dc2626; }
.choix li.bonne    { background: #dcfce7; border-color: #16a34a; }
.choix li.mauvaise { background: #fee2e2; border-color: #dc2626; }
.choix .texte { white-space: nowrap; }
.choix li { flex-wrap: wrap; }
.choix em { margin-left: auto; font-size: .8rem; color: #4b5563; white-space: nowrap; }
/* « Je ne sais pas » et commentaires */
.choix .option.nsp { border-style: dashed; color: #92400e; }
.choix .option.nsp.choisie { border-color: #d97706; background: #fffbeb; }
.commentaire { display: block; margin-top: 10px; font-size: .9rem; color: #4b5563; }
.commentaire textarea {
    display: block; width: 100%; margin-top: 4px; padding: 6px 8px;
    border: 1px solid #d1d5db; border-radius: 6px; font: inherit; resize: vertical;
}
.question.nsp { border-left: 6px solid #d97706; }
.nsp .verdict { color: #b45309; }
.com-eleve { background: #fffbeb; border-radius: 8px; padding: 8px 12px; }
.compteurs { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; list-style: none; padding: 0; margin: 8px 0; }
.c-juste strong { color: #15803d; }
.c-faux strong  { color: #dc2626; }
.c-nsp strong   { color: #b45309; }
.bareme { font-size: .85rem; color: #6b7280; margin: 0; }

/* Enregistrement automatique */
.progression {
    position: sticky; top: 0; z-index: 5;
    background: #1d4ed8; color: #fff; font-weight: 600;
    padding: 8px 14px; border-radius: 8px; margin-bottom: 16px;
}
.statut { margin-left: auto; font-size: .8rem; color: #15803d; }
.statut.erreur { color: #dc2626; font-weight: 700; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

/* Page de théorie */
.theorie section {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    padding: 4px 20px 16px; margin-bottom: 16px;
}
.theorie h2 { color: #1d4ed8; }
.theorie h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.sommaire { background: #eef2ff; border-radius: 12px; padding: 12px 20px; margin-bottom: 16px; }
.sommaire ol { margin: 6px 0 0; }
.sommaire a { color: #1d4ed8; }
.regles { width: 100%; border-collapse: collapse; margin: 8px 0; }
.regles td { border-bottom: 1px solid #e5e7eb; padding: 8px 6px; vertical-align: middle; }
.regles td:first-child { color: #4b5563; width: 30%; }
.regles td:nth-child(2) { font-weight: 600; }
.retenir { background: #ecfdf5; border-left: 5px solid #16a34a; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.retenir ul, .retenir p { margin: 6px 0 0; }
.attention { background: #fef2f2; border-left: 5px solid #dc2626; border-radius: 8px; padding: 10px 14px; }
.exemple { background: #f9fafb; border-left: 5px solid #9ca3af; border-radius: 8px; padding: 10px 14px; }
.rad:has(.frac) { display: inline-block; padding-top: 3px; }
/* Validation question par question */
.bouton.petit { padding: 8px 16px; font-size: .9rem; margin-top: 10px; }
.bouton:disabled { opacity: .6; cursor: wait; }
.statut-com { margin-left: 6px; font-size: .8rem; color: #15803d; }
.statut-com.erreur { color: #dc2626; font-weight: 700; }

/* Barre de progression (dans le bandeau bleu) */
.ligne-progression { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.barre-progression { height: 12px; background: rgba(255,255,255,.3); border-radius: 999px; overflow: hidden; }
.barre-progression span { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width .3s; }

.valider-theorie { text-align: center; margin-top: 24px; }
a.bouton.lien { display: inline-block; text-decoration: none; }

.explication { background: #f9fafb; border-radius: 8px; padding: 8px 12px; margin-bottom: 0; }

.prof { margin-top: 40px; padding-top: 10px; border-top: 1px dashed #9ca3af; }
.prof form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.prof input { padding: 7px; border: 1px solid #d1d5db; border-radius: 6px; width: 110px; }

@media print {
    body { background: #fff; }
    .prof, .bouton, .acces-prof { display: none; }
    .question { break-inside: avoid; }
}

/* Mode prof */
.bandeau-prof {
    background: #7c3aed; color: #fff; font-weight: 700;
    padding: 8px 14px; border-radius: 8px; margin: 0 0 16px;
}
.ligne-boutons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.choix .option.bonne    { background: #dcfce7; border-color: #16a34a; }
.choix .option.mauvaise { background: #fee2e2; border-color: #dc2626; }
.statut.verdict-prof { font-size: 1rem; font-weight: 700; }
.juste .statut.verdict-prof { color: #15803d; }
.faux .statut.verdict-prof  { color: #dc2626; }
.nsp .statut.verdict-prof   { color: #b45309; }

/* Conseils, temps, lien vers la théorie */
.conseils { background: #fff7ed; border-left: 5px solid #d97706; border-radius: 8px; padding: 10px 14px 10px 32px; }
.conseils li { margin: 4px 0; }
.conseils a, .lien-theorie a { color: #1d4ed8; font-weight: 600; }
.themes.temps th { width: 60%; }
.sous-titre { font-weight: 600; margin: 14px 0 4px; }
.plus-longues { margin-top: 0; }
.lien-theorie { margin: 8px 0 0; }

/* Formulaire (résumé des formules) */
.theorie section.formulaire {
    border: 0; padding: 0; overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 30px rgba(29, 78, 216, .15);
}
.f-entete {
    display: flex; align-items: center; gap: 16px;
    padding: 22px 24px;
    background: linear-gradient(135deg, #1d4ed8 0%, #7c3aed 100%);
    color: #fff;
}
.theorie .f-entete h2 { color: #fff; margin: 0; font-size: 1.6rem; letter-spacing: .5px; }
.f-entete-num {
    flex: none; display: grid; place-items: center;
    width: 48px; height: 48px; border-radius: 14px;
    background: rgba(255, 255, 255, .18); font-size: 1.5rem; font-weight: 800;
}
.f-intro { margin: 4px 0 0; color: rgba(255, 255, 255, .88); font-size: .9rem; }
.f-grille {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px; padding: 22px;
    background: #f5f7fb;
}
.f-carte {
    --accent: #1d4ed8; --clair: #eff6ff;
    background: #fff; border-radius: 14px; padding: 0 0 12px;
    border-top: 5px solid var(--accent);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
    transition: transform .15s, box-shadow .15s;
}
.f-carte:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15, 23, 42, .12); }
.f-puissances { --accent: #2563eb; --clair: #eff6ff; }
.f-racines    { --accent: #059669; --clair: #ecfdf5; }
.f-ln         { --accent: #7c3aed; --clair: #f5f3ff; }
.f-somme      { --accent: #db2777; --clair: #fdf2f8; }
.f-domaine    { --accent: #ea580c; --clair: #fff7ed; }
.f-carte.f-large { grid-column: 1 / -1; }
.theorie .f-carte h3 {
    display: flex; align-items: center; gap: 10px;
    margin: 0; padding: 12px 16px;
    background: var(--clair); color: var(--accent); font-size: 1.1rem;
    border-radius: 9px 9px 0 0;
}
.f-icone {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 6px;
    border-radius: 10px; background: var(--accent); color: #fff;
    font-size: .95rem; font-weight: 800;
}
.f-icone sup { font-size: .6em; }
.f-cond-gen { margin: 10px 16px 4px; font-size: .82rem; color: #475569; font-style: italic; }
.f-carte dl { margin: 0 16px; }
.f-carte dl > div {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid #f1f5f9;
}
.f-carte dl > div:last-child { border-bottom: 0; }
.f-carte dt { font-weight: 600; font-size: 1.02rem; color: #0f172a; }
.f-carte dt::before {
    content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent); margin-right: 8px; vertical-align: middle;
}
.f-carte dd:empty { display: none; }
.f-carte dd {
    margin: 0; flex: none; max-width: 50%;
    font-size: .75rem; color: #475569; text-align: right;
    background: #f1f5f9; border-radius: 999px; padding: 3px 10px;
}
.f-piege {
    margin: 10px 16px 0; font-size: .9rem; color: #b91c1c;
    background: #fef2f2; border: 1px dashed #fca5a5; border-radius: 10px; padding: 8px 12px;
}
.f-piege-titre {
    display: block; font-size: .72rem; font-weight: 800; letter-spacing: .8px;
    text-transform: uppercase; color: #dc2626; margin-bottom: 2px;
}

/* Historique des tentatives (page prof) */
.defilement { overflow-x: auto; }
.historique { border-collapse: collapse; background: #fff; font-size: .85rem; min-width: 100%; white-space: nowrap; }
.historique th, .historique td { border: 1px solid #e5e7eb; padding: 6px 8px; text-align: center; }
.historique th { background: #eef2ff; color: #3730a3; }
.historique tr.actuelle td { background: #fffbeb; }
.historique .fort { font-weight: 700; }
.historique .hausse { color: #15803d; font-weight: 700; }
.historique .stable { color: #4b5563; }
/* Grille question × tentative */
.historique.grille td.ok  { color: #15803d; font-weight: 700; }
.historique.grille td.ko  { color: #dc2626; font-weight: 700; background: #fef2f2; }
.historique.grille td.nsp { color: #b45309; font-weight: 700; }
.historique .baisse { color: #dc2626; font-weight: 700; }
.bouton.danger { background: #dc2626; }
.bouton.danger:hover { background: #b91c1c; }

/* Choix en ovales : pas de lettre, pas de rond ; un clic choisit (annulable quelques secondes) */
.choix.ovales { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.choix.ovales .option {
    justify-content: center; text-align: center;
    border-radius: 999px; padding: 12px 18px; min-height: 48px;
    font-size: 1.05rem; background: #fff; border: 2px solid #cbd5e1;
    transition: background .12s, border-color .12s, transform .08s;
}
.choix.ovales .option:hover { border-color: #1d4ed8; background: #eff6ff; }
.choix.ovales .option:active { transform: scale(.97); }
.choix.ovales .option:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.choix.ovales .option.nsp { border-style: dashed; border-color: #f59e0b; }
.choix.ovales .option.nsp:hover { background: #fffbeb; }
fieldset.question.envoi .choix .option { cursor: wait; opacity: .7; }
.choix.ovales .option.choisie { border-color: #1d4ed8; background: #dbeafe; }
.choix.ovales .option.bonne { background: #dcfce7; border-color: #16a34a; }
.choix.ovales .option.mauvaise { background: #fee2e2; border-color: #dc2626; }
.choix.ovales .option:disabled:hover { border-color: #cbd5e1; background: #fff; }
.choix.ovales .option.bonne:disabled:hover { background: #dcfce7; border-color: #16a34a; }
.choix.ovales .option.mauvaise:disabled:hover { background: #fee2e2; border-color: #dc2626; }
.commentaire { margin-bottom: 12px; }
.astuce-prof { font-size: .85rem; color: #4b5563; background: #eef2ff; border-radius: 8px; padding: 8px 12px; margin-top: 10px; }
.statut-ligne { display: flex; margin: 0; min-height: 0; }
.statut-ligne .statut:empty { display: none; }

/* Lien vers le champ du code prof (bas de chaque page) */
.acces-prof { margin: 48px 0 0; text-align: center; font-size: .8rem; }
.acces-prof a { color: #4b5563; }

/* Entraînement libre (entrainement.php) */
.options fieldset { border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; padding: 8px 16px 14px; margin: 0 0 14px; }
.options legend { font-weight: 700; padding: 0 6px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puces label {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    border: 1px solid #d1d5db; border-radius: 999px; padding: 6px 12px; background: #fafafa;
}
.puces label:has(input:checked) { border-color: #1d4ed8; background: #eff6ff; }
.puces input { accent-color: #1d4ed8; }
.type-exercice { margin: 0 0 8px; font-size: .8rem; color: #4b5563; }
.correction > * { margin: 10px 0 0; }
.correction summary { cursor: pointer; color: #1d4ed8; font-weight: 600; margin-top: 10px; }
.methode { background: #f9fafb; border-left: 5px solid #9ca3af; border-radius: 8px; padding: 8px 12px; }
.methode ol { margin: 6px 0 0; padding-left: 22px; }
.methode li { margin: 4px 0; }
.regle { background: #ecfdf5; border-left: 5px solid #16a34a; border-radius: 8px; padding: 8px 12px; }
.bonne-reponse, .ta-reponse { margin: 8px 0 0; }
.score-en-cours { font-weight: 600; }
.actions-bilan { margin: 16px 0; }

/* Modes entraînement / examen / reprise des erreurs */
.mode-actuel { margin: 0 0 10px; font-size: .9rem; color: #374151; }

/* Énoncé en légende du groupe de réponses (flottante : pas dessinée sur la bordure du cadre) */
fieldset.question legend.enonce { display: block; float: left; width: 100%; padding: 0; }
fieldset.question legend.enonce + .statut-ligne { clear: both; }

/* Choix annulable */
.statut.attente { color: #1e40af; font-weight: 600; }
.annuler {
    margin-left: 8px; padding: 3px 12px; font: inherit; font-weight: 700; cursor: pointer;
    color: #1d4ed8; background: #fff; border: 1px solid #1d4ed8; border-radius: 999px;
}
.annuler:hover { background: #eff6ff; }
.bareme.rappel { margin-top: 10px; }

/* Remarque ciblée sur l'erreur commise */
.remarque { background: #fef2f2; border-left: 4px solid #dc2626; border-radius: 8px; padding: 8px 12px; }

/* Questions réussies, repliées */
details.question > summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.question > summary::before { content: "▸"; color: #6b7280; }
details.question[open] > summary::before { content: "▾"; }
details.question[open] > summary { margin-bottom: 6px; }

/* Texte lu par les lecteurs d'écran, invisible à l'écran */
.lecteur {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
