/* =====================================================================
   CCI Quest — feuille de style unique, partagée par toutes les matières.

   Claymorphisme : matière épaisse, angles très arrondis, boutons à lèvre.
   Une seule couleur pilote chaque écran : --tc. Elle vient du jeu.json de
   la matière, donc la couleur est une information (« où suis-je ? »),
   jamais une décoration. Tout le reste s'en déduit.
   ===================================================================== */

:root {
  color-scheme: light dark;

  /* Couleur active. Surchargée en ligne par JS, matière par matière. */
  --tc-base: #2F55D4;

  --gold: #E8952B;  --gold-lip: #A45F08;  --gold-ink: #3d2606;
  --ok: #157F43;    --ok-lip: #0C5C2F;    --ok-soft: #E0F5E8;
  --ko: #C42B2B;    --ko-lip: #8E1B1B;    --ko-soft: #FBE7E7;

  --ink: #141A2E;
  --ink-2: #4C5573;
  --ink-3: #7B849F;
  --bg: #EEF1F9;
  --surface: #FFFFFF;
  --surface-2: #F5F7FD;
  --line: #E1E6F2;

  --r-lg: 30px;
  --r-md: 20px;
  --r-sm: 14px;

  --clay: 0 10px 0 rgba(20, 26, 46, .05), 0 22px 45px -26px rgba(20, 26, 46, .55);
  --clay-sm: 0 5px 0 rgba(20, 26, 46, .05), 0 12px 24px -16px rgba(20, 26, 46, .5);

  --shell: 30rem;
  --fast: 140ms;
}

/* -------------------------------------------------------------------
   Couleurs dérivées.

   Déclarées sur « * » et non sur « :root » : une propriété personnalisée
   qui en référence une autre est résolue là où elle est déclarée. Posée
   sur :root, --tlip figerait la teinte de la racine et ne suivrait plus
   les sections qui changent --tc-base. Sur *, chaque élément recalcule
   à partir de la teinte dont il hérite.
   ------------------------------------------------------------------- */

*, *::before, *::after {
  --tc: var(--tc-base);
  --tlip: color-mix(in oklab, var(--tc) 62%, #05070f);
  --tsoft: color-mix(in oklab, var(--tc) 13%, var(--surface));
  --tink: var(--tc);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E9EDFB;
    --ink-2: #A5AECC;
    --ink-3: #79829F;
    --bg: #0F1424;
    --surface: #1A2038;
    --surface-2: #222941;
    --line: #2E3654;

    --gold: #F0B252;  --gold-lip: #A6740F;  --gold-ink: #3d2606;
    --ok: #35C97B;    --ok-lip: #14904F;    --ok-soft: #12321F;
    --ko: #F06C6C;    --ko-lip: #B03535;    --ko-soft: #361B1E;

    --clay: 0 10px 0 rgba(0, 0, 0, .25), 0 22px 45px -26px rgba(0, 0, 0, .9);
    --clay-sm: 0 5px 0 rgba(0, 0, 0, .25), 0 12px 24px -16px rgba(0, 0, 0, .8);
  }

  /* Les teintes de matière sont choisies pour être lisibles sur fond clair ;
     sur fond sombre il faut les éclaircir, sinon elles disparaissent. */
  *, *::before, *::after {
    --tc: color-mix(in oklab, var(--tc-base) 66%, #FFFFFF);
    --tlip: color-mix(in oklab, var(--tc) 58%, #05070f);
    --tsoft: color-mix(in oklab, var(--tc) 20%, var(--surface));
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
  overflow-wrap: break-word;
}

h1, h2, h3, .display {
  font-family: "Baloo 2", "Nunito", ui-rounded, system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -.01em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }

button, input, select { font: inherit; color: inherit; }

/* Chiffres alignés partout où ils comptent : scores, XP, minuteurs, tableaux. */
.display, .timer, .num, .xp-val, .tile .pc, .score-ring .val { font-variant-numeric: tabular-nums; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 3px solid var(--tc);
  outline-offset: 3px;
  border-radius: 6px;
}

svg.ic { width: 1.25em; height: 1.25em; flex: none; }

.app {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.app.wide { max-width: 64rem; }

/* ---------------------------------------------------------------- */
/* Boutons : la lèvre inférieure s'écrase à l'appui                  */
/* ---------------------------------------------------------------- */

.btn {
  --c: var(--tc);
  --lip: var(--tlip);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  width: 100%;
  min-height: 52px;
  padding: 13px 20px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--c);
  color: #fff;
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--lip);
  transition: transform var(--fast) ease, box-shadow var(--fast) ease, filter var(--fast) ease;
}

.btn:hover:not(:disabled) { filter: brightness(1.06); }

.btn:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 0 0 var(--lip);
}

.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: 0 5px 0 var(--lip); }

.btn.gold   { --c: var(--gold); --lip: var(--gold-lip); color: var(--gold-ink); }
.btn.green  { --c: var(--ok);   --lip: var(--ok-lip); }
.btn.danger { --c: var(--ko);   --lip: var(--ko-lip); }

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--line);
}
.btn.ghost:active:not(:disabled) { box-shadow: 0 0 0 var(--line); }

.btn.small { min-height: 44px; padding: 8px 14px; font-size: .95rem; width: auto; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: 100%; }

/* ---------------------------------------------------------------- */
/* Surfaces                                                          */
/* ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--clay);
}

.card + .card { margin-top: 16px; }
.card.flat { box-shadow: var(--clay-sm); border-radius: var(--r-md); padding: 16px; }

.muted { color: var(--ink-2); }
.tiny { font-size: .85rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 4px 12px; }
.section-head h2 { font-size: 1.15rem; }
.section-head .aside { margin-left: auto; font-size: .82rem; color: var(--ink-3); font-weight: 700; }

/* ---------------------------------------------------------------- */
/* En-tête : XP, niveau, série                                       */
/* ---------------------------------------------------------------- */

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.avatar {
  width: 48px; height: 48px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--tsoft);
  color: var(--tc);
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: var(--clay-sm);
}

.xpbar {
  height: 12px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
  margin-top: 5px;
}

.xpbar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #FFD08A);
  transition: width 700ms cubic-bezier(.2, .8, .3, 1);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--clay-sm);
  font-weight: 800;
  font-size: .92rem;
  white-space: nowrap;
}

.pill.flame { color: var(--ink-3); }
.pill.on    { background: var(--gold); color: var(--gold-ink); }

/* ==================================================================
   TABLEAU DE BORD

   Le mur de casiers. Chaque matière est un bloc de matière colorée qui
   se remplit à mesure que les chapitres sont acquis : d'un coup d'œil,
   on voit ce qui est en retard sans lire un seul chiffre.
   ================================================================== */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.tile {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  min-height: 148px;
  padding: 14px;
  text-align: left;
  border: 0;
  border-radius: 26px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 0 var(--line), 0 18px 34px -24px rgba(20, 26, 46, .9);
  transition: transform var(--fast) ease, box-shadow var(--fast) ease;
}

.tile:active { transform: translateY(6px); box-shadow: 0 0 0 var(--line); }

/* Le niveau de remplissage EST la progression. */
.tile .fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--h, 0%);
  /* Bord adouci : le niveau reste lisible sans barrer le titre d'un trait dur. */
  background: linear-gradient(to bottom,
    color-mix(in oklab, var(--tc) 26%, transparent) 0 2px,
    var(--tsoft) 14px);
  transition: height 900ms cubic-bezier(.2, .8, .25, 1);
  pointer-events: none;
}

.tile > * { position: relative; }

/* Emblème à gauche, part du programme acquise à droite : la même ligne
   porte l'identité de la matière et son avancement. */
.tile .head { display: flex; align-items: center; justify-content: space-between;
              gap: 8px; margin-bottom: auto; }

.tile .glyph {
  width: 38px; height: 38px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--tc);
  color: #fff;
  box-shadow: 0 3px 0 var(--tlip);
}
.tile .glyph svg { width: 21px; height: 21px; }

.tile .pc {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  color: var(--tc);
  white-space: nowrap;
}
.tile .pc small { font-size: .62em; margin-left: .1em; }

.tile .name {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.15;
}

.tile .meta { font-size: .78rem; color: var(--ink-2); line-height: 1.35; }

.tile.empty-tile { box-shadow: 0 0 0 2px var(--line) inset; background: transparent; }
.tile.empty-tile .glyph { background: var(--line); color: var(--ink-3); box-shadow: none; }
.tile.empty-tile .name { color: var(--ink-2); }

/* Carte « reprendre » : l'unique action mise en avant de l'écran. */
.resume {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: var(--tc);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--tlip), 0 22px 40px -26px rgba(20, 26, 46, .9);
  transition: transform var(--fast) ease, box-shadow var(--fast) ease;
}
.resume:active { transform: translateY(7px); box-shadow: 0 0 0 var(--tlip); }
.resume .where { font-size: .82rem; font-weight: 800; opacity: .8; }
.resume h2 { margin: 3px 0 8px; color: #fff; }
.resume .go {
  display: inline-flex; align-items: center; gap: .4em;
  font-weight: 800; font-size: .92rem;
  padding: 7px 14px; border-radius: 99px;
  background: rgba(255, 255, 255, .22);
}

/* ---------------------------------------------------------------- */
/* Parcours des chapitres                                            */
/* ---------------------------------------------------------------- */

.theme-head { display: flex; align-items: baseline; gap: 10px; margin: 28px 4px 4px; }

.theme-head .num {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--tc);
}

.theme-head h2 { font-size: 1.1rem; }

.path { position: relative; padding: 18px 0 6px; }

/* Le fil qui relie les chapitres : il rend le parcours lisible d'un coup d'œil. */
.path::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 4px;
  margin-left: -2px;
  background: repeating-linear-gradient(var(--line) 0 10px, transparent 10px 20px);
  border-radius: 4px;
}

.node { position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.node:nth-child(even) { flex-direction: row-reverse; text-align: right; }

.node .bubble {
  position: relative;
  width: 74px; height: 74px;
  flex: none;
  border: 0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: var(--tc);
  color: #fff;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 var(--tlip), 0 16px 30px -18px rgba(20, 26, 46, .8);
  transition: transform var(--fast) ease, box-shadow var(--fast) ease;
}

.node .bubble:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--tlip), 0 8px 16px -12px rgba(20, 26, 46, .8);
}

.node .bubble.fresh { background: var(--surface); color: var(--tc); box-shadow: 0 6px 0 var(--line); }

/* Anneau de progression dessiné en dégradé conique : pas d'image, pas de SVG.
   « closest-side » est indispensable : sans lui, les pourcentages du masque se
   mesurent sur la diagonale du carré, et l'anneau devient un large disque. */
.node .ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), transparent 0);
  -webkit-mask: radial-gradient(closest-side circle, transparent 0 calc(100% - 6px), #000 calc(100% - 6px));
  mask: radial-gradient(closest-side circle, transparent 0 calc(100% - 6px), #000 calc(100% - 6px));
  pointer-events: none;
}

.node .crown {
  position: absolute;
  top: -10px; right: -8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: var(--gold-ink);
  box-shadow: 0 3px 0 var(--gold-lip);
}

.node .label { flex: 1; min-width: 0; }
.node .label h3 { font-size: 1rem; }
.node .label p { margin: 2px 0 0; font-size: .85rem; color: var(--ink-2); }

/* ---------------------------------------------------------------- */
/* Feuille modale                                                    */
/* ---------------------------------------------------------------- */

.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 14, 30, .58);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  animation: fade 180ms ease both;
}

.sheet {
  width: 100%;
  max-width: var(--shell);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 -10px 60px -20px rgba(0, 0, 0, .6);
  animation: rise 260ms cubic-bezier(.2, .9, .3, 1) both;
}

.sheet .grip { width: 44px; height: 5px; margin: -6px auto 16px; border-radius: 99px; background: var(--line); }

@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(28px); opacity: 0 } }

/* ---------------------------------------------------------------- */
/* Session de questions                                              */
/* ---------------------------------------------------------------- */

.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.progress { flex: 1; height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--tc); transition: width 300ms ease; }

.timer {
  min-width: 56px;
  text-align: center;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--clay-sm);
}

.timer.urgent { background: var(--ko); color: #fff; animation: pulse 700ms ease-in-out infinite; }

@keyframes pulse { 50% { transform: scale(1.08) } }

.question {
  padding: 24px 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--clay);
  margin-bottom: 18px;
}

.question .kicker { font-size: .82rem; font-weight: 700; color: var(--tc); margin-bottom: 8px; }

.question .text {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.choices { display: grid; gap: 10px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  text-align: left;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform var(--fast) ease, box-shadow var(--fast) ease, background var(--fast) ease;
}

.choice:hover:not(:disabled) { background: var(--surface-2); }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.choice:disabled { cursor: default; }

.choice .key {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: .95rem;
}

.choice.picked { background: var(--tsoft); box-shadow: 0 4px 0 var(--tc); }
.choice.right  { background: var(--ok-soft); box-shadow: 0 4px 0 var(--ok); }
.choice.right .key { background: var(--ok); color: #fff; }
.choice.wrong  { background: var(--ko-soft); box-shadow: 0 4px 0 var(--ko); }
.choice.wrong .key { background: var(--ko); color: #fff; }

.verdict {
  position: sticky;
  bottom: 12px;
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--r-lg);
  box-shadow: var(--clay);
  animation: rise 220ms cubic-bezier(.2, .9, .3, 1) both;
}

.verdict.ok { background: var(--ok-soft); }
.verdict.ko { background: var(--ko-soft); }

.verdict .head {
  display: flex; align-items: center; gap: 8px;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.verdict.ok .head { color: var(--ok-lip); }
.verdict.ko .head { color: var(--ko-lip); }

@media (prefers-color-scheme: dark) {
  .verdict.ok .head { color: var(--ok); }
  .verdict.ko .head { color: var(--ko); }
}

.verdict p { font-size: .95rem; }

/* Fiches de révision : la carte se retourne dans l'espace. */
.flash { perspective: 1400px; margin-bottom: 18px; }

.flash .inner {
  position: relative;
  min-height: 260px;
  transform-style: preserve-3d;
  transition: transform 520ms cubic-bezier(.3, .8, .3, 1);
}

.flash.flipped .inner { transform: rotateY(180deg); }

.flash .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--clay);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flash .face.back { transform: rotateY(180deg); background: var(--tsoft); }
.flash .term { font-family: "Baloo 2", system-ui, sans-serif; font-size: 1.4rem; font-weight: 700; }

/* ---------------------------------------------------------------- */
/* Résultats                                                         */
/* ---------------------------------------------------------------- */

.score-ring {
  width: 168px; height: 168px;
  margin: 6px auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--tc) calc(var(--p) * 1%), var(--line) 0);
  position: relative;
}

.score-ring::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--surface); }

.score-ring .val {
  position: relative;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
}

.score-ring .val small { display: block; font-size: .9rem; font-weight: 700; color: var(--ink-2); }

.reward {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  margin-bottom: 10px;
}

.reward .big { font-family: "Baloo 2", system-ui, sans-serif; font-size: 1.3rem; font-weight: 800; color: var(--gold-lip); }
@media (prefers-color-scheme: dark) { .reward .big { color: var(--gold); } }

.badge-pop {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: linear-gradient(120deg, var(--gold), #FFD489);
  color: var(--gold-ink);
  font-weight: 700;
  box-shadow: var(--clay-sm);
  animation: rise 320ms cubic-bezier(.2, .9, .3, 1) both;
}

/* ---------------------------------------------------------------- */
/* Classement                                                        */
/* ---------------------------------------------------------------- */

.rank {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--clay-sm);
  margin-bottom: 10px;
}

.rank.me { background: var(--tsoft); box-shadow: 0 5px 0 var(--tc); }

.rank .pos {
  width: 34px; height: 34px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
}

.rank .pos.p1 { background: var(--gold); color: var(--gold-ink); }
.rank .pos.p2 { background: #C9D3E8; color: #2B3350; }
.rank .pos.p3 { background: #E2B184; color: #48280F; }

/* Filtres en ligne : classement général ou matière par matière. */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex: none;
  min-height: 44px;
  padding: 8px 15px;
  border: 0;
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 800;
  font-size: .9rem;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
}

.tabs button.on { background: var(--tc); color: #fff; box-shadow: 0 3px 0 var(--tlip); }

/* ---------------------------------------------------------------- */
/* Partie multijoueur                                                */
/* ---------------------------------------------------------------- */

.duel-code {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: .22em;
  text-indent: .22em;
  color: var(--tc);
}

.waiting-dots::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }

@keyframes dots { 0% { content: "" } 25% { content: "." } 50% { content: ".." } 75% { content: "..." } }

/* ---------------------------------------------------------------- */
/* Formulaires                                                       */
/* ---------------------------------------------------------------- */

.field { margin-bottom: 14px; }

.field label { display: block; font-weight: 800; font-size: .9rem; margin-bottom: 6px; }

.field input, .field select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.field input:focus-visible, .field select:focus-visible { border-color: var(--tc); }

.field .help { font-size: .82rem; color: var(--ink-2); margin-top: 5px; }
.err {
  font-size: .88rem; color: var(--ko-lip); font-weight: 700;
  background: var(--ko-soft); padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) { .err { color: var(--ko); } }

.code-input {
  text-align: center;
  font-family: "Baloo 2", system-ui, sans-serif !important;
  font-size: 2rem !important;
  font-weight: 800;
  letter-spacing: .3em;
  text-indent: .3em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- */
/* Barre de navigation                                               */
/* ---------------------------------------------------------------- */

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 2px solid var(--line);
}

.nav a {
  flex: 1;
  max-width: 6.5rem;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: 52px;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--ink-3);
  font-size: .72rem;
  font-weight: 800;
}

.nav a.on { color: var(--tc); background: var(--tsoft); }
.nav a svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- */
/* Tableaux (espace enseignant)                                      */
/* ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--r-md); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }

th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 800; color: var(--ink-2); font-size: .82rem; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 800; }
.chip.ok  { background: var(--ok-soft);  color: var(--ok-lip); }
.chip.mid { background: #FFF2DB;         color: #8E5A00; }
.chip.low { background: var(--ko-soft);  color: var(--ko-lip); }

@media (prefers-color-scheme: dark) {
  .chip.ok  { color: var(--ok); }
  .chip.low { color: var(--ko); }
  .chip.mid { background: #3A3018; color: var(--gold); }
}

/* Pastille de couleur d'une matière, dans les tableaux et les listes. */
.dot { width: 11px; height: 11px; border-radius: 4px; background: var(--tc); flex: none; display: inline-block; }

/* ---------------------------------------------------------------- */
/* Notifications                                                     */
/* ---------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(calc(100% - 32px), var(--shell));
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--clay-sm);
  animation: rise 200ms cubic-bezier(.2, .9, .3, 1) both;
}

.toast.bad { background: var(--ko); color: #fff; }

/* ---------------------------------------------------------------- */
/* États vides et chargement                                         */
/* ---------------------------------------------------------------- */

.empty { padding: 32px 20px; text-align: center; color: var(--ink-2); }

.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer { to { background-position: -300% 0 } }

/* ---------------------------------------------------------------- */
/* Écran de connexion                                                */
/* ---------------------------------------------------------------- */

.login-wrap { min-height: 100dvh; display: grid; align-content: center; gap: 22px; padding: 24px 0 40px; }

.logo {
  width: 88px; height: 88px;
  margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 28px;
  background: var(--tc);
  color: #fff;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 8px 0 var(--tlip), 0 26px 50px -24px rgba(20, 26, 46, .9);
}

/* ---------------------------------------------------------------- */

@media (min-width: 48rem) {
  .app { padding-top: 92px; padding-bottom: 40px; }
  /* Le tableau de bord est le seul ecran qui gagne a s'elargir : trois tuiles
     par rangee au lieu de deux. Les autres ecrans restent en colonne etroite,
     lisible a la longueur de ligne. */
  .app.hub { max-width: 46rem; }
  .app.hub .tiles { grid-template-columns: repeat(3, 1fr); }
  .nav { top: 0; bottom: auto; border-top: 0; border-bottom: 2px solid var(--line); padding: 10px 8px; }
  .toast-stack { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .flash .inner { transition: none; }
}
