/* DiabèteQuest — thème CLAIR CHAUD, accent bleu vif (#1565C0).
   Le cercle bleu (symbole international du diabète) et la goutte de
   glycémie capillaire sont les symboles de l'app.
   Goût de Philippe : ni sombre ni pastel — couleur vive sur fond clair chaud.
   Les noms de variables (--dark, --safety-yellow…) sont gardés pour rester
   compatibles avec le moteur Quest commun ; seules leurs VALEURS changent. */
:root {
  color-scheme: light;
  --safety-yellow: #1565C0;   /* accent principal : bleu vif */
  --accent-dark: #0D47A1;
  --on-accent: #ffffff;
  --dark: #faf6f2;            /* fond de page clair chaud */
  --dark-2: #f2e9e4;          /* fond secondaire (champs, puces) */
  --card: #ffffff;            /* cartes */
  --line: #e3d5cf;            /* bordures */
  --text: #1f1a18;            /* texte ardoise */
  --muted: #6e625d;
  --success: #2e7d32;
  --danger: #c62828;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) { :root { color-scheme: light; } html, body { background: #faf6f2; color: #1f1a18; } }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--dark);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--dark);
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

/* ---------- Onboarding ---------- */
.onboarding {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.lang-toggle-top { text-align: right; }
.lang-toggle-top button {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 13px;
}
.onboarding h1 { font-size: 28px; margin: 8px 0 0; }
.tagline { color: var(--safety-yellow); font-weight: 600; margin: 0; }
.program-title { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.field-label { text-align: left; font-size: 13px; color: var(--muted); margin-top: 12px; }
#nameInput, #classCodeInput {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--dark-2);
  color: var(--text);
  font-size: 16px;
}
.totem-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--safety-yellow);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.totem-emoji { font-size: 42px; line-height: 1; }
.totem-name { font-family: Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 600; color: var(--text); margin-top: 8px; }
.totem-name b { color: var(--safety-yellow); font-weight: 600; }
.totem-hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.4; }
.totem-reroll {
  margin-top: 12px;
  width: 100%;
  background: var(--dark-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
}
.share-toggle {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}
.share-toggle .tog {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--line); flex-shrink: 0; position: relative; transition: background .18s;
}
.share-toggle .tog::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .18s;
}
.share-toggle.on .tog { background: var(--safety-yellow); }
.share-toggle.on .tog::after { left: 21px; }
.share-lbl b { font-size: 14px; color: var(--text); }
.share-lbl small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.35; }
.share-status { font-size: 12.5px; color: var(--muted); margin-top: 12px; text-align: center; }
.share-status.on { color: var(--safety-yellow); }
.access-gate { justify-content: center; }
#accessCodeInput, #premiumCodeInput {
  padding: 20px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--dark-2);
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
}
#accessCodeInput:focus, #premiumCodeInput:focus {
  outline: none;
  border-color: var(--safety-yellow);
}
.access-error {
  color: #c62828;
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
}
.premium-dialog #premiumCodeInput { font-size: 18px; letter-spacing: 1.5px; padding: 12px 10px; margin-top: 6px; }
.premium-dialog .premium-or { font-size: 12px; color: var(--muted); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: 1px; }
.welcome-screen { text-align: left; }
.welcome-screen .lang-toggle-top,
.welcome-screen h1,
.welcome-screen .tagline { text-align: center; }
.welcome-intro {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin: 0 0 6px;
}
.welcome-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.welcome-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.welcome-icon { font-size: 24px; line-height: 1; }
.welcome-item-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.welcome-item-desc { font-size: 13px; color: var(--muted); line-height: 1.35; }
.avatar-char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.avatar-char-btn {
  background: var(--dark-2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.avatar-char-btn svg { border-radius: 50%; }
.avatar-char-btn span { font-size: 10px; color: var(--muted); line-height: 1.2; text-align: center; }
.avatar-char-btn.selected { border-color: var(--safety-yellow); }
.avatar-char-btn.selected span { color: var(--text); font-weight: 600; }

.color-picker { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.color-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
}
.color-swatch.selected { border-color: white; }

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.vehicle-btn {
  background: var(--dark-2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.vehicle-btn.selected { border-color: var(--safety-yellow); }
.vehicle-btn span { font-size: 11px; color: var(--muted); }
.vehicle-btn.selected span { color: var(--text); font-weight: 600; }

.vehicle-showcase {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 10px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.vehicle-frame {
  height: 190px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: visible;
}
.vehicle-caption { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }

/* Forme ultime de l'avatar (XP max atteint) : halo doré discret + légère
   pulsation, pour marquer visuellement l'aboutissement même si l'emoji de
   l'avatar est déjà au même stade depuis quelques paliers. */
.vehicle-showcase--maxed {
  position: relative;
  box-shadow: 0 0 0 2px var(--safety-yellow), 0 0 28px rgba(94, 53, 177, 0.35);
  animation: ultimeGlow 2.6s ease-in-out infinite;
}
.vehicle-showcase--maxed .vehicle-caption { color: var(--safety-yellow); font-weight: 600; }
@keyframes ultimeGlow {
  0%, 100% { box-shadow: 0 0 0 2px var(--safety-yellow), 0 0 22px rgba(94, 53, 177, 0.3); }
  50%      { box-shadow: 0 0 0 2px var(--safety-yellow), 0 0 36px rgba(94, 53, 177, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .vehicle-showcase--maxed { animation: none; }
}

/* Posture triomphante de l'avatar à la forme ultime : couronne, étincelles
   et légère bascule/agrandissement — on ne peut pas changer la pose de
   l'emoji lui-même, alors on la simule autour de lui. */
.avatar-triumph-wrap { position: relative; display: inline-flex; }
.avatar-triumph-wrap--maxed > span { animation: triumphPose 3.2s ease-in-out infinite; transform-origin: center bottom; }
@keyframes triumphPose {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.06) rotate(-2deg); }
}
.triumph-crown {
  position: absolute; top: -16px; right: -8px;
  font-size: 34px; transform: rotate(18deg);
  animation: triumphCrownBounce 2.2s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.45));
}
@keyframes triumphCrownBounce {
  0%, 100% { transform: rotate(18deg) translateY(0); }
  50%      { transform: rotate(18deg) translateY(-4px); }
}
.triumph-sparkle { position: absolute; font-size: 18px; opacity: .9; animation: triumphSparkle 1.8s ease-in-out infinite; }
.triumph-sparkle-1 { top: 6px; left: -16px; animation-delay: .3s; }
.triumph-sparkle-2 { bottom: 14px; right: -14px; animation-delay: .9s; }
@keyframes triumphSparkle {
  0%, 100% { opacity: .35; transform: scale(.75); }
  50%      { opacity: 1; transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar-triumph-wrap--maxed > span, .triumph-crown, .triumph-sparkle { animation: none; }
}
.cta {
  margin-top: 20px;
  background: var(--safety-yellow);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 16px;
  padding: 16px;
  border-radius: var(--radius);
}
.secondary {
  margin-top: 10px;
  background: var(--card);
  color: var(--text);
  padding: 14px;
  border-radius: var(--radius);
}
.secondary.danger { color: var(--danger); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.avatar-chip {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-chip svg { display: block; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-level { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lang-btn {
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}
.reset-btn {
  background: var(--card);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
}
.tabs button {
  flex: 1;
  background: var(--dark-2);
  color: var(--muted);
  padding: 9px 3px;
  border-radius: 10px;
  font-size: 11px;
  white-space: nowrap;
}
.tabs button.active {
  background: var(--safety-yellow);
  color: var(--on-accent);
  font-weight: 700;
}

.content { padding: 8px 16px 24px; }

/* ---------- Progress / Map ---------- */
.progress-banner { margin-bottom: 16px; }
.progress-bar {
  height: 10px;
  background: var(--dark-2);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--safety-yellow), var(--success));
}
.progress-label { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: right; }

.quest-path { display: flex; flex-direction: column; gap: 10px; }
.quest-node {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
}
.quest-node.done { border: 1px solid var(--success); }
.quest-node.locked { opacity: 0.45; }
.quest-node.premium-locked { opacity: 1; border: 1px dashed var(--muted); }
.quest-node.premium-locked .quest-node-main { cursor: pointer; }
.quest-premium-note { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.premium-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000; }
.premium-dialog { background: var(--card); border-radius: var(--radius); padding: 22px; max-width: 340px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.premium-dialog h2 { font-size: 17px; margin: 8px 0; }
.premium-dialog p { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.premium-badge { font-size: 12px; font-weight: 700; color: var(--muted); }
.premium-dialog .cta { display: block; text-decoration: none; margin-bottom: 10px; }
.quest-node-main { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.quest-icon { font-size: 26px; width: 36px; text-align: center; }
.quest-body { flex: 1; }
.quest-num { font-size: 11px; color: var(--muted); }
.quest-year-badge {
  display: inline-block; margin-left: 7px; padding: 1px 7px;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.2px; text-transform: uppercase;
}
.quest-year-1 { background: rgba(169, 178, 186, 0.18); color: var(--muted); }
.quest-year-2 { background: rgba(94, 53, 177, 0.18); color: var(--safety-yellow); }
.quest-title { font-size: 14px; font-weight: 600; }
.quest-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.quest-status { font-size: 18px; }

/* ---------- Paliers de difficulté (Débutant / Intermédiaire / Avancé) ----------
   ⚠️ SantéMentaleQuest : une seule compétence, donc un seul nœud sur la carte.
   Les paliers sont empilés en pleine largeur (et non en 3 colonnes étroites)
   pour porter le titre du palier, son nombre de questions et son thème. */
.tier-row { display: flex; flex-direction: column; gap: 8px; }
.tier-pill {
  width: 100%;
  background: var(--dark-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  text-align: left;
  border: 2px solid transparent;
}
.tier-pill:disabled { opacity: 0.4; }
.tier-pill.done { border-color: var(--success); background: #e3f2e5; }
.tier-pill.locked { opacity: 0.5; }
/* Palier payant : visible et cliquable (ouvre la pop-up de code), mais
   signalé par un contour pointillé — ne jamais le griser comme un palier
   non encore atteint, l'élève doit comprendre qu'il peut le débloquer. */
.tier-pill.premium { border-color: var(--muted); border-style: dashed; opacity: 0.85; }
.tier-pill-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 142px;
  white-space: nowrap;
  font-size: 12px;
}
.tier-pill-icon { font-size: 16px; }
.tier-pill-name { font-weight: 700; }
.tier-pill-score { color: var(--safety-yellow); font-weight: 700; }
.tier-pill-count { color: var(--muted); font-size: 10px; font-weight: 600; }
/* Thème du palier : donne de la substance à une carte qui ne compte
   qu'un seul nœud de quête (app à une seule compétence). */
.tier-pill-theme {
  flex: 1;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}
.quest-intro-theme { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }

/* Fiche de compétence sous la carte — n'apparaît que sur une carte à un
   seul nœud (app à une compétence), pour situer l'élève et éviter une page
   à moitié vide. */
.comp-brief {
  background: var(--dark-2);
  border-radius: var(--radius);
  border-left: 3px solid var(--safety-yellow);
  padding: 14px 16px;
  margin-top: 14px;
}
.comp-brief h3 { margin: 0 0 6px; font-size: 14px; }
.comp-brief p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.comp-brief-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.comp-brief-stats span {
  background: var(--card);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
}
.quest-intro-tier {
  display: inline-block;
  background: var(--card);
  color: var(--safety-yellow);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  margin: 8px 0;
}

/* ---------- Quest intro / quiz ---------- */
.quest-intro { text-align: center; }
.quest-intro-icon { font-size: 48px; }
.quest-code { color: var(--muted); font-size: 13px; }
.best-score { color: var(--safety-yellow); font-weight: 700; }

.quiz-progress { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.quiz-question { font-size: 18px; line-height: 1.4; }
.scenario-badge {
  display: inline-block;
  background: #e2edf7;
  color: #1d5a8a;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

/* ---------- Questions d'association de termes ("match") ---------- */
.match-prompt { color: var(--muted); font-size: 13px; margin: 12px 0 8px; }
.match-columns { display: flex; gap: 10px; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.match-btn {
  background: var(--card);
  color: var(--text);
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.3;
  border: 2px solid transparent;
  text-align: left;
  min-height: 44px;
}
.match-term.selected { border-color: var(--safety-yellow); background: #e3eefb; }
.match-btn.matched { border-color: var(--success); background: #e3f2e5; opacity: 0.75; }
.match-btn.wrong { border-color: var(--danger); background: #fde7e7; animation: match-shake 0.35s; }
@keyframes match-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- Questions avec image de cabine ---------- */
.cabin-wrap {
  position: relative;
  margin: 12px 0 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #cfd6db;
  line-height: 0;
}
.cabin-svg { display: block; width: 100%; height: auto; }
.cabin-hotspots { position: absolute; inset: 0; }
.hotspot-dot {
  position: absolute;
  width: 15%;
  padding-top: 15%;
  height: 0;
  margin-left: -7.5%;
  margin-top: -7.5%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.001);
  border: 2px dashed rgba(255, 255, 255, 0.6);
}
.hotspot-dot.selected {
  border: 3px solid var(--safety-yellow);
  background: rgba(94, 53, 177, 0.25);
}
.hotspot-legend { margin-top: 4px; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice-btn {
  text-align: left;
  background: var(--card);
  color: var(--text);
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
  border: 2px solid transparent;
}
.choice-btn.selected {
  border-color: var(--safety-yellow);
  background: #e3eefb;
}

.tf-choices {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}
.tf-btn {
  flex: 1;
  background: var(--card);
  color: var(--text);
  padding: 22px 8px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  border: 2px solid transparent;
  text-align: center;
}
.tf-btn.selected {
  border-color: var(--safety-yellow);
  background: #e3eefb;
}
.quiz-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
.quiz-nav .cta:disabled { opacity: 0.4; }

.quest-result { text-align: center; position: relative; }
.result-icon { font-size: 52px; }
.result-icon.celebrate { animation: result-pop 0.6s ease; }
@keyframes result-pop {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
.result-score { font-size: 18px; font-weight: 700; }
.result-xp { color: var(--safety-yellow); font-weight: 700; }
.result-pass { color: var(--success); font-weight: 600; }
.result-fail { color: var(--danger); font-weight: 600; }
.result-mastery {
  color: var(--safety-yellow);
  font-weight: 800;
  font-size: 15px;
  animation: mastery-glow 1.2s ease-in-out infinite alternate;
}
@keyframes mastery-glow {
  from { text-shadow: 0 0 4px rgba(94, 53, 177,0.3); }
  to { text-shadow: 0 0 14px rgba(94, 53, 177,0.85); }
}

/* ---------- Confettis de célébration (paliers réussis) ---------- */
.confetti-burst {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.35, 0.55, 0.65, 1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(620px) rotate(560deg); opacity: 0; }
}

/* ---------- Badges / Trophies ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.badge-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.badge-card.locked { opacity: 0.4; }
.badge-icon { font-size: 30px; }
.badge-title { font-size: 12px; font-weight: 600; margin-top: 6px; }
.badge-desc { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ---------- Leaderboard ---------- */
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 8px 12px;
}
.leaderboard-row.you {
  border: 2px solid var(--safety-yellow);
  background: #e3eefb;
}
.lb-rank { width: 26px; text-align: center; font-weight: 700; font-size: 14px; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.lb-avatar svg { display: block; }
.lb-name { flex: 1; font-size: 13px; font-weight: 600; }
.lb-you-tag { color: var(--safety-yellow); font-weight: 700; font-size: 11px; }
.lb-xp { font-size: 12px; color: var(--muted); font-weight: 700; }
.leaderboard-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 14px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--safety-yellow);
  color: var(--on-accent);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ---------- Revue des erreurs ---------- */
.review {
  text-align: left;
  margin: 22px 0 8px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.review-title {
  font-size: 15px;
  color: var(--safety-yellow);
  margin: 0 0 14px;
}
.review-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.review-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  white-space: pre-line;
  line-height: 1.4;
}
.review-line {
  font-size: 13.5px;
  padding: 4px 0;
  line-height: 1.4;
}
.review-line.yours { color: #c62828; }
.review-line.good { color: var(--success); font-weight: 600; }
.review-expl {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  line-height: 1.5;
}

/* ---------- Bandeau CFP (nom du centre rattaché au code de classe) ---------- */
.cfp-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-left: 3px solid var(--safety-yellow);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0 4px;
  text-align: left;
}
.cfp-banner .cfp-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  flex: 0 0 auto;
  background: #fff;
}
.cfp-banner .cfp-name {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}
.cfp-banner .cfp-prog {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.join-error {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
  text-align: center;
}

/* Loi 25 : pied de page discret vers la politique de confidentialité */
.privacy-footer{text-align:center;padding:14px 0 22px;}
.privacy-footer a{font-size:12px;color:var(--muted);text-decoration:none;opacity:.75;letter-spacing:.02em;}
.privacy-footer a:hover{opacity:1;text-decoration:underline;}

/* --- Pop-up « Licence requise » : finition ---------------------------------
   Sans ça, le bouton « Valider » garde sa largeur intrinsèque (petite pastille
   collée à gauche) et le lien « Nous écrire » reste un <a> inline : son
   rembourrage recouvre alors à moitié le mot « ou » placé au-dessus. */
.premium-dialog .cta,
.premium-dialog .secondary { display: block; width: 100%; box-sizing: border-box; text-align: center; }
.premium-dialog .premium-or { margin: 16px 0 8px; }

/* ---------- Messagerie enseignant → élève (messagerie.js) ----------
   Reprend les jetons de l'app (carte sombre, accent jaune). Aucun nouvel
   onglet : un bandeau sur la carte quand il y a du non lu, une pastille sur
   le bouton 👥, et l'historique depuis « Ma classe ». */
.reset-btn { position: relative; }
.msg-point {
  position: absolute; top: -7px; right: -8px;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); border: 2px solid var(--dark);
  color: #fff; font-size: 11px; font-weight: 800; line-height: 15px;
  text-align: center; box-sizing: border-box; pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.msg-banniere {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--safety-yellow); color: var(--on-accent);
  border-radius: var(--radius); padding: 13px 14px; margin: 0 0 14px;
  text-align: left; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.msg-banniere-ic { font-size: 24px; flex-shrink: 0; }
.msg-banniere-tx { flex: 1; min-width: 0; }
.msg-banniere-tx b { display: block; font-size: 15px; }
.msg-banniere-tx small { display: block; font-size: 12.5px; opacity: .8; margin-top: 1px; }
.msg-banniere-fl { font-size: 24px; font-weight: 700; flex-shrink: 0; }
.msg-ouvrir { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 14px; }
.msg-compte { background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 2px 8px; }
.msg-info { font-size: 13px; color: var(--muted); background: var(--dark-2); border-radius: var(--radius); padding: 11px 13px; margin: 10px 0 0; text-align: left; line-height: 1.45; }
.msg-ecran { text-align: left; }
.msg-ecran h1 { text-align: center; }
.msg-ecran .welcome-intro { text-align: center; }
.msg-liste { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.msg-vide { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }
.msg-carte { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px; min-width: 0; }
.msg-carte.nouveau { border-color: var(--safety-yellow); box-shadow: 0 0 0 1px var(--safety-yellow); }
.msg-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msg-tete b { font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.msg-portee { font-size: 11px; color: var(--muted); background: var(--dark-2); border-radius: 10px; padding: 2px 8px; white-space: nowrap; }
.msg-date { font-size: 12px; color: var(--muted); margin-top: 3px; }
.msg-neuf { color: var(--safety-yellow); font-weight: 700; }
.msg-texte { margin: 10px 0 0; font-size: 15px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.msg-accuses { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.msg-acc { min-width: 0; background: var(--dark-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 6px; font-size: 13px; font-weight: 600; line-height: 1.25; }
.msg-acc.on { background: var(--safety-yellow); color: var(--on-accent); border-color: var(--safety-yellow); font-weight: 700; }
.msg-etat { font-size: 12px; color: var(--muted); margin-top: 8px; }
@media (max-width: 340px) { .msg-accuses { grid-template-columns: 1fr; } }

/* ---------- DiabèteQuest — finitions du thème clair ----------
   Sur fond clair, une carte blanche sans contour disparaît : on lui donne
   un liseré et une ombre douce. Les boutons de réponse gardent une bordure
   visible au repos (au lieu de « transparent », pensé pour le thème sombre). */
.quest-node, .badge-card, .leaderboard-row, .comp-brief, .totem-card, .vehicle-showcase,
.choice-btn, .tf-btn, .match-btn, .tier-pill, .msg-carte, .cfp-banner {
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(80, 40, 30, 0.07);
}
.choice-btn, .tf-btn { border-width: 2px; }
.choice-btn.selected, .tf-btn.selected { border-color: var(--safety-yellow); background: #e3eefb; }
.quest-node.done { border-color: var(--success); }
.quest-node.premium-locked { border: 1px dashed var(--muted); }
.leaderboard-row.you { border: 2px solid var(--safety-yellow); }
.premium-overlay { background: rgba(31, 26, 24, 0.5); }
.cta:hover { background: var(--accent-dark); }

/* Choix du programme (PAB / SASI) — onboarding et pop-up de changement. */
.prog-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prog-btn {
  background: var(--card); color: var(--text);
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 12px 8px; text-align: center; line-height: 1.25;
}
.prog-btn b { display: block; font-size: 16px; }
.prog-btn small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.prog-btn.selected { border-color: var(--safety-yellow); background: #e3eefb; }
.prog-chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: var(--safety-yellow); color: var(--on-accent);
  border-radius: 8px; padding: 1px 7px; margin-left: 4px; cursor: pointer;
}
.draft-note {
  font-size: 11px; color: var(--muted); text-align: center;
  margin: 18px 12px 0; line-height: 1.4;
}

/* ---------- Paliers : 3 colonnes compactes (8 compétences sur la carte) ----------
   SantéMentaleQuest empile ses paliers pleine largeur (1 seul nœud). Ici, 8
   nœuds × 3 paliers empilés allongeraient trop la carte : on revient aux
   3 colonnes de PédiatrieQuest. Le thème du palier reste visible à l'intro. */
.tier-row { flex-direction: row; }
.tier-pill { flex: 1; width: auto; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 8px 4px; }
.tier-pill-head { flex: none; flex-direction: column; gap: 2px; white-space: normal; font-size: 11px; }
.tier-pill-theme { display: none; }
.tier-pill.done { border: 2px solid var(--success); }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }

/* Très petits écrans (iPhone SE 1re génération, 320 px) : l'en-tête et les onglets
   ne doivent jamais faire défiler la page de côté. */
@media (max-width: 360px) {
  .topbar { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .brand { min-width: 0; }
  .topbar-actions { gap: 4px; flex-shrink: 0; }
  .lang-btn { padding: 8px 9px; }
  .tabs { padding-left: 12px; padding-right: 12px; gap: 4px; }
  .tabs button { min-width: 0; font-size: 12px; padding-left: 4px; padding-right: 4px;
                 white-space: normal; line-height: 1.15; overflow-wrap: anywhere; }   /* libellés sur 2 lignes plutôt que tronqués */
}
