/* Styles communs. Couleurs d'état : jamais seules (toujours doublées d'un texte ou d'un symbole). */
:root {
  --fond: #f4f6f8; --carte: #fff; --texte: #1b2430; --doux: #5b6676; --bord: #d5dbe3; --accent: #1d4ed8; --accent-texte: #fff;
  --ok: #176b43; --ok-fond: #e3f5ec; --orange: #9a4a00; --orange-fond: #fff1dc; --rouge: #a31515; --rouge-fond: #fde4e4;
  --appel-fond: #e6efff; --saute: #6b2fa0; --saute-fond: #f0e6fb; --rayon: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #11161d; --carte: #1a2230; --texte: #e8edf4; --doux: #9aa6b8; --bord: #2d384a; --accent: #6b9bff; --accent-texte: #0c1220;
    --ok: #6fd6a2; --ok-fond: #143325; --orange: #ffb35c; --orange-fond: #3a2610; --rouge: #ff8f8f; --rouge-fond: #3d1717; --appel-fond: #172a4d; --saute: #d2b0ff; --saute-fond: #2a1a40;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

button { cursor: pointer; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); border-radius: 8px; padding: .55em 1em; min-height: 44px; }
button.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); font-weight: 600; }
button.danger { color: var(--rouge); border-color: var(--rouge); }
button:disabled { opacity: .55; cursor: default; }
input, textarea { width: 100%; padding: .6em .7em; min-height: 44px; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); }
label { display: block; font-weight: 600; margin: .8em 0 .25em; }
label.case { display: flex; gap: .5em; align-items: center; font-weight: 400; }
label.case input { width: auto; min-height: 0; }

.centre { max-width: 460px; margin: 6vh auto; padding: 0 1rem; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.1rem 1.2rem; }
.onglets { display: flex; gap: .4rem; margin: 1rem 0 .6rem; flex-wrap: wrap; }
.onglets button[aria-selected="true"] { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.erreur-form { color: var(--rouge); min-height: 1.4em; margin: .6em 0 0; }
.doux { color: var(--doux); }
.liste-sessions { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; }
.liste-sessions a { display: block; padding: .7em .9em; border: 1px solid var(--bord); border-radius: 8px; text-decoration: none; background: var(--carte); }

/* ── page de session ── */
.haut { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; background: var(--carte); border-bottom: 1px solid var(--bord); }
.haut h1 { margin: 0; font-size: 1.3rem; }
.haut .outils { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.code { font: 600 1rem ui-monospace, monospace; letter-spacing: .1em; padding: .15em .5em; border: 1px dashed var(--bord); border-radius: 6px; }
.etat-flux { font-size: .85rem; color: var(--doux); }
.etat-flux.coupe { color: var(--orange); font-weight: 600; }
.avert-son { margin: .8rem 1rem 0; padding: .7em 1em; border: 1px solid var(--orange); background: var(--orange-fond); color: var(--orange); border-radius: 8px; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
/* Avertissement « son désactivé » : fixe, hors du flux. Le masquer (au premier geste de l'utilisateur) ne doit pas faire
   remonter la page sous son doigt : un clic dont le contenu a bougé entre l'appui et le relâchement est perdu. */
.avert-son.flottant { position: fixed; bottom: 4.6rem; left: 1rem; right: 1rem; max-width: 560px; margin: 0 auto; z-index: 5; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.bandeau { margin: .8rem 1rem 0; padding: 1rem 1.2rem; border-radius: var(--rayon); background: var(--appel-fond); border: 2px solid var(--accent); display: grid; gap: .6rem; }
.bandeau strong { font-size: 1.25rem; }
.bandeau .actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 1rem; padding: 1rem 1rem 8rem; }   /* bas réservé : l'avertissement du son ne cache pas la dernière carte */
.ressource { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; display: grid; gap: .8rem; align-content: start; }
.ressource header { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.ressource h2 { margin: 0; font-size: 1.2rem; }
.badge { font-size: .8rem; font-weight: 700; padding: .15em .6em; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.statut-libre .badge { color: var(--ok); background: var(--ok-fond); }
.statut-appelee .badge { color: var(--accent); background: var(--appel-fond); }
.statut-occupee .badge { color: var(--doux); }
.occupant { display: grid; gap: .2rem; }
.occupant .qui { font-weight: 600; }
.chrono { font: 700 2.4rem/1.1 ui-monospace, "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums; padding: .15em .35em; border-radius: 8px; width: fit-content; }
.chrono.ok { color: var(--ok); background: var(--ok-fond); }
.chrono.orange { color: var(--orange); background: var(--orange-fond); }
.chrono.rouge { color: var(--rouge); background: var(--rouge-fond); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .chrono.rouge { animation: none; } }
.niveau { font-size: .9rem; font-weight: 600; min-height: 1.3em; }
.niveau.orange { color: var(--orange); } .niveau.rouge { color: var(--rouge); }
.file { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.file li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .5rem; align-items: baseline; padding: .4em .6em; border-radius: 8px; background: var(--fond); }
.file li.moi { outline: 2px solid var(--accent); }
.file .pos { font-weight: 700; color: var(--doux); }
.file .groupe, .file .attente { color: var(--doux); font-size: .85rem; }
.vide { color: var(--doux); font-style: italic; margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 10; width: min(92vw, 420px); }
.toast { background: var(--texte); color: var(--fond); padding: .7em 1em; border-radius: 8px; transition: opacity .4s; }
.toast.erreur { background: var(--rouge); color: #fff; }
.toast.fin { opacity: 0; }

/* ── gestion et administration ── */
.cache { position: absolute; left: -9999px; }
button.petit { min-height: 36px; min-width: 36px; padding: .25em .6em; font-size: .9rem; }
.barre-gestion, .actions-entree { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.barre-gestion { padding-top: .6rem; border-top: 1px dashed var(--bord); }
.file li.gere { grid-template-columns: 2rem 1fr auto; }
.file li.gere .actions-entree { grid-column: 1 / -1; }
.prio { color: var(--orange); font-weight: 700; }
.panneau { margin: .8rem 1rem 0; }
.gestion-panneau { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .7rem 1rem; }
.gestion-panneau summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.gestion-panneau .actions { margin-top: .6rem; }
.liste-simple { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .4rem; }
.liste-simple li { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .4em .6em; border-radius: 8px; background: var(--fond); }
.liste-simple.carte { padding: .8rem; }

dialog.dialogue { border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--carte); color: var(--texte); width: min(94vw, 480px); padding: 1.2rem; }
dialog.dialogue.large { width: min(94vw, 640px); }
dialog.dialogue::backdrop { background: rgba(0, 0, 0, .5); }
dialog.dialogue form { display: grid; gap: .6rem; }
dialog.dialogue select { width: 100%; min-height: 44px; padding: .4em; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); }
dialog.dialogue .actions { justify-content: flex-end; margin-top: .6rem; }
dialog.dialogue small { display: block; margin-top: .2rem; }

.admin { max-width: 1200px; margin: 0 auto; padding: 1rem; display: grid; gap: 1.6rem; }
.admin h2 { margin-bottom: .5rem; }
.ligne { display: flex; gap: .6rem; flex-wrap: wrap; }
.ligne input { flex: 1 1 260px; width: auto; }
.grille-admin { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 1rem; }
.bloc-session h3 { margin: 0; font-size: 1.15rem; }
.res-liste { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.res { display: grid; gap: .25rem; padding: .6em .8em; border: 1px solid var(--bord); border-radius: 8px; border-left-width: 6px; }
.res.statut-libre { border-left-color: var(--ok); }
.res.statut-appelee { border-left-color: var(--accent); }
.res.statut-occupee { border-left-color: var(--doux); }
.res-tete { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.res.flash { animation: flash 1.2s ease-in-out 5; background: var(--appel-fond); }
@keyframes flash { 50% { background: var(--orange-fond); } }
@media (prefers-reduced-motion: reduce) { .res.flash { animation: none; } }
.chrono.petit { font-size: 1.4rem; }
.defile { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.table th, .table td { text-align: left; padding: .45em .6em; border-bottom: 1px solid var(--bord); vertical-align: middle; }
.table input { min-height: 36px; width: 6rem; }
details.carte > summary { cursor: pointer; font-weight: 700; min-height: 32px; }
details.carte + details.carte { margin-top: .8rem; }
button.lien { background: none; border: 0; padding: 0 .2em; min-height: 32px; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.qui-ligne { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.file .depuis { font-variant-numeric: tabular-nums; }

/* ── TP (D11) : page de session, gestion, suivi. Couleurs d'état toujours doublées d'un symbole et d'un libellé (voir .puce). ── */
textarea { resize: vertical; }
.bouton { display: inline-flex; align-items: center; min-height: 44px; padding: .55em 1em; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); text-decoration: none; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); font-weight: 600; }
.bouton.petit { min-height: 36px; padding: .25em .6em; font-size: .9rem; }
.tp, .suivi { overflow-wrap: anywhere; }
.puce { display: inline-block; font-size: .85rem; font-weight: 700; padding: .1em .6em; border-radius: 99px; border: 1px solid currentColor; white-space: normal; }
.puce.neutre { color: var(--doux); }
.puce.attente { color: var(--orange); background: var(--orange-fond); }
.puce.bloque { color: var(--rouge); background: var(--rouge-fond); }
.puce.valide { color: var(--ok); background: var(--ok-fond); }
.puce.aide { color: var(--accent); background: var(--appel-fond); }
.puce.saute { color: var(--saute); background: var(--saute-fond); }
.puces { display: flex; gap: .4rem; flex-wrap: wrap; margin: .2rem 0; }

.tp { margin: .8rem 1rem 0; display: grid; gap: .8rem; max-width: 820px; }
.tp h2 { margin: 0; }
.tp-carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; display: grid; gap: .6rem; align-content: start; }
.tp-carte h3, .tp-carte h4 { margin: 0; }
.tp-seance { padding: .7em 1em; border-radius: 8px; border: 1px solid var(--ok); background: var(--ok-fond); color: var(--texte); }
.tp-seance.hors { border-color: var(--orange); background: var(--orange-fond); }
.tp-formulaire { display: grid; gap: .3rem; }
.tp-noms, .tp-noms-lecture { display: grid; gap: .5rem; }
.tp-noms-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.tp-nom-ligne { display: grid; gap: .2rem; }
.tp-nom-champ { display: flex; gap: .5rem; align-items: center; }
.tp-nom-champ input { flex: 1 1 auto; min-width: 0; }
.tp-nom-champ button { flex: 0 0 auto; min-height: 44px; min-width: 44px; }
.tp-option { display: grid; gap: .3rem; }
.tp-option > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.reference-bloc { display: grid; gap: .2rem; }
.reference { font: 700 2.2rem/1.1 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .25em; padding: .2em .4em; border: 2px dashed var(--accent); border-radius: 8px; width: fit-content; max-width: 100%; user-select: all; }
.reference-petite { font: 600 1rem ui-monospace, monospace; letter-spacing: .15em; }
.tp-carte.messages.nouveau { border: 2px solid var(--orange); background: var(--orange-fond); }
.liste-simple li.nouveau { font-weight: 700; }
.tp-resume { margin: 0; }
progress { width: 100%; height: 1rem; accent-color: var(--accent); }
.tp-etapes { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.tp-etape { display: grid; grid-template-columns: 2rem 1fr; gap: .6rem; padding: .6em .7em; border-radius: 8px; background: var(--fond); border-left: 5px solid var(--bord); }
.tp-etape.faite { border-left-color: var(--ok); }
.tp-etape .num { font-weight: 700; color: var(--doux); }
.tp-etape .corps { display: grid; gap: .3rem; }
.description { margin: 0; color: var(--doux); white-space: pre-line; }
.tp-jalons { display: grid; gap: .8rem; }
.tp-jalon { border: 1px solid var(--bord); border-left-width: 6px; border-radius: 8px; padding: .7rem .9rem; display: grid; gap: .5rem; background: var(--fond); }
.tp-jalon header { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.tp-jalon h4 { margin: 0; font-size: 1.05rem; }
.tp-jalon.statut-valide { border-left-color: var(--ok); }
.tp-jalon.statut-en_attente { border-left-color: var(--orange); }
.tp-jalon.statut-bloque { border-left-color: var(--rouge); }
.tp-jalon p { margin: 0; }
.attendus { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.attendus li { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .4em .6em; border-radius: 8px; background: var(--carte); }
.note { padding: .5em .7em; border-radius: 8px; background: var(--orange-fond); color: var(--orange); }

/* gestion du TP (fenêtre) */
.tp-section { display: grid; gap: .6rem; padding-bottom: .8rem; margin-bottom: .8rem; border-bottom: 1px solid var(--bord); }
.tp-parcours { border: 1px solid var(--bord); border-radius: 8px; padding: .5rem .8rem; margin-bottom: .6rem; }
.tp-parcours summary { cursor: pointer; font-weight: 700; min-height: 36px; display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; }
.tp-parcours-corps { display: grid; gap: .6rem; padding-top: .4rem; }
.tp-nom { display: grid; gap: .2rem; }
.tp-nom label { margin: 0; }
.tp-gestion-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.tp-gestion-liste li { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .4em .6em; border-radius: 8px; background: var(--fond); }
.tp-gestion-liste li.masque { opacity: .65; }
.tp-gestion-liste .texte { flex: 1 1 14rem; min-width: 0; }
.tp-gestion-jalon { border: 1px solid var(--bord); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .6rem; display: grid; gap: .5rem; }
.tp-gestion-jalon .tete { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: center; }
.tp-importes fieldset { border: 1px solid var(--bord); border-radius: 8px; margin: .5rem 0 0; }

/* page de suivi */
.suivi { max-width: 900px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.suivi section { display: grid; gap: .8rem; align-content: start; }
.suivi h2 { margin: 0; }
.erreur-bloc { border-color: var(--rouge); background: var(--rouge-fond); color: var(--texte); }
.notifs { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: grid; gap: .4rem; padding: .5rem; pointer-events: none; }
.notifs:empty { display: none; }
.notif { pointer-events: auto; display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .7em 1em; border-radius: var(--rayon); background: var(--appel-fond); color: var(--texte); border: 2px solid var(--accent); box-shadow: 0 4px 16px rgba(0, 0, 0, .3); }
.liste-equipes { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.equipe-ligne { border: 1px solid var(--bord); border-left-width: 8px; border-radius: var(--rayon); background: var(--carte); }
.equipe-ligne.bloque { border-left-color: var(--rouge); background: var(--rouge-fond); }
.equipe-ligne.attente { border-left-color: var(--orange); background: var(--orange-fond); }
.equipe-ligne.aide { border-color: var(--accent); border-left-width: 12px; background: var(--appel-fond); }
.equipe-ligne.saute { border-left-color: var(--saute); background: var(--saute-fond); }
.equipe-ligne.eclat { animation: flash 1.2s ease-in-out 6; }
@media (prefers-reduced-motion: reduce) { .equipe-ligne.eclat { animation: none; outline: 3px solid var(--accent); } }
.equipe-carte { display: grid; gap: .4rem; padding: .8rem 1rem; min-height: 44px; color: var(--texte); text-decoration: none; }
.equipe-nom strong { font-size: 1.1rem; }
.equipe-chiffres { font-size: .92rem; }
.formulaire-message { display: grid; gap: .4rem; }
.evaluation { display: flex; gap: .4rem; flex-wrap: wrap; }
button.eval[aria-pressed="true"] { font-weight: 700; border-width: 2px; }
button.eval.valider[aria-pressed="true"] { background: var(--ok-fond); color: var(--ok); border-color: var(--ok); }
button.eval.refuser[aria-pressed="true"] { background: var(--rouge-fond); color: var(--rouge); border-color: var(--rouge); }
.barre-cr { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.barre-cr select { min-height: 44px; flex: 1 1 14rem; min-width: 0; padding: .4em; border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte); }
.cr-equipe { border-top: 1px solid var(--bord); padding-top: .6rem; margin-top: .6rem; }
.cr-jalons, .cr-jalons ul { margin: .2rem 0; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .sans-impression, #toasts, .notifs, .avert-son { display: none !important; }
  .suivi { padding: 0; max-width: none; }
  .carte, .tp-carte { border: 0; padding: 0; background: none; }
  .puce { border: 0; padding: 0; background: none !important; color: #000 !important; }
  .cr-equipe { break-inside: avoid; }
  .defile { overflow: visible; }
  .table th, .table td { border-bottom: 1px solid #999; }
}
.suivi .table th, .suivi .table td { overflow-wrap: normal; }   /* un mot ne se coupe pas dans un tableau : il défile dans .defile */
#cr section { gap: .4rem; }
#cr h3, #cr h4 { margin: .6rem 0 .2rem; }
.suivi, .suivi section { grid-template-columns: minmax(0, 1fr); }   /* une colonne qui peut rétrécir : un tableau large défile dans .defile au lieu d'élargir la page */

/* TP côté élève : tronçons d'étapes pliables, jalons placés juste dessous */
.tp-troncon { border: 1px solid var(--bord); border-radius: 8px; padding: .4rem .7rem; }
.tp-troncon.courant { border-color: var(--bleu, var(--bord)); }
.tp-troncon > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.tp-troncon[open] > summary { margin-bottom: .4rem; }

/* Appel à l'enseignant (D12) : bouton large et visible sur téléphone ; la demande envoyée se distingue par la bordure ET son texte */
.tp-carte.aide { border: 2px solid var(--accent); }
.tp-carte.aide.envoyee { background: var(--appel-fond); }
button.grand { min-height: 56px; font-size: 1.1rem; width: 100%; }
.notif.aide { border-color: var(--rouge); border-width: 3px; }
.carte.aide-detail { border: 2px solid var(--accent); background: var(--appel-fond); }
.equipe-actions { padding: 0 1rem .8rem; }
.aide-texte { font-style: italic; overflow-wrap: anywhere; }
