:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --text: #1b2733;
  --muted: #5b6b7a;
  --border: #dde3e9;
  --accent: #0d7c8a;
  --accent-ink: #ffffff;
  --ok-bg: #e6f5ec; --ok-bd: #34a853; --ok-ink: #1e6f3b;
  --ko-bg: #fdecea; --ko-bd: #d93025; --ko-ink: #a1160a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,32,48,.06), 0 6px 24px rgba(16,32,48,.06);
  --maxw: 780px;
  --fond: #e6f2f4;        /* fond uni, teinté de la couleur d'accent */
  --bandeau: #0d7c8a;     /* barre du haut */
  --bandeau-ink: #ffffff;
  --bandeau-survol: #2a95a2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161c; --surface: #182028; --surface-2: #1f2a33;
    --text: #e7edf3; --muted: #9fb0bd; --border: #2b3945;
    --accent: #3bb3c2; --accent-ink: #06222a;
    --ok-bg: #16301f; --ok-bd: #34a853; --ok-ink: #7fd39b;
    --ko-bg: #3a1c19; --ko-bd: #e06055; --ko-ink: #f0a59d;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 30px rgba(0,0,0,.35);
    --fond: #0f1b20; --bandeau: #0b4a54; --bandeau-ink: #e7f6f8; --bandeau-survol: #14606c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fond); color: var(--text);
  display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.1rem;
  background: var(--bandeau); border-bottom: 1px solid var(--bandeau); color: var(--bandeau-ink);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand, .topbar button.link, .topbar .user { color: var(--bandeau-ink); }
.topbar button.link:hover { background: var(--bandeau-survol); color: var(--bandeau-ink); }
.topbar .ia-etat { border-color: rgba(255,255,255,.55) !important; }
.foot { color: var(--muted); }
.brand { font-weight: 700; cursor: pointer; letter-spacing: .2px; }
.topbar nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.user { margin-left: .5rem; color: var(--muted); font-size: .9rem; display: inline-flex; gap: .4rem; align-items: center; }

button {
  font: inherit; cursor: pointer; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; transition: background .12s, border-color .12s, transform .04s;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); background: var(--accent); }
button.link { border-color: transparent; background: transparent; color: var(--muted); padding: .4rem .6rem; }
button.link:hover { color: var(--text); background: var(--surface-2); }
button.link.small { font-size: .82rem; padding: .15rem .4rem; }

main {
  width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 1.4rem 1.1rem 3rem;
  flex: 1;
}
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem;
}
.card + .card { margin-top: 1rem; }
h1 { font-size: 1.4rem; margin: .1rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
p.lead { color: var(--muted); margin-top: 0; }

label { display: block; font-size: .85rem; color: var(--muted); margin: .8rem 0 .3rem; }
select, input[type=text], input[type=email], input[type=password] {
  font: inherit; width: 100%; padding: .55rem .7rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
}
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > div { flex: 1 1 180px; }
.actions { margin-top: 1.2rem; display: flex; gap: .6rem; flex-wrap: wrap; }

label.check { display: flex; align-items: center; gap: .5rem; margin: 1rem 0 0; color: var(--text); font-size: .92rem; cursor: pointer; }
label.check input { width: auto; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .7rem; margin-top: .3rem; }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; }
.tile-v { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.tile-l { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-top: .2rem; }
.notion-list { list-style: none; margin: 0; padding: 0; }
.notion-list li { padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.notion-list li:last-child { border-bottom: 0; }
.notion-list a { text-decoration: none; }
.cours-acquis { margin-top: 1rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: .92rem; }

/* tableau de bord : parcours en quatre étapes, tâches, avancement */
.tdb-tete { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tdb-tete h1 { margin: 0; }
.tdb-tete select { width: auto; max-width: 100%; }
.etapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.etape { display: flex; flex-direction: column; gap: .3rem; text-align: left; padding: .8rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.etape:hover { border-color: var(--accent); background: var(--surface-2); }
.etape.faite { border-color: var(--ok-bd); }
.etape.faite .onglet-num { background: var(--ok-bd); color: #fff; }
.etape-tete { display: flex; align-items: center; gap: .45rem; font-size: .92rem; }
.etape-chiffre { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.etape-legende { font-size: .8rem; color: var(--muted); min-height: 2.4em; }
.etape .bar { display: block; background: var(--surface); }
.etape small { font-size: .74rem; color: var(--muted); line-height: 1.3; }
.taches { list-style: none; margin: 0; padding: 0; }
.taches li { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.taches li:last-child { border-bottom: 0; }
.taches li > span:nth-child(2) { flex: 1; min-width: 0; }
.tdb-ia { font-size: .85rem; margin: .8rem 0 0; }
.ue-lien { padding: 0; color: var(--text); text-align: left; text-decoration: underline; text-decoration-color: var(--border); }
.tdb-detail { margin-top: 1rem; }
.tdb-detail summary { cursor: pointer; color: var(--accent); font-weight: 600; }
@media (max-width: 900px) { .etapes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .etapes { grid-template-columns: 1fr; } .etape-legende { min-height: 0; } }

/* sliders (paramétrage) */
.slider { display: flex; align-items: center; gap: 1rem; }
.slider input[type=range] { flex: 1; accent-color: var(--accent); }
.slider output { min-width: 3ch; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .3px;
  padding: .16rem .5rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); text-transform: uppercase;
}
.badge.Facile { color: var(--ok-ink); border-color: var(--ok-bd); }
.badge.Moyen { color: #b26a00; border-color: #e0a100; }
.badge.Difficile { color: var(--ko-ink); border-color: var(--ko-bd); }

/* Quiz */
.qhead { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .3rem; }
.qhead .meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: .6rem 0 1.1rem; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.enonce { font-size: 1.08rem; margin: .4rem 0 1rem; }
.statements { margin: 0 0 1rem; padding-left: 1.1rem; color: var(--text); }
.statements li { margin: .25rem 0; }

.options { display: flex; flex-direction: column; gap: .55rem; }
.opt {
  display: flex; gap: .7rem; align-items: flex-start; text-align: left;
  width: 100%; padding: .7rem .85rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .lettre {
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 6px;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.opt.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.opt.selected .lettre { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt.correct { border-color: var(--ok-bd); background: var(--ok-bg); }
.opt.correct .lettre { background: var(--ok-bd); color: #fff; border-color: var(--ok-bd); }
.opt.wrong { border-color: var(--ko-bd); background: var(--ko-bg); }
.opt.wrong .lettre { background: var(--ko-bd); color: #fff; border-color: var(--ko-bd); }
.opt.missed { border-color: var(--ok-bd); border-style: dashed; }
.opt.missed .lettre { color: var(--ok-ink); border-color: var(--ok-bd); }

.feedback { margin-top: 1.1rem; border-radius: 10px; padding: .9rem 1rem; border: 1px solid var(--border); background: var(--surface-2); }
.feedback.ok { background: var(--ok-bg); border-color: var(--ok-bd); }
.feedback.ko { background: var(--ko-bg); border-color: var(--ko-bd); }
.feedback h3 { margin: 0 0 .4rem; font-size: .95rem; }
.feedback p { margin: .4rem 0; }
.feedback .section { margin-top: .6rem; }
.feedback .section b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-bottom: .1rem; }
.feedback a { color: var(--accent); font-weight: 600; text-decoration: none; }
.feedback a:hover { text-decoration: underline; }

/* Résultat + dashboard */
.score { font-size: 2.4rem; font-weight: 700; }
.score small { font-size: 1rem; font-weight: 400; color: var(--muted); }
table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.grid th, table.grid td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); }
table.grid th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.tar { text-align: right; }

.notice { padding: 1rem 1.2rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.error { border-color: var(--ko-bd); color: var(--ko-ink); background: var(--ko-bg); }
.spin { color: var(--muted); }

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .card { padding: 1.1rem; }
}

/* cours et corrections */
.corr .avant { background: var(--ko-bg); padding: .1rem .3rem; border-radius: 4px; }
.corr .section { margin-top: .6rem; }
.corr .section b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-bottom: .1rem; }
.corr textarea { width: 100%; margin-top: .8rem; font: inherit; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
a.btn { display: inline-block; text-decoration: none; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .5rem .9rem; }
a.btn:hover { background: var(--surface-2); }
.qimg { display: block; max-width: 100%; max-height: 420px; margin: 0 auto 1rem; border-radius: 8px; border: 1px solid var(--border); }
input[type=file] { font: inherit; }
.corr-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.2rem; align-items: start; }
.contexte { display: block; text-decoration: none; color: var(--muted); font-size: .8rem; }
.contexte img { display: block; width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.contexte span { display: block; margin-top: .3rem; }
@media (max-width: 900px) { .corr-grid { grid-template-columns: 1fr; } }

/* pages complémentaires d'une réponse */
.autres-pages { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem; margin-bottom: .6rem; font-size: .85rem; }
.autres-pages .muted { color: var(--muted); align-self: center; }
.autre-page { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .25rem .6rem; }
.autre-page[open] { flex-basis: 100%; padding: .4rem .6rem .6rem; }
.autre-page summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.autre-page .contexte { margin-top: .5rem; }

/* schéma d'une question + crédit */
.qfig { margin: 0 0 1rem; }
.qfig .qimg { margin-bottom: .3rem; }
.qfig figcaption { text-align: center; font-size: .78rem; color: var(--muted); }
#signalement textarea { width: 100%; font: inherit; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
.analyse-ia { white-space: pre-line; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: .6rem .8rem; }

/* onglet Process (fonctionnement et conditions d'utilisation) */
.process h2 { margin-top: 1.4rem; }
.process li { margin: .3rem 0; }
.cgu-acceptation { margin: 1.4rem 0 0; padding-top: .8rem; border-top: 1px solid var(--border); color: var(--muted); }
table.process td { vertical-align: top; }
table.process td:first-child { white-space: nowrap; }
@media (max-width: 700px) { table.process td:first-child { white-space: normal; } }

/* infobulles */
#tip { position: fixed; z-index: 50; max-width: min(340px, calc(100vw - 16px)); padding: .55rem .7rem;
  background: var(--text); color: var(--bg); border-radius: 8px; font-size: .82rem; line-height: 1.4;
  box-shadow: var(--shadow); pointer-events: none; }

/* regroupement des cours par UE */
table.grid tr.ue-titre th { padding-top: 1rem; font-size: .85rem; color: var(--text); text-transform: none; letter-spacing: 0; }

/* fiches d'apprentissage */
.fiche-vue { display: block; width: 100%; height: 70vh; margin-top: .8rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.fiche textarea, #fConsignes { width: 100%; margin-top: .6rem; font: inherit; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
/* écran d'un cours : étapes à suivre, bouton de la prochaine action, journal des actions */
.etapes-cours { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.etapes-cours li { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem .7rem; border: 2px solid var(--border); border-radius: 10px; background: var(--surface-2); opacity: .75; }
.etapes-cours li > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.etapes-cours small { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.etapes-cours li.en-cours { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.etapes-cours li.en-cours .onglet-num { background: var(--accent); color: var(--accent-ink); }
.etapes-cours li.fait { opacity: 1; border-color: var(--ok-bd); }
.etapes-cours li.fait .onglet-num { background: var(--ok-bd); color: #fff; }
button.a-faire { animation: a-faire 1.6s ease-in-out infinite; }
@keyframes a-faire { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { button.a-faire { animation: none; outline: 2px solid var(--accent); outline-offset: 2px; } }
.journal-cours { margin-top: 1.1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.journal-cours ul { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.journal-cours li { padding: .2rem 0; }
.journal-cours li .spin { font-variant-numeric: tabular-nums; margin-right: .4rem; }
.journal-cours summary { cursor: pointer; color: var(--accent); font-size: .85rem; margin-top: .3rem; }
@media (max-width: 760px) { .etapes-cours { grid-template-columns: 1fr; } }

/* contenu repris d'un étudiant qui a pris les mêmes décisions (passerelle) */
.partagee { font-size: .8rem; margin: .2rem 0 .6rem; }

/* trace d'une mise à jour après modification du cours (question, fiche) */
.maj-note { font-size: .82rem; color: #7a4b00; background: #fff6dd; border: 1px solid #e0a100; border-radius: 8px; padding: .35rem .6rem; margin: .4rem 0 .8rem; }

/* fiche demandée : le bloc pulse lentement tant que la fiche est en préparation */
.fiche.en-preparation { border-color: #e0a100; animation: prep-pouls 2.4s ease-in-out infinite; }
.prep-pastille { display: inline-block; margin-right: .3rem; background: #e0a100; animation: ia-pouls 1.2s ease-in-out infinite; }
@keyframes prep-pouls { 0%, 100% { opacity: 1; box-shadow: var(--shadow); } 50% { opacity: .55; box-shadow: 0 0 0 4px rgba(224,161,0,.25); } }
@media (prefers-reduced-motion: reduce) { .fiche.en-preparation, .prep-pastille { animation: none; } }
.fiche .section { margin-top: .6rem; }
.fiche .section b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-bottom: .1rem; }

/* ------------------------------------------------------------------ mobile et tablette */
/* encoche et barres système (iPhone, iPad, Android) */
.topbar { padding-left: max(1.1rem, env(safe-area-inset-left)); padding-right: max(1.1rem, env(safe-area-inset-right)); }
main { padding-left: max(1.1rem, env(safe-area-inset-left)); padding-right: max(1.1rem, env(safe-area-inset-right)); }
.foot { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
html { -webkit-text-size-adjust: 100%; }
img, iframe { max-width: 100%; }

/* écrans tactiles : cibles d'au moins 44 px, pas d'effet de survol qui reste collé */
@media (pointer: coarse) {
  button, a.btn, select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=file] { min-height: 44px; }
  button.link.small { min-height: 36px; padding: .35rem .6rem; font-size: .9rem; }
  .opt { padding: .85rem .9rem; }
  .opt .lettre { width: 2rem; height: 2rem; }
  label.check { min-height: 44px; }
  label.check input { width: 22px; height: 22px; }
  .slider input[type=range] { height: 36px; }
  summary { min-height: 36px; display: flex; align-items: center; }
  button:hover { background: var(--surface); }
  button.primary:hover { background: var(--accent); filter: none; }
  /* 16 px au moins dans les champs : iOS ne zoome pas à la saisie */
  select, input, textarea { font-size: 16px !important; }
}

/* tablette (portrait) et petits ordinateurs */
@media (max-width: 1024px) {
  main { padding-top: 1rem; }
  .fiche-vue { height: 62vh; }
}

/* téléphone et petite tablette */
@media (max-width: 760px) {
  /* barre du haut : le titre et le compte sur une ligne, le menu défile à l'horizontale */
  .topbar { flex-direction: column; align-items: stretch; gap: .3rem; padding-top: .45rem; padding-bottom: .35rem; }
  .topbar nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: .15rem; margin: 0 -.4rem; padding: 0 .4rem; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav button, .topbar nav .user { flex: none; white-space: nowrap; }
  .user { margin-left: auto; }

  main { padding: .8rem .7rem 2.5rem; }
  .card { padding: 1rem .9rem; border-radius: 10px; }
  .card + .card { margin-top: .7rem; }
  h1 { font-size: 1.2rem; }
  .enonce { font-size: 1.02rem; }
  .score { font-size: 2rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .tile-v { font-size: 1.15rem; }
  .qhead { flex-wrap: wrap; }
  .corr-grid { gap: .8rem; }

  /* boutons d'action : pleine largeur, faciles à toucher */
  .actions { gap: .5rem; }
  .actions > button, .actions > a.btn { flex: 1 1 100%; text-align: center; }
  .actions > button.link { flex: 0 1 auto; }

  /* tableaux : une ligne devient un bloc, on ne fait pas défiler la page de côté */
  table.grid, table.grid tbody, table.grid tr, table.grid td, table.grid th { display: block; width: auto; }
  table.grid thead { display: none; }
  table.grid tr { padding: .6rem 0; border-bottom: 1px solid var(--border); }
  table.grid tr:last-child { border-bottom: 0; }
  table.grid td, table.grid th { border: 0; padding: .15rem 0; text-align: left !important; }
  table.grid td[style] { width: auto !important; }
  table.grid td.tar { display: inline-block; margin-right: .6rem; vertical-align: middle; }
  table.grid td:empty { display: none; }
  table.grid tr.ue-titre { padding: .9rem 0 .2rem; border-bottom: 0; }
  table.process td:first-child { font-size: 1rem; padding-top: .2rem; }
  table.process td:nth-child(2)::before { content: "Ce que fait l'application — "; color: var(--muted); font-size: .8rem; }
  table.process td:nth-child(3)::before { content: "Ce que cela implique — "; color: var(--muted); font-size: .8rem; }

  .fiche-vue { height: 65vh; }
  .qimg { max-height: 300px; }
  #tip { max-width: calc(100vw - 16px); font-size: .9rem; }
}
.astuce-tactile { display: none; }
@media (hover: none) {
  .astuce-tactile { display: inline; }
  /* l'appui long sert à l'infobulle : pas de sélection de texte ni de menu sur les boutons */
  button, .badge, a.btn, summary { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

/* sous-onglets de l'écran Cours : trois grands boutons en tête d'écran */
.onglets { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.onglet { display: flex; align-items: center; gap: .6rem; text-align: left; padding: .75rem .8rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.onglet:hover { border-color: var(--accent); background: var(--surface); }
.onglet.actif { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.onglet-num { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-weight: 700; display: grid; place-items: center; }
.onglet.actif .onglet-num { background: var(--accent-ink); color: var(--accent); }
.onglet-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.onglet-txt small { font-size: .76rem; color: var(--muted); }
.onglet.actif .onglet-txt small { color: inherit; opacity: .85; }
.onglet-nb { flex: none; display: inline-block; min-width: 1.5rem; padding: 0 .4rem; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700; line-height: 1.5rem; text-align: center; }
.onglet.actif .onglet-nb { background: var(--accent-ink); color: var(--accent); }
.onglets-note { font-size: .82rem; margin: 1rem .2rem 0; }

/* témoin et centre de notifications de l'IA */
.ia-etat { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border) !important; border-radius: 999px; padding: .3rem .7rem; font-size: .88rem; white-space: nowrap; }
.ia-pastille { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); flex: none; }
.ia-etat.ecoute .ia-pastille { background: var(--ok-bd); }
.ia-etat.travaille { color: var(--text); border-color: #e0a100 !important; }
.ia-etat.travaille .ia-pastille { background: #e0a100; animation: ia-pouls 1.2s ease-in-out infinite; }
.ia-nb { min-width: 1.25rem; padding: 0 .3rem; border-radius: 999px; background: var(--ko-bd); color: #fff; font-size: .72rem; line-height: 1.25rem; text-align: center; font-weight: 700; }
@keyframes ia-pouls { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .ia-etat.travaille .ia-pastille { animation: none; } }

#iaPanneau { position: fixed; top: 3.6rem; right: max(.8rem, env(safe-area-inset-right)); z-index: 40; width: min(380px, calc(100vw - 1.6rem)); max-height: calc(100vh - 5rem); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: .8rem .9rem; }
#iaPanneau h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: .9rem 0 .35rem; }
.ia-tete { display: flex; align-items: center; justify-content: space-between; }
.ia-presence { margin: .3rem 0 0; font-size: .9rem; color: var(--muted); }
.ia-presence.travaille { color: #b26a00; font-weight: 600; }
.ia-presence.ecoute { color: var(--ok-ink); }
.ia-item { display: flex; flex-direction: column; gap: .15rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-size: .88rem; }
.ia-item + .ia-item { margin-top: .4rem; }
.ia-item.encours { border-left: 4px solid #e0a100; }
.ia-item.fini { background: transparent; }
.ia-item small { color: var(--muted); font-size: .78rem; }
.ia-etape { color: var(--text); }
.chrono { font-variant-numeric: tabular-nums; font-weight: 600; }

#toasts { position: fixed; right: max(.8rem, env(safe-area-inset-right)); bottom: max(.8rem, env(safe-area-inset-bottom)); z-index: 45; display: flex; flex-direction: column; gap: .5rem; width: min(340px, calc(100vw - 1.6rem)); }
.toast { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .85rem; border-radius: 10px; border: 1px solid var(--border); border-left: 4px solid var(--accent);
  background: var(--surface); box-shadow: var(--shadow); font-size: .88rem; cursor: pointer; animation: toast-entree .25s ease-out; }
.toast.encours { border-left-color: #e0a100; }
.toast.fini { border-left-color: var(--ok-bd); }
.toast small { color: var(--muted); font-size: .75rem; }
@keyframes toast-entree { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) {
  #iaPanneau { top: 5.6rem; left: .5rem; right: .5rem; width: auto; }
  .onglets { grid-template-columns: 1fr; gap: .4rem; }
  .onglet-txt small { display: none; }
}

/* version de test et statistique des décisions */
#bandeauTest { position: sticky; top: 0; z-index: 30; background: #6a1b9a; color: #fff; text-align: center; font-size: .85rem; font-weight: 700; letter-spacing: .3px; padding: .4rem .8rem; }
body.mode-test { --fond: #efe3f6; --bandeau: #6a1b9a; --bandeau-survol: #8e3fb8; }
body.mode-test .topbar { top: 1.9rem; border-bottom-color: #4a0f70; }
body.mode-test .card { border-color: #b98ad1; }
@media (prefers-color-scheme: dark) { body.mode-test { --fond: #24122e; --bandeau: #4a1470; --bandeau-survol: #63208f; } }

/* messagerie */
/* messages et paramétrage : deux icônes à droite, près de la pastille du compte */
.topbar button.icone { position: relative; padding: .4rem .5rem; line-height: 0; }
.topbar button.icone svg { width: 1.45rem; height: 1.45rem; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
/* point rouge : il y a des messages non lus */
#msgNb { position: absolute; top: .22rem; right: .22rem; width: .7rem; height: .7rem; border-radius: 50%;
  background: #e11d48; border: 2px solid var(--bandeau, #0e7c86); font-size: 0; }
#msgNb[hidden] { display: none; }
#testBandeau { display: block; width: 100%; border: 0; border-radius: 0; background: #e0a100; color: #1b1300; font-weight: 600; padding: .5rem 1rem; }
#testBandeau[hidden] { display: none; }
#testBandeau:hover { background: #f0b21a; }
.msg-liste { list-style: none; margin: 0 0 1rem; padding: 0; }
.msg-ligne { display: flex; align-items: center; gap: .7rem; padding: .6rem .4rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.msg-ligne:last-child { border-bottom: 0; }
.msg-ligne.cliquable { cursor: pointer; border-radius: 9px; }
.msg-ligne.cliquable:hover, .msg-ligne.cliquable:focus-visible { background: var(--surface-2); }
.msg-qui { flex: 1 1 10rem; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.msg-qui small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; object-fit: cover; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; }
#msgTrouves { margin-top: .8rem; }
.fil-carte { display: flex; flex-direction: column; }
.fil-tete { display: flex; align-items: center; gap: .6rem; padding-bottom: .7rem; border-bottom: 1px solid var(--border); }
.fil { display: flex; flex-direction: column; gap: .45rem; height: min(56vh, 30rem); overflow-y: auto; padding: .9rem .2rem; overscroll-behavior: contain; }
.bulle { align-self: flex-start; max-width: 82%; display: flex; flex-direction: column; gap: .15rem; padding: .5rem .75rem; border-radius: 14px 14px 14px 4px; background: var(--surface-2); border: 1px solid var(--border); }
.bulle.moi { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bulle-txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle a { color: inherit; text-decoration: underline; }
.bulle small { font-size: .7rem; opacity: .75; align-self: flex-end; }
.bulle .vocal { font-weight: 600; }
.vocal-efface { font-style: italic; opacity: .8; }
.saisie { display: flex; align-items: flex-end; gap: .5rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.saisie[hidden] { display: none; }
.saisie textarea { flex: 1; min-width: 0; font: inherit; resize: none; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
.saisie.enreg { align-items: center; font-variant-numeric: tabular-nums; }
.saisie.enreg #filAnnuler { margin-left: auto; }
.enreg-point { width: .8rem; height: .8rem; border-radius: 50%; background: var(--ko-bd); animation: ia-pouls 1.2s ease-in-out infinite; }
.fil-note { font-size: .78rem; margin: .6rem 0 0; }
@media (prefers-reduced-motion: reduce) { .enreg-point { animation: none; } }

/* fenêtre de messagerie flottante */
#chatBulle { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 42; width: 3.4rem; height: 3.4rem; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 1.5rem; box-shadow: var(--shadow); padding: 0; }
#chatBulle[hidden], #chatFenetre[hidden] { display: none; }
#chatBulle:hover { background: var(--accent); filter: brightness(1.08); }
#chatBulle.alerte { animation: chat-alerte 1s ease-in-out infinite; }
#chatNb { position: absolute; top: -.2rem; right: -.2rem; min-width: 1.35rem; padding: 0 .3rem; border-radius: 999px; background: var(--ko-bd); color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center; }
#chatNb[hidden] { display: none; }
@keyframes chat-alerte { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217,48,37,.6); } 50% { transform: scale(1.1); box-shadow: 0 0 0 12px rgba(217,48,37,0); } }
@media (prefers-reduced-motion: reduce) { #chatBulle.alerte { animation: none; outline: 3px solid var(--ko-bd); } }
#chatFenetre { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4rem); z-index: 42; width: min(370px, calc(100vw - 2rem)); height: min(520px, calc(100vh - 7rem)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 40px rgba(16,32,48,.25); overflow: hidden; }
.chat-tete { display: flex; align-items: center; gap: .3rem; padding: .55rem .6rem .55rem .8rem; background: var(--accent); color: var(--accent-ink); }
.chat-tete b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tete button.link { color: var(--accent-ink); }
.chat-tete button.link:hover { background: rgba(255,255,255,.2); color: var(--accent-ink); }
.chat-fil { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; padding: .7rem; overscroll-behavior: contain; }
.chat-fil .msg-liste { margin: 0; }
.chat-info { margin: 0 0 .4rem; font-size: .85rem; color: var(--muted); }
.chat-saisie { display: flex; align-items: flex-end; gap: .4rem; padding: .5rem; border-top: 1px solid var(--border); }
.chat-saisie textarea { flex: 1; min-width: 0; font: inherit; resize: none; max-height: 6rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
.chat-saisie button { padding: .45rem .7rem; }

/* pastille du compte, à droite de la barre du haut, et son menu */
.topbar nav { flex: 1; }
.topbar .user { margin-left: auto; position: relative; }
.pastille-compte { display: inline-flex; align-items: center; gap: .45rem; padding: .2rem .7rem .2rem .25rem; border-radius: 999px; border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.16); color: var(--bandeau-ink); font-weight: 600; }
.pastille-compte:hover { background: rgba(255,255,255,.28); }
.pastille-compte img, .pastille-initiale { width: 1.9rem; height: 1.9rem; border-radius: 50%; object-fit: cover; flex: none; }
.pastille-initiale { display: grid; place-items: center; background: var(--bandeau-ink); color: var(--bandeau); font-weight: 700; }
.pastille-initiale[hidden] { display: none; }
.pastille-fleche { font-size: .7rem; opacity: .85; }
#menuCompte { position: fixed; z-index: 50; min-width: 11rem; display: flex; flex-direction: column; padding: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
#menuCompte[hidden] { display: none; }
#menuCompte button { border: 0; background: transparent; color: var(--text); text-align: left; padding: .55rem .7rem; border-radius: 7px; }
#menuCompte button:hover { background: var(--surface-2); }

/* profil */
.oblig { color: var(--ko-bd); }
.annees { margin: .5rem 0 0; padding-left: 1.1rem; }
.annees li { margin: .2rem 0; }
.profil-lien { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .5rem; }
.profil-lien img { width: 1.7rem; height: 1.7rem; border-radius: 50%; object-fit: cover; }
.profil-photo { display: flex; align-items: center; gap: 1rem; margin: .4rem 0 .6rem; flex-wrap: wrap; }
.profil-photo img, .profil-vide { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex: none; }
.profil-vide { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 2.2rem; font-weight: 700; }
.card textarea { width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
input:disabled { background: var(--surface-2); color: var(--muted); }

/* origine des corrections, conseils de dépôt */
.badge.origine-errata { color: #7a4b00; border-color: #e0a100; background: #fff6dd; }
.badge.origine-ia { color: var(--accent); border-color: var(--accent); }
.errata-note { background: #fff6dd; border: 1px solid #e0a100; border-radius: 9px; padding: .5rem .7rem; color: #4d3200; }
.notice.conseil { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.badge.origine-diaporama { color: #1f3a68; border-color: #1f3a68; background: #e8eef7; }

/* alertes : éléments manquants, traitements en échec — effacées seulement à la demande de l'étudiant */
#alertesBandeau { display: block; width: 100%; border: 0; border-bottom: 1px solid #e0a100; border-radius: 0; background: #fff3cd; color: #5c4400; padding: .5rem 1.1rem; text-align: left; font-weight: 600; font-size: .9rem; }
#alertesBandeau:hover { background: #ffe9a8; }
.ia-alerte { color: #b26a00; font-weight: 700; }
.ia-item.alerte { border-left: 4px solid #e0a100; background: #fff8e1; color: #3d2f00; }
.ia-item.alerte.echec { border-left-color: var(--ko-bd); background: var(--ko-bg); color: var(--ko-ink); }
.alerte-choix { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.alerte-choix button { font-size: .85rem; padding: .35rem .7rem; }
.toast.alerte { border-left-color: #e0a100; background: #fff8e1; color: #3d2f00; }
.ia-item.alerte .ia-etape { white-space: pre-line; }

/* personne n'est connecté : ni pastille de compte, ni menus, seulement l'écran de connexion */
#userTag[hidden] { display: none; }
body.anonyme [data-nav]:not(.brand), body.anonyme #iaBtn { display: none; }

/* blocs repliables : une flèche dans le titre déplie ou replie le contenu */
details.repli > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem; }
details.repli > summary::-webkit-details-marker { display: none; }
details.repli > summary::before {
  content: ""; flex: none; width: .6rem; height: .6rem; border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent); transform: rotate(-45deg); transition: transform .15s; margin-left: .15rem;
}
details.repli[open] > summary::before { transform: rotate(45deg); }
details.repli > summary h2 { margin: 0; }
details.repli[open] > summary { margin-bottom: .6rem; }

/* titres d'UE : plus gros, une couleur par UE, repliables d'un clic */
table.grid tbody.ue-bloc > tr.ue-titre { cursor: pointer; }
table.grid tbody.ue-bloc > tr.ue-titre th {
  font-size: 1.05rem; font-weight: 700; color: var(--ue); padding: .55rem .7rem;
  border-left: 5px solid var(--ue); border-bottom: 0;
  background: color-mix(in srgb, var(--ue) 10%, transparent);
}
table.grid tbody.ue-bloc > tr.ue-titre th .spin { font-size: .82rem; font-weight: 400; }
table.grid tbody.ue-bloc > tr.ue-titre .ue-nom::before {
  content: ""; display: inline-block; width: .5rem; height: .5rem; margin: 0 .6rem .12rem .1rem;
  border-right: 3px solid var(--ue); border-bottom: 3px solid var(--ue); transform: rotate(45deg); transition: transform .15s;
}
table.grid tbody.ue-bloc.replie > tr.ue-titre .ue-nom::before { transform: rotate(-45deg); margin-bottom: 0; }
table.grid tbody.ue-bloc.replie > tr:not(.ue-titre) { display: none; }
table.grid tbody.ue-bloc:not(:first-of-type) > tr.ue-titre th { border-top: .7rem solid var(--surface); }
/* « Contact » : écrire à l'administrateur du site ; libellé coloré, à droite */
.topbar nav button.contact { margin-left: auto; background: #f59e0b; color: #1f2937; font-weight: 700; padding: .35rem .8rem; }
.topbar nav button.contact:hover { background: #fbbf24; color: #1f2937; }
.topbar nav button.link.contact.ici { background: #fbbf24; box-shadow: inset 0 -3px 0 #1f2937; }
.topbar nav button.icone ~ .user { margin-left: .3rem; }

/* onglet où l'on se trouve : fond plus clair, texte gras et trait blanc dessous */
.topbar nav button.link.ici { background: rgba(255,255,255,.22); font-weight: 700; box-shadow: inset 0 -3px 0 #fff; }
.topbar nav button.icone.ici { box-shadow: inset 0 -3px 0 #fff; }

/* questions : les boutons sont en haut de la carte et y restent quand on fait défiler ; plus petits */
.quiz-actions { position: sticky; top: 0; z-index: 5; margin: -.4rem 0 .8rem; padding: .45rem 0; gap: .5rem;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.quiz-actions button { font-size: .88rem; padding: .4rem .8rem; min-height: 36px; }

/* mention affichée sur tout contenu produit par l'IA */
.mention-ia { font-size: .82rem; color: var(--muted); border-left: 3px solid #e0a100; padding: .15rem .6rem; margin: .7rem 0 .5rem; }
