/* ===========================
   VARIABLES & RESET
=========================== */

:root {
  color-scheme: dark;

  /* Fonds */
  --bg:        #09090f;
  --surface:   #0f1117;
  --surface-2: #14161e;
  --surface-3: #1a1d28;

  /* Bordures */
  --border:       #1e2132;
  --border-strong: #2b2f45;

  /* Texte */
  --text:  #dde3ed;
  --muted: #8892a4;
  --light: #55627a;

  /* Épreuves */
  --e1:        #a78bfa;
  --e1-dim:    rgba(167, 139, 250, .10);
  --e1-border: rgba(167, 139, 250, .28);
  --e1-dark:   #7c3aed;

  --e3:        #60a5fa;
  --e3-dim:    rgba(96, 165, 250, .10);
  --e3-border: rgba(96, 165, 250, .28);
  --e3-dark:   #2563eb;

  --e5:        #22d3ee;
  --e5-dim:    rgba(34, 211, 238, .10);
  --e5-border: rgba(34, 211, 238, .28);
  --e5-dark:   #0891b2;

  /* Niveaux flashcard */
  --n0: #55627a;
  --n1: #f87171;
  --n2: #fbbf24;
  --n3: #34d399;

  /* Misc */
  --radius:    12px;
  --radius-sm: 8px;
  --max-w:     960px;
  --shadow:    0 2px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.6);
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ===========================
   LAYOUT
=========================== */

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ===========================
   BOUTONS
=========================== */

.btn-primary, .btn-secondary, .btn-success,
.btn-reset, .btn-back, .btn-flip, .btn-correction, .btn-skip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity var(--transition), transform var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn-primary:hover, .btn-secondary:hover, .btn-success:hover,
.btn-correction:hover, .btn-flip:hover, .btn-skip:hover {
  opacity: 0.82;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--muted);
}
.btn-secondary:hover { color: var(--text); }

.btn-success {
  background: rgba(52, 211, 153, .15);
  border-color: rgba(52, 211, 153, .35);
  color: var(--n3);
}

.btn-reset {
  background: transparent;
  border-color: var(--border);
  color: var(--light);
  font-size: 0.82rem;
}
.btn-reset:hover { border-color: var(--n1); color: var(--n1); }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 6px 0;
  border: none;
  background: none;
}
.btn-back:hover { color: var(--text); }

.btn-full { width: 100%; justify-content: center; display: flex; padding: 13px; }

.btn-skip {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted);
}
.btn-skip:hover { color: var(--text); border-color: var(--text); }

/* Couleurs épreuve */
.btn-e1 { background: var(--e1); color: #09090f; border-color: transparent; font-weight: 700; }
.btn-e3 { background: var(--e3); color: #09090f; border-color: transparent; font-weight: 700; }
.btn-e5 { background: var(--e5); color: #09090f; border-color: transparent; font-weight: 700; }

/* ===========================
   PROGRESS BARS
=========================== */

.progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.fill-e1 { background: var(--e1); }
.fill-e3 { background: var(--e3); }
.fill-e5 { background: var(--e5); }
.fill-global { background: linear-gradient(90deg, var(--e1), var(--e3), var(--e5)); }

/* ===========================
   BADGES / TAGS
=========================== */

.badge-e1, .badge-e3, .badge-e5 {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.badge-e1 { background: var(--e1-dim); color: var(--e1); border: 1px solid var(--e1-border); }
.badge-e3 { background: var(--e3-dim); color: var(--e3); border: 1px solid var(--e3-border); }
.badge-e5 { background: var(--e5-dim); color: var(--e5); border: 1px solid var(--e5-border); }

.tag-epreuve { padding: 2px 9px; border-radius: 99px; font-size: 0.72rem; font-weight: 700; }
.tag-e1 { background: var(--e1-dim); color: var(--e1); }
.tag-e3 { background: var(--e3-dim); color: var(--e3); }
.tag-e5 { background: var(--e5-dim); color: var(--e5); }

/* ===========================
   PAGE ACCUEIL
=========================== */

.home-header {
  padding: 52px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.home-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.app-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.app-subtitle {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.9rem;
}

.global-stats {
  display: flex;
  gap: 28px;
  align-items: center;
  flex-shrink: 0;
}

.global-stat { text-align: right; }
.global-num { display: block; font-size: 1.4rem; font-weight: 800; }
.global-lbl { font-size: 0.78rem; color: var(--muted); }

/* Grille des épreuves sur l'accueil */
.epreuve-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.epreuve-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.epreuve-card-e1 { border-left: 3px solid var(--e1); }
.epreuve-card-e3 { border-left: 3px solid var(--e3); }
.epreuve-card-e5 { border-left: 3px solid var(--e5); }

.epreuve-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.epreuve-card-e1:hover { border-color: var(--e1-border); }
.epreuve-card-e3:hover { border-color: var(--e3-border); }
.epreuve-card-e5:hover { border-color: var(--e5-border); }

.epreuve-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.epreuve-card-top h2 { font-size: 1.05rem; font-weight: 700; }

.epreuve-full-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 18px;
}

.epreuve-card-body {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.epreuve-mini-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.mini-stat { font-size: 0.82rem; color: var(--muted); }
.mini-stat strong { color: var(--text); display: block; font-size: 1rem; }

.epreuve-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.home-reset { text-align: center; margin-top: 36px; }

/* ===========================
   HUB ÉPREUVE
=========================== */

.ep-header {
  padding: 36px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.ep-header h1 { font-size: 1.5rem; font-weight: 800; margin: 10px 0 4px; }
.ep-header p { color: var(--muted); font-size: 0.875rem; }
.ep-badge { font-size: 0.78rem; font-weight: 800; }

.ep-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--transition);
}
.mode-card:hover { border-color: var(--border-strong); }

.mode-icon { font-size: 1.8rem; margin-bottom: 10px; }
.mode-card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.mode-card > p { color: var(--muted); font-size: 0.85rem; margin-bottom: 18px; }
.mode-stats { margin-bottom: 20px; }
.mode-total { font-size: 0.82rem; color: var(--muted); margin-top: 8px; font-weight: 600; }

.domaine-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.domaine-name { color: var(--muted); }
.domaine-count { color: var(--text); font-weight: 600; white-space: nowrap; }
.domaine-row .progress-bar { grid-column: 1 / -1; margin-top: 0; }

/* ===========================
   FLASHCARDS
=========================== */

.fc-session-header { padding: 28px 0 12px; }

.fc-progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.fc-counter { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.fc-domaine { font-size: 0.75rem; }

.fc-progress-bar { height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; }
.fc-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
  background: linear-gradient(90deg, var(--e1), var(--e5));
}

/* Carte 3D flip */
.fc-card-wrap {
  perspective: 1200px;
  margin: 20px 0;
  min-height: 360px;
}

.fc-card {
  width: 100%;
  min-height: 360px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.fc-card.flipped { transform: rotateY(180deg); }

.fc-face {
  position: absolute;
  width: 100%;
  min-height: 360px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.fc-back { transform: rotateY(180deg); }

.fc-auteur {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.fc-categorie {
  font-size: 0.78rem;
  color: var(--light);
  margin-bottom: 14px;
  text-transform: capitalize;
}
.fc-question {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  flex: 1;
  display: flex;
  align-items: center;
  color: var(--text);
}
.fc-reponse {
  font-size: 0.88rem;
  line-height: 1.6;
  flex: 1;
  overflow-y: auto;
  color: var(--text);
}

/* Liste numérotée dans le verso */
.fc-reponse .fc-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: fc-item;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fc-reponse .fc-list li {
  counter-increment: fc-item;
  display: flex;
  gap: 10px;
  align-items: baseline;
  line-height: 1.5;
}
.fc-reponse .fc-list li::before {
  content: counter(fc-item);
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: var(--border);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Texte libre */
.fc-reponse .fc-text { margin: 0; }

/* Terme clé avant " : " */
.fc-reponse strong {
  font-weight: 700;
  color: var(--text);
}

/* Exemples discrets */
.fc-reponse .fc-ex {
  font-style: italic;
  font-size: 0.83em;
  color: var(--muted);
}

/* Flèche → */
.fc-reponse .fc-arrow {
  font-weight: 700;
  margin: 0 2px;
  opacity: 0.7;
}

.btn-flip {
  margin-top: 20px;
  padding: 11px 22px;
  align-self: flex-start;
}

/* Rating */
.fc-rating { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.fc-rating-label {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}
.fc-rating-btns { display: flex; gap: 10px; }

.btn-rate {
  flex: 1;
  padding: 10px 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-rate:hover { opacity: 0.82; transform: translateY(-1px); }

.btn-difficile {
  background: rgba(248, 113, 113, .12);
  border-color: rgba(248, 113, 113, .3);
  color: var(--n1);
}
.btn-bien {
  background: rgba(251, 191, 36, .12);
  border-color: rgba(251, 191, 36, .3);
  color: var(--n2);
}
.btn-maitrise {
  background: rgba(52, 211, 153, .12);
  border-color: rgba(52, 211, 153, .3);
  color: var(--n3);
}

/* Raccourcis clavier */
.fc-keyboard-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--light);
  margin-top: 8px;
  letter-spacing: .02em;
}
.fc-keyboard-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: inherit;
}

/* Indicateur niveau */
.fc-niveau-indicator {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 0 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.niveau-0 { color: var(--n0); }
.niveau-1 { color: var(--n1); }
.niveau-2 { color: var(--n2); }
.niveau-3 { color: var(--n3); }

/* Fin de session */
.fc-complete {
  text-align: center;
  padding: 64px 20px;
}
.fc-complete-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  margin: 0 auto 20px;
}
.fc-complete h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.fc-complete p { color: var(--muted); margin-bottom: 24px; }
.fc-complete-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin: 24px 0 36px;
}
.stat-item { text-align: center; }
.stat-val { display: block; font-size: 1.8rem; font-weight: 800; }
.stat-lbl { font-size: 0.82rem; color: var(--muted); }
.fc-complete-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ===========================
   EXERCICES — LISTE
=========================== */

.ex-list { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }

.ex-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color var(--transition), transform var(--transition);
}
.ex-list-item:hover { transform: translateX(3px); border-color: var(--border-strong); }
.ex-done { border-left: 3px solid var(--n3); }

.ex-list-left { display: flex; align-items: center; gap: 14px; }

.ex-list-check {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.check-empty { border: 2px solid var(--border-strong); }
.check-done { color: #09090f; }

.ex-list-titre { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; color: var(--text); }
.ex-list-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.ex-methodo-tag {
  font-size: 0.72rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
  color: var(--muted);
}
.ex-steps-count { font-size: 0.72rem; color: var(--light); }
.ex-completions-tag { font-size: 0.72rem; color: var(--n3); font-weight: 600; }
.ex-list-arrow { color: var(--light); }

/* ===========================
   EXERCICE — DÉTAIL
=========================== */

.ex-header {
  padding: 32px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.ex-meta { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; }
.ex-methodo { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.ex-titre { font-size: 1.3rem; font-weight: 800; line-height: 1.3; }
.ex-completions { font-size: 0.78rem; color: var(--n3); font-weight: 600; margin-top: 6px; }

.ex-scenario {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.ex-scenario-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: var(--light);
  margin-bottom: 10px;
}
.ex-scenario-body { font-size: 0.9rem; line-height: 1.75; color: var(--muted); }

/* Navigation étapes */
.ex-steps-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background var(--transition), transform var(--transition);
}
.step-dot.step-done { background: var(--n3); }
.step-dot.step-active { transform: scale(1.5); }

/* Étape */
.ex-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.ex-step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ex-step-num {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #09090f;
}
.ex-step-label { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.ex-step-instruction { color: var(--muted); font-size: 0.875rem; margin-bottom: 14px; line-height: 1.65; }

.ex-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.65;
  resize: vertical;
  transition: border-color var(--transition);
  background: var(--bg);
  color: var(--text);
}
.ex-textarea:focus { outline: none; border-color: var(--border-strong); }
.ex-textarea::placeholder { color: var(--light); }

/* Correction */
.ex-correction {
  margin-top: 18px;
  border: 1px solid rgba(52, 211, 153, .22);
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: slideDown 0.22s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ex-correction-header {
  background: rgba(52, 211, 153, .12);
  color: var(--n3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(52, 211, 153, .18);
}
.ex-correction-body {
  padding: 16px;
  font-size: 0.875rem;
  line-height: 1.75;
  background: rgba(52, 211, 153, .04);
  color: var(--text);
}
.ex-conseil {
  padding: 12px 16px;
  background: rgba(251, 191, 36, .06);
  border-top: 1px solid rgba(251, 191, 36, .18);
  font-size: 0.82rem;
  color: var(--n2);
  line-height: 1.55;
}
.conseil-icon { margin-right: 6px; }

.ex-step-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: center;
}

/* Fin d'exercice */
.ex-complete {
  text-align: center;
  padding: 64px 20px;
}
.ex-complete-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  margin: 0 auto 20px;
}
.ex-complete h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.ex-complete-titre { font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.ex-complete p { color: var(--muted); margin-bottom: 8px; }
.ex-complete-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap;
}

/* ===========================
   ÉTATS VIDES
=========================== */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ===========================
   RESPONSIVE
=========================== */

@media (max-width: 640px) {
  #app { padding: 0 14px 60px; }

  .home-top { flex-direction: column; gap: 12px; }
  .global-stats { flex-direction: row; }
  .global-stat { text-align: left; }

  .epreuve-card-body { flex-direction: column; align-items: flex-start; }
  .epreuve-actions { width: 100%; }
  .epreuve-actions .btn-primary { flex: 1; justify-content: center; }

  .ep-modes { grid-template-columns: 1fr; }
  .fc-rating-btns { flex-direction: column; }
  .fc-face { padding: 20px; }
  .fc-question { font-size: 1rem; }
  .fc-complete-actions { flex-direction: column; align-items: center; }
  .ex-step-actions { flex-direction: column; }
  .ex-step-actions > * { width: 100%; justify-content: center; }
}

/* ===========================
   MODAL PRÉNOM
=========================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 15, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: ob-fade-in 0.25s ease;
}

.modal-overlay.modal-closing {
  animation: ob-fade-out 0.28s ease forwards;
}

.modal-card {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 40px 36px 32px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  animation: ob-slide-up 0.3s ease;
  position: relative;
  overflow: hidden;
}

.modal-deco {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--e1-dim), var(--e3-dim));
  border: 1px solid var(--e3-border);
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 22px;
}

.modal-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: var(--e3);
}

.modal-input.modal-input-error {
  border-color: #f87171;
  animation: ob-shake 0.35s ease;
}

.modal-btn {
  width: 100%;
  background: var(--e3);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  font-family: inherit;
}

.modal-btn:hover  { opacity: 0.88; }
.modal-btn:active { transform: scale(0.98); }

/* ===========================
   GUIDE INTERACTIF
=========================== */

.guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 15, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: ob-fade-in 0.25s ease;
}

.guide-overlay.modal-closing {
  animation: ob-fade-out 0.28s ease forwards;
}

.guide-card {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 32px 30px 24px;
  max-width: 420px;
  width: 92%;
  animation: ob-slide-up 0.3s ease;
}

.guide-greeting {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.guide-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  animation: ob-slide-in 0.35s ease both;
}

.guide-step-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.guide-step-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.guide-step-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.guide-step-desc kbd {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-family: inherit;
}

.guide-btn {
  width: 100%;
  background: linear-gradient(90deg, var(--e1), var(--e3));
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
  transition: opacity 0.2s;
  font-family: inherit;
}

.guide-btn:hover { opacity: 0.88; }

.guide-skip {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}

.guide-skip:hover { color: var(--text); }

/* ===========================
   WIDGET "ILS CHARBONNENT"
=========================== */

.charbonnent-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.charbonnent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 4px;
}

.charbonnent-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.charbonnent-count {
  font-size: 0.72rem;
  color: var(--muted);
}

.charbonnent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.nom-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 13px;
  font-size: 0.8rem;
  color: var(--muted);
}

.nom-chip-me {
  background: var(--e3-dim);
  border-color: var(--e3-border);
  color: var(--e3);
  font-weight: 700;
}

/* Lien "Revoir le guide" */
.guide-trigger {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.guide-trigger:hover { color: var(--text); }

/* ===========================
   ANIMATIONS ONBOARDING
=========================== */

@keyframes ob-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes ob-fade-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes ob-slide-up {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes ob-slide-in {
  from { transform: translateX(-10px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes ob-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-7px); }
  75%       { transform: translateX(7px); }
}

/* ===========================
   QUIZ QCM
=========================== */

/* Bouton Quiz dans les cards d'accueil */
.btn-quiz {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.btn-quiz:hover { border-color: var(--light); color: var(--text); }

/* Sélection du mode */
.quiz-mode-screen { max-width: 600px; margin: 0 auto; }

.quiz-modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 0 40px;
}

.quiz-mode-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.quiz-mode-btn:hover {
  border-color: var(--light);
  box-shadow: var(--shadow);
}
.quiz-mode-featured {
  border-width: 1.5px;
}
.quiz-mode-icon { font-size: 1.4rem; flex-shrink: 0; }
.quiz-mode-info { display: flex; flex-direction: column; gap: 2px; }
.quiz-mode-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.quiz-mode-count { font-size: 0.78rem; color: var(--muted); }

.quiz-domaines-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 12px 0 4px;
}

/* En-tête de question */
.quiz-header { padding: 28px 0 12px; }

.quiz-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.quiz-timer {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 99px;
}
.quiz-timer-urgent {
  color: #ef4444;
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.3);
  animation: quiz-pulse 1s ease infinite;
}
@keyframes quiz-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* Carte question */
.quiz-question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.quiz-question-text {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
  margin-top: 8px;
}

/* Options */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 16px;
}
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.5;
  font-family: inherit;
  color: var(--text);
  transition: border-color .12s, background .12s;
}
.quiz-option:hover:not([disabled]) {
  border-color: var(--light);
  background: var(--bg);
}
.quiz-option[disabled] { cursor: default; }

.quiz-option-letter {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.quiz-option-text { flex: 1; }

/* Feedback correct / wrong */
.quiz-option-correct {
  border-color: #22c55e;
  background: rgba(34,197,94,.06);
}
.quiz-option-correct .quiz-option-letter {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}
.quiz-option-wrong {
  border-color: #ef4444;
  background: rgba(239,68,68,.06);
}
.quiz-option-wrong .quiz-option-letter {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.quiz-next-btn {
  width: 100%;
  justify-content: center;
  margin-top: 6px;
}

/* Score */
.quiz-score-screen {
  max-width: 520px;
  margin: 32px auto 60px;
  text-align: center;
}
.quiz-score-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 5px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
.quiz-score-num   { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.quiz-score-denom { font-size: 0.82rem; color: var(--muted); }
.quiz-score-pct   { font-size: 1.3rem; font-weight: 700; color: var(--text); }

.quiz-grade-great { border-color: #22c55e; color: #16a34a; }
.quiz-grade-ok    { border-color: #f59e0b; color: #d97706; }
.quiz-grade-low   { border-color: #ef4444; color: #dc2626; }

/* Récap erreurs */
.quiz-recap-section { margin: 24px 0; text-align: left; }
.quiz-recap-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.quiz-recap-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #ef4444;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
}
.quiz-recap-q { font-size: 0.84rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.quiz-recap-a { font-size: 0.8rem; color: #16a34a; }
.quiz-recap-expl { font-size: 0.78rem; color: #64748b; font-style: italic; margin-top: 4px; }

.quiz-explication {
  margin-top: 14px;
  padding: 12px 16px;
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #166534;
  line-height: 1.5;
}
.quiz-explication-icon { margin-right: 6px; }

.quiz-next-btn { margin-top: 12px; width: 100%; }

.quiz-parfait {
  font-size: 1rem;
  font-weight: 700;
  color: #16a34a;
  margin: 20px 0;
}

.quiz-score-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 28px;
}

@media (max-width: 640px) {
  .quiz-option { padding: 11px 14px; }
  .quiz-score-actions { flex-direction: column; align-items: center; }
  .quiz-score-actions > * { width: 100%; justify-content: center; }
}
