/* ---------- Base ---------- */
* { box-sizing: border-box; }
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #3b82f6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --warn: #f59e0b;
  --ok: #10b981;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 10px 20px rgba(16,24,40,.08);
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 0 .25em; border-radius: 4px; font-size: .95em; }

/* ---------- Layout ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: .95rem; }
.nav a:hover { color: var(--text); }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}
/* Session pages (Lab) : on réclame toute la largeur, les Labs ont besoin de l'espace. */
body.session-wide .main {
  max-width: min(1720px, calc(100vw - 24px));
  padding: .6rem .8rem 1rem;
}
.footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.small { font-size: .85rem; }
.muted { color: var(--muted); }

/* ---------- Components ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
}
.card.wide { max-width: none; }
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

.hero {
  padding: 2rem 1rem;
  text-align: center;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), #fafbff);
  margin-bottom: 1.5rem;
}
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 0 0 .5rem; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 60ch; margin: 0 auto; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 1.5rem;
}

.domain-card {
  display: flex; flex-direction: column;
  gap: .4rem;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: transform .1s, box-shadow .1s;
}
.domain-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.domain-card .badge {
  align-self: flex-start;
  background: var(--accent); color: white;
  padding: 2px 8px; border-radius: 6px;
  font-size: .75rem; letter-spacing: .05em;
}
.domain-card .cta { margin-top: auto; color: var(--accent); font-weight: 600; }

/* ---------- Forms ---------- */
.stacked-form label, .inline-form label { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.stacked-form input[type=text],
.stacked-form input[type=email],
.stacked-form input[type=password],
.stacked-form input[type=number],
.stacked-form select,
.stacked-form textarea,
.inline-form input, .inline-form select {
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
}
.stacked-form textarea { min-height: 80px; resize: vertical; }
.inline-form { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
legend { padding: 0 .5rem; font-weight: 600; }
.checkbox { flex-direction: row !important; align-items: center; gap: .5rem; }
.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem; border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px; cursor: pointer;
  color: var(--text); font: inherit; text-decoration: none;
  transition: background .1s, border-color .1s;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Banners ---------- */
.banner {
  padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.banner.info { background: #eff6ff; border-color: #bfdbfe; }
.banner.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.banner.neutral { background: #f9fafb; }

.rgpd-banner {
  margin-top: 2rem; padding: 1rem; border-radius: var(--radius);
  background: #fffbeb; border: 1px solid #fde68a;
  font-size: .9rem;
}

/* ---------- Pills / status ---------- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #e5e7eb; color: var(--text);
  font-size: .8rem;
  margin-right: .3rem;
}
.pill.phase-discovery { background: #dbeafe; color: #1e3a8a; }
.pill.phase-coaching  { background: #dcfce7; color: #065f46; }
.pill.phase-done      { background: #e0e7ff; color: #3730a3; }
.pill.warn            { background: #fef3c7; color: #92400e; }

/* ---------- Session layout ---------- */
.session-head {
  display: flex; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.2rem;
  background: var(--surface); border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.session-head h1 { margin: 0; font-size: 1.4rem; }

/* Barre de session compacte pour les pages Lab (Excel, Python, SQL, Git...).
   Un clic sur ⇕ bascule body.chrome-collapsed qui cache toute la zone extra. */
.session-head-slim {
  padding: .4rem .7rem;
  margin-bottom: .4rem;
  align-items: center;
  box-shadow: none;
  border-left-width: 3px;
}
.session-head-slim .session-head-left { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-width: 0; }
.session-head-slim .session-title { font-size: 1rem; }
.session-head-slim .session-head-right { display: flex; gap: .3rem; align-items: center; }
.session-chrome-toggle { padding: .15rem .5rem !important; font-size: .85rem !important; }
.session-chrome-extra { display: block; }
body.chrome-collapsed .session-chrome-extra { display: none; }

.session-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .session-layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .english-layout { grid-template-columns: 340px minmax(0, 1fr); }
}

.chat-col { display: flex; flex-direction: column; min-height: 60vh; }
.chat-log {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 70vh;
  display: flex; flex-direction: column; gap: .8rem;
}

.msg {
  border-radius: 12px;
  padding: .7rem 1rem;
  max-width: 85%;
  box-shadow: var(--shadow);
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-user { background: #eff6ff; align-self: flex-end; border: 1px solid #bfdbfe; }
.msg-assistant { background: #ecfdf5; align-self: flex-start; border: 1px solid #a7f3d0; }
.msg-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.msg-body { white-space: normal; }
.msg-body table { border-collapse: collapse; margin: .4rem 0; font-size: .9rem; }
.msg-body th, .msg-body td { border: 1px solid var(--border); padding: 4px 8px; }
.msg-body th { background: rgba(0,0,0,.04); }
.msg-body pre { background: #0f172a; color: #e2e8f0; padding: .6rem .8rem; border-radius: 8px; overflow-x: auto; }
.msg-body code { background: rgba(0,0,0,.06); }
.msg-body pre code { background: none; color: inherit; }
.msg-actions { display: flex; gap: .3rem; margin-top: .4rem; opacity: .7; flex-wrap: wrap; }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions .btn.small { padding: .2rem .5rem; font-size: .75rem; }
.msg-actions .btn.active { background: #1e6091; color: #fff; border-color: #1e6091; }
.msg-translation {
  margin-top: .5rem;
  padding: .5rem .7rem;
  background: rgba(30, 96, 145, 0.06);
  border-left: 3px solid #1e6091;
  border-radius: 4px;
  font-size: .85rem;
  color: #334155;
  font-style: italic;
}

.chat-form {
  margin-top: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem;
}
.chat-form textarea {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}
.chat-actions { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; }
.spinner.htmx-indicator { display: none; }
.spinner.htmx-request { display: inline-block; }

/* ---------- Side widgets ---------- */
.side-col { display: flex; flex-direction: column; gap: 1rem; }
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
}
.widget > summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.widget[open] > summary { margin-bottom: .6rem; }
.feature-fab { background: #fffbeb; border-color: #fde68a; }

.assets { list-style: none; padding: 0; margin: 0; }
.assets li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.assets li:last-child { border: none; }

/* ---------- Excel Lab (full-screen workspace) ---------- */
.lab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: .6rem;
  height: calc(100vh - 140px);
  min-height: 600px;
  margin-top: .4rem;
}
/* Quand la chrome est pliée on regagne sa hauteur. */
body.chrome-collapsed .lab-layout { height: calc(100vh - 80px); }

/* Le panneau Quest empilé sous la grille : rendu collapsible via un header clickable. */
.lab-quest { position: relative; }
.lab-quest.collapsed > *:not(.lab-quest-toggle) { display: none; }
.lab-quest-toggle {
  position: absolute; top: .3rem; right: .4rem;
  padding: .1rem .4rem; font-size: .75rem;
  background: rgba(255,255,255,.8); border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; z-index: 2;
}

/* Splitter drag-to-resize entre la grille et le panneau quêtes/mémo/charts. */
.lab-splitter {
  height: 6px;
  cursor: row-resize;
  background: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 50%, #f1f5f9 100%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: background-color .15s;
  position: relative;
}
.lab-splitter::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); width: 40px; height: 2px;
  background: #94a3b8; border-radius: 2px;
}
.lab-splitter:hover, .lab-splitter.dragging {
  background: #93c5fd;
}
.lab-bottom {
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 55%;  /* valeur par défaut, pilotée par JS via --lab-bottom-h */
  height: var(--lab-bottom-h, 220px);
}
.lab-bottom:empty { display: none; }
.lab-layout.chat-collapsed { grid-template-columns: minmax(0, 1fr) 44px; }
.lab-layout.chat-collapsed .lab-chat-log,
.lab-layout.chat-collapsed .chat-form,
.lab-layout.chat-collapsed .lab-extras { display: none; }

/* Nouvelle UX : chat caché, FAB pour rouvrir */
.lab-layout.chat-hidden { grid-template-columns: minmax(0, 1fr); }
.lab-layout.chat-hidden .lab-chat { display: none; }

.chat-fab {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; align-items: center; gap: .4rem;
  padding: .7rem 1.1rem;
  background: var(--primary); color: white;
  border: none; border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  cursor: pointer; font: inherit; font-size: .95rem;
  z-index: 4000;
  transition: transform .12s, box-shadow .12s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.chat-fab .chat-fab-label { font-weight: 500; }
@media (max-width: 600px) {
  .chat-fab { right: 12px; bottom: 12px; padding: .6rem .9rem; }
  .chat-fab .chat-fab-label { display: none; }
}

.lab-main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lab-toolbar {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.lab-toolbar-inner { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.lab-toolbar-inner .sep { width: 1px; height: 20px; background: var(--border); margin: 0 .3rem; }
.lab-formula-bar {
  display: flex; gap: .5rem; align-items: center; padding: .4rem .6rem;
  border-bottom: 1px solid var(--border); background: #fff;
}
.lab-formula-bar #lab-cell-ref {
  min-width: 80px; font-family: ui-monospace, monospace;
}
.lab-formula-bar input {
  flex: 1; padding: .3rem .5rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
  font-family: ui-monospace, monospace; font-size: .9rem;
}

.lab-host {
  flex: 1; overflow: auto;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.lab-grid {
  border-collapse: separate; border-spacing: 0;
  font-size: .88rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.lab-grid thead th {
  position: sticky; top: 0; z-index: 3;
  background: #f1f5f9; border: 1px solid var(--border);
  min-width: 88px; text-align: center; font-weight: 600;
}
.lab-grid thead th.corner {
  left: 0; z-index: 4; min-width: 44px;
  background: #e2e8f0;
}
.lab-grid tbody th {
  position: sticky; left: 0; z-index: 2;
  background: #f1f5f9; border: 1px solid var(--border);
  min-width: 44px; text-align: center; color: var(--muted); font-weight: 500;
}
.lab-grid td {
  border: 1px solid #e5e7eb;
  min-width: 88px; height: 22px; padding: 1px 4px;
  white-space: nowrap;
  content-visibility: auto;
  contain-intrinsic-size: 22px 88px;
}
.lab-grid td:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: #fff7ed;
  z-index: 1;
}
.lab-grid td.formula { background: #eef2ff; }
.lab-grid td.cell-error { background: #fef2f2; color: var(--danger); }

.lab-tabs {
  display: flex; gap: .25rem; padding: .3rem .5rem;
  border-top: 1px solid var(--border); background: #f8fafc;
  overflow-x: auto;
}
.lab-tab {
  padding: .25rem .7rem; border: 1px solid var(--border);
  background: #fff; border-radius: 6px 6px 0 0;
  font: inherit; font-size: .85rem; cursor: pointer;
  white-space: nowrap;
}
.lab-tab:hover { background: #eff6ff; }
.lab-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.lab-tab.add { color: var(--muted); padding: .25rem .6rem; }

.lab-status {
  padding: .35rem .6rem;
  border-top: 1px solid var(--border);
  background: #f9fafb;
  font-size: .78rem; color: var(--muted);
}

.lab-charts {
  padding: .5rem .8rem;
  border-top: 1px solid var(--border);
  background: #fafafa;
  max-height: 40vh; overflow-y: auto;
}
.lab-memo {
  padding: .5rem .8rem;
  border-top: 1px solid var(--border);
  background: #eff6ff;
  max-height: 40vh; overflow-y: auto;
}
.lab-memo h4 { color: #1e3a8a; }
.lab-memo-card {
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: .5rem .8rem;
  margin-bottom: .5rem;
}
.lab-memo-card summary { cursor: pointer; padding: .2rem 0; }
.lab-memo-body p { margin: .4rem 0; }
.lab-memo-body pre {
  background: #0f172a; color: #e2e8f0;
  padding: .5rem .7rem; border-radius: 6px;
  font-size: .82rem; overflow-x: auto;
}
.lab-memo-body ol, .lab-memo-body ul { padding-left: 1.3rem; }
.lab-memo-body kbd {
  background: #f1f5f9; border: 1px solid #cbd5e1;
  border-radius: 4px; padding: 0 .3em; font-size: .85em;
}
.lab-chart {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .7rem; margin-bottom: .6rem;
}
.lab-chart header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .9rem; font-weight: 600; margin-bottom: .3rem;
}

.lab-chat {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.lab-chat-head {
  padding: .5rem .7rem;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.lab-chat-log {
  flex: 1; max-height: none;
  border: none; border-radius: 0;
}
.lab-chat .chat-form { border: none; border-top: 1px solid var(--border); border-radius: 0; }
.lab-extras { margin: .4rem .6rem; padding: .4rem .5rem; border: 1px dashed var(--border); border-radius: 6px; }
.lab-subwidget { margin-top: .5rem; padding: .4rem .6rem; background: #f9fafb; border-radius: 6px; }

/* Modal */
.lab-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.lab-modal {
  background: var(--surface); border-radius: 12px;
  padding: 1.2rem 1.4rem; width: min(480px, 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.lab-modal label { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .7rem; }
.lab-modal select, .lab-modal input[type=text] {
  padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
.lab-modal .actions { margin-top: .6rem; }

/* On mobile, stack and hide the chat by default */
@media (max-width: 900px) {
  .lab-layout { grid-template-columns: 1fr; height: auto; }
  .lab-main { height: 70vh; }
  .lab-chat { height: 400px; }
}

/* ---------- Excel grid (legacy sidebar, fallback) ---------- */
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  background: var(--surface);
}
.grid-table th, .grid-table td {
  border: 1px solid var(--border);
  min-width: 60px;
  height: 30px;
  padding: 2px 4px;
}
.grid-table th {
  background: #f1f5f9; font-weight: 600;
  text-align: center;
  position: sticky; top: 0;
}
.grid-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--primary);
  background: #fff7ed;
}
.grid-table td.formula { background: #eef2ff; }
.grid-table td.error { background: #fef2f2; color: var(--danger); }

#grid-host {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 380px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.grid-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }

.cefr-list, .theme-list { padding-left: 1.2rem; }
.cefr-list li code { font-weight: 700; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl thead th { background: #f9fafb; font-weight: 600; }
.tbl.compact { font-size: .85rem; }

/* ---------- KPIs ---------- */
.kpi-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1.2rem;
  text-align: center;
  min-width: 140px;
}
.kpi .kpi-n { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.kpi span { color: var(--muted); font-size: .9rem; }

.requests { list-style: none; padding: 0; margin: 0; }
.requests li {
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .6rem;
  background: #fafafa;
}

.profile-panel { margin-bottom: 1rem; padding: .6rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.session-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.inline-details { display: inline-block; }

/* ---------- Prose (legal/rgpd pages) ---------- */
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 1.5rem; }
.prose p, .prose li { max-width: 72ch; }

/* ---------- Triage form (home) ---------- */
.triage-form {
  display: flex; gap: .5rem; margin: 1.2rem auto 0;
  max-width: 720px;
  flex-wrap: wrap;
}
.triage-form input[type=text] {
  flex: 1; min-width: 260px;
  padding: .9rem 1.1rem;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.triage-form input[type=text]:focus { outline: 0; border-color: var(--primary); }
.triage-form button { padding: .9rem 1.3rem; font-size: 1.05rem; }

/* ---------- Families (home) ---------- */
.families { margin-top: 2rem; }
.families-title { font-size: 1rem; color: var(--muted); font-weight: 500; margin: 0 0 .6rem; text-align: center; }
.family-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.family-card {
  display: flex; gap: 1rem; align-items: stretch;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
.family-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.family-emoji { font-size: 2.3rem; line-height: 1; align-self: center; }
.family-body h3 { margin: 0 0 .2rem; }
.family-body p { margin: 0 0 .4rem; color: var(--muted); font-size: .95rem; }

.family-inner-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-top: 1.5rem;
}
.formation-card { border-left: 4px solid var(--accent); }

.skills-strip {
  margin-top: 1.5rem;
  padding: .7rem 1rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-size: .95rem;
}
.foot-details { margin-bottom: 1rem; }
.foot-details summary { cursor: pointer; }

/* ---------- Self-study (cours libre) ---------- */
.lesson-index { padding-left: 1.5rem; }
.lesson-index li { margin-bottom: .7rem; }
.lesson-item { margin-bottom: 1rem; }
.lesson-item .attempt-box {
  width: 100%; padding: .6rem .8rem;
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
  background: #fafafa;
}
.hints-list { margin-top: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.hint { background: #fef9c3; padding: .5rem .7rem; border-radius: 6px; border-left: 3px solid #eab308; }
.hint.hint-hidden { display: none; }
.answer-box { margin-top: .8rem; }
.answer-box summary { cursor: pointer; display: inline-flex; }
.answer-box .answer-content {
  margin-top: .6rem; padding: .8rem 1rem;
  background: #ecfdf5; border-left: 3px solid #10b981;
  border-radius: 6px;
}

/* ---------- Flashcards ---------- */
.flashcards { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.flashcard {
  position: relative;
  min-height: 100px;
  padding: .8rem;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  transition: transform .18s;
}
.flashcard .fc-back { display: none; font-weight: 500; }
.flashcard.flipped { background: #ecfdf5; }
.flashcard.flipped .fc-front { display: none; }
.flashcard.flipped .fc-back { display: block; }

/* ---------- Code Lab (Python / WASM sandbox) ---------- */
.code-lab { padding: 0; }
.cl-cells { padding: .6rem; display: flex; flex-direction: column; gap: .8rem; overflow-y: auto; flex: 1; }
.cl-cell {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden;
}
.cl-cell-head {
  display: flex; gap: .4rem; align-items: center;
  padding: .3rem .5rem; background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.cl-cell-label { font-family: ui-monospace,monospace; color: #0f766e; font-size: .85rem; }
.cl-cell-editor .CodeMirror {
  height: auto; min-height: 60px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .9rem;
}
.cl-cell-output {
  padding: .5rem .7rem; background: #0f172a; color: #e2e8f0;
  font-family: ui-monospace, monospace; font-size: .85rem;
  white-space: pre-wrap; border-top: 1px solid var(--border);
  max-height: 300px; overflow-y: auto;
}

/* ---------- Git Lab (terminal simulé) ---------- */
.git-lab-main { padding: 0; display: flex; flex-direction: column; }
.git-terminal {
  flex: 1;
  background: #0f172a; color: #e2e8f0;
  padding: .7rem .9rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  font-size: .88rem;
  line-height: 1.45;
  min-height: 320px;
}
.gt-line { white-space: pre-wrap; word-break: break-word; }
.git-prompt {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .7rem;
  background: #0f172a;
  border-top: 1px solid #1e293b;
}
.git-prompt-label {
  color: #10b981;
  font-family: ui-monospace, monospace;
  font-size: .85rem;
  white-space: nowrap;
}
.git-input {
  flex: 1;
  background: transparent; color: #e2e8f0;
  border: none; outline: none;
  font-family: ui-monospace, monospace;
  font-size: 1rem; /* ≥16px prevents iOS auto-zoom */
  padding: .2rem 0;
}
.git-input:focus { outline: none; }

/* ---------- SQL Lab extras ---------- */
.sql-lab-body { display: grid; grid-template-columns: 220px 1fr; gap: .6rem; flex: 1; min-height: 0; }
@media (max-width: 900px) { .sql-lab-body { grid-template-columns: 1fr; } }
.sql-schema {
  background: #f8fafc; border-right: 1px solid var(--border);
  padding: .6rem .7rem; overflow-y: auto;
}
.sql-schema h4 { margin: .2rem 0 .4rem; font-size: .95rem; }
.sql-schema-item { margin-bottom: .3rem; }
.sql-schema-item pre {
  background: #0f172a; color: #bae6fd;
  padding: .4rem .5rem; border-radius: 6px;
  font-size: .75rem; white-space: pre-wrap;
}
.sql-cells { flex: 1; }
.sql-results {
  padding: .5rem .7rem; background: #fafafa;
  border-top: 1px solid var(--border);
  max-height: 300px; overflow: auto;
}
.sql-table { font-size: .85rem; }
.sql-table th, .sql-table td { padding: .25rem .5rem; }

/* ---------- Notebook (OneNote-like) ---------- */
.notebook-header { margin-bottom: .5rem; }
.notebook-layout {
  display: grid;
  grid-template-columns: 220px 280px 1fr;
  gap: .8rem;
  min-height: 70vh;
  margin-top: .6rem;
}
@media (max-width: 1000px) {
  .notebook-layout { grid-template-columns: 1fr; }
  .nb-sections, .nb-pages { max-height: 30vh; overflow-y: auto; }
}
.nb-sections, .nb-pages, .nb-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .8rem;
  overflow-y: auto;
}
.nb-sections h3, .nb-pages h3 { margin: 0 0 .5rem; font-size: 1rem; }
.nb-section-list, .nb-page-list { list-style: none; padding: 0; margin: 0 0 .5rem; }
.nb-section { border-left: 4px solid var(--accent, var(--border)); margin-bottom: .2rem; }
.nb-section-link {
  display: flex; gap: .4rem; align-items: center;
  padding: .4rem .6rem; border-radius: 6px;
  text-decoration: none; color: var(--text);
}
.nb-section.active .nb-section-link { background: #eff6ff; font-weight: 600; }
.nb-section:hover { background: rgba(0,0,0,.02); }
.nb-page { margin-bottom: .2rem; }
.nb-page a {
  display: block; padding: .4rem .6rem; border-radius: 6px;
  text-decoration: none; color: var(--text);
  border: 1px solid transparent;
}
.nb-page a:hover { background: #f8fafc; }
.nb-page.active a { background: #eff6ff; border-color: #bfdbfe; }
.nb-add { margin-top: .5rem; }

.nb-editor { display: flex; flex-direction: column; }
.nb-editor-toolbar {
  display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
  padding-bottom: .5rem; margin-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.nb-edit-form { gap: .5rem; }
.nb-edit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .8rem;
}
@media (max-width: 900px) { .nb-edit-grid { grid-template-columns: 1fr; } }
.nb-preview {
  padding: .6rem .8rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 60vh; overflow-y: auto;
  font-size: .9rem;
}
.nb-preview h1 { font-size: 1.2rem; }
.nb-preview h2 { font-size: 1.05rem; }
.nb-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.nb-toast {
  position: fixed; bottom: 20px; right: 20px;
  background: #111827; color: #fff;
  padding: .6rem 1rem; border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 5000;
}
.nb-toast.show { opacity: 1; }

/* ---------- Quests ---------- */
.lab-quest {
  padding: .6rem .8rem;
  border-top: 1px solid var(--border);
  background: #fef9c3;
  max-height: 60vh; overflow-y: auto;
}
.lab-quest h4 { margin: .2rem 0 .5rem; color: #854d0e; }
.quest-stats { display: flex; gap: .3rem; margin-bottom: .6rem; flex-wrap: wrap; }
.quest-list { display: flex; flex-direction: column; gap: .5rem; }
.quest-card {
  background: #fff; border: 1px solid #fde68a; border-radius: 10px;
  padding: .6rem .8rem; cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.quest-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.quest-card.finished { opacity: .75; background: #f0fdf4; border-color: #86efac; }
.quest-card.locked { opacity: .55; cursor: not-allowed; background: #f8fafc; border-color: #cbd5e1; }
.quest-card.locked:hover { transform: none; box-shadow: none; }
.quest-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: .8rem; }
.quest-card-head { display: flex; justify-content: space-between; align-items: start; gap: .5rem; margin-bottom: .3rem; }

/* ---------- Team dashboard ---------- */
.team-domain-bars { display: flex; flex-direction: column; gap: .25rem; margin: .3rem 0; }
.team-dom-row { display: grid; grid-template-columns: 100px 1fr 40px; gap: .5rem; align-items: center; }
.team-dom-label { font-size: .85rem; font-weight: 500; }
.team-dom-bar {
  background: #f1f5f9; height: 14px; border-radius: 7px; overflow: hidden;
}
.team-dom-bar > div {
  height: 100%; background: linear-gradient(90deg, #3b82f6, #10b981);
}

/* ---------- Quest ribbon (home) ---------- */
.quest-ribbon {
  display: grid; grid-template-columns: 120px 1fr; gap: .8rem; align-items: center;
  padding: .5rem .4rem; border-left: 4px solid var(--accent); margin-bottom: .4rem;
}
@media (max-width: 600px) { .quest-ribbon { grid-template-columns: 1fr; } }
.quest-ribbon-label { font-size: .95rem; }
.quest-ribbon-path {
  display: flex; align-items: center; gap: .2rem; overflow-x: auto; padding: .2rem 0;
}
.qr-node {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  min-width: 110px; max-width: 150px;
  padding: .4rem .3rem;
  border: 2px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text);
  text-decoration: none; text-align: center; font-size: .78rem;
  transition: transform .1s;
}
.qr-node:hover { transform: translateY(-2px); text-decoration: none; }
.qr-node.done { background: #dcfce7; border-color: #86efac; color: #065f46; }
.qr-node.progress { background: #fef3c7; border-color: #fde047; }
.qr-node.locked { opacity: .55; cursor: not-allowed; background: #f1f5f9; border-color: #cbd5e1; }
.qr-node.locked:hover { transform: none; }
.qr-node-icon {
  width: 28px; height: 28px; line-height: 28px;
  border-radius: 50%;
  background: var(--accent); color: white; font-weight: 700;
}
.qr-node.done .qr-node-icon { background: #10b981; }
.qr-node.locked .qr-node-icon { background: #94a3b8; }
.qr-node-title { font-size: .78rem; font-weight: 500; line-height: 1.2; }
.qr-node-progress { font-size: .7rem; color: var(--muted); }
.qr-connector {
  flex: 0 0 24px; height: 2px;
  background: repeating-linear-gradient(90deg, var(--border) 0 6px, transparent 6px 10px);
}
.quest-head { display: flex; gap: .3rem; align-items: baseline; margin-bottom: .2rem; }
.quest-progress {
  height: 6px; background: #fef3c7; border-radius: 3px; margin: .4rem 0 .3rem;
  overflow: hidden;
}
.quest-progress-bar { height: 100%; background: linear-gradient(90deg, #f59e0b, #10b981); transition: width .3s; }

.quest-head-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: .4rem; padding: .4rem .6rem;
  background: #1e293b; color: #fff; border-radius: 6px; margin-top: .8rem;
}
.quest-step {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem 1rem; margin-top: .6rem;
}
.quest-step.step-done { border-left: 4px solid #10b981; }
.quest-instruction { margin: .5rem 0; }
.quest-hints { margin: .6rem 0; padding: .5rem; background: #fef9c3; border-radius: 8px; }
.quest-hint { padding: .3rem .5rem; background: #fff; border-radius: 6px; margin-top: .3rem; }
.quest-hint.hidden { display: none; }
.quest-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.quest-feedback { margin-top: .5rem; }
.quest-done { text-align: center; background: #f0fdf4; border-color: #86efac; }

/* ---------- Content Blocks ---------- */
.cb { margin: .6rem 0; }
.cb-callout {
  display: flex; gap: .6rem;
  padding: .6rem .9rem; border-radius: 10px;
  border-left: 4px solid var(--muted);
  background: #f9fafb;
}
.cb-callout .cb-icon { font-size: 1.3rem; line-height: 1.2; }
.cb-tone-info     { border-color: #3b82f6; background: #eff6ff; }
.cb-tone-tip      { border-color: #eab308; background: #fef9c3; }
.cb-tone-success  { border-color: #10b981; background: #ecfdf5; }
.cb-tone-warn     { border-color: #f59e0b; background: #fff7ed; }
.cb-tone-pitfall  { border-color: #ef4444; background: #fef2f2; }
.cb-tone-quote    { border-color: #64748b; background: #f1f5f9; font-style: italic; }

.cb-table { width: 100%; border-collapse: collapse; margin: .6rem 0; }
.cb-table th, .cb-table td { border: 1px solid var(--border); padding: .35rem .6rem; text-align: left; }
.cb-table th { background: #f1f5f9; }
.cb-table caption { caption-side: bottom; color: var(--muted); font-size: .9rem; padding-top: .3rem; }

.cb-code pre { background: #0f172a; color: #e2e8f0; padding: .7rem 1rem; border-radius: 8px; overflow-x: auto; }
.cb-code .cb-caption { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }

.cb-diagram .mermaid, .cb-diagram pre {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem; overflow-x: auto;
}
.cb-chart figcaption, .cb-image figcaption, .cb-audio figcaption,
.cb-video figcaption, .cb-animation figcaption {
  font-size: .85rem; color: var(--muted); margin-top: .2rem;
}
.cb-image img { max-width: 100%; height: auto; border-radius: 8px; }

.cb-quiz { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: .8rem 1rem; }
.cb-quiz-choices { display: flex; flex-direction: column; gap: .3rem; margin: .5rem 0; }
.cb-choice { display: flex; gap: .5rem; padding: .3rem .5rem; border-radius: 6px; cursor: pointer; }
.cb-choice:hover { background: rgba(0,0,0,.04); }
.cb-choice.correct { background: #dcfce7; }
.cb-choice.wrong { background: #fee2e2; }
.cb-quiz-feedback { margin-top: .4rem; padding: .4rem .6rem; background: rgba(255,255,255,.7); border-radius: 6px; }

.cb-divider { border: 0; border-top: 1px solid var(--border); }
.cb-divider-spaced { margin: 1.5rem 0; }
.cb-divider-heavy { border-top-width: 3px; }

.cb-math-display { display: block; text-align: center; margin: .6rem 0; }

/* ---------- Voice controls ---------- */
.voice-controls { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.voice-controls .btn.active { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
#vl-mic.active { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.vl-utterance {
  background: #fff; border: 1px solid #bae6fd; border-radius: 8px;
  padding: .4rem .6rem; margin-bottom: .3rem;
}
.vl-utterance .vl-text { font-family: ui-monospace, monospace; font-size: .92rem; }

/* ---------- Anonymisation prompt ---------- */
.anonymize-card {
  background: #fff7ed;
  border: 1px solid #fdba74;
  padding: .8rem 1rem;
  border-radius: 10px;
  margin: .8rem 0;
}
.anonymize-card ul { margin: .5rem 0; padding-left: 1.2rem; }
.anonymize-card code { background: rgba(0,0,0,.05); }

/* ---------- Demo / sandbox ---------- */
.demo-ribbon {
  background: #fef9c3;
  border: 1px solid #fde68a;
  color: #854d0e;
  padding: .5rem .8rem;
  border-radius: 8px;
  display: flex; justify-content: space-between; gap: .5rem;
  margin-bottom: .8rem;
  font-size: .9rem;
}

/* ---------- Hamburger nav ---------- */
.nav-hamburger {
  display: none;
  flex-direction: column; justify-content: space-between;
  width: 28px; height: 20px;
  padding: 0; border: none; background: transparent; cursor: pointer;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block; width: 100%; height: 2px;
  background: var(--text); border-radius: 2px;
  transform-origin: center;
  transition: transform .22s ease, opacity .15s ease;
}
/* Animate to X when open */
.nav-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.nav-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
@media (max-width: 768px) {
  .nav-hamburger { display: flex; }
  .nav {
    display: none;
    flex-direction: column;
    position: absolute; top: 56px; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .6rem 1rem 1rem;
    gap: .8rem;
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }
  .nav.open { display: flex; }
  .topbar { position: relative; }
}

/* ---------- Mobile Lab / Coach tab switcher ---------- */
.mobile-lab-tabs {
  display: none;
}
@media (max-width: 900px) {
  .mobile-lab-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
  }
  .mobile-lab-tab {
    flex: 1; padding: .55rem .5rem;
    border: none; background: transparent;
    font: inherit; font-size: .9rem; font-weight: 500;
    color: var(--muted); cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px; transition: color .12s, border-color .12s;
  }
  .mobile-lab-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
  /* Show/hide panels via JS-toggled class */
  .lab-layout.show-lab .lab-chat { display: none !important; }
  .lab-layout.show-chat .lab-main { display: none !important; }
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 600px) {
  .main { padding: .8rem .6rem 2rem; }
  .topbar { padding: .6rem .8rem; }
  .nav { gap: .6rem; font-size: .85rem; }
  .msg { max-width: 95%; }
  .session-head h1 { font-size: 1.1rem; }
  .kpi { flex: 1; min-width: 120px; }
  .row2 { grid-template-columns: 1fr; }
  .lab-main { height: 60vh; }
  .lab-chat { height: auto; min-height: 300px; }

  /* Generic sessions: collapse side-col exercises panel by default, ensure it's reachable */
  .side-col { order: 2; }
  .chat-col { order: 1; }

  /* Comfortable touch targets */
  .btn { min-height: 38px; }
  .mobile-lab-tab { min-height: 44px; }

  /* Exercises panel: full-width inputs on mobile */
  .el-input { width: 100% !important; }

  /* Quest cards single column on small screens */
  .quest-card { padding: .6rem .8rem; }
  .quest-steps-list { padding-left: .8rem; }

  /* Admin: ensure KPI cards wrap tightly */
  .kpi { min-width: 100px; }
}

/* ---------- Admin dashboard tabs ---------- */
.admin-tabs {
  display: flex; gap: .2rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}
.admin-tab {
  padding: .5rem 1rem;
  border: none; background: transparent;
  color: var(--muted);
  font: inherit; font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .12s, border-color .12s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  color: #1e6091;
  border-bottom-color: #1e6091;
}
.admin-tab .pill { margin-left: .3rem; font-size: .7rem; padding: 0 .4rem; }
.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }
.tbl-scroll {
  max-height: 520px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
}
.tbl-scroll table { margin: 0; }
.tbl-scroll thead th {
  position: sticky; top: 0; background: #f8fafc; z-index: 1;
  border-bottom: 1px solid var(--border);
}

/* ---------- English Lab (full-width layout, same pattern as Excel) ---------- */

/* Level bar at top of lab-main */
.el-level-bar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .5rem .8rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.el-level-btns { display: flex; gap: .3rem; flex-wrap: wrap; }
.el-level-btn {
  padding: .25rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: all .12s;
}
.el-level-btn:hover { border-color: #0369a1; color: #0369a1; }
.el-level-btn.active { background: #0369a1; border-color: #0369a1; color: #fff; }

.el-theme-select {
  flex: 1; min-width: 160px; max-width: 240px;
  padding: .28rem .5rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: .85rem; background: var(--surface);
}
.el-tab-toggle {
  margin-left: auto;
  padding: .28rem .7rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: .85rem;
  transition: all .12s;
}
.el-tab-toggle:hover { border-color: #0369a1; color: #0369a1; }

/* ── Exercises panel (standalone, always visible) ──────────────────────── */
.ex-panel {
  border-top: 2px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.ex-panel-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .45rem .8rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.ex-panel-title {
  font-weight: 600; font-size: .85rem; white-space: nowrap;
  color: var(--text); flex-shrink: 0;
}
.ex-panel-body {
  flex: 1; overflow-y: auto; padding: .8rem 1rem;
  max-height: 380px;
  -webkit-overflow-scrolling: touch;
}

/* Exercise sets picker bar (inside ex-panel-head) */
.ex-sets-bar {
  display: flex; align-items: center; gap: .3rem; flex-wrap: wrap;
  flex: 1;
}
.el-set-btn {
  padding: .3rem .75rem;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: .82rem; white-space: nowrap;
  transition: all .12s; line-height: 1.3;
}
.el-set-btn:hover { border-color: #0369a1; color: #0369a1; background: #f0f9ff; }
.el-set-btn.active {
  background: #0369a1; border-color: #0369a1;
  color: #fff; font-weight: 600;
}
.el-badge {
  display: inline-block;
  padding: 0 .3rem;
  background: rgba(255,255,255,.25); color: inherit;
  border-radius: 3px; font-size: .72rem; font-weight: 700;
  margin-right: .25rem;
}
.el-set-btn:not(.active) .el-badge {
  background: #e0f2fe; color: #0369a1;
}

/* Written + voice panels inside lab-main */
.el-written, .el-voice {
  flex: 1; overflow-y: auto; padding: 1rem 1.2rem;
}

/* Welcome state */
.el-welcome { color: var(--muted); padding: 2rem; text-align: center; }
.el-welcome p { margin: .4rem 0; }

/* Set header inside exercise panel */
.el-set-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.el-set-title { font-weight: 700; font-size: 1.05rem; }
.el-set-score { font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.el-score-bar {
  display: inline-block; width: 80px; height: 6px;
  background: var(--border); border-radius: 3px; overflow: hidden;
}
.el-score-bar span {
  display: block; height: 100%;
  background: #10b981; border-radius: 3px;
  transition: width .3s;
}

/* Individual exercises */
.el-exercises-list { display: flex; flex-direction: column; gap: .8rem; }
.el-exercise {
  padding: .9rem 1rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface);
  transition: border-color .15s;
}
.el-exercise.el-correct { border-color: #10b981; background: #f0fdf4; }
.el-exercise.el-incorrect { border-color: #dc2626; background: #fef2f2; }

.el-ex-meta { margin-bottom: .4rem; }
.el-type-badge {
  display: inline-block;
  padding: 0 .5rem;
  background: #f1f5f9; border-radius: 4px;
  font-size: .75rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.el-prompt {
  font-size: 1rem; font-weight: 500; color: var(--text);
  margin-bottom: .6rem; white-space: pre-wrap;
}
.el-input {
  width: 100%; padding: .5rem .65rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 1rem; background: var(--surface);
  transition: border-color .12s;
}
.el-input:focus { outline: none; border-color: #0369a1; box-shadow: 0 0 0 2px rgba(3,105,161,.1); }
.el-input:disabled { background: #f1f5f9; color: var(--muted); }

.el-feedback { margin-top: .5rem; font-size: .88rem; }
.el-ok { color: #10b981; font-weight: 600; }
.el-wrong { color: #dc2626; }
.el-wrong em { font-style: normal; font-weight: 600; }

.el-controls {
  display: flex; gap: .5rem; margin-top: 1.2rem; flex-wrap: wrap;
}

/* Mini-cours contextuel ─────────────────────────────────────────────────── */
.el-minicours {
  margin-top: .6rem;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  font-size: .88rem;
  overflow: hidden;
}
.el-minicours-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .4rem .7rem;
  background: #dbeafe;
  cursor: pointer;
  user-select: none;
}
.el-minicours-head strong { color: #1e40af; }
.el-minicours-body {
  padding: .6rem .8rem;
  color: #1e293b;
  line-height: 1.55;
  display: none;
}
.el-minicours.open .el-minicours-body { display: block; }
.el-minicours-toggle { font-size: .75rem; color: #3b82f6; }

/* General course panel (top of lab, for non-contextual theory) ────────── */
.el-course-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: .8rem;
  overflow: hidden;
}
.el-course-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .8rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.el-course-panel-body { padding: .7rem .9rem; display: none; }
.el-course-panel.open .el-course-panel-body { display: block; }
