/* BOOSTprof Studio — design tokens + chrome, implémentation du handoff
   « BOOSTprof Studio.dc.html » (claude.ai/design) : interface étudiante sans
   jargon, accents multi-teintes, technique rangée dans la modale Debug. */
@import url("/static/boost-tokens.css");
:root {
  --prof: #5f7d10;            /* BOOSTprof chartreuse, assombri pour le clair */
  --prof-bright: #b9eb28;
  --rev-max: min(2400px, 94vw);   /* révision : occupe la largeur dispo, plafonnée */
  /* Identité « cahier » : page blanc-papier, encre bleu-noir (le bic), marge rouge
     Séyès en signature, réglure bleue en texture, surligneur jaune pour « maintenant ». */
  --ink: #121212;
  --paper: #ffffff;
  --bg: #f5f5f5;
  --muted: #5a5a60;
  --faint: #8a8a92;
  --line: rgba(0,0,0,0.10);
  --line2: rgba(0,0,0,0.16);
  --margin: var(--prof);          /* la marge signature -> accent BOOSTprof */
  --rule: rgba(13,165,221,0.18);
  --pen: #0da5dd;                 /* bleu BOOSTmoi : interactif + quiz */
  --penbg: rgba(13,165,221,0.08);
  --mark: #ffe35c;
  --blue: #0da5dd;
  --bluebg: rgba(13,165,221,0.08);
  --amber: #bf8a00;
  --green: #2e913e;
  --greenbg: rgba(46,145,62,0.10);
  --red: #d32f2f;
  --violet: #0da5dd;
  --grad: linear-gradient(120deg, #0da5dd, #0b86bb);  /* aplat accent (info BOOSTmoi) */
  --grad-shadow: 0 8px 22px -12px rgba(13,165,221,0.45);
  --fs-good: #6fcf6b;
  --fs-bad: #ff6b6b;
  --serif: var(--font-proxima);  /* le systeme BOOSTmoi na pas de serif de lecture */
  --mono: var(--font-mono);
}
:root[data-theme="light"] { --boost-prof: rgb(95, 125, 16); }  /* chartreuse lisible sur clair */
h1.hero, .proc-head h1 { font-family: var(--font-brand); font-style: italic; font-weight: 600; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body {
  font-family: var(--font-proxima);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
/* atmosphère : trois lavis radiaux très doux (violet / corail / turquoise).
   Couche FIXE et composée une seule fois — surtout PAS background-attachment:
   fixed, qui sur Safari iOS repeint tout le viewport à chaque frame de scroll
   (scintillement puis crash de l'onglet). */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  /* Lavis quasi-neutre papier — très doux, pas de violet/corail/turquoise arc-en-ciel */
  background:
    radial-gradient(60% 50% at 15% -5%, oklch(0.88 0.03 240 / 0.18), transparent 60%),
    radial-gradient(55% 45% at 100% 10%, oklch(0.9 0.02 60 / 0.10), transparent 60%),
    radial-gradient(50% 55% at 85% 105%, oklch(0.88 0.03 210 / 0.10), transparent 62%);
}
::selection { background: oklch(0.55 0.13 250 / 0.22); }

@keyframes vkblink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes vkrise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes vkshift { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

.mono { font-family: var(--mono); }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(252, 251, 248, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1320px; margin: 0 auto; padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
body.viewer .topbar-in { max-width: var(--rev-max); }   /* l'entête suit la largeur élargie de la révision */
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
/* déconnexion : bouton fantôme discret à l'extrême droite du topbar */
.logout-form { margin: 0; display: flex; flex-shrink: 0; }
.logout-btn {
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--muted);
  background: none; border: 1px solid var(--line2); border-radius: 9px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.logout-btn:hover { color: var(--ink); border-color: var(--ink); }
.brand-s {
  width: 27px; height: 27px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: #fff;
  background: var(--ink);
  /* filet de marge rouge à gauche du « S » — signature cahier */
  box-shadow: inset 3px 0 0 var(--margin);
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 16px; }
/* Logotype BOOSTprof (magistral) dans la topbar / la connexion. */
.brand .boost, .login-brand .boost { font-size: 20px; line-height: 1; }
.nav-steps { display: flex; align-items: center; gap: 6px; }
.nav-step {
  display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted);
  text-decoration: none; transition: all .15s;
}
.nav-step .n { font-family: var(--mono); font-size: 10px; opacity: 0.8; }
.nav-step.active { background: var(--grad); color: #fff; font-weight: 600; }
/* ancien arc-en-ciel supprimé — la topbar porte déjà sa bordure basse */
.rainbow { display: none; }

.page { flex: 1; max-width: 1320px; width: 100%; margin: 0 auto; padding: 58px 28px 80px; animation: vkrise .3s ease; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  color: var(--violet); font-weight: 600; margin-bottom: 14px;
}
h1.hero { font-size: clamp(28px, 5vw, 40px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.04; max-width: 780px; }
.lede { font-size: 16px; color: var(--muted); line-height: 1.55; max-width: 620px; margin-top: 16px; }
.lede b { color: var(--ink); font-weight: 600; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper);
  font-size: 13px; padding: 11px 20px; border-radius: 10px;
  z-index: 90; transition: all .2s; box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}
.toast.show { transform: translateX(-50%); opacity: 1; }
/* le toast du plein écran : même recette, ancré DANS la scène (top layer) */
.fs-toast { position: absolute; z-index: 40; }

/* ================= IMPORTER ================= */
.src-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.15fr); gap: 26px; margin-top: 38px; align-items: start; }
.files-col, .upload-col { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.files-col .jobs-block, .upload-col .type-toggle { margin: 0; }   /* gap de colonne gère l'espacement */

.dropzone {
  border: 2px dashed var(--line2); border-radius: 20px; background: var(--paper);
  padding: 46px 40px; text-align: center; min-height: 250px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  cursor: pointer; box-shadow: 0 18px 40px -28px rgba(60, 40, 90, 0.5);
}
.dropzone.drag { border-color: var(--pen); background: var(--penbg); }
.dz-circle {
  width: 54px; height: 54px; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--grad);
}
.dz-title { font-size: 18px; font-weight: 600; }
.dz-sub { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 8px; }

.file-card {
  border: 1.5px solid var(--ink); border-radius: 18px; background: var(--paper);
  padding: 24px 26px; animation: vkrise .25s ease;
  box-shadow: 0 18px 40px -28px rgba(60, 40, 90, 0.5);
}
.file-row { display: flex; align-items: flex-start; gap: 18px; }
.file-thumb {
  width: 96px; height: 60px; border-radius: 9px; flex-shrink: 0; color: #fff;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.file-name { font-size: 15px; font-weight: 600; word-break: break-all; }
.file-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 7px; display: flex; gap: 16px; flex-wrap: wrap; }
.bar-track { height: 6px; border-radius: 4px; background: #ded9cd; overflow: hidden; margin-top: 13px; }
.bar-fill {
  height: 100%; width: 0%; border-radius: 4px; transition: width .2s;
  background: var(--grad);
}
.bar-fill.done { background: var(--green); }
.file-status { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 7px; }
.file-status.ok { color: oklch(0.5 0.12 172); }
.file-actions { display: flex; gap: 12px; margin-top: 22px; }
.btn-primary {
  flex: 1; background: var(--grad); color: #fff; font-size: 14px; font-weight: 700;
  font-family: inherit; padding: 14px 22px; border: none; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: var(--grad-shadow);
}
.btn-primary:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.btn-ghost {
  padding: 14px 18px; border: 1px solid var(--line2); border-radius: 12px;
  background: none; font-family: inherit; cursor: pointer; font-size: 14px; color: var(--muted);
}
.btn-dark {
  margin-top: 4px; background: var(--grad); color: #fff; font-size: 14px; font-weight: 700;
  padding: 13px 24px; border: none; border-radius: 13px; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 9px; box-shadow: var(--grad-shadow);
}

.section-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--faint); margin-bottom: 12px; }

.jobs-block { margin-top: 26px; }
.job-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--line2); border-radius: 14px;
  background: var(--paper); cursor: pointer; margin-bottom: 10px;
  box-shadow: 0 10px 26px -24px rgba(60, 40, 90, 0.5);
}
.job-row .left { display: flex; align-items: center; gap: 13px; min-width: 0; }
.job-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.job-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 3px; }
.job-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.job-state { font-family: var(--mono); font-size: 10.5px; }
.job-action { font-family: var(--mono); font-size: 11px; color: var(--violet); font-weight: 600; }
.job-action.outline { color: var(--muted); border: 1px solid var(--line2); border-radius: 7px; padding: 4px 10px; }
.job-mini {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  border: 1px solid var(--line2); border-radius: 7px; background: none;
  padding: 6px 10px; cursor: pointer;
}
.job-mini:hover { color: var(--ink); border-color: var(--ink); }
.job-mini.del:hover { color: var(--red); border-color: var(--red); }
.job-manage {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--line2); border-radius: 7px; background: none;
  padding: 4px 9px; cursor: pointer;
}
.job-manage:hover { color: var(--ink); border-color: var(--ink); }

.key-warn {
  background: #f6e8c8; color: #7a5200;
  border-bottom: 1px solid var(--amber);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.03em;
  text-align: center; padding: 8px 24px;
}

.contract-card {
  background: var(--paper); border: 1px solid var(--line2); border-radius: 18px;
  padding: 24px 26px; box-shadow: 0 18px 40px -30px rgba(60, 40, 90, 0.45);
}
.promise { display: flex; gap: 13px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.promise .mark { font-size: 15px; font-weight: 700; margin-top: 1px; font-family: var(--mono); }
.promise:nth-child(2) .mark { color: oklch(0.58 0.19 292); }
.promise:nth-child(3) .mark { color: oklch(0.58 0.2 350); }
.promise:nth-child(4) .mark { color: oklch(0.6 0.17 30); }
.promise:nth-child(5) .mark { color: oklch(0.56 0.15 172); }
.promise:nth-child(6) .mark { color: oklch(0.6 0.16 250); }
.promise .txt { font-size: 13.5px; line-height: 1.5; }

/* ================= PRÉPARATION ================= */
.proc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 30px; }
.proc-head h1 { font-size: clamp(24px, 4vw, 32px); font-weight: 700; letter-spacing: -0.02em; }
.counters { display: flex; gap: 28px; font-family: var(--mono); }
.counter .k { font-size: 11px; color: var(--faint); margin-bottom: 5px; }
.counter .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counter .v.green { color: oklch(0.55 0.14 172); }
#ctr-words { color: var(--ink); }
#ctr-cost { color: var(--violet); }

.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
/* cycle de teintes du handoff : 292 → 350 → 30 → 172 → 250 → 95 → 320 → 150 */
.stage-card:nth-child(8n+1) { --h: 292; }
.stage-card:nth-child(8n+2) { --h: 350; }
.stage-card:nth-child(8n+3) { --h: 30; }
.stage-card:nth-child(8n+4) { --h: 172; }
.stage-card:nth-child(8n+5) { --h: 250; }
.stage-card:nth-child(8n+6) { --h: 95; }
.stage-card:nth-child(8n+7) { --h: 320; }
.stage-card:nth-child(8n+8) { --h: 150; }
.stage-card {
  --hc: oklch(0.6 0.18 var(--h));
  --hsoft: oklch(0.6 0.18 var(--h) / 0.13);
  background: var(--paper); border: 1px solid var(--line2); border-radius: 14px;
  padding: 20px 22px; transition: all .2s;
  box-shadow: 0 10px 26px -22px rgba(60, 40, 90, 0.5);
}
.stage-card.active { border-color: var(--hc); box-shadow: 0 12px 30px -14px var(--hc); }
.stage-card.done { border-color: var(--hc); }
.stage-card.failed { border-color: var(--red); }
.stage-top { display: flex; align-items: center; gap: 13px; margin-bottom: 13px; }
.stage-glyph {
  width: 38px; height: 38px; border-radius: 12px; background: #e7e2d6; color: var(--faint);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 16px; flex-shrink: 0; transition: all .2s;
}
.stage-card.active .stage-glyph { background: var(--hsoft); color: var(--hc); box-shadow: 0 0 0 4px var(--hsoft); }
.stage-card.done .stage-glyph { background: var(--hc); color: #fff; }
.stage-card.failed .stage-glyph { background: oklch(0.55 0.16 28 / 0.12); color: var(--red); }
.stage-name { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.stage-status { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.stage-card.active .stage-status, .stage-card.done .stage-status { color: var(--hc); }
.stage-card.failed .stage-status { color: var(--red); }
.stage-bar { height: 6px; border-radius: 4px; background: #ded9cd; overflow: hidden; }
.stage-bar div { height: 100%; width: 0%; background: var(--hc); border-radius: 4px; transition: width .2s linear; }
.stage-card.done .stage-bar div { width: 100%; }
.stage-card.failed .stage-bar div { background: var(--red); }
.stage-detail { font-size: 12px; color: var(--muted); margin-top: 11px; line-height: 1.45; min-height: 34px; }

.proc-foot { margin-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.proc-note { font-size: 13px; color: var(--muted); }
.btn-resume { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 13px; cursor: pointer; background: none; }

/* ================= RÉVISER ================= */
.viewer-page { flex: 1; width: 100%; animation: vkrise .3s ease; padding-bottom: 56px; }
.viewer-head { max-width: var(--rev-max); margin: 0 auto; padding: 38px 28px 0; }
.viewer-head-in {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  border-bottom: 1.5px solid var(--ink); padding-bottom: 20px;
}
.viewer-head h1 { font-size: clamp(22px, 3.5vw, 30px); font-weight: 700; letter-spacing: -0.02em; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-new { padding: 10px 16px; border: 1px solid var(--line2); border-radius: 10px; cursor: pointer; font-size: 13px; color: var(--muted); background: none; font-family: inherit; text-decoration: none; }
.btn-new-ic { display: none; }   /* texte sur desktop ; bascule en icône sur XS */
.btn-fs-open {
  padding: 10px 16px; border: none; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 700; color: #fff; background: var(--grad);
  font-family: inherit; box-shadow: var(--grad-shadow);
}
.btn-fs-open:hover { filter: brightness(1.08); }

.transport { max-width: var(--rev-max); margin: 0 auto; padding: 16px 28px 0; display: flex; align-items: center; gap: 16px; }
.transport[hidden] { display: none; }   /* photos : pas de barre de lecture */
.play-main {
  width: 44px; height: 44px; border-radius: 50%; color: #fff; border: none;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px; flex-shrink: 0;
}
.transport-label { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 96px; }
.scrub { position: relative; flex: 1; min-width: 160px; height: 8px; background: #ded9cd; border-radius: 4px; cursor: pointer; }
.scrub-fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%; border-radius: 4px;
  background: linear-gradient(90deg, oklch(0.64 0.18 292), oklch(0.62 0.19 332));
}
.scrub-dot {
  position: absolute; top: 50%; left: 0%; transform: translate(-50%, -50%);
  width: 13px; height: 13px; border-radius: 50%; background: oklch(0.62 0.19 312);
  border: 2px solid var(--paper); box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* ---- l'invite permanente d'entraînement (bordure dégradée animée) ---- */
.practice-wrap { max-width: var(--rev-max); margin: 18px auto 0; padding: 0 28px; }
.practice-dock {
  border-radius: 18px; padding: 2px;
  /* shimmer bleu-stylo discret (ex-arc-en-ciel) : reste dans la palette cahier */
  background: linear-gradient(100deg, var(--pen), oklch(0.42 0.07 255), oklch(0.62 0.1 232), var(--pen));
  background-size: 200% 100%;
  animation: vkshift 10s linear infinite;
}
.practice-in {
  border-radius: 16px; background: var(--paper); padding: 15px 18px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.practice-in[hidden] { display: none; }   /* flex display would otherwise beat [hidden] */
.practice-lead { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 240px; }
.practice-star { font-size: 22px; flex-shrink: 0; }
.practice-field { flex: 1; min-width: 160px; }
.practice-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; color: var(--faint); margin-bottom: 4px; }
.practice-input {
  /* 16px minimum : sous ce seuil, iOS Safari zoome la page au focus */
  width: 100%; border: none; background: transparent; font-family: inherit;
  font-size: 16px; font-weight: 500; color: var(--ink); outline: none;
}
.practice-input:disabled { opacity: 0.55; }
.practice-cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.quiz-history {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); max-width: 220px;
  background: var(--paper); border: 1px solid var(--line2); border-radius: 9px; padding: 8px 10px; cursor: pointer;
}
.quiz-panel .quiz-history { max-width: none; width: 100%; margin-bottom: 12px; }
.practice-badge { font-size: 12px; color: var(--muted); white-space: nowrap; }
.practice-badge.loading { animation: vkblink 1s steps(1) infinite; color: var(--violet); }
.practice-go {
  background: var(--grad); color: #fff; font-size: 14px; font-weight: 700;
  padding: 12px 20px; border-radius: 12px; cursor: pointer; border: none;
  display: flex; align-items: center; gap: 9px; font-family: inherit;
  box-shadow: 0 8px 24px -8px oklch(0.62 0.2 312 / 0.7); white-space: nowrap;
  min-height: 44px;
}
.practice-go:hover { filter: brightness(1.08); }
.practice-go:disabled { opacity: 0.5; cursor: default; filter: none; }

/* ----- step 2 : starters suggérés ----- */
.practice-opt { color: var(--faint); font-weight: 400; letter-spacing: 0; }
/* step 2 replaces the form, so it IS the paper card (matches .practice-in) — no
   background would let the dock's gradient border bleed through. */
.practice-suggest {
  border-radius: 16px; background: var(--paper); padding: 16px 18px;
  animation: vkrise .25s ease;
}
.practice-suggest[hidden] { display: none; }
.suggest-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.suggest-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.suggest-back {
  font-family: var(--mono); font-size: 11px; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid var(--line2); border-radius: 9px; padding: 6px 12px;
  transition: border-color .15s, color .15s;
}
.suggest-back:hover { border-color: var(--ink); color: var(--ink); }
.suggest-list { display: flex; flex-wrap: wrap; gap: 9px; }
.suggest-chip {
  --ch: 292; padding: 11px 17px; border-radius: 12px; font-size: 13px; font-weight: 500;
  line-height: 1.3; cursor: pointer; font-family: inherit; color: var(--ink);
  border: 1px solid oklch(0.56 0.16 var(--ch) / 0.35);
  background: oklch(0.56 0.16 var(--ch) / 0.07);
  transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
}
.suggest-chip:hover {
  border-color: oklch(0.56 0.16 var(--ch)); transform: translateY(-1px);
  background: oklch(0.56 0.16 var(--ch) / 0.14);
  box-shadow: 0 8px 20px -14px oklch(0.56 0.16 var(--ch) / 0.8);
}
.suggest-empty { color: var(--muted); font-size: 13px; }

/* ================= LECTEUR — carousel un chapitre à la fois =================
   UN SEUL chapitre est rendu à la fois. L'ancienne pellicule posait les 77
   cellules côte à côte (~50 000 px de large) : Safari iOS devait composer une
   surface énorme et tuait l'onglet (« un problème s'est produit à plusieurs
   reprises »). Ici la scène n'affiche qu'une carte ; les vignettes restent
   petites et se chargent à la demande (content-visibility + lazy-load). */
/* en-tête du lecteur : métadonnées (pleine largeur) + bouton plein écran */
.reader-bar {
  max-width: var(--rev-max); margin: 10px auto 0; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.reader-meta { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; min-width: 0; }
.reader-chno {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--acc);
  background: var(--accsoft); border-radius: 6px; padding: 3px 9px;
}
.reader-kind {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 600; color: var(--muted);
}
.reader-flags { display: flex; gap: 5px; }

/* trois colonnes : image | texte | quiz */
.reader-col { --ch: 292; --acc: oklch(0.56 0.16 var(--ch)); --accsoft: oklch(0.56 0.16 var(--ch) / 0.13); min-width: 0; }
.reader-img-col, .reader-text {
  background: var(--paper); border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: 0 18px 44px -30px rgba(60, 40, 90, 0.5);
}
.reader-img-col { overflow: hidden; }
.reader-slide {
  position: relative;                 /* ancre les flèches superposées + la boîte réponse */
  display: flex; align-items: center; justify-content: center;
  background: #f1ede4; border-radius: 16px; padding: 14px;
}
.reader-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line2); background: rgba(247, 244, 236, 0.86); color: var(--ink);
  font-size: 22px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.45);
  transition: background .15s, opacity .15s;
}
.reader-arrow.prev { left: 12px; }
.reader-arrow.next { right: 12px; }
.reader-arrow:hover { background: var(--paper); }
.reader-arrow:disabled { opacity: 0; pointer-events: none; }
/* surlignage CLAIR de la réponse sur l'image (boîte LLM /locate), pulsée */
.ans-box {
  position: absolute; z-index: 2; pointer-events: none; border-radius: 4px;
  border: 3px solid oklch(0.62 0.2 312); background: oklch(0.62 0.2 312 / 0.18);
  animation: ansPulse 1.4s ease-in-out infinite;
}
@keyframes ansPulse {
  0%, 100% { box-shadow: 0 0 0 3px oklch(0.62 0.2 312 / 0.25), 0 0 16px oklch(0.62 0.2 312 / 0.4); }
  50% { box-shadow: 0 0 0 7px oklch(0.62 0.2 312 / 0.35), 0 0 34px oklch(0.62 0.2 312 / 0.7); }
}
.reader-img {
  width: 100%; height: auto; max-height: 64vh;
  object-fit: contain; border-radius: 8px; background: #fff; cursor: zoom-in;
  box-shadow: 0 10px 28px -16px rgba(0, 0, 0, 0.4);
  transition: filter .3s ease;
}
/* question en cours (sans réponse) : on floute la diapo ET le texte transcrit
   pour ne pas y lire la réponse pendant qu'on répond. */
body.quiz-asking .reader-img, body.quiz-asking .lightbox-img { filter: blur(14px) brightness(0.94); }
body.quiz-asking .reader-text { filter: blur(6px); user-select: none; }
.reader-text { padding: 18px 20px; overflow-y: auto; max-height: 72vh; transition: filter .3s ease; }
.reader-text::-webkit-scrollbar { width: 7px; }
.reader-text::-webkit-scrollbar-thumb { background: #cdc7b8; border-radius: 5px; }

.flag-chip {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.05em;
  border-radius: 3px; padding: 1px 4px; border: 1px solid currentColor; background: var(--paper);
}
.flag-truncated { color: var(--amber); }
.flag-low_align_confidence { color: var(--red); }
.flag-silent { color: var(--faint); }

.reader-text-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.reader-text-bar .cite-chip { margin-bottom: 0; }
.cite-chip { display: inline-flex; align-items: center; gap: 7px; cursor: copy; margin-bottom: 11px; }
.cite-time { font-family: var(--mono); font-size: 10px; color: var(--acc); font-weight: 600; }
.cite-copy { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.cell-body { font-family: var(--serif); font-size: 15px; line-height: 1.75; }
.cell-body .sn { transition: background .15s; border-radius: 3px; padding: 0 2px; }
.cell-body .sn.on { background: oklch(0.56 0.16 var(--ch, 292) / 0.24); }
.cell-body .silent-note { color: var(--faint); font-style: italic; }

/* left margin rule — signature cahier sur la colonne de texte */
.reader-text { border-left: 3px solid var(--margin) !important; }

/* markdown transcrit (photos) : titres, listes, tableaux, + ajouts manuscrits */
.md-legend { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }
.cell-body.md { font-family: var(--serif); font-size: 15px; line-height: 1.75; }
.cell-body.md h1 { font-size: 18px; font-weight: 700; margin: 14px 0 6px; }
.cell-body.md h2 { font-size: 16px; font-weight: 700; margin: 12px 0 5px; }
.cell-body.md h3 { font-size: 14.5px; font-weight: 600; margin: 11px 0 4px; color: var(--acc); }
.cell-body.md h4, .cell-body.md h5, .cell-body.md h6 { font-size: 13.5px; font-weight: 600; margin: 9px 0 3px; }
.cell-body.md p { margin: 6px 0; }
.cell-body.md ul, .cell-body.md ol { margin: 5px 0; padding-left: 20px; }
.cell-body.md li { margin: 2px 0; }
.cell-body.md strong { font-weight: 700; }
.cell-body.md code { font-family: var(--mono); font-size: 12.5px; background: var(--line2); border-radius: 4px; padding: 1px 4px; }
.cell-body.md pre { background: #f1ede4; border-radius: 8px; padding: 12px; overflow-x: auto; }
.cell-body.md pre code { background: none; padding: 0; }
.cell-body.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.cell-body.md th, .cell-body.md td { border: 1px solid var(--line2); padding: 5px 9px; text-align: left; }
.cell-body.md th { background: var(--accsoft); font-weight: 600; }
.cell-body.md blockquote { border-left: 3px solid var(--line2); margin: 6px 0; padding-left: 12px; color: var(--muted); }
/* formules KaTeX : une formule large défile au lieu de déborder la colonne/cellule */
.cell-body.md .katex-display { overflow-x: auto; overflow-y: hidden; margin: 8px 0; padding-bottom: 2px; }
.cell-body.md td .katex-display, .cell-body.md th .katex-display { margin: 4px 0; text-align: left; }
.cell-body.md .katex { font-size: 1.05em; }
/* contenu MANUSCRIT / ajouté à la main → encre distincte de l'imprimé */
.ms { color: oklch(0.52 0.2 264); background: oklch(0.52 0.2 264 / 0.1); border-radius: 3px; padding: 0 2px; font-style: italic; }

/* loader pendant la localisation (bbox LLM) + agrandissement plein écran */
.slide-loader {
  position: absolute; z-index: 4; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: rgba(20, 19, 15, 0.82); color: #fff; font-size: 13px; white-space: nowrap;
}
.slide-loader[hidden] { display: none; }
.slide-loader .spin {
  width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* zoom image seule (au-dessus du lecteur plein écran) */
.lightbox { position: fixed; inset: 0; z-index: 210; background: rgba(12, 11, 9, 0.96); }
.lightbox[hidden] { display: none; }
.lb-imgwrap {
  position: absolute; inset: 0; overflow: auto;
  display: flex; align-items: center; justify-content: center; padding: 2vh;
}
.lightbox-img { max-width: 100%; max-height: 96vh; object-fit: contain; cursor: zoom-in; user-select: none; }
.lightbox.zoom .lb-imgwrap { align-items: flex-start; justify-content: flex-start; }
.lightbox.zoom .lightbox-img { max-width: none; max-height: none; width: 170%; cursor: zoom-out; }
#lb-box { position: fixed; }                       /* coordonnées viewport */
.answer-hl { background: oklch(0.86 0.17 95); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.lightbox-close {
  position: fixed; top: 16px; right: 18px; z-index: 2; width: 40px; height: 40px;
  border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.16); color: #fff;
  font-size: 18px; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

/* lecteur PLEIN ÉCRAN : même disposition 3 colonnes, qui remplit la fenêtre */
#reader.reader-fs {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; flex-direction: column; gap: 12px; padding: 14px 18px; overflow: hidden;
}
#reader.reader-fs .reader-bar, #reader.reader-fs .read-cols, #reader.reader-fs .thumbs-wrap {
  max-width: none; margin: 0; padding: 0;
}
#reader.reader-fs .read-cols { flex: 1 1 auto; min-height: 0; align-items: stretch; }
#reader.reader-fs .reader-col { display: flex; flex-direction: column; }
#reader.reader-fs .reader-img-col, #reader.reader-fs .reader-text, #reader.reader-fs .quiz-panel { max-height: none; overflow: auto; }
#reader.reader-fs .reader-slide { flex: 1 1 auto; min-height: 0; }
#reader.reader-fs .reader-img { max-height: 100%; height: 100%; }
#reader.reader-fs .thumbs-wrap { flex: 0 0 auto; }
/* le rapport de compréhension (cartes cahiers) vit SOUS le lecteur ; en plein écran
   il est un enfant de #reader et, visible, écrasait l'image à 0 px de haut. */
#reader.reader-fs .sg-report { display: none; }

/* rail de vignettes : petite diapo + numéro de chapitre + premiers mots */
.thumbs-wrap { max-width: var(--rev-max); margin: 16px auto 0; padding: 0 28px 8px; overflow-x: auto; overflow-y: hidden; }
.thumbs-wrap::-webkit-scrollbar { height: 9px; }
.thumbs-wrap::-webkit-scrollbar-track { background: #ded9cd; }
.thumbs-wrap::-webkit-scrollbar-thumb { background: #b8b2a4; border-radius: 6px; }
.thumbs-row { display: flex; gap: 11px; min-width: min-content; }
.thumb {
  --acc: oklch(0.56 0.16 var(--ch, 292));
  flex: 0 0 auto; width: 108px;
  content-visibility: auto; contain-intrinsic-size: 108px 96px;
  display: flex; flex-direction: column; gap: 5px;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
}
.thumb-img {
  width: 108px; height: 61px; object-fit: cover; border-radius: 7px;
  border: 2px solid var(--line2); background: #fff; transition: border-color .15s;
}
.thumb.active .thumb-img, .thumb.playing .thumb-img { border-color: var(--acc); }
.thumb-cap { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.thumb-n { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--acc); }
.thumb-words {
  font-size: 10.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 108px;
}
.thumb.active .thumb-words { color: var(--ink); }
/* photos : vignettes en format page (portrait) ; vidéo garde le format image (paysage 16:9) */
#reader.is-photos .thumb { width: 86px; contain-intrinsic-size: 86px 132px; }
#reader.is-photos .thumb-img { width: 86px; height: 112px; }
#reader.is-photos .thumb-words { max-width: 86px; }

.center-note { margin: auto; color: var(--faint); font-family: var(--mono); font-size: 12px; padding: 60px; text-align: center; }

/* ============ EN PAGE : carousel + panneau de quiz côte à côte ============ */
.read-cols { display: flex; align-items: flex-start; gap: 16px; max-width: var(--rev-max); margin: 10px auto 0; padding: 0 28px; }
.reader-img-col { flex: 1.1 1 0; }
.read-cols .reader-text { flex: 1 1 0; }
.quiz-panel { flex: 0 0 330px; }
/* bascule En page | Plein écran dans l'entête */
.mode-toggle { display: inline-flex; gap: 3px; padding: 3px; background: var(--paper); border: 1px solid var(--line2); border-radius: 10px; }
.mode-toggle[hidden] { display: none; }   /* hidden until a quiz is ready (photos) — UA [hidden] loses to inline-flex */
.mode-btn { border: none; background: none; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 7px 13px; border-radius: 8px; transition: all .15s; }
.mode-btn.on { background: var(--grad); color: #fff; box-shadow: var(--grad-shadow); }

.quiz-empty {
  border: 1px dashed var(--line2); border-radius: 16px; padding: 30px 22px;
  text-align: center; background: var(--paper);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.quiz-empty[hidden] { display: none; }   /* flex display would otherwise beat [hidden] */
.quiz-empty-ic {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  font-size: 18px; color: #fff; background: var(--grad); box-shadow: var(--grad-shadow);
  margin-bottom: 3px;
}
.quiz-empty-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.quiz-empty-sub { font-size: 12.5px; line-height: 1.55; color: var(--muted); max-width: 280px; }
.quiz-empty-cta {
  margin-top: 8px; font-family: inherit; font-size: 13px; font-weight: 600; color: #fff;
  background: var(--grad); border: none; border-radius: 11px; padding: 10px 18px; cursor: pointer;
  box-shadow: var(--grad-shadow);
}
.quiz-empty-cta:hover { filter: brightness(1.06); }
.quiz-empty-cta:disabled { opacity: .6; cursor: default; filter: none; }
.quiz-empty-tip { font-size: 10.5px; color: var(--faint); }

/* ----- correction manuelle de la transcription (photos) ----- */
.reader-text-tools { position: relative; display: flex; align-items: center; }
/* kebab (⋮) overflow menu — the three transcription actions live behind it */
.tx-kebab {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line2);
  background: none; color: var(--muted); cursor: pointer; line-height: 1;
  font-size: 18px; font-weight: 700; letter-spacing: 0.06em;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.tx-kebab:hover, .tx-kebab.on { border-color: var(--ink); color: var(--ink); }
.tx-menu {
  position: fixed; z-index: 240; min-width: 220px;   /* fixed → never clipped by the scrolling text column; JS sets top/right */
  display: flex; flex-direction: column; padding: 6px;
  background: var(--paper); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 16px 44px -18px rgba(27, 35, 48, 0.4); animation: vkrise .15s ease;
}
.tx-menu[hidden] { display: none; }
.tx-menu-item {
  text-align: left; border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 13px; color: var(--ink); padding: 9px 11px; border-radius: 8px; white-space: nowrap;
  transition: background .12s, color .12s;
}
.tx-menu-item:hover { background: var(--penbg); color: var(--pen); }

/* « Transcription complète » modal — whole-folder transcript, rendu / source */
.tx-modal {
  position: fixed; inset: 0; z-index: 240; display: flex;
  align-items: center; justify-content: center; padding: 4vh 4vw;
}
.tx-modal[hidden] { display: none; }   /* flex display would otherwise beat [hidden] */
.tx-modal-backdrop {
  position: absolute; inset: 0; background: rgba(12, 11, 9, 0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.tx-modal-panel {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  width: min(880px, 100%); max-height: 92vh; background: var(--paper);
  border: 1px solid var(--line2); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 80px -24px rgba(0, 0, 0, 0.5);
}
.tx-modal-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.tx-modal-title { font-weight: 700; font-size: 15px; color: var(--ink); margin-right: auto; }
.tx-tabs { display: flex; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; }
.tx-tab {
  font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer;
  background: none; border: none; padding: 6px 16px; transition: background .15s, color .15s;
}
.tx-tab.on { background: var(--violet); color: #fff; }
.tx-modal-actions { display: flex; align-items: center; gap: 8px; }
.tx-copy {
  font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 6px 11px;
  transition: border-color .15s, color .15s;
}
.tx-copy:hover { border-color: var(--ink); color: var(--ink); }
.tx-close {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line2);
  background: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
  transition: border-color .15s, color .15s;
}
.tx-close:hover { border-color: var(--red); color: var(--red); }
.tx-modal-body { overflow-y: auto; padding: 18px 22px; }
/* modale « Transcription complète » (gallery) — instruction tuteur + transcription */
.tut-intro { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: 0 0 18px; }
.tut-intro b { color: var(--ink); font-weight: 600; }
.tut-block { margin-bottom: 20px; }
.tut-block:last-child { margin-bottom: 0; }
.tut-block-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.tut-block-title { font-weight: 600; font-size: 13.5px; color: var(--ink); margin-right: auto; }
.tut-block-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tut-pre {
  font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line2); border-radius: 10px;
  padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 300px; overflow-y: auto; margin: 0;
}
.tx-rendu[hidden], .tx-source[hidden] { display: none; }
.tx-source {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; margin: 0;
}
.tx-edit {
  width: 100%; box-sizing: border-box; min-height: 340px; resize: vertical;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px;
}
.tx-edit:focus { outline: none; border-color: var(--ink); }
.tx-edit-actions { display: flex; gap: 8px; margin-top: 10px; }
.tx-save {
  font-family: inherit; font-size: 13px; font-weight: 600; color: #fff; cursor: pointer;
  background: var(--grad); border: none; border-radius: 10px; padding: 9px 18px; box-shadow: var(--grad-shadow);
}
.tx-save:disabled { opacity: .6; cursor: default; }
.tx-cancel {
  font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 16px;
}
.tx-cancel:hover { border-color: var(--ink); color: var(--ink); }
.quiz-card[hidden] { display: none; }   /* flex display would otherwise show an empty box */
.quiz-card {
  --ch: 292; --acc: oklch(0.56 0.16 var(--ch)); --accsoft: oklch(0.56 0.16 var(--ch) / 0.13);
  background: var(--paper); border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: 0 18px 44px -30px rgba(60, 40, 90, 0.5); padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.quiz-kicker { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--acc); }
.quiz-fb { font-size: 14px; font-weight: 700; }
.quiz-fb.good { color: oklch(0.55 0.14 150); }
.quiz-fb.bad { color: var(--red); }
.quiz-q { font-size: 16px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.quiz-choices { display: grid; gap: 9px; }
.quiz-choice {
  text-align: left; font-family: inherit; font-size: 14px; cursor: pointer;
  padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line2);
  background: var(--paper); color: var(--ink); transition: border-color .15s, background .15s;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--acc); }
.quiz-choice:disabled { cursor: default; }
.quiz-choice.good { border-color: oklch(0.55 0.14 150); background: oklch(0.55 0.14 150 / 0.12); font-weight: 600; }
.quiz-choice.bad { border-color: var(--red); background: oklch(0.55 0.16 28 / 0.1); }
.quiz-expl { font-size: 13px; line-height: 1.55; color: var(--muted); background: var(--accsoft); border-radius: 10px; padding: 12px 14px; }
/* la note d'explication prend la couleur du résultat (vert juste / rouge faux), pas l'accent */
.quiz-expl.good { background: oklch(0.55 0.14 150 / 0.12); }
.quiz-expl.bad { background: oklch(0.55 0.16 28 / 0.12); }
.quiz-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.quiz-src, .quiz-next {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--paper); color: var(--ink);
}
.quiz-src:hover { border-color: var(--acc); }
.quiz-next { border: none; background: var(--grad); color: #fff; box-shadow: var(--grad-shadow); margin-left: auto; }

@media (max-width: 900px) {
  .read-cols { flex-direction: column; }
  .reader-img-col, .read-cols .reader-text, .quiz-panel { flex: none; width: 100%; }
}

/* ================= PLEIN ÉCRAN (entraînement) ================= */
.fs-stage {
  --acc: oklch(0.76 0.16 var(--ch, 292));
  --accsoft: oklch(0.76 0.16 var(--ch, 292) / 0.18);
  position: fixed; inset: 0; z-index: 100; background: #100f0c; cursor: none;
  /* use 100dvh so the overlay fits iOS viewport without the Fullscreen API */
  height: 100dvh; height: 100svh;
  overflow: hidden;
}
.fs-stage[hidden] { display: none; }
.fs-stage.show-cursor, .fs-stage.quiz, .fs-stage.reveal { cursor: auto; }
/* photos quiz is always auto-cursor */
.fs-stage.photos-quiz { cursor: auto; }
/* DEUX ZONES. La diapo (haut) est toujours visible EN ENTIER — object-fit
   contain, jamais rognée ni mise à l'échelle du viewport, jamais masquée. Le
   texte et le quiz vivent SOUS elle, jamais par-dessus. La diapo ne fait que
   se flouter pendant le choix de réponse, puis redevient nette. */
.fs-body {
  position: absolute; left: 0; right: 0;
  top: 58px; bottom: 86px;            /* dégage l'entête et les commandes */
  display: flex; flex-direction: column; gap: 1.6vh; padding: 0 4vw;
}
.fs-slide-zone {
  flex: 1 1 52%; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  transition: flex-basis .35s ease;
}
/* question ouverte : la diapo rétrécit un peu (reste entière) pour laisser
   la place aux choix — elle ne disparaît jamais */
.fs-stage.quiz .fs-slide-zone, .fs-stage.reveal .fs-slide-zone { flex-basis: 40%; }
.fs-img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; border-radius: 12px; background: #000;
  box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.85);
  transition: filter .35s ease;
}
.fs-stage.quiz .fs-img { filter: blur(16px) brightness(0.82); }  /* flou PENDANT le choix */
/* révélé / en pause / écoute : net (aucune classe → aucun filtre) */
.fs-content {
  flex: 1 1 48%; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.6vh; overflow-y: auto; text-align: center;
}

/* stories : une barre par question */
.fs-stories {
  position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 5px;
  padding: 14px 16px; z-index: 5; pointer-events: none;
}
.fs-story { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,0.22); overflow: hidden; }
.fs-story div { height: 100%; width: 0%; background: #fff; border-radius: 2px; transition: width .25s linear; }

/* entête : marque + type ✦ · score ★ + fermer */
.fs-head {
  position: absolute; top: 26px; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.fs-head-left { display: flex; align-items: center; gap: 10px; color: #fff; flex-wrap: wrap; min-width: 0; }
.fs-head-left .brand-s { width: 26px; height: 26px; border-radius: 7px; font-size: 12px; }
.fs-head-left .nm { font-weight: 700; }
.fs-pill {
  font-family: var(--mono); font-size: 11px; color: #fff;
  background: rgba(255,255,255,0.16); border-radius: 999px; padding: 3px 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw;
}
.fs-head-right { display: flex; align-items: center; gap: 12px; color: #fff; }
.fs-score { font-family: var(--mono); font-size: 13px; background: rgba(255,255,255,0.16); border-radius: 999px; padding: 5px 13px; }
.fs-score .ok { color: var(--fs-good); }
.fs-close {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.16);
  color: #fff; border: none; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px;
}

/* sous-titres : SOUS la diapo (jamais par-dessus), dévoilés au fil de la voix */
.fs-caption {
  width: 100%; max-width: 1000px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3em;
  font-size: clamp(20px, 3.4vh, 42px); line-height: 1.3; font-weight: 600; color: #fff;
  transition: opacity .12s linear; pointer-events: none;
}
.fs-caption.off { opacity: 0; }
/* question ouverte : la phrase à trou se compacte au-dessus des choix */
.fs-stage.quiz .fs-caption, .fs-stage.reveal .fs-caption {
  font-size: clamp(17px, 2.4vh, 30px);
}
.cap-word { display: inline-block; opacity: 0.32; transition: opacity .25s, text-shadow .25s; will-change: opacity; }
.cap-word.seen { opacity: 1; }
.cap-word.on { opacity: 1; text-shadow: 0 0 22px var(--acc); }
/* le trou : UNE pastille de largeur FIXE — ni la longueur du mot ni le nombre
   de mots n'indicent la réponse (mots masqués consécutifs regroupés) */
.fs-caption .cap-word.cap-mask {
  width: 2.6em; min-width: 2.6em; opacity: 1; text-align: center;
  color: var(--acc); background: var(--accsoft);
  border: 2px dashed var(--acc); border-radius: 0.42em; font-weight: 800;
  text-shadow: none;
}
.fs-stage.quiz .cap-word.cap-mask { animation: vkblink 1s steps(1) infinite; }
/* réponse révélée : pastille pleine à l'accent, texte sombre */
.fs-caption .cap-word.cap-reveal {
  opacity: 1; padding: 0.04em 0.4em; border-radius: 0.4em;
  background: var(--acc); color: #15140f; font-weight: 800;
  box-shadow: 0 8px 26px -8px var(--acc); text-shadow: none;
  animation: capReveal .55s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes capReveal {
  0% { transform: scale(.5); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* le panneau de question : dans la zone de contenu, SOUS la diapo */
.fs-quiz {
  width: 100%; display: flex; justify-content: center;
}
.fs-quiz[hidden] { display: none; }
.fs-quiz-card {
  width: min(100%, 680px);
  display: flex; flex-direction: column; align-items: center; gap: 1.6vh;
  background: rgba(16, 15, 12, .5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 18px;
  padding: clamp(14px, 2.2vh, 22px) clamp(16px, 3vw, 28px);
  box-shadow: 0 20px 60px -24px rgba(0, 0, 0, .6);
  animation: vkrise .3s ease;
}
.fs-quiz-kicker {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.85);
}
.fs-quiz-fb { font-size: clamp(22px, 3.6vw, 32px); font-weight: 800; animation: vkrise .3s ease; }
.fs-quiz-fb.good { color: oklch(0.78 0.15 152); }
.fs-quiz-fb.bad { color: oklch(0.78 0.16 70); }
.fs-quiz-q { font-weight: 700; font-size: clamp(18px, 2.6vh, 26px); line-height: 1.25; color: #fff; }
.fs-quiz-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; width: 100%; }
.fs-choice {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 60px; padding: 15px 20px; border-radius: 16px;
  font-family: inherit; font-size: clamp(15px, 2.1vw, 19px); font-weight: 600; text-align: left;
  color: #fff; background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .28);
  cursor: pointer; touch-action: manipulation; transition: all .2s;
}
.fs-choice:hover, .fs-choice:focus-visible { border-color: var(--acc); transform: translateY(-1px); outline: none; }
.fs-choice:disabled { cursor: default; transform: none; }
.fs-choice .mk { font-weight: 800; font-size: 18px; }
.fs-choice.good {
  border-color: var(--fs-good); background: oklch(0.74 0.16 152 / .28); font-weight: 700;
  box-shadow: 0 10px 30px -10px var(--fs-good);
}
.fs-choice.bad { border-color: var(--fs-bad); background: oklch(0.64 0.2 25 / .24); animation: quizShake .3s; }
.fs-choice.off { opacity: .4; }
@keyframes quizShake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.fs-quiz-expl {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: vkrise .3s ease;
}
.fs-quiz-expl[hidden] { display: none; }
.fs-quiz-expl .row {
  width: 100%; display: flex; gap: 13px; align-items: flex-start; text-align: left;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 15px; padding: 16px 18px;
}
.fs-quiz-expl .bulb { font-size: 20px; flex-shrink: 0; }
.fs-quiz-expl .txt { color: rgba(255,255,255,0.95); font-size: clamp(14px, 1.9vw, 16px); line-height: 1.55; flex: 1; }
.fs-quiz-expl .verdict { font-weight: 700; margin-bottom: 4px; display: block; }
.fs-quiz-expl .verdict.good { color: var(--fs-good); }
.fs-quiz-expl .verdict.bad { color: var(--fs-bad); }
/* fond de la note plein écran = couleur du résultat */
.fs-quiz-expl.good .row { background: oklch(0.62 0.16 150 / 0.22); border-color: oklch(0.72 0.16 150 / 0.45); }
.fs-quiz-expl.bad .row { background: oklch(0.6 0.19 28 / 0.22); border-color: oklch(0.7 0.19 28 / 0.45); }
.fs-continue {
  font-family: inherit; font-size: 15px; font-weight: 700; min-height: 44px;
  background: #fff; color: #15140f; border: none; border-radius: 13px;
  padding: 13px 30px; cursor: pointer; touch-action: manipulation;
  display: inline-flex; align-items: center; gap: 9px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}
.fs-continue:hover { filter: brightness(1.05); }
.fs-continue.ghost { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.4); box-shadow: none; }
.fs-done-title { font-size: clamp(34px, 7vw, 64px); font-weight: 800; letter-spacing: -0.02em; color: #fff; }
.fs-done-score { font-size: clamp(17px, 2.6vw, 24px); color: rgba(255,255,255,0.85); }

/* commandes du bas : citation · ↑ ⏯ ↓ */
.fs-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  color: #fff;
}
.fs-cite { font-family: var(--mono); font-size: 12px; opacity: 0.8; }
.fs-flag { font-family: var(--mono); font-size: 11px; color: var(--amber); margin-left: 14px; }
.fs-nav { display: flex; align-items: center; gap: 14px; }
.fs-nav button {
  border: none; border-radius: 50%; cursor: pointer; color: #fff;
  background: rgba(255,255,255,0.16); width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  touch-action: manipulation;
}
.fs-nav button.big { width: 50px; height: 50px; background: #fff; color: #15140f; font-size: 15px; }

/* points des questions, à droite — peut être long (« toutes les dates ») :
   plafonné en hauteur et défilable pour ne jamais déborder de l'écran */
.fs-dots {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%); z-index: 6;
  display: flex; flex-direction: column; gap: 9px; align-items: center;
  max-height: 78vh; overflow-y: auto; padding: 4px 0;
  scrollbar-width: none;
}
.fs-dots::-webkit-scrollbar { display: none; }
.fs-dot {
  width: 7px; height: 7px; border-radius: 50%; cursor: pointer; border: none; padding: 0;
  background: rgba(255,255,255,0.45); transition: all .2s;
}
.fs-dot.cur { width: 11px; height: 11px; background: var(--acc); }
.fs-dot.done { background: rgba(255,255,255,0.85); }

.fs-hint {
  /* au-dessus des commandes, pas par-dessus la diapo */
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 13px; color: rgba(255, 255, 255, .85);
  background: rgba(0, 0, 0, .55); padding: 12px 20px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5;
}
.fs-stage.paused .fs-hint, .fs-stage.ended .fs-hint { opacity: 1; }

/* ===== PHOTOS QUIZ FULLSCREEN (self-paced, no audio) =====
   Un écran entier, une question à la fois. La diapo-source est masquée par défaut
   et révélée à la demande (anti-triche). iOS-safe : CSS overlay, pas l'API Fullscreen. */
.fs-stage.photos-quiz .fs-stories,
.fs-stage.photos-quiz .fs-body,
.fs-stage.photos-quiz .fs-hint,
.fs-stage.photos-quiz .fs-controls,
.fs-stage.photos-quiz .fs-dots { display: none; }
.fs-stage.photos-quiz .fs-head {
  /* reste en place mais on masque la pill vidéo */
  background: transparent;
}
.fs-stage.photos-quiz .fs-head-left .nm { display: none; }

/* zone principale photos-quiz : colonne centrée, scrollable, pleine hauteur */
.fs-pq {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  gap: 16px; z-index: 2;
}
/* vertically center the quiz (no more empty gap at the bottom) but stay scroll-safe:
   the spacers absorb free space when it fits, and collapse to 0 so a long question
   scrolls from the top instead of being clipped. */
.fs-pq::before, .fs-pq::after { content: ""; flex: 1 1 0; min-height: 0; }
.fs-pq[hidden] { display: none !important; }

/* barre de progression : marks ✓ ✗ · */
.fs-progress {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 7px;
  width: 100%; max-width: 480px; flex-shrink: 0; padding: 4px 0;
}
.fs-pm {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; transition: all .2s;
  background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}
.fs-pm.cur {
  background: rgba(255,255,255,0.22); color: #fff;
  box-shadow: 0 0 0 2.5px rgba(255,255,255,0.55);
}
.fs-pm.correct { background: oklch(0.52 0.14 152 / .7); color: #fff; }
.fs-pm.wrong   { background: oklch(0.52 0.16 25 / .7);  color: #fff; }

/* source photo (hidden by default, shown on demand) */
.fs-pq-img {
  width: 100%; max-width: 680px; border-radius: 12px;
  object-fit: contain; flex-shrink: 0;
  box-shadow: 0 12px 40px -16px rgba(0,0,0,.7);
  animation: vkrise .25s ease;
}
.fs-pq-img[hidden] { display: none; }

/* question card */
.fs-pq-card {
  width: 100%; max-width: 680px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 18px;
  background: rgba(16,15,12,.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.12);
  border-left: 3.5px solid var(--margin);   /* signature rouge de marge */
  border-radius: 18px;
  padding: clamp(18px, 3.2vh, 28px) clamp(18px, 4vw, 32px);
  box-shadow: 0 20px 60px -24px rgba(0,0,0,.7);
  animation: vkrise .3s ease;
}
.fs-pq-q {
  font-family: var(--serif); font-size: clamp(18px, 3.2vw, 26px);
  font-weight: 500; line-height: 1.4; color: #fff;
}
/* choices: full-width single-column on mobile */
.fs-pq-choices { display: flex; flex-direction: column; gap: 10px; width: 100%; }
/* peek button */
.fs-peek-btn {
  align-self: flex-start;
  background: none; border: none; padding: 0;
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em;
  color: rgba(255,255,255,.45); cursor: pointer; transition: color .15s;
}
.fs-peek-btn:hover { color: rgba(255,255,255,.8); }
/* when photo is showing, change label text via JS */

/* end/summary card reuses fs-pq-card, fs-done-* */

/* ============ DÉTAILS PAR ÉTAPE — dépliant « debug » sous chaque carte ======
   Remplace l'ancienne modale Debug : chaque étape du pipeline porte son propre
   panneau entrée/sortie + journal, dépliable en place. */
.stage-toggle {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 2px 0;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
}
.stage-toggle:hover { color: var(--ink); }
.stage-toggle .chev { display: inline-block; transition: transform .15s; }
.stage-card.open .stage-toggle .chev { transform: rotate(90deg); }
.stage-card:not(.open) .stage-debug { display: none; }
.stage-debug {
  margin-top: 11px; background: #1c1b17; border: 1px solid #34322b; border-radius: 10px;
  padding: 13px 15px; font-family: var(--mono); color: #cfc9bb;
  max-height: 270px; overflow-y: auto; overflow-x: hidden;
}
.stage-debug::-webkit-scrollbar { width: 8px; }
.stage-debug::-webkit-scrollbar-thumb { background: #48443b; border-radius: 5px; }
.dbg-io { display: flex; gap: 10px; font-size: 11.5px; line-height: 1.65; }
.dbg-io .k { color: oklch(0.7 0.15 172); min-width: 56px; flex-shrink: 0; }
.dbg-io .v { color: #ded8ca; word-break: break-word; }
.dbg-tech { font-size: 11.5px; color: #8a8576; line-height: 1.6; margin: 9px 0 0; }
.dbg-journal { margin-top: 11px; border-top: 1px solid #2c2a23; padding-top: 10px; font-size: 12px; line-height: 1.85; }
.dbg-journal .ln .t { color: #6f6a5c; }
.dbg-journal .ev { color: #d9d4c6; word-break: break-word; overflow-wrap: anywhere; }
.dbg-journal .ev.ok { color: #a9c08a; }
.dbg-journal .ev.warn { color: #d9a45f; }
.dbg-journal .empty { color: #6f6a5c; font-style: italic; font-size: 11.5px; }
.proc-cost { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ============ IMPORT : sélecteur Vidéo|Photos + file d'attente photos ======= */
.type-toggle {
  display: inline-flex; gap: 4px; margin: 4px 0 22px; padding: 4px;
  background: var(--paper); border: 1px solid var(--line2); border-radius: 12px;
}
.type-btn {
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 9px 18px; border-radius: 9px; transition: all .15s;
}
.type-btn.on { background: var(--grad); color: #fff; box-shadow: var(--grad-shadow); }

.folder-row { display: flex; gap: 10px; margin-bottom: 16px; }
.folder-select {
  flex: 1; min-width: 0; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line2); border-radius: 10px; padding: 11px 14px;
}
.photo-queue {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px; margin-top: 16px;
}
.qthumb { position: relative; aspect-ratio: 4/3; }
.qthumb img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line2); background: #fff;
}
.qthumb .qext {
  display: none; position: absolute; inset: 0; border-radius: 8px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line2); background: var(--paper);
  font: 600 12px/1 var(--mono); letter-spacing: 0.06em; color: var(--muted);
}
.qthumb.noimg img { display: none; }
.qthumb.noimg .qext { display: flex; }
.qx {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px;
  border-radius: 50%; border: none; cursor: pointer; font-size: 12px; line-height: 1;
  background: var(--ink); color: var(--paper); box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.qthumb.busy .qx { display: none; }
.qthumb.busy::after {
  content: ""; position: absolute; inset: 0; border-radius: 8px;
  background: rgba(255,255,255,0.45);
}

/* ================= GALERIE ================= */
.gal-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 26px;
}
.gal-head h1 { font-size: 30px; font-weight: 600; margin-top: 6px; }
.gal-sub { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.gal-sub.err { color: var(--red); font-weight: 600; }
.gal-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-line {
  font-family: var(--mono); font-size: 12px; color: var(--ink); text-decoration: none;
  border: 1px solid var(--line2); border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
.btn-line:hover { border-color: var(--ink); }
.btn-danger {
  font-family: inherit; font-size: 13px; font-weight: 600; color: #fff; cursor: pointer;
  background: var(--red); border: none; border-radius: 10px; padding: 11px 18px;
}
.btn-danger:hover { filter: brightness(0.95); }
.gal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px;
}
.gthumb {
  position: relative; margin: 0; aspect-ratio: 3/4; border: 1px solid var(--line2);
  border-radius: 12px; overflow: hidden; background: var(--paper); cursor: pointer;
}
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gthumb.bad { border-color: var(--red); box-shadow: 0 0 0 1px var(--red) inset; }
.gthumb.bad figcaption { background: var(--red); }
/* per-page transcription status — the loader sweeps page by page as each runs */
.gthumb-tx { position: absolute; inset: 0; display: none; pointer-events: none; }
.gthumb.tx-pending { opacity: 0.5; }
.gthumb.tx-active { border-color: var(--pen); box-shadow: 0 0 0 2px var(--pen) inset; }
.gthumb.tx-active .gthumb-tx {
  display: flex; align-items: center; justify-content: center;
  background: oklch(0.99 0.004 250 / 0.55);
}
.gthumb.tx-active .gthumb-tx::after {
  content: ""; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line2); border-top-color: var(--pen);
  animation: spin .8s linear infinite;
}
.gthumb.tx-done { border-color: var(--green); }
.gthumb.tx-done .gthumb-tx { display: block; }
.gthumb.tx-done .gthumb-tx::after {
  content: "✓"; position: absolute; top: 6px; left: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.4);
}
.gthumb-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); }
.gthumb figcaption {
  position: absolute; left: 8px; bottom: 8px; font-size: 10.5px; color: #fff;
  background: rgba(0,0,0,0.55); border-radius: 6px; padding: 2px 7px;
}
.gx {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
  border-radius: 50%; border: none; cursor: pointer; font-size: 13px; line-height: 1;
  background: var(--ink); color: var(--paper); box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.gx:hover { background: var(--red); }
.gx:disabled { opacity: 0.4; cursor: default; }
.gal-empty { color: var(--muted); font-size: 14px; padding: 40px 4px; }

/* manual page selection while a sub-group form is open */
.gsel { display: none; }
.gal-grid.selecting .gthumb { cursor: pointer; }
.gal-grid.selecting .gx { display: none; }                 /* delete hidden while selecting */
.gthumb.selected { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet) inset; }
.gthumb.selected .gsel {
  position: absolute; top: 8px; left: 8px; display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--violet); color: #fff;
  font-size: 12px; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.gal-grid.selecting .gthumb.locked { opacity: 0.4; cursor: not-allowed; }
.gal-grid.selecting .gthumb.locked::after {
  content: "🔒"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 18px;
}

/* ----- sub-groups (gérer page) — sits above the photo grid ----- */
.sg-manage { margin-bottom: 30px; border-bottom: 1px solid var(--line); padding-bottom: 26px; }
.sg-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sg-sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.sg-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px;
  padding: 16px; border: 1px solid var(--line2); border-radius: 14px; background: var(--paper);
}
.sg-form[hidden] { display: none; }   /* flex display would otherwise beat [hidden] */
.sg-input {
  flex: 1 1 280px; font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line2); border-radius: 10px; padding: 10px 14px; background: var(--bg);
}
.sg-input:focus { outline: none; border-color: var(--ink); }
.sg-pick-hint { flex: 1 1 240px; font-size: 11.5px; color: var(--muted); }
.sg-form-actions { display: flex; gap: 8px; }
.sg-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.sg-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border: 1px solid var(--line2); border-radius: 12px; background: var(--paper);
}
.sg-reorder { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.sg-move {
  width: 24px; height: 18px; line-height: 1; font-size: 11px; cursor: pointer;
  border: 1px solid var(--line2); border-radius: 6px; background: var(--paper); color: var(--muted);
}
.sg-move:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.sg-move:disabled { opacity: .35; cursor: default; }
.sg-row-main { flex: 1 1 auto; min-width: 0; }
.sg-row-name { font-size: 14.5px; font-weight: 500; }
.sg-row-range { font-size: 11px; color: var(--muted); margin-top: 3px; }
/* sous-thèmes par section (gallery) : chips + bouton (re)génération */
.sg-row-themes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.sgt-chip {
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--pen);
  background: var(--penbg); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.sgt-gen {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--muted);
  background: none; border: 1px dashed var(--line2); border-radius: 999px;
  padding: 3px 10px; cursor: pointer; transition: color .15s, border-color .15s;
}
.sgt-gen:hover { color: var(--pen); border-color: var(--pen); }
.sgt-gen:disabled { opacity: .65; cursor: default; }
.sg-row-themes.generating { min-height: 26px; }
.sgt-spin {
  width: 13px; height: 13px; border: 2px solid var(--line2); border-top-color: var(--pen);
  border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
.sgt-status { font-size: 11.5px; color: var(--muted); }
.sg-row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sg-del {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line2); cursor: pointer;
  background: var(--paper); color: var(--muted); font-size: 13px; line-height: 1;
}
.sg-del:hover { border-color: var(--red); color: var(--red); }
.sg-empty { color: var(--faint); font-size: 13px; padding: 6px 2px; }

/* ----- sub-group picker (practice dock) ----- */
.sg-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.sg-picker[hidden] { display: none; }
.sg-picker-label { font-size: 10.5px; color: var(--faint); letter-spacing: .08em; }
.sg-picker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sg-pick {
  --ch: 292; font-family: var(--mono); font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--line2); border-radius: 999px; padding: 5px 12px;
  background: var(--paper); color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.sg-pick:hover { border-color: oklch(0.56 0.16 var(--ch)); }
.sg-pick.on {
  border-color: oklch(0.56 0.16 var(--ch)); color: var(--ink); font-weight: 500;
  background: oklch(0.56 0.16 var(--ch) / 0.13);
}

/* ----- comprehension report (under the quiz) ----- */
.sg-report { max-width: var(--rev-max); margin: 24px auto 0; padding: 0 28px; }
.sg-report[hidden] { display: none; }
.sg-report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sg-report-actions { display: flex; align-items: center; gap: 14px; }
.sg-report-hint { font-size: 10.5px; color: var(--faint); }
.sg-report-reset {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 5px 11px;
  transition: border-color .15s, color .15s;
}
.sg-report-reset:hover { border-color: var(--red); color: var(--red); }
.sg-report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.sgr-card {
  --ch: 292; border: 1px solid var(--line2); border-radius: 14px; padding: 14px 16px;
  background: var(--paper); display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.sgr-card:hover {
  border-color: oklch(0.56 0.16 var(--ch));
  box-shadow: 0 10px 26px -18px oklch(0.56 0.16 var(--ch) / 0.6); transform: translateY(-1px);
}
.sgr-card-na, .sgr-card-na:hover {
  border-color: var(--line2); box-shadow: none; transform: none;
}
.sgr-head {
  text-align: left; cursor: pointer; font-family: inherit; background: none; border: 0;
  padding: 0; width: 100%; display: flex; flex-direction: column; gap: 7px;
}
.sgr-card-na .sgr-head { cursor: default; }
.sgr-name { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.sgr-meta { font-size: 10.5px; color: var(--faint); }
.sgr-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.sgr-bar.mini { height: 4px; }
.sgr-bar-fill { height: 100%; border-radius: 3px; background: oklch(0.56 0.16 var(--ch)); transition: width .3s; }
.sgr-stat { font-size: 11px; color: var(--muted); }
.sgr-ok { color: var(--green); font-weight: 600; }
/* per-sub-theme breakdown inside a cahier card (amalgam = the cahier total) */
.sgr-themes { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 9px; }
.sgr-th { display: grid; grid-template-columns: 1fr 48px auto; align-items: center; gap: 8px; }
.sgr-th-name { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgr-th-untag .sgr-th-name { color: var(--faint); font-style: italic; }
.sgr-th-stat { font-size: 10.5px; color: var(--muted); }
.sgr-gen {
  align-self: flex-start; font-family: var(--mono); font-size: 10.5px; cursor: pointer;
  background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 5px 11px;
  color: var(--muted); transition: border-color .15s, color .15s;
}
.sgr-gen:hover { border-color: oklch(0.56 0.16 var(--ch)); color: var(--ink); }
.sgr-gen:disabled { opacity: .6; cursor: default; }
/* generator: photos has no free text — empty-state, sub-theme picker, gen CTA */
.practice-empty { font-size: 12.5px; color: var(--muted); padding: 6px 2px; }
.practice-empty[hidden] { display: none; }
.practice-lead[hidden] { display: none; }   /* flex display would otherwise beat [hidden] */
.practice-go[hidden] { display: none; }      /* flex display would otherwise beat [hidden] */
.sg-themes-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.sg-themes-row[hidden] { display: none; }    /* flex display would otherwise beat [hidden] */
.sg-themes { display: flex; flex-wrap: wrap; gap: 6px; }
.sg-themes-empty { font-size: 11px; color: var(--faint); }
.sg-theme {
  --ch: 292; font-family: var(--mono); font-size: 11.5px; cursor: pointer;
  border: 1px dashed var(--line2); border-radius: 999px; padding: 4px 11px;
  background: var(--paper); color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.sg-theme:hover { border-color: oklch(0.56 0.16 var(--ch)); }
.sg-theme.on {
  border-style: solid; border-color: oklch(0.56 0.16 var(--ch)); color: var(--ink);
  font-weight: 500; background: oklch(0.56 0.16 var(--ch) / 0.13);
}
.sg-gen-themes {
  font-family: var(--mono); font-size: 10.5px; cursor: pointer; color: var(--violet);
  background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 5px 11px;
  transition: border-color .15s, color .15s;
}
.sg-gen-themes:hover { border-color: var(--violet); }
.sg-gen-themes:disabled { opacity: .6; cursor: default; }

/* ================= RESPONSIVE ================= */
@media (max-width: 760px) {
  .topbar-in { padding: 0 16px; gap: 10px; height: 54px; }
  .nav-step { padding: 7px 10px; }
  .nav-step span:not(.n) { display: none; }   /* numéros seuls sur téléphone */
  .topbar .btn-new { padding: 7px 11px; font-size: 16px; }
  .btn-new-tx { display: none; }              /* « Nouvelle vidéo » → ＋ seul sur XS */
  .btn-new-ic { display: inline; }
  .page { padding: 36px 18px 64px; }
  .src-grid { grid-template-columns: 1fr; }   /* empile fichiers / import sur mobile */
  .counters { gap: 18px; }
  .counter .v { font-size: 19px; }
  .viewer-head { padding: 24px 18px 0; }
  .transport, .practice-wrap, .reader-stage, .thumbs-wrap { padding-left: 18px; padding-right: 18px; }
  .transport-label { min-width: 0; }
  .practice-in { gap: 12px; }
  .practice-star { display: none; }
  .reader-arrow { width: 38px; height: 38px; font-size: 20px; }
  .reader-arrow.prev { left: 8px; }
  .reader-arrow.next { right: 8px; }
  .reader-img { max-height: 38vh; }
  .reader-text { max-height: 30vh; }
  .fs-body { padding: 0 12px; gap: 1vh; }
  .fs-caption { font-size: clamp(20px, 5.4vw, 30px); }
  .fs-quiz-card { gap: 1.2vh; }
  .fs-quiz-choices { grid-template-columns: 1fr; gap: 10px; }
  .fs-choice { min-height: 54px; }
  .fs-pill { max-width: 34vw; }
  .fs-dots { right: 8px; }
  /* photos quiz mobile */
  .fs-pq { padding: 52px 12px calc(env(safe-area-inset-bottom, 0px) + 16px); gap: 12px; }
  .fs-pq-card { padding: 16px 16px; gap: 14px; }
  .fs-pq-q { font-size: clamp(17px, 4.8vw, 22px); }
}

/* =================================================================
   CAHIER-CENTRIQUE — nouveaux composants (index + gallery refonte)
   ================================================================= */

/* ---- breadcrumb ---- */
.breadcrumb {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500;
}
.bc-item {
  color: var(--muted); text-decoration: none;
  transition: color .15s;
}
.bc-item:hover { color: var(--ink); }
.bc-item.bc-active { color: var(--ink); font-weight: 600; }
.bc-sep { color: var(--faint); font-size: 12px; }

/* ---- home page ---- */
.page-home {
  padding-left: 28px;
  /* Filet vertical rouge-marge à gauche — signature cahier */
  border-left: 3px solid var(--margin);
  margin-left: 0;
  position: relative;
}
.page-home::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--margin);
  pointer-events: none;
}
.home-title {
  font-size: clamp(24px, 4vw, 34px); font-weight: 700; letter-spacing: -0.02em;
  margin-bottom: 28px; color: var(--ink);
}
.home-empty { padding: 48px 0; }
.home-empty-msg { color: var(--muted); font-size: 14px; }

/* ---- cahiers grid ---- */
.cahiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 24px;
  /* cap so a few cahiers read as a deliberate shelf rather than tiny cards
     marooned at the left of an ultra-wide page; the wall fills as you add more */
  max-width: 1080px;
}

/* ---- cahier card ---- */
.cahier-card {
  display: flex; flex-direction: column;
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line2);
  background: var(--paper);
  text-decoration: none; color: var(--ink);
  box-shadow: 0 6px 20px -14px rgba(27, 35, 48, 0.25);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  /* Filet rouge-marge à gauche de chaque carte */
  border-left: 3px solid var(--margin);
  cursor: pointer;
  animation: vkrise .25s ease;
}
.cahier-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -14px rgba(27, 35, 48, 0.30);
  border-left-color: var(--margin);
}
.cahier-card:focus-visible {
  outline: 2px solid var(--pen); outline-offset: 2px;
}

/* cover : photo ou placeholder réglure */
.cahier-cover {
  position: relative; aspect-ratio: 3/4; overflow: hidden;
  background: var(--paper);
}
.cahier-cover-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.cahier-cover-ruled {
  width: 100%; height: 100%;
  background: var(--paper);
  position: relative; overflow: hidden;
}
/* Réglure bleue en texture sur le placeholder */
.cahier-cover-lines {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 26px,
    var(--rule) 26px,
    var(--rule) 27px
  );
  opacity: 0.7;
}
.cahier-cover-ruled::before {
  content: "";
  position: absolute; left: 22px; top: 0; bottom: 0; width: 2px;
  background: var(--margin); opacity: 0.5;
  z-index: 1;
}

/* label band at the bottom */
.cahier-label {
  padding: 11px 13px 12px;
  border-top: 1px solid var(--line);
}
.cahier-label-name {
  font-size: 14px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 5px;
}
.cahier-label-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.cahier-page-count {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
}

/* status pills */
.cahier-pill {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  border-radius: 999px; padding: 2px 8px;
  white-space: nowrap;
}
.pill-pret   { background: oklch(0.52 0.1 150 / 0.12); color: oklch(0.40 0.1 150); }
.pill-running { background: oklch(0.46 0.1 252 / 0.10); color: var(--pen); animation: vkblink 1.2s steps(1) infinite; }
.pill-todo   { background: oklch(0.64 0.13 64 / 0.12); color: oklch(0.50 0.12 64); }
.pill-err    { background: oklch(0.55 0.16 28 / 0.10); color: var(--red); }
.pill-new    { background: var(--line); color: var(--muted); }

/* ---- « + Nouveau cahier » card ---- */
.cahier-new {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 180px;
  border: 1.5px dashed var(--line2);
  border-left: 3px solid var(--margin);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 24px 16px;
  transition: border-color .15s, color .15s, background .15s;
}
.cahier-new:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }
.cahier-new.creating { background: var(--paper); border-style: solid; border-color: var(--ink); color: var(--ink); }
.cahier-new-icon { font-size: 28px; font-weight: 300; line-height: 1; }
.cahier-new-label { font-size: 14px; font-weight: 600; }
.cahier-new-form { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.cahier-new-input {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line2); border-radius: 9px; padding: 9px 12px;
  background: var(--bg); outline: none;
}
.cahier-new-input:focus { border-color: var(--pen); }
.cahier-new-hint { font-size: 10px; color: var(--faint); text-align: center; }

/* ---- cahier page (gallery) ---- */
.page-cahier {
  border-left: 3px solid var(--margin);
}

/* header */
.cahier-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 32px; padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.cahier-head-left { flex: 1 1 auto; min-width: 0; }
.cahier-head-right {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0;
}
.cahier-title {
  font-size: clamp(22px, 4vw, 30px); font-weight: 700; letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.cahier-rename-form {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px;
}
.cahier-rename-form[hidden] { display: none; }
.cahier-rename-input {
  font-family: inherit; font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  border: none; border-bottom: 2px solid var(--pen); background: transparent;
  color: var(--ink); outline: none; width: 100%; padding: 2px 0;
}
.cahier-rename-hint { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.cahier-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* CTA buttons */
.btn-cahier-revise {
  display: inline-flex; align-items: center;
  background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 700; font-family: inherit;
  padding: 11px 20px; border-radius: 12px; text-decoration: none;
  transition: filter .15s; white-space: nowrap;
}
.btn-cahier-revise:hover { filter: brightness(1.12); }
.btn-cahier-revise[hidden] { display: none; }

.btn-cahier-transcribe {
  display: inline-flex; align-items: center;
  background: var(--pen); color: #fff;
  font-size: 14px; font-weight: 700; font-family: inherit;
  padding: 11px 20px; border-radius: 12px; border: none; cursor: pointer;
  transition: filter .15s; white-space: nowrap;
}
.btn-cahier-transcribe:hover { filter: brightness(1.1); }
.btn-cahier-transcribe:disabled { opacity: 0.5; cursor: default; filter: none; }
.btn-cahier-transcribe[hidden] { display: none; }

/* inline progress bar */
.cahier-progress {
  display: flex; flex-direction: column; gap: 5px; min-width: 200px;
}
.cahier-progress[hidden] { display: none; }
.cahier-progress-label {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cahier-progress-bar {
  height: 5px; border-radius: 3px; background: var(--line2); overflow: hidden;
}
.cahier-progress-fill {
  height: 100%; width: 0%; border-radius: 3px;
  background: var(--pen); transition: width .3s linear;
}

/* ⋯ menu */
.cahier-menu-wrap { position: relative; }
.btn-cahier-menu {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line2); background: none;
  color: var(--muted); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.btn-cahier-menu:hover { border-color: var(--ink); color: var(--ink); }
.cahier-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--paper); border: 1px solid var(--line2); border-radius: 12px;
  padding: 6px; min-width: 210px;
  box-shadow: 0 12px 30px -10px rgba(27, 35, 48, 0.25);
  animation: vkrise .15s ease;
}
.cahier-menu[hidden] { display: none; }
.cahier-menu-item {
  display: block; width: 100%; text-align: left;
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: none; border: none; border-radius: 8px;
  padding: 9px 13px; cursor: pointer;
  transition: background .12s;
}
.cahier-menu-item:hover { background: var(--bg); }
.cahier-menu-item-danger { color: var(--red); }
.cahier-menu-item-danger:hover { background: oklch(0.55 0.16 28 / 0.08); }

/* ---- sections within the cahier page ---- */
.cahier-section { margin-top: 36px; }
.cahier-section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.cahier-section-title {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--faint); font-weight: 600;
}
.btn-add-pages {
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  border: 1px solid var(--line2); border-radius: 10px; padding: 8px 14px;
  background: none; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-add-pages:hover { border-color: var(--pen); background: var(--paper); }
.btn-add-section {
  font-family: var(--mono); font-size: 12px; color: var(--pen);
  border: 1px solid var(--pen); border-radius: 10px; padding: 8px 14px;
  background: none; cursor: pointer;
  transition: background .15s;
}
.btn-add-section:hover { background: oklch(0.46 0.1 252 / 0.07); }

/* ---- inline dropzone (gallery) ---- */
.cahier-dropzone {
  border: 2px dashed var(--line2); border-radius: 16px;
  background: var(--paper); padding: 36px 32px;
  text-align: center; margin-bottom: 18px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cahier-dropzone[hidden] { display: none; }
.cahier-dropzone.drag { border-color: var(--pen); background: oklch(0.46 0.1 252 / 0.05); }
.cdz-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cdz-icon { font-size: 28px; color: var(--faint); }
.cdz-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.cdz-sub { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }

/* ---- upload queue (gallery) ---- */
.cahier-queue[hidden] { display: none; }
.queue-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.queue-actions { display: flex; gap: 10px; margin-bottom: 18px; }

/* sg-pick-hint shift hint */
.sg-pick-hint-shift { color: var(--faint); font-style: italic; font-size: 10.5px; }

/* ---- btn-ghost (used in queue-actions) ---- */
.btn-ghost {
  padding: 12px 18px; border: 1px solid var(--line2); border-radius: 12px;
  background: none; font-family: inherit; cursor: pointer; font-size: 14px; color: var(--muted);
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }

/* ---- responsive — cahier ---- */
@media (max-width: 760px) {
  .page-home, .page-cahier { border-left-width: 2px; }
  .cahiers-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .cahier-head { flex-direction: column; }
  .cahier-head-right { width: 100%; }
  .cahier-menu { right: auto; left: 0; }
  .bc-item.bc-active { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- phones (xs ≤ 560px) : keep the top bar on ONE row + fullscreen in bounds ---- */
@media (max-width: 560px) {
  .brand-name { display: none; }                 /* logo-only frees the top bar */
  .topbar-in { gap: 10px; }
  .bc-item.bc-active { max-width: 108px; }
  /* the viewer top bar is the crowded one (brand + 3-level breadcrumb + mode
     toggle): collapse the breadcrumb to the « ‹ Mes cahiers » back-link — the h1
     just below already names the cahier — and compact the mode toggle so the
     « Plein écran » button stops being pushed off-screen. */
  body.viewer .breadcrumb { min-width: 0; white-space: nowrap; }
  body.viewer .breadcrumb .bc-sep,
  body.viewer .breadcrumb #bc-cahier,
  body.viewer .breadcrumb .bc-active { display: none; }
  body.viewer .mode-toggle { flex-shrink: 0; }
  body.viewer .mode-btn { padding: 6px 10px; font-size: 11.5px; }
  body.viewer .mode-fs-lbl { display: none; }    /* fullscreen = icon-only on phones */

  /* the « Compréhension par thème » header (eyebrow + hint + reset) overflowed at
     phone widths — and because it widened the whole layout viewport, it pushed the
     position:fixed fullscreen ✕ and the top bar off the visible 320px frame. Wrap. */
  .sg-report-head { flex-wrap: wrap; }
  .sg-report-actions { flex-wrap: wrap; }

  /* fullscreen training: the head bar must keep the ✕ on screen, and the answer
     choices stack in one column. NOTE: vw padding resolves against the (wider)
     layout viewport on mobile and overflows the visible width → use fixed px. */
  .fs-body { padding: 0 12px; }
  .fs-head { padding: 0 12px; }
  .fs-head-left { gap: 6px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
  .fs-head-left .nm { display: none; }
  .fs-pill { max-width: 30vw; min-width: 0; }
  .fs-head-right { gap: 8px; flex: 0 0 auto; }   /* never shrinks → ✕ stays visible */
  .fs-score { font-size: 11px; padding: 4px 8px; }
  .fs-close { width: 30px; height: 30px; }
  .fs-quiz-card { padding: 14px 14px; }
  .fs-quiz-q { overflow-wrap: break-word; }
  .fs-quiz-choices { grid-template-columns: 1fr; }
  .fs-choice { min-height: 52px; padding: 12px 15px; }
  /* xs FOCUS ON THE QUIZ: on a phone the page image squeezes the question into a
     sliver, so while a question is up (or being revealed) drop the slide entirely
     and let the question + choices own the whole screen. The quiz tests recall
     « sans regarder la page » anyway; exit fullscreen to see the page. */
  .fs-stage.quiz .fs-slide-zone,
  .fs-stage.reveal .fs-slide-zone { display: none; }
  .fs-stage.quiz .fs-content,
  .fs-stage.reveal .fs-content { flex: 1 1 auto; justify-content: center; gap: 2.4vh; }
  .fs-stage.quiz .fs-caption,
  .fs-stage.reveal .fs-caption { font-size: clamp(16px, 2.1vh, 22px); }
}

@media (prefers-reduced-motion: reduce) {
  .cahier-card, .cahier-card:hover { transition: none; transform: none; }
  .pill-running { animation: none; }
  .cahier-progress-fill { transition: none; }
}

/* =================================================================
   ÉTUDIER — tuteur conversationnel
   ================================================================= */

/* topbar + page container full-width (like body.viewer) */
body.study .topbar-in { max-width: var(--rev-max); }
/* Étudier topbar: brand left · breadcrumb · actions (Réviser + ⋯ menu) right */
body.study .brand { margin-right: 6px; }   /* cancel the global margin-right:auto */
.study-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.study-menu-wrap { position: relative; flex-shrink: 0; }
.study-menu-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line2);
  background: none; color: var(--muted); font-size: 19px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.study-menu-btn:hover, .study-menu-btn.on { border-color: var(--ink); color: var(--ink); }
.study-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 210px;
  background: var(--paper); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(27, 35, 48, 0.4); padding: 6px;
  display: flex; flex-direction: column;
}
.study-menu[hidden] { display: none; }   /* [hidden] vs display:flex */
.study-menu-logout { margin: 0; display: flex; }
.study-menu-item {
  width: 100%; text-align: left; cursor: pointer; font-family: inherit; font-size: 13.5px;
  color: var(--ink); background: none; border: none; border-radius: 8px; padding: 9px 12px;
  transition: background .12s, color .12s;
}
.study-menu-item:hover { background: var(--penbg); color: var(--pen); }
.study-menu-reset:hover { background: oklch(0.55 0.16 28 / 0.09); color: var(--red); }

/* the « Réviser → » link in the study topbar */
.study-revise-link {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line2); border-radius: 9px; padding: 6px 12px;
  transition: color .15s, border-color .15s; flex-shrink: 0;
}
.study-revise-link:hover { color: var(--ink); border-color: var(--ink); }

/* main split layout */
.study-page {
  flex: 1; display: flex; gap: 0;
  max-width: var(--rev-max); width: 100%; margin: 0 auto;
  padding: 0 28px 0; animation: vkrise .3s ease;
  min-height: 0;
  /* fill the viewport height below the topbar */
  height: calc(100vh - 60px);
}

/* LEFT panel — cahier pages */
.study-left {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  padding-right: 20px; padding-top: 20px; padding-bottom: 20px;
  overflow: hidden;
}

/* carrousel : une page (aperçu + transcription) à la fois, comme Réviser */
.study-reader {
  flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.study-reader-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px;
}
.study-reader-meta {
  flex: 1 1 auto; min-width: 0; text-align: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.study-arrow {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line2); background: var(--paper); color: var(--ink);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s, color .15s;
}
.study-arrow:hover:not(:disabled) { border-color: var(--pen); color: var(--pen); }
.study-arrow:disabled { opacity: 0.35; cursor: default; }

/* onglets : afficher la page OU la transcription */
.study-reader-tabs { flex: 0 0 auto; display: flex; gap: 4px; }
.study-rtab {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint);
  background: none; border: none; cursor: pointer; padding: 5px 10px; border-radius: 7px;
  transition: color .15s, background .15s;
}
.study-rtab.on { background: var(--penbg); color: var(--pen); }
.study-rtab:hover:not(.on) { color: var(--ink); }

/* corps : une seule vue à la fois (page / transcription) */
.study-reader-view { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.study-reader.view-page .study-reader-text { display: none; }
.study-reader.view-transcript .study-reader-img-wrap { display: none; }

.study-reader-img-wrap {
  flex: 1 1 0; min-height: 0; margin: 0; cursor: zoom-in;
  display: flex; align-items: center; justify-content: center; border-radius: 10px;
}
.study-reader-img {
  max-width: 100%; max-height: 100%; height: auto; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line2); background: var(--paper);
  box-shadow: 0 8px 22px -14px rgba(27, 35, 48, 0.3);
  transition: border-color .15s, box-shadow .15s;
}
.study-reader-img-wrap:hover .study-reader-img,
.study-reader-img-wrap:focus-visible .study-reader-img {
  border-color: var(--pen); box-shadow: 0 8px 22px -10px rgba(13, 165, 221, 0.5);
}
.study-reader-img-wrap:focus-visible { outline: none; }

.study-reader-text {
  flex: 1 1 0; min-height: 0; overflow-y: auto;
  border-left: 3px solid var(--margin); padding: 2px 0 12px 14px;
  -webkit-overflow-scrolling: touch;
}
.study-reader-text::-webkit-scrollbar { width: 6px; }
.study-reader-text::-webkit-scrollbar-thumb { background: #cdc7b8; border-radius: 4px; }

.study-thumbs {
  flex: 0 0 auto; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden;
  padding: 6px 0 4px;
}
.study-thumbs::-webkit-scrollbar { height: 8px; }
.study-thumbs::-webkit-scrollbar-thumb { background: #cdc7b8; border-radius: 5px; }
.study-thumb {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; padding: 0; cursor: pointer;
}
.study-thumb-img {
  width: 54px; height: 70px; object-fit: cover; border-radius: 6px;
  border: 2px solid var(--line2); background: var(--paper); transition: border-color .15s;
}
.study-thumb:hover .study-thumb-img { border-color: var(--pen); }
.study-thumb.active .study-thumb-img { border-color: var(--prof); }
.study-thumb-n { font-size: 9.5px; color: var(--faint); }
.study-thumb.active .study-thumb-n { color: var(--prof); font-weight: 600; }
/* aperçu plein écran d'une page au clic — composant partagé (Étudier + gallery) */
.study-lightbox,
.gal-lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 32px;
}
.study-lightbox[hidden], .gal-lightbox[hidden] { display: none; }   /* [hidden] perd contre display:flex sans ça */
.study-lb-backdrop,
.gal-lb-backdrop {
  position: absolute; inset: 0; background: rgba(20, 22, 28, 0.86);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.study-lb-img,
.gal-lb-img {
  position: relative; max-width: 96vw; max-height: 92vh;
  border-radius: 8px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7); object-fit: contain;
}
.study-lb-close,
.gal-lb-close {
  position: absolute; top: 18px; right: 22px; z-index: 1; width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer; border: none;
  background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 18px;
}
.study-lb-close:hover, .gal-lb-close:hover { background: rgba(255, 255, 255, 0.26); }

/* transcription rendue par page dans .study-reader-text (carrousel) */

/* RIGHT panel — chat */
.study-right {
  flex: 1 1 0; min-width: 0;   /* 50/50 avec le lecteur */
  display: flex; flex-direction: column;
  padding-left: 20px; padding-top: 20px; padding-bottom: 20px;
  gap: 10px;
}

/* scrollable message list */
.study-chat-log {
  flex: 1 1 0; overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.study-chat-log::-webkit-scrollbar { width: 6px; }
.study-chat-log::-webkit-scrollbar-thumb { background: #cdc7b8; border-radius: 4px; }

/* chat bubbles */
.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }

.chat-bubble {
  max-width: 88%; padding: 12px 15px; border-radius: 14px;
  font-size: 14px; line-height: 1.6;
  animation: vkrise .2s ease;
}
.chat-msg-user .chat-bubble {
  background: var(--pen); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-user .chat-bubble p { margin: 0; }

/* assistant bubble: paper + serif + margin rule (signature cahier) */
.chat-msg-assistant .chat-bubble {
  background: var(--paper);
  border: 1px solid var(--line2);
  border-left: 3px solid var(--margin);
  border-bottom-left-radius: 4px;
  font-family: var(--serif);
  box-shadow: 0 4px 14px -8px rgba(27, 35, 48, 0.18);
  /* markdown content */
  color: var(--ink);
  overflow-wrap: break-word;        /* jamais de débordement horizontal */
}
/* markdown inside assistant bubble */
.chat-msg-assistant .chat-bubble table {
  display: block; width: max-content; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; font-size: 12px; margin: 6px 0;
}
.chat-msg-assistant .chat-bubble th,
.chat-msg-assistant .chat-bubble td { border: 1px solid var(--line2); padding: 3px 8px; text-align: left; }
.chat-msg-assistant .chat-bubble pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg-assistant .chat-bubble h1 { font-size: 16px; font-weight: 700; margin: 10px 0 5px; }
.chat-msg-assistant .chat-bubble h2 { font-size: 15px; font-weight: 700; margin: 9px 0 4px; }
.chat-msg-assistant .chat-bubble h3 { font-size: 13.5px; font-weight: 600; margin: 8px 0 3px; color: var(--pen); }
.chat-msg-assistant .chat-bubble p { margin: 5px 0; }
.chat-msg-assistant .chat-bubble p:first-child { margin-top: 0; }
.chat-msg-assistant .chat-bubble p:last-child { margin-bottom: 0; }
.chat-msg-assistant .chat-bubble ul,
.chat-msg-assistant .chat-bubble ol { margin: 5px 0; padding-left: 18px; }
.chat-msg-assistant .chat-bubble li { margin: 2px 0; }
.chat-msg-assistant .chat-bubble strong { font-weight: 700; }
.chat-msg-assistant .chat-bubble code {
  font-family: var(--mono); font-size: 12px;
  background: var(--line2); border-radius: 4px; padding: 1px 4px;
}
.chat-msg-assistant .chat-bubble blockquote {
  border-left: 3px solid var(--line2); margin: 5px 0; padding-left: 10px; color: var(--muted);
}

/* skeleton / thinking indicator */
.chat-skeleton .chat-bubble {
  color: var(--muted); font-family: var(--mono); font-size: 12px;
}
.study-thinking {
  display: inline-flex; align-items: center; gap: 8px;
}
.study-thinking .spin {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--line2); border-top-color: var(--pen);
  animation: spin .7s linear infinite;
}

/* input bar */
.study-input-bar {
  display: flex; gap: 8px; align-items: flex-end;
  border: 1px solid var(--line2); border-radius: 14px;
  padding: 8px 8px 8px 12px; background: var(--paper);
  transition: border-color .15s;
  flex-shrink: 0;
}
.study-input-bar:focus-within { border-color: var(--ink); }

.study-input {
  flex: 1 1 0; resize: none; border: none; background: transparent;
  font-family: inherit; font-size: 14px; color: var(--ink); outline: none;
  line-height: 1.5; min-height: 40px; max-height: 120px; overflow-y: auto;
}
.study-input::placeholder { color: var(--faint); }
.study-input:disabled { opacity: .55; }

.study-send {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--grad-shadow); flex-shrink: 0;
  transition: filter .15s;
}
.study-send:hover { filter: brightness(1.1); }
.study-send:disabled { opacity: .5; cursor: default; filter: none; }

/* (Réinitialiser la session a migré dans le kebab ⋯ du header) */

/* « Étudier → » CTA on the gallery (cahier) page */
.btn-cahier-study {
  display: inline-flex; align-items: center;
  background: var(--grad); color: #fff;
  font-size: 14px; font-weight: 700; font-family: inherit;
  padding: 11px 20px; border-radius: 12px; text-decoration: none;
  transition: filter .15s; white-space: nowrap;
  box-shadow: var(--grad-shadow);
}
.btn-cahier-study:hover { filter: brightness(1.1); }
.btn-cahier-study[hidden] { display: none; }

/* ---- responsive: phones ≤ 560px — stack chat first, then pages ---- */
@media (max-width: 560px) {
  .study-page {
    flex-direction: column-reverse;
    height: auto; padding: 0 0 80px;
  }
  .study-left {
    border-right: none; border-top: 1px solid var(--line);
    padding: 16px 16px 20px; overflow: visible;
  }
  .study-reader { flex: none; }
  .study-reader-view { display: block; }
  .study-reader-text { overflow: visible; }
  .study-reader-img-wrap, .study-reader-img { max-height: 40vh; }
  .study-right {
    flex: none; padding: 16px 16px 0;
    height: 60vh; min-height: 360px;
  }
  body.study .topbar-in { padding: 0 14px; gap: 8px; }
  body.study .brand-name { display: none; }              /* « S » seul */
  body.study .breadcrumb .bc-sep,
  body.study .breadcrumb #bc-cahier,
  body.study .breadcrumb .bc-active { display: none; }   /* → « ‹ Mes cahiers » seul */
  .study-head-actions { gap: 6px; }
  .study-revise-link { padding: 6px 9px; }
}

/* ---- responsive: narrow tablets 561–900px ---- */
@media (min-width: 561px) and (max-width: 900px) {
  .study-right { flex: 0 0 320px; }
}
