/* =========================================================================
   Réviser le Livret du citoyen — feuille de styles
   -------------------------------------------------------------------------
   Approche MOBILE-FIRST : les styles de base ciblent le téléphone.
   Les media queries `min-width` enrichissent ensuite tablette et desktop.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f5f6f9;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef0f5;
  --bg-blur: rgba(255, 255, 255, .88);
  --text: #1a1d29;
  --text-muted: #5b6270;
  --border: #e1e4eb;
  --border-strong: #c9cedb;
  --primary: #14213d;
  --primary-hover: #223154;
  --primary-contrast: #ffffff;
  --accent-blue: #002395;
  --accent-red: #c8102e;
  --success: #1a7f37;
  --success-bg: #e6f4ea;
  --danger: #c62828;
  --danger-bg: #fdecea;
  --warning: #8a5a00;
  --warning-bg: #fff6e0;
  --focus: #0b63d6;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 3px rgba(20, 33, 61, .08), 0 1px 2px rgba(20, 33, 61, .06);
  --shadow-lg: 0 8px 24px rgba(20, 33, 61, .12);

  --container: 980px;
  --gutter: 1rem;            /* marge latérale mobile */
  --tap: 44px;               /* cible tactile minimale (WCAG 2.5.5) */
  --tabbar-h: 3.5rem;        /* hauteur de la barre d'onglets mobile */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

[data-theme="dark"] {
  --bg: #0e1117;
  --bg-elevated: #171b24;
  --bg-subtle: #1e232e;
  --bg-blur: rgba(23, 27, 36, .88);
  --text: #edeef2;
  --text-muted: #a3aab8;
  --border: #2a3040;
  --border-strong: #3b4356;
  --primary: #8fb0ff;
  --primary-hover: #aac2ff;
  --primary-contrast: #0e1117;
  --success: #4ade80;
  --success-bg: #133023;
  --danger: #f87171;
  --danger-bg: #341b1b;
  --warning: #f0c674;
  --warning-bg: #332a12;
  --focus: #7fb0ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 4.5rem; /* les ancres ne passent pas sous l'en-tête collant */
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  /* place pour la barre d'onglets fixe du mobile (hauteur + bordure + air) */
  padding-bottom: calc(var(--tabbar-h) + 1px + .5rem + var(--safe-b));
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Un anneau de focus visible et cohérent, uniquement au clavier. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

h1, h2, h3 { line-height: 1.25; color: var(--text); text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.6vw, 1.9rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.2rem, 1.08rem + .6vw, 1.35rem); margin: 2rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; }

p { text-wrap: pretty; }

.lead { color: var(--text-muted); font-size: 1rem; max-width: 62ch; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Lien d'évitement pour la navigation au clavier. */
.skip-link {
  position: absolute; left: .5rem; top: -100vh; z-index: 200;
  background: var(--primary); color: var(--primary-contrast);
  padding: .7rem 1rem; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: .5rem; }

/* ---------- Layout ---------- */
#app {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.25rem var(--gutter) 2.5rem;
  padding-left: max(var(--gutter), var(--safe-l));
  padding-right: max(var(--gutter), var(--safe-r));
  outline: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  /* En PWA plein écran, le contenu passe sous la barre d'état : on décale. */
  padding-top: var(--safe-t);
}
/* Le flou est porté par un pseudo-élément, et non par l'en-tête lui-même :
   `backdrop-filter` créerait sinon un bloc conteneur, et la barre d'onglets
   `position: fixed` du mobile se collerait à l'en-tête au lieu du bas
   de la fenêtre. */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg-blur);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}
.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: .5rem var(--gutter);
  padding-left: max(var(--gutter), var(--safe-l));
  padding-right: max(var(--gutter), var(--safe-r));
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3.25rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  font-size: .95rem;
  color: var(--text);
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-flag {
  display: inline-block;
  width: 22px; height: 15px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent-blue) 33%, #fff 33% 66%, var(--accent-red) 66%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
  flex-shrink: 0;
}
.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-text strong { color: var(--primary); }

/* La navigation principale vit en bas de l'écran sur mobile (zone du pouce). */
.main-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  display: flex;
  background: var(--bg-blur);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}
.main-nav a {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  min-height: var(--tabbar-h);
  padding: .35rem .25rem;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.main-nav a:hover { text-decoration: none; }
.main-nav .nav-icon { font-size: 1.15rem; line-height: 1; }
.main-nav .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.main-nav a.active { color: var(--primary); }
.main-nav a.active .nav-icon { transform: translateY(-1px); }

.theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 999px;
  width: var(--tap);
  height: var(--tap);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { background: var(--bg-subtle); }

.site-footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.25rem var(--gutter) 2rem;
  padding-left: max(var(--gutter), var(--safe-l));
  padding-right: max(var(--gutter), var(--safe-r));
  color: var(--text-muted);
  font-size: .82rem;
  border-top: 1px solid var(--border);
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: var(--tap);
  padding: .65rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-large { padding: .85rem 1.5rem; font-size: 1.05rem; min-height: 3rem; }
.btn-block { width: 100%; }
.btn-quit {
  background: none; border: none; color: var(--text-muted);
  font-size: .85rem; cursor: pointer; text-decoration: underline;
  min-height: var(--tap); padding: 0 .5rem; flex-shrink: 0;
}

/* Message d'erreur en ligne (remplace les alert() bloquants). */
.form-error {
  margin: .75rem 0 0;
  padding: .7rem .9rem;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-weight: 500;
}

/* ---------- Contrôles de formulaire ---------- */
/* 16px minimum : en dessous, iOS zoome automatiquement au focus. */
input[type="search"], input[type="text"], select, textarea {
  font-size: max(16px, 1rem);
}
input[type="checkbox"], input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ---------- Accueil ---------- */
.hero { padding: .5rem 0 1.5rem; }
.tricolor-bar {
  height: 4px; width: 64px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent-blue) 33%, #fff 33% 66%, var(--accent-red) 66%);
  margin-bottom: 1rem;
}
.hero h1 .accent { color: var(--primary); }
.hero-actions { display: flex; flex-direction: column; gap: .65rem; margin: 1.25rem 0; }
.disclaimer {
  font-size: .85rem; color: var(--text-muted); background: var(--bg-subtle);
  border-radius: var(--radius-sm); padding: .7rem .85rem; max-width: 62ch;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin: 1.25rem 0 2rem;
}
.stat-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem .6rem; text-align: center; box-shadow: var(--shadow);
}
.stat-number { display: block; font-size: 1.45rem; font-weight: 700; color: var(--primary); }
.stat-label { display: block; font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }

.parties-overview { margin: 2rem 0; }
.parties-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.partie-card {
  display: flex; flex-direction: column; gap: .3rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-left: 4px solid var(--partie-color, var(--primary));
  border-radius: var(--radius); padding: .9rem 1rem; color: var(--text); box-shadow: var(--shadow);
}
.partie-card:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.partie-icon { font-size: 1.4rem; }
.partie-titre { font-weight: 700; }
.partie-desc { font-size: .85rem; color: var(--text-muted); }
.partie-pages { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

.recent-results { margin: 2rem 0; }
.results-list { list-style: none; padding: 0; margin: 0; }
.results-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.result-date { color: var(--text-muted); font-size: .8rem; grid-column: 1; }
.result-mode { grid-column: 1; }
.result-score { font-weight: 700; grid-column: 2; grid-row: 1 / span 2; align-self: center; }

.about-box {
  margin-top: 2rem; padding: 1rem; background: var(--bg-subtle); border-radius: var(--radius);
}
.about-box h2 { margin-top: 0; }
.about-box p { color: var(--text-muted); font-size: .92rem; }

/* ---------- En-tête de vue / filtres / recherche ---------- */
.view-header { margin-bottom: 1rem; }

/* Sur mobile, les puces défilent horizontalement au lieu d'empiler 3 lignes. */
.filter-bar {
  display: flex;
  gap: .5rem;
  margin: 1rem calc(var(--gutter) * -1);
  padding: .25rem var(--gutter);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex; align-items: center;
  min-height: var(--tap);
  border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text);
  border-radius: 999px; padding: .45rem 1rem; font-size: .9rem; cursor: pointer;
  border-left: 3px solid var(--partie-color, var(--border-strong));
  white-space: nowrap;
}
.filter-chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }

.search-bar { margin: .75rem 0 1.25rem; position: relative; }
.search-bar input {
  width: 100%;
  min-height: var(--tap);
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
}
.search-count { display: block; margin-top: .4rem; font-size: .8rem; color: var(--text-muted); }

/* ---------- Liste des fiches ---------- */
.fiches-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.fiche-card {
  display: block; background: var(--bg-elevated); border: 1px solid var(--border);
  border-left: 4px solid var(--partie-color, var(--primary)); border-radius: var(--radius);
  padding: .9rem 1rem; color: var(--text); box-shadow: var(--shadow); position: relative;
}
.fiche-card:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.fiche-card.is-read { opacity: .82; }
.fiche-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.fiche-badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700;
  background: var(--partie-color, var(--primary)); color: #fff; padding: .25rem .6rem; border-radius: 999px;
}
.read-check { font-size: .75rem; color: var(--success); font-weight: 700; white-space: nowrap; }
.fiche-card h3 { font-size: 1.02rem; margin: .3rem 0; }
.fiche-card p { font-size: .88rem; color: var(--text-muted); margin: 0 0 .5rem; }
.fiche-pages { font-size: .75rem; color: var(--text-muted); }
.empty-state { color: var(--text-muted); padding: 2rem 0; text-align: center; }

/* ---------- Détail d'une fiche ---------- */
.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: 1rem; }
.breadcrumb a { display: inline-block; padding: .25rem 0; }
.fiche-detail-header { border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: 1rem; }
.fiche-detail-header .fiche-badge { white-space: normal; }
.fiche-detail-header h1 { margin-top: .5rem; }
.fiche-pages { display: block; margin: .25rem 0; font-size: .85rem; color: var(--text-muted); }

/* Interrupteur « lue » : cible tactile pleine largeur. */
.read-toggle {
  display: flex; align-items: center; gap: .6rem;
  margin-top: .9rem; padding: .65rem .85rem;
  min-height: var(--tap);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 500; cursor: pointer;
}
.read-toggle:has(input:checked) { background: var(--success-bg); border-color: var(--success); color: var(--success); }

.fiche-section { margin: 1.5rem 0; }
.fiche-section h2 {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem;
  font-size: 1.05rem; border-left: 3px solid var(--partie-color, var(--primary));
  padding-left: .6rem; margin: 0 0 .75rem;
}
.section-page { font-size: .72rem; font-weight: 400; color: var(--text-muted); white-space: nowrap; }
.point-list { margin: 0; padding-left: 1.15rem; }
.point-list li { margin-bottom: .5rem; }

.citation {
  margin: 1rem 0; padding: .75rem .9rem; border-left: 3px solid var(--primary);
  background: var(--bg-subtle); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-style: italic;
}
.citation footer { margin-top: .3rem; font-size: .8rem; font-style: normal; color: var(--text-muted); }

.astuce-box {
  margin: .75rem 0; padding: .7rem .9rem; background: var(--warning-bg); border-radius: var(--radius-sm);
  font-size: .9rem;
}

.a-retenir {
  margin-top: 1.75rem; padding: 1rem; background: var(--bg-subtle); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.a-retenir h2 { margin-top: 0; }
.a-retenir ul { padding-left: 1.15rem; margin: 0; }
.a-retenir li { margin-bottom: .5rem; font-weight: 500; }

.fiche-nav { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.75rem; }
.fiche-nav .btn { text-align: left; justify-content: flex-start; }
.fiche-qcm-cta { margin-top: 1.25rem; }
.fiche-qcm-cta .btn { width: 100%; }

/* ---------- QCM : configuration ---------- */
.qcm-config fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem 1rem; margin: 0 0 1rem;
  background: var(--bg-elevated);
}
.qcm-config legend { font-weight: 700; padding: 0 .4rem; font-size: .95rem; }
.chips-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-checkbox {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: var(--tap);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--partie-color, var(--border-strong));
  border-radius: 999px; padding: .4rem .9rem;
  font-size: .9rem; cursor: pointer; background: var(--bg-elevated);
}
.chip-checkbox.checked { background: var(--bg-subtle); font-weight: 600; }

/* Les options en radio/case s'empilent sur mobile, avec de vraies cibles tactiles. */
.radio-row { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .95rem; }
.radio-row label {
  display: inline-flex; align-items: center; gap: .55rem;
  min-height: var(--tap); padding: .35rem .6rem .35rem .4rem;
  border-radius: var(--radius-sm); cursor: pointer; flex: 1 1 auto;
}
.radio-row label:hover { background: var(--bg-subtle); }
.radio-row label:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.radio-row.radio-col { flex-direction: column; gap: .25rem; }
.radio-row.radio-col label { flex: 1 1 auto; width: 100%; }
/* Rangée compacte de nombres (10 / 20 / 40 / Toutes) */
.radio-row.radio-inline label { flex: 1 1 0; min-width: 5rem; justify-content: center; }

/* ---------- QCM : session ---------- */
.qcm-topbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.progress-track { flex: 1 1 auto; min-width: 0; height: 8px; background: var(--bg-subtle); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width .25s; }
@media (prefers-reduced-motion: reduce) { .progress-fill { transition: none; } }
.qcm-counter { font-size: .82rem; color: var(--text-muted); white-space: nowrap; }

.question-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.question-meta .fiche-badge { white-space: normal; }
.fav-btn {
  background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted);
  line-height: 1; width: var(--tap); height: var(--tap); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; border-radius: 999px;
}
.fav-btn:hover { background: var(--bg-subtle); }
.fav-btn.active { color: #e8a20a; }

.question-text { font-size: 1.15rem; margin: .5rem 0 1rem; outline: none; }
.hint { font-size: .85rem; color: var(--text-muted); margin: -.25rem 0 .75rem; }

.options-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.option-item {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .8rem .9rem; min-height: var(--tap);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--bg-elevated);
}
.option-item:hover { background: var(--bg-subtle); }
.option-item input { margin-top: .12rem; }
.option-item.checked { border-color: var(--primary); background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--primary); }
.option-item.is-correct { border-color: var(--success); background: var(--success-bg); box-shadow: inset 0 0 0 1px var(--success); }
.option-item.is-wrong { border-color: var(--danger); background: var(--danger-bg); box-shadow: inset 0 0 0 1px var(--danger); }
.option-item input:disabled { opacity: 1; }

/* Barre d'action collante : le bouton principal reste sous le pouce. */
.qcm-actions {
  position: sticky;
  /* s'arrête au-dessus de la barre d'onglets, jamais dessous */
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 20;
  display: flex;
  gap: .6rem;
  margin: 1rem calc(var(--gutter) * -1) 0;
  padding: .75rem var(--gutter);
  padding-bottom: max(.75rem, var(--safe-b));
  background: var(--bg-blur);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
}
.qcm-actions .btn { flex: 1 1 0; }

.feedback-area { margin-top: 1rem; }
.feedback-banner { font-weight: 700; padding: .7rem .9rem; border-radius: var(--radius-sm); margin-bottom: .6rem; }
.feedback-banner.correct { background: var(--success-bg); color: var(--success); }
.feedback-banner.incorrect { background: var(--danger-bg); color: var(--danger); }
.feedback-explication { color: var(--text-muted); font-size: .92rem; }

.recall-box { padding: 1rem; background: var(--bg-subtle); border-radius: var(--radius); }
.recall-hint { color: var(--text-muted); font-size: .9rem; margin-top: 0; }
.recall-box > .btn { width: 100%; }
.reveal-content { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.reveal-answer { font-size: 1.05rem; }
.reveal-explication { color: var(--text-muted); }
.reveal-page { font-size: .8rem; color: var(--text-muted); }
.self-assess { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.self-assess .btn { flex: 1 1 8rem; }

/* ---------- QCM : résultats ---------- */
.qcm-results { text-align: left; }
.score-circle {
  width: clamp(120px, 34vw, 140px);
  aspect-ratio: 1;
  border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; margin: 1rem auto 1.75rem;
  border: 6px solid var(--border);
}
.score-circle.great { border-color: var(--success); }
.score-circle.ok { border-color: #d29c1e; }
.score-circle.low { border-color: var(--danger); }
.score-pct { font-size: 1.75rem; font-weight: 800; }
.score-frac { font-size: .85rem; color: var(--text-muted); }

.partie-breakdown { display: flex; flex-direction: column; gap: .75rem; margin: 1rem 0 2rem; }
.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .3rem .75rem;
  font-size: .88rem;
}
.breakdown-label { color: var(--text-muted); grid-column: 1; min-width: 0; }
.breakdown-frac { grid-column: 2; text-align: right; color: var(--text-muted); white-space: nowrap; }
.breakdown-bar { grid-column: 1 / -1; height: 10px; background: var(--bg-subtle); border-radius: 999px; overflow: hidden; }
.breakdown-fill { height: 100%; border-radius: 999px; }

.missed-list { display: flex; flex-direction: column; gap: .75rem; }
.missed-item { padding: .85rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.missed-q { font-weight: 600; margin: 0 0 .35rem; }
.missed-a { margin: 0 0 .25rem; }
.missed-e { color: var(--text-muted); font-size: .88rem; margin: 0 0 .35rem; }
.missed-meta { font-size: .78rem; color: var(--text-muted); margin: 0; }
.perfect-score { text-align: center; font-size: 1.1rem; padding: 1.5rem; }

.results-actions { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.75rem; }

/* ---------- Progression ---------- */
.progress-summary {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem; margin: 1.25rem 0 2rem;
}

/* Sur mobile le tableau devient une liste de cartes ; il redevient un
   vrai tableau à partir de la tablette (voir media query plus bas). */
.history-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.history-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.history-table tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.history-table td { border: none; padding: 0; }
.history-table td[data-l="date"] { grid-column: 1; color: var(--text-muted); font-size: .8rem; }
.history-table td[data-l="mode"] { grid-column: 1; }
.history-table td[data-l="score"] { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 700; white-space: nowrap; }

.danger-zone .btn { width: 100%; }

/* =========================================================================
   Tablette — à partir de 600px
   ========================================================================= */
@media (min-width: 600px) {
  :root { --gutter: 1.5rem; }

  .stats-grid, .progress-summary { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .parties-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
  .fiches-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .hero-actions { flex-direction: row; flex-wrap: wrap; }
  .hero-actions .btn { flex: 0 0 auto; }
  .results-actions { flex-direction: row; flex-wrap: wrap; }
  .results-actions .btn { flex: 0 0 auto; }
  .fiche-nav { flex-direction: row; justify-content: space-between; gap: 1rem; }
  .fiche-nav .btn { flex: 0 1 auto; }
  .fiche-qcm-cta { text-align: center; }
  .fiche-qcm-cta .btn { width: auto; }
  .danger-zone .btn { width: auto; }
  .recall-box > .btn { width: auto; }

  .qcm-actions {
    bottom: 0;
    margin-left: 0; margin-right: 0;
    padding-left: 0; padding-right: 0;
    background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
    border-top: none; position: static;
  }
  .qcm-actions .btn { flex: 0 0 auto; min-width: 12rem; }
}

/* =========================================================================
   Desktop — à partir de 768px : la navigation remonte dans l'en-tête
   ========================================================================= */
@media (min-width: 768px) {
  body { padding-bottom: 0; }

  .header-inner { gap: 1.25rem; padding-top: .6rem; padding-bottom: .6rem; }
  .brand { font-size: 1rem; }
  .brand-text { white-space: nowrap; }

  .main-nav {
    position: static;
    margin-left: auto;
    gap: .25rem;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: none;
    padding: 0;
  }
  .main-nav a {
    flex: 0 0 auto;
    flex-direction: row;
    gap: .35rem;
    min-height: 2.5rem;
    padding: .45rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-weight: 500;
  }
  .main-nav a:hover { background: var(--bg-subtle); }
  .main-nav a.active { color: var(--primary); background: var(--bg-subtle); }
  .main-nav .nav-icon { font-size: 1rem; }

  .theme-toggle { margin-left: 0; }

  #app { padding-top: 1.5rem; padding-bottom: 4rem; }

  h3 { font-size: 1.1rem; }
  .lead { font-size: 1.05rem; }
  .question-text { font-size: 1.3rem; }
  .stat-number { font-size: 1.6rem; }

  .breakdown-row { grid-template-columns: 150px minmax(0, 1fr) 100px; gap: .75rem; }
  .breakdown-label { grid-column: 1; }
  .breakdown-bar { grid-column: 2; }
  .breakdown-frac { grid-column: 3; }

  .history-table thead {
    position: static; width: auto; height: auto;
    clip: auto; clip-path: none; overflow: visible;
  }
  .history-table tr { display: table-row; }
  .history-table td, .history-table th {
    display: table-cell;
    text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border);
  }
  .history-table th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
  .history-table td[data-l="date"] { font-size: .9rem; color: var(--text); }
  .history-table td[data-l="score"] { font-weight: 400; }

  .results-list li { display: flex; gap: .75rem; align-items: baseline; }
  .result-date { min-width: 9rem; font-size: .9rem; }
  .result-score { margin-left: auto; }

  .filter-bar {
    flex-wrap: wrap;
    overflow: visible;
    margin-left: 0; margin-right: 0;
    padding-left: 0; padding-right: 0;
  }
  .radio-row.radio-inline label { flex: 0 0 auto; min-width: 0; }
  .radio-row.radio-col { gap: .1rem; }
}

/* ---------- Impression ---------- */
@media print {
  .site-header, .main-nav, .theme-toggle, .qcm-actions, .filter-bar, .search-bar, .fiche-nav, .fiche-qcm-cta { display: none !important; }
  body { padding-bottom: 0; background: #fff; color: #000; }
  #app { max-width: none; padding: 0; }
  a { color: #000; text-decoration: underline; }
}

/* =========================================================================
   Références de page vers le livret source
   Chaque information affichée porte la page du PDF dont elle provient.
   ========================================================================= */
.page-ref {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .1rem .45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
}
a.page-ref:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
  text-decoration: none;
}
.page-ref-static { cursor: default; }

/* Référence accolée à un élément de liste : discrète, alignée en fin de ligne. */
.point-list .page-ref,
.a-retenir .page-ref { margin-left: .35rem; }

/* Les listes « À retenir » alignent leur puce et leur référence. */
.a-retenir li { display: block; }

.citation-ref { margin-top: .4rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.astuce-box { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem .5rem; }
.astuce-box .astuce-text { flex: 1 1 12rem; min-width: 0; }

/* Bandeau expliquant le principe de référencement. */
.source-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: 1rem 0 0;
  padding: .7rem .85rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .82rem;
}

/* Dans l'en-tête d'une section de fiche, la référence reste à droite. */
.fiche-section h2 .page-ref { margin-left: auto; }

/* En-tête de question : badge de partie + référence de page. */
.question-source {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  min-width: 0;
}
.missed-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.reveal-page { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.breakdown-label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; }

/* Référence discrète en fin de puce : présente sur chaque information,
   sans alourdir la lecture d'une liste de points. */
.page-ref-quiet {
  margin-left: .4rem;
  padding: 0 .3rem;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 500;
  opacity: .75;
}
a.page-ref-quiet:hover {
  opacity: 1;
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}
.point-list li { margin-bottom: .55rem; }

/* =========================================================================
   Fiches d'info
   ========================================================================= */
.cards-quickstart { margin: 0 0 1.5rem; }
.quickstart-hint { margin: .5rem 0 0; font-size: .82rem; color: var(--text-muted); text-align: center; }

/* Compact visuellement, mais la cible tactile reste conforme sur mobile. */
.btn-sm { min-height: var(--tap); padding: .35rem .8rem; font-size: .82rem; }
.topic-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .85rem; }

.topic-group { margin-bottom: 1rem; padding-left: .6rem; border-left: 3px solid var(--partie-color, var(--border)); }
.topic-group:last-child { margin-bottom: 0; }
.topic-group-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .4rem; margin-bottom: .5rem;
}
.topic-group-title { font-size: .85rem; font-weight: 700; color: var(--text-muted); }
.topic-group-toggle {
  background: none; border: none; padding: .3rem .5rem; min-height: var(--tap);
  color: var(--primary); font-size: .78rem; font-weight: 600; cursor: pointer; text-decoration: underline;
}
.topic-chip { font-size: .82rem; }

/* Fiche d'info : une seule face, l'information est affichée directement.
   Pas de retournement — on lit, puis on passe à la suivante. */
.info-card {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  margin: .5rem 0 0;
  padding: 1.1rem 1rem;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--partie-color, var(--primary));
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  /* Le balayage horizontal pilote la navigation : on laisse le défilement
     vertical au navigateur, mais on évite le rebond horizontal. */
  touch-action: pan-y;
}
.info-card.is-acquise { border-color: var(--success); background: var(--success-bg); }
@media (prefers-reduced-motion: no-preference) {
  .info-card { animation: info-apparait .22s ease-out; }
}
@keyframes info-apparait {
  from { opacity: .4; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

.info-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.info-card-context {
  margin: 0;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
/* L'information elle-même : c'est le contenu principal de l'écran. */
.info-card-text {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.5;
  font-weight: 500;
}
.info-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .3rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.acquis-toggle {
  min-height: var(--tap);
  padding: .4rem .9rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.acquis-toggle:hover { background: var(--bg-subtle); }
.acquis-toggle.is-on { background: var(--success); border-color: var(--success); color: #fff; }

.info-nav .btn { flex: 1 1 0; }
.info-nav .btn[disabled] { opacity: .45; cursor: not-allowed; }
.info-hint {
  margin: .6rem 0 0;
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
}
@media (hover: hover) and (pointer: fine) {
  /* Sur ordinateur, on navigue au clavier plutôt qu'au doigt. */
  .info-hint::after { content: " Ou utilisez les flèches ← →."; }
}

@media (min-width: 768px) {
  .btn-sm { min-height: 2.25rem; }
  .topic-group-toggle { min-height: 2rem; }
}

@media (min-width: 600px) {
  .cards-quickstart .btn { width: auto; }
  .cards-quickstart { text-align: center; }
  .info-card { padding: 1.5rem 1.4rem; }
  .info-card-text { font-size: 1.3rem; }
  .info-nav .btn { flex: 0 0 auto; min-width: 11rem; }
}

/* Information clé mise en valeur dans les fiches d'info. */
.info-card-text .cle,
.missed-a .cle {
  font-weight: 700;
  color: var(--primary);
}
.info-card-text .cle-libelle,
.missed-a .cle-libelle {
  font-weight: 800;
  color: var(--text);
}
.info-card.is-acquise .info-card-text .cle { color: var(--success); }

/* Badge de partie sur les cartes de fiches : le titre peut passer à la ligne. */
.fiche-card .fiche-badge { white-space: normal; }

/* =========================================================================
   Confort de lecture des fiches
   -------------------------------------------------------------------------
   Le contenu du livret est dense. Trois leviers : une longueur de ligne
   limitée (~66 caractères, contre 117 auparavant sur grand écran), une
   respiration verticale plus large, et un découpage visuel par section.
   ========================================================================= */
.fiche-detail { --mesure: 66ch; }

/* Longueur de ligne : au-delà de ~75 caractères, l'œil perd la ligne suivante. */
.fiche-detail .lead,
.fiche-detail .point-list li,
.fiche-detail .a-retenir li,
.fiche-detail .astuce-text,
.fiche-detail .citation { max-width: var(--mesure); }

/* Chaque section devient un bloc identifiable plutôt qu'un flux continu. */
.fiche-section {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 4.5rem;
}
.fiche-section:focus { outline: none; }
.fiche-section h2 {
  margin-top: 0;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
  border-left: 0;
  padding-left: 0;
}
.fiche-section h2::before {
  content: "";
  flex: 0 0 auto;
  width: 4px;
  align-self: stretch;
  min-height: 1.2em;
  margin-right: .55rem;
  border-radius: 2px;
  background: var(--partie-color, var(--primary));
}

/* Respiration entre les points : le principal facteur de lisibilité d'une liste. */
.fiche-detail .point-list { padding-left: 1.35rem; }
.fiche-detail .point-list li {
  margin-bottom: .9rem;
  line-height: 1.68;
}
.fiche-detail .point-list li::marker { color: var(--partie-color, var(--primary)); }
.fiche-detail .a-retenir li { margin-bottom: .8rem; line-height: 1.6; }

/* Les références de page ne doivent pas concurrencer le texte. */
.fiche-detail .page-ref-quiet {
  opacity: .45;
  font-size: .66rem;
  vertical-align: baseline;
}
.fiche-detail .page-ref-quiet:hover,
.fiche-detail .page-ref-quiet:focus-visible { opacity: 1; }

/* Sommaire : permet d'atteindre une section sans parcourir toute la fiche. */
.fiche-toc {
  margin: 1.25rem 0;
  padding: .9rem 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.fiche-toc-title {
  margin: 0 0 .5rem;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.fiche-toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.fiche-toc li {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: .1rem 0;
  border-bottom: 1px solid var(--border);
}
.fiche-toc li:last-child { border-bottom: 0; }
.fiche-toc-link {
  flex: 1 1 auto;
  min-height: var(--tap);
  padding: .35rem 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: .92rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.fiche-toc-link:hover { text-decoration: underline; }

.source-note-compact { font-size: .78rem; padding: .5rem .7rem; }

/* Informations clés en gras, comme dans les fiches d'info. */
.fiche-detail .cle { font-weight: 700; color: var(--primary); }
.fiche-detail .cle-libelle { font-weight: 800; color: var(--text); }

@media (min-width: 768px) {
  .fiche-section { padding: 1.25rem 1.4rem; }
  .fiche-detail .point-list li { font-size: 1.02rem; }
}

/* Sections repliables : la fiche s'ouvre sur un plan, on déplie à la demande. */
details.fiche-section { padding: 0; }
.fiche-section-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  padding: .85rem 1rem;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.fiche-section-head::-webkit-details-marker { display: none; }
.fiche-section-head:hover { background: var(--bg-subtle); }
.fiche-section-head h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding-bottom: 0;
  border-bottom: 0;
}
/* Chevron indiquant l'état plié/déplié. */
.fiche-section-head::after {
  content: "";
  flex: 0 0 auto;
  width: .55rem;
  height: .55rem;
  margin-left: .25rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .2s;
}
details.fiche-section[open] > .fiche-section-head::after { transform: rotate(-135deg); }
@media (prefers-reduced-motion: reduce) {
  .fiche-section-head::after { transition: none; }
}
.fiche-section-count {
  flex: 0 0 auto;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
details.fiche-section[open] > .fiche-section-head { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
details.fiche-section > .point-list,
details.fiche-section > .citation,
details.fiche-section > .astuce-box { margin-left: 1rem; margin-right: 1rem; }
details.fiche-section > .point-list { padding-top: .9rem; padding-bottom: .3rem; }
details.fiche-section > .astuce-box:last-child,
details.fiche-section > .citation:last-child { margin-bottom: 1rem; }

.fiche-toc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
.fiche-toc-head .fiche-toc-title { margin: 0; }

@media (min-width: 768px) {
  .fiche-section-head { padding: 1rem 1.4rem; }
  details.fiche-section > .point-list,
  details.fiche-section > .citation,
  details.fiche-section > .astuce-box { margin-left: 1.4rem; margin-right: 1.4rem; }
}

/* Sur une fiche à 21 sections, le sommaire deviendrait lui-même un mur :
   il est donc repliable, et fermé d'emblée au-delà de 6 sections. */
details.fiche-toc { padding: 0; }
.fiche-toc-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  padding: .6rem 1rem;
  margin-bottom: 0;
  cursor: pointer;
  list-style: none;
}
.fiche-toc-head::-webkit-details-marker { display: none; }
.fiche-toc-head::after {
  content: "";
  width: .5rem; height: .5rem;
  margin-left: auto;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .2s;
}
details.fiche-toc[open] > .fiche-toc-head::after { transform: rotate(-135deg); }
@media (prefers-reduced-motion: reduce) { .fiche-toc-head::after { transition: none; } }
.fiche-toc-actions { padding: 0 1rem .5rem; }
details.fiche-toc ol { padding: 0 1rem .5rem; }

/* =========================================================================
   Confort de lecture — QCM et fiches d'info
   Mêmes leviers que les fiches : longueur de ligne limitée, respiration,
   repères en gras. Une question ou une explication se lit d'un trait.
   ========================================================================= */
.qcm-session, .qcm-results, .cards-session, .qcm-config { --mesure: 66ch; }

.question-text,
.hint,
.feedback-explication,
.reveal-answer,
.reveal-explication,
.info-card-text,
.missed-q, .missed-a, .missed-e,
.qcm-results > .lead { max-width: var(--mesure); }

/* Les propositions : une ligne aérée se compare plus vite. */
.option-item { line-height: 1.55; }
.option-item > span { max-width: var(--mesure); }
.question-text { line-height: 1.4; }

/* Repères en gras, comme ailleurs dans l'application. */
.question-text .cle,
.feedback-explication .cle,
.reveal-answer .cle,
.reveal-explication .cle,
.missed-item .cle { font-weight: 700; color: var(--primary); }
.question-text .cle-libelle,
.missed-item .cle-libelle { font-weight: 800; }
.feedback-banner.correct + .feedback-explication .cle { color: var(--success); }

/* « Réponse » : une étiquette plutôt qu'un mot en gras noyé dans la phrase. */
.reponse-label {
  display: inline-block;
  margin-right: .4rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: baseline;
}

/* Les listes de révision de fin de session : des blocs, pas un pavé. */
.missed-list { gap: 1rem; }
.missed-item {
  padding: 1rem;
  border-left: 3px solid var(--partie-color, var(--border-strong));
  line-height: 1.6;
}
.missed-q { margin-bottom: .6rem; font-size: 1.02rem; }
.missed-a { margin-bottom: .5rem; }
.missed-e { margin-bottom: .6rem; }

/* Écrans de configuration : les blocs de réglages respirent. */
.qcm-config fieldset { margin-bottom: 1.25rem; }
.qcm-config legend { font-size: 1rem; }
.radio-row.radio-col label { line-height: 1.5; padding-top: .5rem; padding-bottom: .5rem; }
.radio-row.radio-col label > span,
.radio-row.radio-col { max-width: var(--mesure); }

@media (min-width: 768px) {
  .question-text { font-size: 1.35rem; }
  .option-item { padding: .9rem 1rem; }
  .missed-item { padding: 1.1rem 1.25rem; }
}

/* =========================================================================
   Ma sélection
   ========================================================================= */
.sel-teaser {
  padding: 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.sel-teaser h2 { margin-top: 0; }
.sel-teaser-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.25rem;
  margin: .75rem 0 1rem;
  padding: 0;
  list-style: none;
  font-size: .92rem;
  color: var(--text-muted);
}
.sel-teaser-list strong { color: var(--primary); font-size: 1.1rem; }
.sel-teaser .btn { width: 100%; }

.sel-bloc {
  margin: 1rem 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sel-bloc-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: var(--tap);
  padding: .8rem 1rem;
  cursor: pointer;
  list-style: none;
}
.sel-bloc-head::-webkit-details-marker { display: none; }
.sel-bloc-head::after {
  content: "";
  width: .5rem; height: .5rem;
  margin-left: auto;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .2s;
}
.sel-bloc[open] > .sel-bloc-head::after { transform: rotate(-135deg); }
@media (prefers-reduced-motion: reduce) { .sel-bloc-head::after { transition: none; } }
.sel-bloc[open] > .sel-bloc-head { border-bottom: 1px solid var(--border); }
.sel-bloc-title { font-size: 1rem; font-weight: 700; }
.sel-bloc-count {
  padding: .1rem .5rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 700;
}
.sel-bloc .empty-state { padding: 1.25rem 1rem; }

.sel-list { margin: 0; padding: 0; list-style: none; --mesure: 62ch; }
.sel-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--partie-color, var(--primary));
}
.sel-item:last-child { border-bottom: 0; }
.sel-item-main { flex: 1 1 auto; min-width: 0; }
.sel-item-meta {
  margin: 0 0 .3rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
}
.sel-item-text {
  margin: 0 0 .5rem;
  max-width: var(--mesure);
  line-height: 1.6;
}
.sel-item-text .cle { font-weight: 700; color: var(--primary); }
.sel-item-text .cle-libelle { font-weight: 800; }
.sel-item-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: 0;
  font-size: .82rem;
}
.sel-remove {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
}
.sel-remove:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

@media (min-width: 600px) {
  .sel-teaser .btn { width: auto; }
}

/* =========================================================================
   Confort de lecture — progression
   ========================================================================= */
#app .bloc-carte {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
#app .bloc-carte > h2 { margin-top: 0; }
#app .bloc-carte > .lead { max-width: 62ch; }
.history-table + .btn { margin-top: 1rem; }

/* =========================================================================
   L'explication d'une question est le vrai contenu à apprendre :
   elle doit se lire, pas se deviner en petits caractères gris.
   ========================================================================= */
.explication-box {
  margin: .75rem 0 0;
  padding: .9rem 1rem;
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.explication-label {
  display: block;
  margin-bottom: .35rem;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--warning);
}
.explication-box .feedback-explication {
  margin: 0;
  max-width: 62ch;
  font-size: 1.05rem;   /* auparavant .92rem en gris clair */
  line-height: 1.6;
  color: var(--text);   /* plus de gris atténué */
}
.explication-box .feedback-explication .cle { font-weight: 700; color: var(--text); }

/* Marque explicite sur les propositions corrigées : les puces radio
   désactivées se ressemblent toutes, la couleur seule ne suffit pas. */
.option-item.is-correct::after,
.option-item.is-wrong::after {
  margin-left: auto;
  align-self: center;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}
.option-item.is-correct::after { content: "✓"; color: var(--success); }
.option-item.is-wrong::after { content: "✗"; color: var(--danger); }
/* Une fois corrigée, la puce n'a plus de rôle : on l'efface pour ne pas
   laisser croire à une sélection. */
.option-item.is-correct input:disabled,
.option-item.is-wrong input:disabled { opacity: .25; }

@media (min-width: 768px) {
  #app .bloc-carte { padding: 1.25rem 1.4rem; }
  .explication-box .feedback-explication { font-size: 1.1rem; }
}
