:root {
  --bg: var(--ecg-canvas);
  --bg-soft: var(--ecg-canvas-soft);
  --panel: var(--ecg-surface);
  --panel-2: var(--ecg-surface-raised);
  --border: var(--ecg-border);
  --text: var(--ecg-text);
  --text-muted: var(--ecg-muted);
  --accent: var(--ecg-coral);
  --accent-2: var(--ecg-teal);
  --good: var(--ecg-green);
  --warn: var(--ecg-amber);
  --bad: var(--ecg-danger);
  --shadow: var(--ecg-shadow);
  --radius: var(--ecg-radius);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1c2b3a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ─────────── Topbar ─────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--ecg-header);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  border-radius: 10px;
  /* Bouton uniforme aux couleurs du logo LIRYC (fond turquoise de marque),
     pour un cartouche net sans bord blanc autour du JPG. */
  background: #0d6b85;
  padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.brand-logo-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.brand-logo {
  height: 50px;                  /* logo LIRYC (badge turquoise) — +25 % */
  width: auto;
  display: block;
  border-radius: 4px;
}
.logo {
  font-size: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(255, 90, 110, 0.3));
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }

.badge {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.badge-muted { color: var(--text-muted); }
.badge-ok { color: var(--good); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.badge-bad { color: var(--bad); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }

/* ─────────── Layout ─────────── */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  min-height: calc(100vh - 65px);
}

body.home-mode .layout { grid-template-columns: 1fr; }
body.home-mode .sidebar { display: none; }
body.home-mode .content { padding-inline: clamp(18px, 6vw, 72px); }

/* ─────────── Sidebar ─────────── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  background: var(--bg-soft);
  overflow-y: auto;
  max-height: calc(100vh - 65px);
  position: sticky;
  top: 65px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-head h2 { font-size: 15px; margin: 0; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.case-search { display: grid; gap: 6px; margin-bottom: 12px; }
.case-search span { color: var(--text-muted); font-size: 11px; font-weight: 700; }
.case-search input {
  width: 100%; min-height: 42px; padding: 9px 11px; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 14px;
}
.case-search input:focus { outline: 3px solid rgba(79,209,197,.18); border-color: var(--accent-2); }

/* Bouton Accueil (haut de la sidebar) */
.sidebar-home {
  width: 100%; margin-bottom: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 700; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s, background 0.14s;
}
.sidebar-home:hover {
  transform: translateY(-1px); border-color: var(--accent-2);
  background: var(--panel-2); box-shadow: var(--shadow);
}
.pill {
  font-size: 12px; font-weight: 700;
  background: var(--panel-2); padding: 3px 10px; border-radius: 999px;
}

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filter-chip {
  font-size: 11.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--accent-2); color: var(--text); }
.filter-chip.active {
  background: linear-gradient(135deg, var(--accent), #ff7b8b);
  color: #fff; border-color: transparent;
}

.case-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.case-item {
  width: 100%; color: var(--text); font: inherit; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel);
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 10px;
}
.case-item:hover { border-color: var(--accent-2); transform: translateX(2px); }
.case-item:focus-visible { outline: 3px solid rgba(79,209,197,.3); outline-offset: 1px; border-color: var(--accent-2); }
.case-item.active { border-color: var(--accent); background: var(--panel-2); }
.case-item .n {
  font-size: 12px; font-weight: 700; color: var(--accent-2);
  min-width: 26px; text-align: center;
}
.case-item .t { font-size: 13px; font-weight: 500; line-height: 1.25; }
.case-item .fam { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }
.case-item .t, .case-item .fam { display: block; }

/* ─────────── Content ─────────── */
.content { padding: 28px 32px; overflow-y: auto; }
.hidden { display: none !important; }

.welcome { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.welcome-card {
  width: min(720px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow);
}
.welcome-card h2 { margin-top: 0; }
.welcome-card p { color: var(--text-muted); line-height: 1.6; }
.tips { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 10px; }
.tips li { font-size: 13.5px; color: var(--text); }

/* Crédit LIRYC en pied de la carte d'accueil */
.welcome-credit {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.welcome-credit a { display: inline-flex; transition: transform 0.15s ease, filter 0.15s ease; }
.welcome-credit a:hover { transform: translateY(-1px); filter: brightness(1.06); }
.welcome-logo {
  height: 96px;                  /* grand logo LIRYC (PNG transparent) */
  width: auto;
  display: block;
}
.welcome-credit .credit-text { margin: 0; font-size: 13px; color: var(--text-muted); }
.welcome-credit .credit-text a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.welcome-credit .credit-text a:hover { text-decoration: underline; }

/* Case view */
.case-view { max-width: 960px; margin: 0 auto; animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.case-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.case-header h2 { margin: 6px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.chip {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(79, 209, 197, 0.12); color: var(--accent-2);
  border: 1px solid rgba(79, 209, 197, 0.3);
}
.case-num { font-size: 40px; font-weight: 800; color: var(--panel-2); line-height: 1; }
.case-context { color: var(--text-muted); line-height: 1.6; margin: 4px 0 20px; white-space: pre-wrap; }

.ecg-gallery { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.ecg-gallery img {
  width: 100%; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; cursor: zoom-in; box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.ecg-gallery img:hover { transform: scale(1.005); }

/* Page 2 du tracé — révélée après correction, sous le commentaire IA */
.case-page2 { margin-top: 22px; animation: fade 0.35s ease; }
.case-page2 .page2-title {
  margin: 0 0 12px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent-2);
}
.case-page2 .ecg-gallery { margin-bottom: 0; }

/* Answer block */
.answer-block { margin-bottom: 20px; }
.answer-block label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
textarea {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; font-family: inherit; font-size: 14.5px; line-height: 1.6;
  resize: vertical; transition: border 0.15s;
}
textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.12); }

.answer-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--accent), #ff7b8b);
  color: #fff; border: none; border-radius: 10px;
  padding: 12px 22px; font-size: 14.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 90, 110, 0.3); transition: transform 0.12s, box-shadow 0.12s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255, 90, 110, 0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 18px; font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────── Result ─────────── */
.result { animation: fade 0.35s ease; }
.result-top {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
}
.score-ring {
  --val: 0;
  width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--ring-color) calc(var(--val) * 1%), var(--panel-2) 0);
}
.score-ring::before {
  content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--panel);
}
.score-ring span { position: relative; font-size: 26px; font-weight: 800; }
.score-ring small { position: relative; font-size: 11px; color: var(--text-muted); display: block; text-align: center; }
.verdict h3 { margin: 0 0 4px; font-size: 18px; }
.verdict p { margin: 0; color: var(--text-muted); font-size: 13.5px; }
.dx-line { margin-top: 8px; font-size: 13px; }
.dx-line b { color: var(--accent-2); }

.subscores { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.subscores .sub {
  font-size: 12px; color: var(--text-muted);
  background: var(--panel-2); padding: 4px 10px; border-radius: 8px;
}
.subscores .sub b { color: var(--text); margin-left: 4px; }
.result-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }

/* ── Sprint 3 : sous-scores explicites (diagnostic / description / sécurité) ── */
.subscore-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px;
}
.subscore {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.subscore .ss-head {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); display: flex; align-items: center; gap: 7px;
}
.subscore .ss-ic { font-size: 15px; }
.subscore .ss-val { font-size: 26px; font-weight: 800; margin-top: 8px; color: var(--sc, var(--text)); line-height: 1; }
.subscore .ss-val small { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-left: 2px; }
.subscore .ss-val--text { font-size: 17px; }
.subscore .ss-bar { height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-top: 10px; }
.subscore .ss-bar i { display: block; height: 100%; background: var(--sc, var(--accent-2)); border-radius: 999px; transition: width 0.5s ease; }
.subscore .ss-note { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }
.subscore--safety.safe { border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.06); }
.subscore--safety.safe .ss-val--text { color: var(--good); }
.subscore--safety.unsafe { border-color: rgba(248,113,113,0.45); background: rgba(248,113,113,0.06); }
.subscore--safety.unsafe .ss-val--text { color: var(--bad); }

/* Phrase pédagogique actionnable (une seule ligne, mise en avant) */
.punch-line {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(79,209,197,0.1), rgba(255,90,110,0.06));
  border: 1px solid var(--border); border-left: 3px solid var(--accent-2);
  border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1.45;
}

/* ── P1 (note UX §12) : révélation du thème après correction ──
   Le titre/famille sont anonymisés AVANT la soumission ; ce bandeau les
   dévoile a posteriori comme récompense pédagogique. */
.reveal-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(124,111,247,0.14), rgba(79,209,197,0.08));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px;
  animation: revealIn 0.45s ease;
}
.reveal-ic { font-size: 22px; line-height: 1.2; }
.reveal-body { min-width: 0; }
.reveal-t { font-size: 14.5px; line-height: 1.4; }
.reveal-t b { color: var(--accent-2); }
.reveal-fam { color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.reveal-d { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
@keyframes revealIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── P5 : validation de concepts (« le système m'a-t-il bien compris ? ») ──
   Chaque concept extrait par le pipeline reçoit un vote 👍/👎 qui alimente la
   curation golden/NER. Bloc discret, facultatif, sous le commentaire. */
.concept-review {
  margin: 18px 0; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px;
}
.concept-review h4 {
  margin: 0 0 4px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent-2);
}
.cr-help { margin: 0 0 12px; font-size: 12.5px; color: var(--text-muted); }
.cr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cr-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 9px;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}
.cr-item.cr-done { border-color: rgba(79,209,197,0.4); }
.cr-txt { font-size: 13px; line-height: 1.5; min-width: 0; }
.cr-terme { font-weight: 600; color: var(--text); }
.cr-arrow { color: var(--text-muted); margin: 0 4px; }
.cr-txt b { color: var(--accent-2); }
.cr-unmapped { color: var(--warn); font-style: italic; }
.cr-statut {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; border: 1px solid var(--border);
}
.cr-statut.st-present { color: var(--good); background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); }
.cr-statut.st-absent { color: var(--bad); background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); }
.cr-statut.st-hyp { color: var(--warn); background: rgba(251,191,36,0.1); border-color: rgba(251,191,36,0.3); }
.cr-vote { display: flex; gap: 6px; flex-shrink: 0; }
.cr-btn {
  cursor: pointer; border: 1px solid var(--border); background: var(--panel);
  border-radius: 8px; padding: 4px 9px; font-size: 15px; line-height: 1;
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
}
.cr-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent-2); }
.cr-btn:disabled { cursor: default; opacity: 0.55; }
.cr-btn.cr-ok.voted { background: rgba(52,211,153,0.18); border-color: var(--good); }
.cr-btn.cr-ko.voted { background: rgba(248,113,113,0.18); border-color: var(--bad); }
.cr-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.cr-status { font-size: 12.5px; }
.cr-status.ok { color: var(--good); }
.cr-status.warn { color: var(--text-muted); }


.tag {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
}
.tag-exacte { color: var(--good); background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.35); }
.tag-acceptable { color: var(--accent-2); background: rgba(79,209,197,0.1); border-color: rgba(79,209,197,0.35); }
.tag-partielle { color: var(--warn); background: rgba(251,191,36,0.1); border-color: rgba(251,191,36,0.35); }
.tag-incorrecte { color: var(--bad); background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.35); }
.tag-err-aucune { color: var(--good); background: rgba(52,211,153,0.08); }
.tag-err-etudiant { color: var(--bad); background: rgba(248,113,113,0.08); }
.tag-err-incomplet { color: var(--warn); background: rgba(251,191,36,0.08); }
.tag-err-formulation { color: var(--accent-2); background: rgba(79,209,197,0.08); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.card h4 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.card.found h4 { color: var(--good); }
.card.missed h4 { color: var(--warn); }
.card.wrong h4 { color: var(--bad); }
.card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.card li { font-size: 13px; line-height: 1.4; display: flex; gap: 8px; align-items: flex-start; }
.rang {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  background: var(--panel-2); color: var(--text-muted); flex-shrink: 0; margin-top: 1px;
}
.rang.A { color: var(--bad); background: rgba(248, 113, 113, 0.14); }
.rang.B { color: var(--warn); background: rgba(251, 191, 36, 0.14); }
.rang.C { color: var(--accent-2); background: rgba(79, 209, 197, 0.14); }
.card li .corr { color: var(--text-muted); }
.empty { color: var(--text-muted); font-size: 12.5px; font-style: italic; }

.comment-box {
  background: linear-gradient(135deg, rgba(79, 209, 197, 0.06), rgba(255, 90, 110, 0.05));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
}
.comment-box h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2); }
.comment-box .md { line-height: 1.65; font-size: 14px; }
.comment-box .md ul { margin: 8px 0; padding-left: 20px; }

.reference {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.reference summary {
  padding: 14px 20px; cursor: pointer; font-weight: 600; font-size: 14px;
  background: var(--panel); user-select: none;
  display: flex; align-items: center; gap: 10px;
}
.reference summary:hover { background: var(--panel-2); }
.reference summary .ref-ic { font-size: 16px; }
.reference .ref-body { padding: 4px 20px 18px; }

/* Sections structurées de la référence enseignant */
.ref-section { padding: 16px 0; border-top: 1px solid var(--border); }
.ref-section:first-child { border-top: none; }
.ref-section h5 {
  margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text); display: flex; align-items: center; gap: 8px;
}
.ref-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.ref-dot.interp { background: var(--accent-2); box-shadow: 0 0 0 3px rgba(79,209,197,0.15); }
.ref-dot.comment { background: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,110,0.15); }
.ref-intro { color: var(--text); font-weight: 600; margin: 0 0 10px; font-size: 13.5px; }
.ref-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ref-list li {
  position: relative; padding: 8px 12px 8px 30px; font-size: 13.5px; line-height: 1.5;
  color: var(--text); background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 8px;
}
.ref-list li::before {
  content: "›"; position: absolute; left: 12px; top: 7px;
  color: var(--accent-2); font-weight: 800; font-size: 14px;
}
.ref-interp .ref-list li { border-left: 3px solid rgba(79,209,197,0.5); }
.ref-prose p {
  margin: 0 0 10px; font-size: 13.5px; line-height: 1.68; color: var(--text-muted);
}
.ref-prose p:first-child { color: var(--text); }
.ref-prose p:last-child { margin-bottom: 0; }

/* ─────────── Bascule de mode (libre / QCM) ─────────── */
.mode-switch {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px;
}
.mode-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 9px 18px; border-radius: 9px; transition: all 0.15s;
}
.mode-btn:hover:not(.active):not(:disabled) { color: var(--text); }
.mode-btn.active {
  background: linear-gradient(135deg, var(--accent-2), #6ee7db);
  color: #06231f; box-shadow: 0 4px 12px rgba(79,209,197,0.25);
}
.mode-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─────────── QCM ─────────── */
.qcm-block { animation: fade 0.25s ease; margin-bottom: 20px; }
.qcm-question {
  font-size: 15.5px; font-weight: 600; margin: 0 0 4px; line-height: 1.5;
}
.qcm-question::after {
  content: attr(data-hint); display: block; font-size: 12px; font-weight: 500;
  color: var(--text-muted); margin-top: 3px;
}
.qcm-options { list-style: none; margin: 14px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.qcm-option {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel);
  transition: all 0.14s; user-select: none;
}
.qcm-option:hover { border-color: var(--accent-2); transform: translateX(2px); }
.qcm-option .qcm-check {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  border: 2px solid var(--border); display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: transparent; transition: all 0.14s;
}
.qcm-option.selected { border-color: var(--accent-2); background: rgba(79,209,197,0.07); }
.qcm-option.selected .qcm-check { background: var(--accent-2); border-color: var(--accent-2); color: #06231f; }
.qcm-option .qcm-text { flex: 1; font-size: 14px; line-height: 1.4; }
.qcm-option .qcm-letter {
  font-size: 12px; font-weight: 800; color: var(--text-muted);
  background: var(--panel-2); width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center; flex-shrink: 0;
}

/* États après validation */
.qcm-option.st-correct { border-color: rgba(52,211,153,0.6); background: rgba(52,211,153,0.1); cursor: default; }
.qcm-option.st-correct .qcm-check { background: var(--good); border-color: var(--good); color: #04231a; }
.qcm-option.st-correct .qcm-letter { color: var(--good); }
.qcm-option.st-missed { border-color: rgba(251,191,36,0.6); background: rgba(251,191,36,0.08); cursor: default; }
.qcm-option.st-missed .qcm-check { border-color: var(--warn); color: var(--warn); }
.qcm-option.st-missed .qcm-letter { color: var(--warn); }
.qcm-option.st-wrong { border-color: rgba(248,113,113,0.6); background: rgba(248,113,113,0.09); cursor: default; }
.qcm-option.st-wrong .qcm-check { background: var(--bad); border-color: var(--bad); color: #2a0b0b; }
.qcm-option.st-wrong .qcm-letter { color: var(--bad); }
.qcm-option.st-neutral { opacity: 0.7; cursor: default; }

.qcm-result { margin-top: 4px; animation: fade 0.3s ease; }
.qcm-verdict {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 20px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel);
}
.qcm-verdict.good { border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.07); }
.qcm-verdict.warn { border-color: rgba(251,191,36,0.4); background: rgba(251,191,36,0.07); }
.qcm-verdict.bad { border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.07); }
.qcm-score {
  font-size: 30px; font-weight: 800; line-height: 1; flex-shrink: 0;
}
.qcm-score small { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.qcm-verdict.good .qcm-score { color: var(--good); }
.qcm-verdict.warn .qcm-score { color: var(--warn); }
.qcm-verdict.bad .qcm-score { color: var(--bad); }
.qcm-expected { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.qcm-expected b { color: var(--text); }
.qcm-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.qcm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.qcm-legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }
.qcm-legend i.st-correct { background: var(--good); }
.qcm-legend i.st-missed { background: var(--warn); }
.qcm-legend i.st-wrong { background: var(--bad); }

/* ─────────── Lightbox ─────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9);
  display: flex; flex-direction: column; z-index: 100; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.lightbox-toolbar { display: flex; justify-content: center; gap: 8px; padding-bottom: 10px; flex: 0 0 auto; }
.lightbox-toolbar button { min-width: 48px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; font-weight: 750; }
.lightbox-stage { flex: 1 1 auto; min-height: 0; overflow: auto; display: block; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.lightbox img { display: block; max-width: none; height: auto; margin: auto; border-radius: 8px; background: #fff; touch-action: pan-x pan-y pinch-zoom; }
body.viewer-open { overflow: hidden; }

.badge-error { color: var(--bad); font-weight: 600; }

/* ─────────── Mini-progression (header) ─────────── */
.progress-mini {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-muted);
  background: var(--panel); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px;
}
.progress-mini b { color: var(--text); font-weight: 700; }
.progress-mini .pm-sep { opacity: 0.5; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* ─────────── Accueil orienté action ─────────── */
.home-kicker, .bank-welcome-kicker, .home-free-practice > span, .home-btn .hb-kicker {
  color: var(--accent-2); text-transform: uppercase; letter-spacing: .09em;
  font-size: 10.5px; font-weight: 800;
}
.hero-title { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.hero-sub { color: var(--text-muted); line-height: 1.6; margin: 0 0 22px; }

.home-actions { display: flex; flex-direction: column; gap: 12px; }
.home-btn {
  display: flex; align-items: center; gap: 16px; text-align: left;
  width: 100%; padding: 16px 18px; cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-family: inherit;
  text-decoration: none; transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.home-btn:hover { transform: translateY(-2px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.home-btn:focus-visible, .home-quick-action:focus-visible { outline: 3px solid rgba(79,209,197,.3); outline-offset: 2px; }
.home-btn--primary {
  background: linear-gradient(135deg, rgba(79,209,197,0.17), rgba(255,90,110,0.12));
  border-color: rgba(79,209,197,0.45);
}
.home-btn .hb-ic { font-size: 26px; flex-shrink: 0; width: 34px; text-align: center; }
.home-btn .hb-body { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.home-btn .hb-title { font-size: 15px; font-weight: 700; }
.home-btn .hb-desc { font-size: 12.5px; color: var(--text-muted); }
.home-btn .hb-arrow { flex: 0 0 auto; color: var(--accent-2); font-size: 22px; font-weight: 800; }
.home-btn--learning { padding-block: 20px; }
.home-btn--learning .hb-title { font-size: 18px; }
.home-btn--explore { background: transparent; }

.home-free-practice { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.home-free-practice > div { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.home-quick-action {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-soft); color: var(--text); cursor: pointer; font: inherit;
  font-size: 11.5px; font-weight: 700;
}
.home-quick-action:hover { border-color: var(--accent-2); }
.home-quick-action small { color: var(--text-muted); font-size: 10px; font-weight: 500; }

.bank-welcome {
  max-width: 680px; margin: 38px auto; padding: 28px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.bank-welcome h2 { margin: 7px 0 9px; font-size: 25px; }
.bank-welcome p { margin: 0; color: var(--text-muted); line-height: 1.6; }

/* Bandeau de progression (accueil) */
.home-progress {
  margin-top: 22px; padding: 18px; display: grid;
  grid-template-columns: repeat(3, auto) 1fr; align-items: center; gap: 22px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.hp-stat { display: flex; flex-direction: column; align-items: center; }
.hp-stat b { font-size: 22px; font-weight: 800; color: var(--accent-2); line-height: 1; }
.hp-stat span { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.hp-bar-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.hp-bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.hp-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--good));
  border-radius: 999px; transition: width 0.5s ease;
}
.hp-bar-label { font-size: 11px; color: var(--text-muted); text-align: right; }

.home-tips { margin-top: 20px; }
.home-tips summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  user-select: none; padding: 6px 0;
}
.home-tips summary:hover { color: var(--text); }
.home-tips .tips { margin-top: 8px; }

/* ─────────── Sidebar : état « déjà lu » ─────────── */
.case-item .ci-main { flex: 1; min-width: 0; }
.case-item.done { border-left: 3px solid rgba(52,211,153,0.5); }
.case-item.done .t { color: var(--text-muted); }
.ci-badge {
  font-size: 10.5px; font-weight: 800; color: var(--good);
  background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.3);
  padding: 2px 7px; border-radius: 999px; flex-shrink: 0; white-space: nowrap;
}

/* ─────────── Boucle d'engagement : « Continuer » ─────────── */
.next-actions {
  margin-top: 22px; padding: 20px 22px;
  background: linear-gradient(135deg, rgba(79,209,197,0.06), rgba(255,90,110,0.05));
  border: 1px solid var(--border); border-radius: var(--radius);
  animation: fade 0.35s ease;
}
.na-title { margin: 0 0 14px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2); }
.na-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.na-btn {
  display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 14px 16px; cursor: pointer; color: var(--text); font-family: inherit;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.na-btn:hover { transform: translateY(-2px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.na-btn--primary { border-color: rgba(255,90,110,0.4); background: rgba(255,90,110,0.08); }
.na-btn.disabled { opacity: 0.45; pointer-events: none; }
.na-btn .na-ic { font-size: 20px; flex-shrink: 0; }
.na-btn .na-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.na-btn .na-t { font-size: 14px; font-weight: 700; }
.na-btn .na-d { font-size: 12px; color: var(--text-muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
  body.bank-mode .content { grid-row: 1; }
  body.bank-mode .sidebar { grid-row: 2; }
  body.case-mode .sidebar { padding: 10px 16px; }
  body.case-mode .sidebar-head, body.case-mode .filters, body.case-mode .case-list { display: none; }
  body.case-mode .sidebar-home { margin: 0; }
  .case-num { font-size: 28px; }
  .progress-mini { display: none; }
  .home-progress { grid-template-columns: repeat(3, 1fr); }
  .home-progress .hp-bar-wrap { grid-column: 1 / -1; }
  .subscore-grid { grid-template-columns: 1fr; }
  body.home-mode .content { padding: 18px; }
}

@media (max-width: 600px) {
  .welcome-card { padding: 24px 18px; }
  .home-free-practice > div { flex-direction: column; align-items: stretch; }
  .home-quick-action { border-radius: 10px; text-align: left; }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 58px; padding: 7px max(12px, env(safe-area-inset-right)) 7px max(12px, env(safe-area-inset-left));
  }
  .brand { min-width: 0; gap: 9px; }
  .brand-logo-link { padding: 4px 8px; border-radius: 8px; }
  .brand-logo { height: 36px; }
  .brand .logo, .brand > div { display: none; }
  .brand::after { content: "ECG Lecture"; font-size: 15px; font-weight: 800; white-space: nowrap; }
  .header-actions, #health-badge { display: none; }
  .layout { min-height: calc(100dvh - 58px); }
  .content { padding: 16px 12px calc(28px + env(safe-area-inset-bottom)); }
  body.home-mode .content { padding: 14px 12px calc(28px + env(safe-area-inset-bottom)); }
  .sidebar { padding: 14px 12px calc(24px + env(safe-area-inset-bottom)); }
  body.case-mode .sidebar { padding: 8px 12px; }
  .sidebar-home, .case-item, .filter-chip { min-height: 44px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filter-chip { flex: 0 0 auto; padding-inline: 13px; }
  .bank-welcome { margin: 8px 0 16px; padding: 20px 18px; }
  .case-header h2 { font-size: 21px; }
  .case-num { font-size: 24px; }
  .case-context { margin-bottom: 14px; }
  .ecg-gallery { margin-inline: -6px; margin-bottom: 18px; }
  .ecg-gallery img { border-radius: 8px; }
  textarea { min-height: 150px; font-size: 16px; }
  .mode-switch { overflow-x: auto; }
  .mode-btn { min-height: 44px; white-space: nowrap; }
  .answer-actions { align-items: stretch; }
  .answer-actions .btn-primary { flex: 1 1 auto; justify-content: center; min-height: 48px; }
  .answer-actions .btn-ghost { min-height: 48px; }
  .next-actions { padding: 17px 14px; }
  .na-grid { grid-template-columns: 1fr; }
  .na-btn { min-height: 58px; }
  .lightbox { padding-top: max(8px, env(safe-area-inset-top)); }
  .lightbox-toolbar { justify-content: stretch; }
  .lightbox-toolbar button { flex: 1 1 auto; min-width: 0; padding-inline: 8px; }
}

/* ─────────── Version pré-alpha : badge, note & signalement ─────────── */
.prealpha-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: #fbbf24; background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.35); white-space: nowrap;
}

.prealpha-note {
  margin: 12px 0 0; padding: 10px 14px; font-size: 13px; line-height: 1.5;
  color: var(--text-muted); background: rgba(251, 191, 36, 0.06);
  border: 1px dashed rgba(251, 191, 36, 0.30); border-radius: 10px;
}
.prealpha-note strong { color: var(--text); }
.link-report {
  background: none; border: none; padding: 0; margin-left: 2px;
  color: var(--accent-2); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-report:hover { color: var(--accent); }

/* Modale de signalement */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 11, 17, 0.72); backdrop-filter: blur(3px);
}
.modal.hidden { display: none; }
.modal-card {
  position: relative; width: 100%; max-width: 520px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 24px 20px; max-height: 90vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text-muted); font-size: 14px; cursor: pointer;
}
.modal-close:hover { color: var(--text); border-color: var(--accent-2); }
.modal-card h3 { margin: 0 0 8px; font-size: 18px; }
.modal-sub { margin: 0 0 18px; font-size: 13.5px; color: var(--text-muted); line-height: 1.55; }
.modal-sub strong { color: #fbbf24; }
.modal-card label {
  display: block; margin: 12px 0 6px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-2);
}
.modal-field {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 10px; resize: vertical;
}
.modal-field:focus {
  outline: none; border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.12);
}
select.modal-field { cursor: pointer; }
.modal-context { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); font-style: italic; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-status {
  margin-top: 14px; padding: 10px 13px; font-size: 13px; line-height: 1.5;
  border-radius: 10px;
}
.modal-status.hidden { display: none; }
.modal-status.ok {
  color: var(--good); background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.35);
}
.modal-status.warn {
  color: #fbbf24; background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.modal-status a { color: var(--accent-2); font-weight: 700; }

@media (max-width: 640px) {
  .prealpha-badge { display: none; }   /* le header reste lisible sur mobile */
}
