/* =========================================================================
   Style — 2I2D Terminale
   ========================================================================= */
:root {
  --encre: #13233a;
  --encre-2: #4a5a70;
  --fond: #f4f1ea;
  --papier: #fffdf8;
  --ligne: #dcd5c6;
  --bleu: #1f4e8c;
  --bleu-clair: #e5edf8;
  --ambre: #d98e04;
  --ambre-clair: #fdf1d8;
  --vert: #1d7a4b;
  --vert-clair: #e2f3ea;
  --rouge: #b3261e;
  --rouge-clair: #fbe6e4;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(19, 35, 58, .06), 0 4px 16px rgba(19, 35, 58, .06);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --texte: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --titre: Georgia, "Cambria", "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--texte); color: var(--encre); background: var(--fond);
  font-size: 16px; line-height: 1.5;
  background-image: linear-gradient(var(--fond) 0 0), radial-gradient(circle at 1px 1px, rgba(19,35,58,.07) 1px, transparent 0);
  background-size: auto, 22px 22px;
}
a { color: var(--bleu); }
h1, h2, h3 { font-family: var(--titre); font-weight: 700; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.12rem; }
.cache { display: none !important; }

/* ---------- En-tête ---------- */
.entete {
  background: var(--encre); color: #fff; border-bottom: 4px solid var(--ambre);
}
.entete .int { max-width: 1040px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo .pastille { width: 42px; height: 42px; border-radius: 8px; background: var(--ambre); color: var(--encre); display: grid; place-items: center; font-weight: 800; font-family: var(--mono); font-size: .95rem; }
.logo b { display: block; font-family: var(--titre); font-size: 1.15rem; }
.logo small { color: #b9c6d8; font-size: .8rem; }
.entete .eleve { margin-left: auto; font-size: .9rem; color: #d7e0ec; display: flex; gap: 10px; align-items: center; }
.entete .eleve button { background: transparent; color: #fff; border: 1px solid #50627d; }

main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 80px; }
.pied { text-align: center; color: var(--encre-2); font-size: .8rem; padding: 20px; }

/* ---------- Cartes et grilles ---------- */
.carte { background: var(--papier); border: 1px solid var(--ligne); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 22px; }
.grille { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grille-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.choix {
  text-align: left; cursor: pointer; border: 1px solid var(--ligne); background: var(--papier); border-radius: var(--rayon);
  padding: 18px; box-shadow: var(--ombre); transition: transform .12s, border-color .12s; font: inherit; color: inherit; width: 100%;
}
.choix:hover, .choix:focus-visible { transform: translateY(-2px); border-color: var(--bleu); outline: none; }
.choix .num { font-family: var(--mono); font-size: .78rem; color: var(--bleu); font-weight: 700; letter-spacing: .04em; }
.choix h3 { margin: 4px 0 6px; }
.choix p { margin: 0; color: var(--encre-2); font-size: .92rem; }
.grand-choix { padding: 28px; }
.grand-choix .icone { font-size: 2rem; }
.barre { height: 6px; background: #ece6d9; border-radius: 3px; margin-top: 12px; overflow: hidden; }
.barre i { display: block; height: 100%; background: var(--vert); }
.etiquette { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bleu-clair); color: var(--bleu); font-weight: 600; }

/* ---------- Formulaires ---------- */
label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  font: inherit; color: inherit; width: 100%; padding: 10px 12px; border: 1px solid #bfb6a3; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--bleu-clair); border-color: var(--bleu); }
textarea { min-height: 90px; resize: vertical; }
.champ { margin-bottom: 14px; }
.ligne-champs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 10px 18px; border: 1px solid var(--bleu);
  background: var(--bleu); color: #fff; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sec { background: transparent; color: var(--bleu); }
.btn.ambre { background: var(--ambre); border-color: var(--ambre); color: var(--encre); }
.btn.rouge { background: var(--rouge); border-color: var(--rouge); }
.btn.petit { padding: 6px 12px; font-size: .88rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.retour { background: none; border: none; color: var(--bleu); cursor: pointer; font: inherit; padding: 0; margin-bottom: 14px; }

/* ---------- Exercice ---------- */
.exo { background: var(--papier); border: 1px solid var(--ligne); border-radius: var(--rayon); margin-bottom: 22px; box-shadow: var(--ombre); overflow: hidden; }
.exo > header { padding: 14px 20px; border-bottom: 1px solid var(--ligne); background: #faf6ec; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.exo > header h3 { margin: 0; }
.exo > header .pts { margin-left: auto; font-family: var(--mono); font-size: .85rem; color: var(--encre-2); }
.exo .corps { padding: 18px 20px; }
.contexte { background: var(--bleu-clair); border-left: 4px solid var(--bleu); padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.question { padding: 14px 0; border-top: 1px dashed var(--ligne); }
.question:first-of-type { border-top: none; }
.question .enonce { margin-bottom: 10px; }
.question .enonce .qn { font-family: var(--mono); font-weight: 700; color: var(--bleu); margin-right: 6px; }
.question .enonce .qp { font-family: var(--mono); font-size: .78rem; color: var(--encre-2); }
.saisie { display: flex; align-items: center; gap: 10px; max-width: 420px; }
.saisie input { max-width: 260px; font-family: var(--mono); }
.saisie .unite { font-weight: 600; color: var(--encre-2); white-space: nowrap; }
.options { display: grid; gap: 8px; }
.options label { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border: 1px solid var(--ligne); border-radius: 8px; background: #fff; cursor: pointer; margin: 0; }
.options label:hover { border-color: var(--bleu); }
.options input { margin-top: 4px; }
.question.juste { background: linear-gradient(90deg, var(--vert-clair), transparent 70%); }
.question.faux { background: linear-gradient(90deg, var(--rouge-clair), transparent 70%); }
.question.juste, .question.faux, .question.a-corriger { margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.question.a-corriger { background: linear-gradient(90deg, var(--ambre-clair), transparent 70%); }
.retour-q { margin-top: 10px; font-size: .93rem; }
.retour-q .verdict { font-weight: 700; }
.juste .verdict { color: var(--vert); }
.faux .verdict { color: var(--rouge); }
.a-corriger .verdict { color: #8a5a00; }
.correction { margin-top: 6px; padding: 8px 12px; background: #fff; border: 1px solid var(--ligne); border-radius: 6px; }
.formule { font-family: var(--mono); background: #f2efe6; padding: 1px 6px; border-radius: 4px; white-space: normal; }
pre.code { font-family: var(--mono); background: #10202f; color: #e8f0f8; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: .9rem; margin: 8px 0; }
table.dt { border-collapse: collapse; margin: 10px 0; font-size: .93rem; background: #fff; }
table.dt th, table.dt td { border: 1px solid #c9c0ad; padding: 5px 10px; text-align: left; }
table.dt th { background: #efe9dc; }

/* ---------- Évaluation ---------- */
.bandeau-eval {
  position: sticky; top: 0; z-index: 20; background: var(--encre); color: #fff; padding: 10px 20px;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border-bottom: 3px solid var(--ambre);
}
.bandeau-eval .chrono { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; background: #0b1726; padding: 2px 12px; border-radius: 6px; }
.bandeau-eval .chrono.urgent { background: var(--rouge); }
.bandeau-eval .prog { font-size: .9rem; color: #c8d3e2; }
.bandeau-eval .btn { margin-left: auto; }
.alerte { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alerte.info { background: var(--bleu-clair); border-color: #b6c9e6; }
.alerte.attention { background: var(--ambre-clair); border-color: #f0cf8a; }
.alerte.danger { background: var(--rouge-clair); border-color: #efb3ae; }
.alerte.ok { background: var(--vert-clair); border-color: #a9dcc0; }
.sans-copie { -webkit-user-select: none; user-select: none; }
.sans-copie input, .sans-copie textarea { -webkit-user-select: text; user-select: text; }
.regles li { margin-bottom: 6px; }

/* ---------- Résultats ---------- */
.note-grande { font-family: var(--titre); font-size: 3.2rem; font-weight: 700; color: var(--bleu); line-height: 1; }
.note-grande small { font-size: 1.3rem; color: var(--encre-2); }
.code-controle { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .15em; background: var(--encre); color: var(--ambre); padding: 6px 14px; border-radius: 8px; display: inline-block; }
.tableau-res { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tableau-res th, .tableau-res td { padding: 8px 10px; border-bottom: 1px solid var(--ligne); text-align: left; }
.tableau-res td.n { text-align: right; font-family: var(--mono); }

/* ---------- Fenêtre modale ---------- */
.modale-fond { position: fixed; inset: 0; background: rgba(10, 20, 35, .55); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modale { background: var(--papier); border-radius: 12px; padding: 24px; max-width: 480px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.3); }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .entete .eleve { margin-left: 0; }
  .exo .corps { padding: 14px; }
  .question.juste, .question.faux, .question.a-corriger { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
}
@media print {
  .entete, .bandeau-eval, .actions, .retour, .pied { display: none !important; }
  body { background: #fff; }
  .exo { box-shadow: none; break-inside: avoid; }
}

/* ---------- Calculatrice intégrée ---------- */
.calc-btn { position: fixed; right: 18px; bottom: 18px; z-index: 60; font: inherit; font-weight: 700; padding: 12px 16px; border-radius: 99px; border: none; background: var(--encre); color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); cursor: pointer; }
.calc-btn:hover { background: var(--bleu); }
.calc { position: fixed; right: 18px; bottom: 76px; z-index: 61; width: 300px; background: var(--papier); border: 1px solid var(--ligne); border-radius: 12px; box-shadow: 0 10px 34px rgba(0,0,0,.25); padding: 12px; }
.calc-titre { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.calc-x { border: none; background: none; font-size: 1.4rem; cursor: pointer; color: var(--encre-2); }
.calc-hist { font-family: var(--mono); font-size: .85rem; min-height: 52px; max-height: 120px; overflow-y: auto; background: #f2efe6; border-radius: 6px; padding: 6px 8px; margin-bottom: 8px; }
.calc-hist span { color: var(--encre-2); }
.calc-err { color: var(--rouge); }
.calc-in { font-family: var(--mono) !important; margin-bottom: 8px; }
.calc-touches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.calc-touches button { font: inherit; font-family: var(--mono); padding: 8px 0; border: 1px solid var(--ligne); background: #fff; border-radius: 6px; cursor: pointer; }
.calc-touches button:hover { border-color: var(--bleu); }
.calc-touches [data-t="="] { background: var(--bleu); color: #fff; border-color: var(--bleu); }
@media print { .calc, .calc-btn { display: none !important; } }

/* ---------- Comptes, évaluations ouvertes/fermées, espace prof ---------- */
.grille-3 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.choix.ferme, .choix:disabled { cursor: not-allowed; opacity: .55; filter: grayscale(1); transform: none !important; border-color: var(--ligne) !important; }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; font-weight: 700; letter-spacing: .03em; font-family: var(--texte); margin-left: 6px; }
.badge.vert { background: var(--vert-clair); color: var(--vert); }
.badge.gris { background: #e6e3dc; color: #6b6b6b; }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }
.onglets { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; border-bottom: 2px solid var(--ligne); }
.onglets button { font: inherit; background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--encre-2); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.onglets button.actif { color: var(--bleu); border-bottom-color: var(--ambre); }
.petit-texte { font-size: .85rem; color: var(--encre-2); }
.carte-eval { display: grid; gap: 10px; }
.carte-eval .ligne-champs { align-items: end; }
.code-geant { font-family: var(--mono); font-size: 2rem; font-weight: 800; letter-spacing: .12em; color: var(--encre); background: var(--ambre-clair); border: 2px dashed var(--ambre); border-radius: 10px; padding: 6px 16px; display: inline-block; }
.filtres { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 10px; }
.filtres .champ { margin: 0; min-width: 170px; }
.tableau-res tr.gris td { color: #999; }
.tableau-res td .btn { margin: 2px 0; }
.tableau-res tr.suspecte td { background: var(--rouge-clair); }
