/* MathLab – feuille de style commune à toutes les pages (accueil, QCM, espace élève, page prof, cours, messages).
   Couleurs en variables (mode clair / sombre), gros boutons faciles à toucher sur téléphone. */

:root {
  --fond: #f4f6f8; --carte: #fff; --texte: #1d2329; --doux: #4f5b66; --lien: #0b5cad; --bord: #d0d6dd;
  --entete: #1d3557; --entete-texte: #fff; --accent: #c0392b; --vif: #ffd166; --vif-texte: #1d2329;
  --info-fond: #e8f1fb; --info-bord: #1f6fc5; --info-titre: #0d4f99;
  --erreur: #b00020; --ok: #1e7d43; --question: #6a1b9a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #15191d; --carte: #1f252b; --texte: #e8ecef; --doux: #aab4bd; --lien: #8cc4f5; --bord: #3a4651;
    --entete: #0f1f33; --info-fond: #1a2a3b; --info-bord: #5aa2e6; --info-titre: #9ccbf5;
    --erreur: #ff8a80; --ok: #7ad79a; --question: #d7a6f0; --accent: #ff7a6b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.45;
       background: var(--fond); color: var(--texte); display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 12px 16px 40px; }
a { color: var(--lien); }
h1 { font-size: 1.5em; margin: 14px 0 10px; } h2 { font-size: 1.25em; margin: 18px 0 10px; }
img { max-width: 100%; height: auto; }
.info, .note, small { color: var(--doux); }
.error, .erreur { color: var(--erreur); } .ok { color: var(--ok); }
footer { text-align: center; font-size: .9em; color: var(--doux); padding: 20px 16px; }

/* ---------- Boutons et champs : grands et contrastés ---------- */
button, input[type=submit], .bouton {
  display: inline-block; min-height: 44px; padding: 10px 18px; font-size: 1em; font-weight: bold; line-height: 1.2;
  border: 2px solid var(--entete); border-radius: 8px; background: var(--entete); color: #fff;
  text-decoration: none; cursor: pointer; text-align: center;
}
button:hover, input[type=submit]:hover, .bouton:hover { filter: brightness(1.15); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--vif); outline-offset: 2px; }
input[type=text], input[type=password], select {
  min-height: 44px; font-size: 1.1em; padding: 8px 10px; border: 2px solid var(--bord); border-radius: 8px;
  background: var(--carte); color: var(--texte); max-width: 100%;
}
label { font-weight: bold; }

/* ---------- En-tête commun ---------- */
header.site { background: var(--entete); color: var(--entete-texte); padding: 10px 16px; }
.site-barre { max-width: 860px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.site-nom { color: #fff; font-size: 1.4em; font-weight: bold; text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.site-nav a { color: #fff; }
.site-nav form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.site-nav .qui { font-size: .95em; }
.site-nav .bouton.vif { background: var(--vif); border-color: var(--vif); color: var(--vif-texte); }
.site-nav button, .site-nav .bouton.clair { background: transparent; border-color: #fff; color: #fff; }
.site-sous-titre { max-width: 860px; margin: 4px auto 0; opacity: .9; }

/* ---------- Encart de connexion (accueil) et formulaires ---------- */
section.encart { background: var(--carte); border: 3px solid var(--info-bord); border-radius: 10px; margin: 16px 0; padding: 8px 16px; }
section.encart h2 { margin: 6px 0; }
section.encart input[type=text], section.encart input[type=password] { width: 14em; }
section.encart.connecte { padding: 12px 16px; }
.auth-barre { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.auth-form input[type=text], .auth-form input[type=password] { width: 12em; }

/* ---------- Accueil ---------- */
main > h2 { border-bottom: 3px solid var(--accent); padding-bottom: 4px; margin-top: 26px; }
details, section.brevet { background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; margin: 10px 0; padding: 4px 14px; }
section.brevet { border: 2px solid var(--accent); padding: 10px 14px; }
section.brevet h3 { margin: 4px 0 8px; color: var(--accent); }
summary { cursor: pointer; font-weight: bold; font-size: 1.1em; padding: 12px 0; }
details ul, section.brevet ul { margin: 0 0 10px; padding-left: 20px; }
details li, section.brevet li { margin: 10px 0; }
a.ferme { color: var(--doux); }
a.cours { font-size: .9em; margin-left: 6px; white-space: nowrap; } a.cours.ferme { color: var(--doux); }
span.version { font-size: .8em; color: var(--doux); } p.note { font-size: .9em; margin: 2px 0 8px; }
a.gros { display: block; background: var(--accent); color: #fff; padding: 12px; border-radius: 8px; text-align: center; font-weight: bold; margin: 6px 0 8px; text-decoration: none; }

/* ---------- Pages de QCM ---------- */
.class-info { margin: 18px 0; padding: 14px 16px; background: var(--info-fond); border-left: 5px solid var(--info-bord); border-radius: 6px; }
.class-info h3 { margin-top: 0; color: var(--info-titre); }
.cours-lien { margin: 8px 0; padding: 8px 12px; background: var(--info-fond); border: 1px solid var(--bord); border-radius: 8px; }
.cours-lien small, .cours-version { color: var(--doux); }
#countdown { font-size: 1.1em; }
main table { width: 100%; border-collapse: collapse; margin: 16px 0; }
main td { padding: 10px; border: 1px solid var(--bord); vertical-align: top; background: var(--carte); }
.question-column { width: 50%; }
.ques { font-weight: bold; color: var(--question); }
.reponse { margin: 6px 0; display: flex; align-items: center; }
.reponse input[type=radio] { flex: none; width: 22px; height: 22px; margin: 0 8px 0 2px; }
.reponse label { flex: 1; min-width: 0; font-weight: normal; padding: 8px 4px; cursor: pointer; overflow-wrap: anywhere; }
img.schema { display: block; max-width: 100%; height: auto; max-height: 280px; background: #fff; }
#submit-btn { font-size: 1.1em; padding: 12px 24px; }

/* ---------- Espace élève ---------- */
main section:not(.encart):not(.brevet) { background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.ligne-barre { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.barre { flex: 1; height: 22px; border: 2px solid var(--texte); border-radius: 4px; background: var(--carte); overflow: hidden; }
.rempli { height: 100%; }
.rempli.r { background: repeating-linear-gradient(45deg, #c0392b 0 6px, #f3b6ae 6px 12px); }
.rempli.o { background: #e8a33d; } .rempli.v { background: #1e7d43; }
.pc { min-width: 4.2em; font-weight: bold; text-align: right; }
.petit .barre { height: 14px; border-width: 1px; }
.theme { margin: 8px 0; } .theme span.t { display: block; font-size: .9em; }
table.liste { font-size: .92em; } table.liste th, table.liste td { border: 0; border-bottom: 1px solid var(--bord); padding: 6px 4px; text-align: left; }
td.n { text-align: center; }

/* ---------- Page prof ---------- */
body.prof main { max-width: none; }
form.filtres { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 12px; }
.tableau { overflow: auto; max-height: 78vh; border: 1px solid var(--bord); background: var(--carte); }
.tableau table { border-collapse: separate; border-spacing: 0; font-size: .85em; margin: 0; width: auto; }
.tableau th, .tableau td { border: 0; border-right: 1px solid var(--bord); border-bottom: 1px solid var(--bord); padding: 4px 6px;
                           text-align: center; white-space: nowrap; vertical-align: middle; background: var(--carte); }
.tableau thead th { position: sticky; top: 0; background: var(--fond); z-index: 2; white-space: normal; min-width: 90px; max-width: 120px; vertical-align: bottom; font-weight: normal; }
.tableau thead th small { display: block; }
.tableau th.nom { position: sticky; left: 0; background: var(--fond); z-index: 1; text-align: left; font-weight: bold; }
.tableau thead th.nom { z-index: 3; }
.tableau td a { color: inherit; text-decoration: none; display: block; }
.tableau td.r { background: #f8c9c4; color: #1d2329; } .tableau td.o { background: #fde2b3; color: #1d2329; } .tableau td.v { background: #c7ecc9; color: #1d2329; }
.tableau tfoot td, .tableau tfoot th { font-weight: bold; background: var(--fond); }
label.case { display: block; margin: 6px 0; font-weight: normal; } label.case input { width: 20px; height: 20px; vertical-align: middle; margin-right: 6px; }
p.moyenne { display: inline-block; padding: 6px 10px; border-radius: 6px; color: #1d2329; }
p.moyenne.r { background: #f8c9c4; } p.moyenne.o { background: #fde2b3; } p.moyenne.v { background: #c7ecc9; }

/* ---------- Téléphone : une question par ligne, boutons pleine largeur si besoin ---------- */
@media (max-width: 600px) {
  main { padding: 10px 12px 30px; }
  table.qcm, table.qcm tbody, table.qcm tr, table.qcm td { display: block; width: 100%; }
  .question-column { width: 100%; }
  .site-nom { font-size: 1.25em; }
  section.encart input[type=text], section.encart input[type=password] { width: 100%; }
}
