:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --success: #16a34a;
  --error: #dc2626;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 2rem;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 { font-size: 1.25rem; margin: 0; }
header a { color: #fff; text-decoration: none; font-size: 0.9rem; opacity: 0.9; }

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

@media (min-width: 640px) {
  main { max-width: 640px; }
}
@media (min-width: 1024px) {
  main { max-width: 900px; }
}
@media (min-width: 1400px) {
  main { max-width: 1200px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* Écrans "formulaire court" (accueil, en-tête des résultats) : pas d'intérêt à s'étirer sur
   toute la largeur d'un grand écran, contrairement à la grille d'exercices. */
.card-etroite {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* Une carte par exercice, réparties sur toute la largeur disponible. Grille à colonnes fixes
   (et non auto-fit) pour pouvoir donner aux exercices "texte à trous" (6 phrases, plus denses)
   deux fois plus de place qu'un exercice normal : 3 exercices normaux par ligne sur grand écran,
   mais seulement 2 "texte à trous" — sinon trop serré (demande du 2026-09-17). */
.grille-exercices {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-flow: dense;
  gap: 1rem;
  align-items: start;
}
.grille-exercices > .item-conjugaison,
.grille-exercices > .correction-item {
  grid-column: span 1;
}

@media (min-width: 700px) {
  .grille-exercices { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grille-exercices { grid-template-columns: repeat(4, 1fr); }
  .grille-exercices > .item-conjugaison,
  .grille-exercices > .correction-item { grid-column: span 2; }
  .grille-exercices > .item-conjugaison.texte-a-trous,
  .grille-exercices > .correction-item.texte-a-trous { grid-column: span 4; }
}
@media (min-width: 1400px) {
  .grille-exercices { grid-template-columns: repeat(6, 1fr); }
  .grille-exercices > .item-conjugaison,
  .grille-exercices > .correction-item { grid-column: span 2; }
  .grille-exercices > .item-conjugaison.texte-a-trous,
  .grille-exercices > .correction-item.texte-a-trous { grid-column: span 3; }
}

.barre-actions {
  max-width: 480px;
  margin: 1rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"], select {
  width: 100%;
  max-width: 420px;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  /* évite le zoom automatique iOS sur focus */
}

button {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

button:active { background: var(--primary-dark); }
button.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.hidden { display: none !important; }

.exercice-numero {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.item-conjugaison,
.correction-item {
  margin-bottom: 0;
}

.consigne {
  margin: 0 0 0.6rem 0;
  font-weight: 700;
  font-size: 1rem;
}
.sous-titre {
  margin: 0 0 0.75rem 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.item-conjugaison .badge,
.correction-item .badge {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--muted);
  background: #eef2ff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
}

.pronom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.pronom-row label {
  width: 70px;
  margin: 0;
  flex-shrink: 0;
}
.pronom-row input {
  margin: 0;
  flex: 1;
}

.progress {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.score-badge {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  margin: 0.5rem 0 1rem;
}

/* Résultats : un exercice par ligne (pas de grille multi-colonnes), chaque ligne coupée en 2 —
   réponses de l'élève à gauche, correction + points à droite (demande du 2026-09-17). */
.liste-corrections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.correction-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.correction-entete .consigne { margin-bottom: 0; }

.points-pill {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}
.points-pill.succes { background: #dcfce7; color: #15803d; }
.points-pill.partiel { background: #ffedd5; color: #9a3412; }
.points-pill.echec { background: #fee2e2; color: var(--error); }

.correction-colonnes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 0.85rem;
}
@media (min-width: 560px) {
  .correction-colonnes { grid-template-columns: 1fr 1fr; }
  .col-correction { border-left: 1px solid var(--border); padding-left: 1.25rem; }
}

.col-titre {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.6rem 0;
}

.reponse-ligne, .correction-ligne {
  font-size: 0.9rem;
  margin: 0 0 0.5rem 0;
}
.reponse-ligne:last-child, .correction-ligne:last-child { margin-bottom: 0; }
.correction-ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.trou-reponse strong { display: block; font-size: 0.85rem; margin-bottom: 0.15rem; }
.trou-reponse u { text-decoration-color: var(--primary); }

.trou-ligne { margin-bottom: 0.85rem; }
.trou-ligne:last-child { margin-bottom: 0; }
.trou-consigne { margin: 0 0 0.25rem 0; }
.trou-contexte { margin: 0; line-height: 1.6; }
.trou-numero { color: var(--muted); font-size: 0.85rem; margin-right: 0.15rem; }
.trou-contexte input {
  width: 130px;
  display: inline-block;
  margin: 0 0.25rem;
  padding: 0.35rem 0.5rem;
}
.phrase-identifier { font-style: italic; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; }

.explication-box {
  background: #eef2ff;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: none;
}
.explication-box.visible { display: block; }

.lien-explication {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  padding: 0;
  width: auto;
  text-align: left;
  text-decoration: underline;
  margin-top: 0.25rem;
  cursor: pointer;
}

.serie-histo {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.serie-histo:last-child { border-bottom: none; }

.erreur { color: var(--error); font-size: 0.85rem; margin-top: -0.5rem; margin-bottom: 0.75rem; }
