@charset "UTF-8";
/* ============================================================================
   CURIO — Design system
   ----------------------------------------------------------------------------
   Direction artistique « Studio Savoir » : le savoir comme un jeu de cartes
   éditoriales. Profondeur par empilement (fond → surface → carte), filets de
   1px, rayons généreux, halos d'ambiance colorés par le thème, et UNE seule
   courbe d'accélération partout (--ease) pour que tout le produit ait le
   même « toucher ».

   Sommaire
     1.  Polices (auto-hébergées)
     2.  Tokens globaux
     3.  Thèmes (10)
     4.  Reset & base
     5.  Fond d'ambiance
     6.  Shell & mise en page
     7.  Primitives (boutons, champs, cartes…)
     8.  Composants
     9.  Animations
     10. Accessibilité & responsive
   ========================================================================= */


/* ============================================================================
   1. POLICES — auto-hébergées (aucun appel à Google Fonts : RGPD + vitesse)
   ----------------------------------------------------------------------------
   Outfit et Inter sont des polices variables : un seul fichier par sous-
   ensemble couvre tous les graisses de 100 à 900. 4 fichiers ≈ 176 Ko.
   ========================================================================= */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/outfit-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/outfit-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}


/* ============================================================================
   2. TOKENS GLOBAUX — identiques dans tous les thèmes
   ========================================================================= */
:root {
  /* ---- Typographie ---- */
  --font-display: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Échelle typographique (base 16px, ratio ~1.25) */
  --fs-xs: 0.75rem;    /* 12 — méta, légendes */
  --fs-sm: 0.875rem;   /* 14 — libellés */
  --fs-base: 1rem;     /* 16 — corps (jamais moins sur mobile : évite le zoom auto iOS) */
  --fs-md: 1.0625rem;  /* 17 — corps de leçon */
  --fs-lg: 1.25rem;    /* 20 */
  --fs-xl: 1.5rem;     /* 24 */
  --fs-2xl: 1.875rem;  /* 30 */
  --fs-3xl: 2.25rem;   /* 36 */
  --fs-4xl: 3rem;      /* 48 */

  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-body: 1.65;     /* lecture longue confortable */

  /* ---- Espacement : rythme de 4px ---- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* ---- Rayons ---- */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;      /* rayon signature des cartes */
  --r-2xl: 28px;
  --r-full: 999px;

  /* ---- Mouvement ----
     Une seule courbe pour toute l'app : expo.out. C'est ce qui donne le
     « démarrage franc, arrivée en douceur » des interfaces natives. */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);  /* léger dépassement */
  --t-fast: 120ms;
  --t-base: 220ms;
  --t-slow: 380ms;

  /* ---- Élévation (l'ombre est recolorée par thème via --shadow-hue) ---- */
  --shadow-sm: 0 1px 2px var(--shadow-color);
  --shadow-md: 0 4px 12px var(--shadow-color);
  --shadow-lg: 0 12px 32px var(--shadow-color);
  --shadow-xl: 0 24px 64px var(--shadow-color);

  /* ---- Couches (z-index) ---- */
  --z-ambient: 0;
  --z-base: 1;
  --z-sticky: 20;
  --z-tabbar: 40;
  --z-overlay: 100;
  --z-toast: 1000;

  /* ---- Mise en page ---- */
  --content-max: 720px;
  --tabbar-h: 64px;

  /* Zones sûres iOS : 0 par défaut sur les navigateurs qui ne connaissent pas env() */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}


/* ============================================================================
   3. THÈMES
   ----------------------------------------------------------------------------
   Chaque thème redéfinit EXACTEMENT le même jeu de tokens sémantiques.
   Aucun composant ne connaît une couleur en dur : changer de thème ne
   touche donc jamais à la structure, seulement à la palette.

   ⚠️  Toujours écrire `:root[data-theme="…"]`, jamais `[data-theme="…"]`
   tout court. Un sélecteur non ancré à :root s'applique à N'IMPORTE quel
   élément portant l'attribut — or les boutons du sélecteur de thème
   portent justement data-theme="jour". Chaque bouton redéfinissait alors
   toute la palette pour lui-même (--surface passait au blanc) tandis que
   la propriété `color`, elle, restait héritée du thème courant : libellé
   clair sur carte blanche, illisible.

   Contrat de chaque thème :
     --bg / --bg-2      fonds de page
     --surface / -2     cartes et surfaces empilées
     --border / -strong filets
     --text / -muted / -dim   3 niveaux de texte (4.5:1 / 4.5:1 / 3:1 mini)
     --primary / -ink / -soft action principale
     --accent           accent secondaire
     --success / --danger / --warning
     --blob-1 / --blob-2   halos d'ambiance
     --shadow-color
   ========================================================================= */

/* ---- JOUR — clair, neutre, chaud ---------------------------------------- */
:root[data-theme="jour"] {
  color-scheme: light;
  --bg: #f6f6fb;
  --bg-2: #ecedf5;
  --surface: #ffffff;
  --surface-2: #f4f4f9;
  --border: #e5e5ef;
  --border-strong: #d3d3e2;
  --text: #14141f;
  --text-muted: #55556b;
  --text-dim: #8a8aa3;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #eeecff;
  --accent: #db2777;
  --success: #067647;
  --success-soft: #e7f6ee;
  --danger: #c81e1e;
  --danger-soft: #fdeaea;
  --warning: #b45309;
  --blob-1: #6366f1;
  --blob-2: #ec4899;
  --blob-opacity: 0.16;
  --shadow-color: rgb(20 20 43 / 8%);
  --meta-theme: #f6f6fb;
}

/* ---- NUIT — sombre neutre (défaut) -------------------------------------- */
:root[data-theme="nuit"] {
  color-scheme: dark;
  --bg: #0b0b12;
  --bg-2: #08080e;
  --surface: #16161f;
  --surface-2: #1e1e2a;
  --border: #262633;
  --border-strong: #363648;
  --text: #edecf2;
  --text-muted: #a1a1b5;
  --text-dim: #6f6f85;
  --primary: #818cf8;
  --primary-ink: #0b0b12;
  --primary-soft: #1e1e3a;
  --accent: #f472b6;
  --success: #34d399;
  --success-soft: #0d2a20;
  --danger: #f87171;
  --danger-soft: #2e1416;
  --warning: #fbbf24;
  --blob-1: #6366f1;
  --blob-2: #a855f7;
  --blob-opacity: 0.20;
  --shadow-color: rgb(0 0 0 / 45%);
  --meta-theme: #0b0b12;
}

/* ---- NÉON — noir profond, accents acides, halos lumineux ---------------- */
:root[data-theme="neon"] {
  color-scheme: dark;
  --bg: #04050a;
  --bg-2: #000103;
  --surface: #0b0e18;
  --surface-2: #12172a;
  --border: #1c2340;
  --border-strong: #2b3563;
  --text: #eafcff;
  --text-muted: #8fb4c4;
  --text-dim: #5d7f90;
  --primary: #00f0b5;
  --primary-ink: #00160f;
  --primary-soft: #052b23;
  --accent: #ff2e88;
  --success: #00f0b5;
  --success-soft: #052b23;
  --danger: #ff2e88;
  --danger-soft: #2d0618;
  --warning: #ffd400;
  --blob-1: #00f0b5;
  --blob-2: #ff2e88;
  --blob-opacity: 0.26;
  --shadow-color: rgb(0 0 0 / 65%);
  --meta-theme: #04050a;
  /* Seul thème à assumer la lueur : c'est son identité. */
  --glow: 0 0 24px color-mix(in srgb, var(--primary) 45%, transparent);
}

/* ---- PASTEL — clair, lavande & pêche, très doux ------------------------- */
:root[data-theme="pastel"] {
  color-scheme: light;
  --bg: #fbf8ff;
  --bg-2: #f4eeff;
  --surface: #ffffff;
  --surface-2: #faf6ff;
  --border: #ece4f8;
  --border-strong: #d9cbee;
  --text: #2f2545;
  --text-muted: #6b5f85;
  --text-dim: #9b8fb3;
  --primary: #7c5cd6;
  --primary-ink: #ffffff;
  --primary-soft: #f1eaff;
  --accent: #e26aa5;
  --success: #2f855a;
  --success-soft: #e6f6ee;
  --danger: #c53030;
  --danger-soft: #fdecec;
  --warning: #b7791f;
  --blob-1: #c4b5fd;
  --blob-2: #fbcfe8;
  --blob-opacity: 0.42;
  --shadow-color: rgb(84 56 138 / 10%);
  --meta-theme: #fbf8ff;
}

/* ---- TERRACOTTA — argile sombre, orange brûlé --------------------------- */
:root[data-theme="terracotta"] {
  color-scheme: dark;
  --bg: #191110;
  --bg-2: #120c0b;
  --surface: #241917;
  --surface-2: #302120;
  --border: #3a2825;
  --border-strong: #513833;
  --text: #f6ece7;
  --text-muted: #bfa398;
  --text-dim: #8d7368;
  --primary: #f97316;
  --primary-ink: #1b0f06;
  --primary-soft: #3a1f0c;
  --accent: #e8b04b;
  --success: #86c06c;
  --success-soft: #1c2a15;
  --danger: #ef6b6b;
  --danger-soft: #331414;
  --warning: #e8b04b;
  --blob-1: #f97316;
  --blob-2: #b45309;
  --blob-opacity: 0.22;
  --shadow-color: rgb(20 8 4 / 55%);
  --meta-theme: #191110;
}

/* ---- OCÉAN — bleu abyssal, cyan ---------------------------------------- */
:root[data-theme="ocean"] {
  color-scheme: dark;
  --bg: #061626;
  --bg-2: #030e1a;
  --surface: #0c2136;
  --surface-2: #123047;
  --border: #163a56;
  --border-strong: #205377;
  --text: #e7f4fb;
  --text-muted: #9dbdd3;
  --text-dim: #6791ad;
  --primary: #38bdf8;
  --primary-ink: #04141f;
  --primary-soft: #0b2f45;
  --accent: #5eead4;
  --success: #2dd4bf;
  --success-soft: #06302c;
  --danger: #fb7185;
  --danger-soft: #35131c;
  --warning: #fbbf24;
  --blob-1: #0ea5e9;
  --blob-2: #2dd4bf;
  --blob-opacity: 0.24;
  --shadow-color: rgb(1 12 22 / 55%);
  --meta-theme: #061626;
}

/* ---- FORÊT — vert profond, mousse & lime ------------------------------- */
:root[data-theme="foret"] {
  color-scheme: dark;
  --bg: #0a1710;
  --bg-2: #061009;
  --surface: #12261a;
  --surface-2: #1a3524;
  --border: #1f3f2a;
  --border-strong: #2d5a3c;
  --text: #e9f5ec;
  --text-muted: #a2c1ab;
  --text-dim: #6f9179;
  --primary: #4ade80;
  --primary-ink: #052013;
  --primary-soft: #0d2e1b;
  --accent: #a3e635;
  --success: #4ade80;
  --success-soft: #0d2e1b;
  --danger: #f87171;
  --danger-soft: #2e1416;
  --warning: #facc15;
  --blob-1: #22c55e;
  --blob-2: #a3e635;
  --blob-opacity: 0.20;
  --shadow-color: rgb(2 15 8 / 55%);
  --meta-theme: #0a1710;
}

/* ---- RÉTRO — impression 70s, crème, rouille & olive -------------------- */
:root[data-theme="retro"] {
  color-scheme: light;
  --bg: #f4ecd8;
  --bg-2: #e9dcc0;
  --surface: #fdf8ec;
  --surface-2: #f1e7cf;
  --border: #ded0ae;
  --border-strong: #c4b189;
  --text: #2c2418;
  --text-muted: #6b5c42;
  --text-dim: #94815f;
  --primary: #b4451f;
  --primary-ink: #fdf8ec;
  --primary-soft: #f7e4d6;
  --accent: #5c7a29;
  --success: #4a6b1f;
  --success-soft: #eaf0d9;
  --danger: #a32c1a;
  --danger-soft: #f9e2dd;
  --warning: #9a6a12;
  --blob-1: #d97706;
  --blob-2: #65a30d;
  --blob-opacity: 0.22;
  --shadow-color: rgb(70 50 20 / 12%);
  --meta-theme: #f4ecd8;
}

/* ---- ENCRE — papier & encre, éditorial --------------------------------- */
:root[data-theme="encre"] {
  color-scheme: light;
  --bg: #f2efe6;
  --bg-2: #e7e3d6;
  --surface: #fbfaf5;
  --surface-2: #f0ede3;
  --border: #ddd8c8;
  --border-strong: #bdb7a3;
  --text: #16181d;
  --text-muted: #4d5259;
  --text-dim: #82868f;
  --primary: #1e3a8a;
  --primary-ink: #fbfaf5;
  --primary-soft: #e3e8f5;
  --accent: #9f1239;
  --success: #14532d;
  --success-soft: #e2eee7;
  --danger: #9f1239;
  --danger-soft: #f9e4e9;
  --warning: #854d0e;
  --blob-1: #1e3a8a;
  --blob-2: #9f1239;
  --blob-opacity: 0.10;
  --shadow-color: rgb(30 30 20 / 10%);
  --meta-theme: #f2efe6;
}

/* ---- MONO — noir & blanc, zéro couleur --------------------------------- */
:root[data-theme="mono"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-2: #f2f2f2;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --border: #e0e0e0;
  --border-strong: #111111;
  --text: #000000;
  --text-muted: #4a4a4a;
  --text-dim: #767676;
  --primary: #000000;
  --primary-ink: #ffffff;
  --primary-soft: #f0f0f0;
  --accent: #000000;
  --success: #1a1a1a;
  --success-soft: #eeeeee;
  --danger: #1a1a1a;
  --danger-soft: #eeeeee;
  --warning: #1a1a1a;
  --blob-1: #000000;
  --blob-2: #666666;
  --blob-opacity: 0.05;
  --shadow-color: rgb(0 0 0 / 10%);
  --meta-theme: #ffffff;
}
/* En mono, la couleur ne peut plus porter le sens (juste/faux) : on
   s'appuie uniquement sur l'icône, le texte et l'épaisseur du filet.
   C'est aussi ce qui rend le thème utilisable en cas de daltonisme total. */
:root[data-theme="mono"] .quiz-opt--correct { border-width: 2.5px; }
:root[data-theme="mono"] .quiz-opt--wrong { border-style: dashed; border-width: 2px; }


/* ============================================================================
   4. RESET & BASE
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

/* L'attribut `hidden` ne vaut que display:none dans la feuille du
   navigateur : n'importe quel `display` défini ici l'écrase en silence.
   Un élément [hidden] avec display:inline-flex resterait donc visible.
   Cette règle rend l'attribut fiable partout. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;  /* iOS : pas de gonflement du texte en paysage */
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;              /* dvh > vh : gère la barre d'URL mobile qui se rétracte */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;              /* filet de sécurité : jamais de scroll horizontal */
  /* La transition de thème : seules les couleurs bougent, jamais la mise en page. */
  transition: background-color var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
}

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; padding: 0; cursor: pointer; }

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  font-weight: 700;
}

/* Chiffres à chasse fixe pour tous les compteurs : sans ça, un « 1 » plus
   étroit qu'un « 8 » fait tressauter la largeur pendant les animations. */
.tabular { font-variant-numeric: tabular-nums; }

::selection { background: var(--primary); color: var(--primary-ink); }

/* ---- Focus : visible, cohérent, jamais supprimé ---- */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: fixed;
  top: calc(var(--safe-t) + var(--sp-2));
  left: 50%;
  translate: -50% -200%;
  z-index: var(--z-toast);
  padding: var(--sp-3) var(--sp-5);
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: var(--r-full);
  font-weight: 600;
  transition: translate var(--t-base) var(--ease);
}
.skip-link:focus { translate: -50% 0; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  stroke: currentColor;
  fill: none;
}
.icon--sm { width: 18px; height: 18px; }
.icon--lg { width: 32px; height: 32px; }


/* ============================================================================
   5. FOND D'AMBIANCE
   ----------------------------------------------------------------------------
   Deux halos radiaux qui dérivent très lentement. Ils sont en position fixed
   et pointer-events:none : purement décoratifs, jamais dans le chemin du
   doigt. C'est ce qui donne la profondeur « premium » sans image.
   ========================================================================= */
.ambient {
  position: fixed;
  inset: 0;
  z-index: var(--z-ambient);
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
  transition: background-color var(--t-slow) var(--ease);
}

.ambient__blob {
  position: absolute;
  width: 78vmax;
  height: 78vmax;
  border-radius: 50%;
  opacity: var(--blob-opacity);
  filter: blur(80px);
  /* will-change absent volontairement : ces éléments sont énormes, les
     promouvoir en couche GPU coûte plus de mémoire que ça ne rapporte. */
  transition: background var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
}
.ambient__blob--1 {
  top: -34vmax;
  left: -22vmax;
  background: radial-gradient(circle at center, var(--blob-1), transparent 62%);
  animation: drift-a 26s var(--ease) infinite alternate;
}
.ambient__blob--2 {
  bottom: -40vmax;
  right: -26vmax;
  background: radial-gradient(circle at center, var(--blob-2), transparent 62%);
  animation: drift-b 32s var(--ease) infinite alternate;
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(8vmax, 6vmax, 0) scale(1.14); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.1); }
  to   { transform: translate3d(-7vmax, -5vmax, 0) scale(1); }
}


/* ============================================================================
   6. SHELL & MISE EN PAGE
   ========================================================================= */
.app {
  position: relative;
  z-index: var(--z-base);
  min-height: 100dvh;
}

.view {
  /* Marges latérales adaptatives + respect des encoches en paysage */
  padding-inline: max(var(--sp-5), var(--safe-l), var(--safe-r));
  padding-top: calc(var(--safe-t) + var(--sp-4));
  /* Réserve la place de la tabbar : sans ça le dernier élément de liste
     passe DERRIÈRE la barre et devient intappable. */
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--sp-8));
  max-width: calc(var(--content-max) + var(--sp-10));
  margin-inline: auto;
}
.view:focus { outline: none; }

/* Écrans sans tabbar (auth, leçon, quiz) */
.view--full { padding-bottom: calc(var(--safe-b) + var(--sp-8)); }

/* Transition d'écran : montée courte + fondu. Enter uniquement — la sortie
   est instantanée pour que la navigation reste nerveuse. */
.screen { animation: screen-in var(--t-slow) var(--ease) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to   { opacity: 1; transform: none; }
}

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--lg { gap: var(--sp-6); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: var(--sp-3);
}


/* ============================================================================
   7. PRIMITIVES
   ========================================================================= */

/* ---- Boutons -----------------------------------------------------------
   Hauteur mini 48px partout : au-dessus du minimum de 44pt d'Apple et des
   48dp de Material, pour une cible confortable au pouce.
   ------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;      /* supprime le délai de 300ms sur mobile */
  border: 1px solid transparent;
  /* On n'anime que transform / opacity / couleurs : jamais width ou height,
     qui forceraient un recalcul de mise en page à chaque frame. */
  transition:
    transform var(--t-fast) var(--ease),
    background-color var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease),
    opacity var(--t-base) var(--ease);
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: var(--shadow-md), var(--glow, none);
}
@media (hover: hover) {
  .btn--primary:hover { filter: brightness(1.08); box-shadow: var(--shadow-lg), var(--glow, none); }
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
@media (hover: hover) {
  .btn--ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
}

.btn--quiet {
  background: transparent;
  color: var(--text-muted);
}
@media (hover: hover) {
  .btn--quiet:hover { background: var(--surface-2); color: var(--text); }
}

.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
@media (hover: hover) {
  .btn--danger:hover { background: var(--danger-soft); }
}

.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 56px; font-size: var(--fs-lg); padding-inline: var(--sp-8); }

/* État désactivé / en cours : opacité réduite + curseur explicite +
   pointer-events coupés pour qu'un double-tap ne renvoie pas 2 requêtes. */
.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Bouton icône seul — hitbox élargie au-delà du visuel */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:active { transform: scale(0.9); }
@media (hover: hover) {
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
}

/* ---- Spinner ----
   display:inline-block obligatoire : il est rendu dans un <span> imbriqué
   (donc PAS enfant direct du flex du bouton, qui l'aurait « blockifié »
   tout seul). En inline pur, width/height sont ignorés et il s'affichait
   en 4×24 px — un trait, pas un rond. Invisible à l'œil car il ne dure
   qu'une fraction de seconde. */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Cartes ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; overflow: hidden; }

/* ---- Champs de formulaire ---- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }

.field__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.field__req { color: var(--danger); }

.field__wrap { position: relative; display: flex; align-items: center; }

.input {
  width: 100%;
  /* 16px minimum : en dessous, iOS zoome automatiquement au focus. */
  font-size: var(--fs-base);
  min-height: 52px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
}
.input::placeholder { color: var(--text-dim); }
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input--has-btn { padding-right: 52px; }
.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 15%, transparent);
}

.field__toggle {
  position: absolute;
  right: 4px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  cursor: pointer;
}
@media (hover: hover) { .field__toggle:hover { color: var(--text); } }

/* Texte d'aide persistant (≠ placeholder, qui disparaît à la saisie) */
.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  line-height: 1.45;
}

/* Erreur placée SOUS le champ concerné, avec icône : la couleur seule ne
   suffit jamais à porter le sens. */
.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--danger);
  animation: slip-in var(--t-base) var(--ease);
}
.field__error .icon { width: 14px; height: 14px; margin-top: 2px; }

@keyframes slip-in {
  from { opacity: 0; transform: translate3d(0, -4px, 0); }
  to   { opacity: 1; transform: none; }
}

/* ---- Pastilles ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.chip--primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip .icon { width: 13px; height: 13px; }


/* ============================================================================
   8. COMPOSANTS
   ========================================================================= */

/* ---- 8.1 Barre d'onglets -----------------------------------------------
   Fixée en bas (zone du pouce), floutée, avec respect de la barre gestuelle.
   3 destinations seulement : bien en dessous de la limite de 5.
   ------------------------------------------------------------------------ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-tabbar);
  display: flex;
  justify-content: center;
  gap: var(--sp-1);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  padding-inline: var(--sp-2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: background-color var(--t-slow) var(--ease), border-color var(--t-slow) var(--ease);
}
.tabbar[hidden] { display: none; }

.tab {
  position: relative;
  flex: 1;
  /* 96px : à 4 onglets sur un écran de 375px, 120px déborderait. */
  max-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--tabbar-h);
  color: var(--text-dim);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color var(--t-base) var(--ease);
}
.tab__ico {
  display: grid;
  place-items: center;
  width: 46px;
  height: 30px;
  border-radius: var(--r-full);
  transition: background-color var(--t-base) var(--ease), transform var(--t-base) var(--spring);
}
.tab__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
/* L'onglet actif ne se signale pas QUE par la couleur : la pastille de
   fond et la graisse du libellé le disent aussi. */
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"] .tab__ico {
  background: var(--primary-soft);
  transform: translateY(-1px);
}
.tab[aria-current="page"] .tab__label { font-weight: 700; }
.tab:active .tab__ico { transform: scale(0.88); }

/* ---- 8.2 En-tête d'écran ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  min-height: 44px;
}
.topbar__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar__sub { font-size: var(--fs-xs); color: var(--text-dim); }

/* ---- 8.3 Bandeau d'accueil (niveau + XP + série) ---- */
.hero { margin-bottom: var(--sp-6); }

.hero__greet {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-1);
}
.hero__greet em {
  font-style: normal;
  background: linear-gradient(100deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__sub { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-5); }

.hero__panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-5);
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--sp-5);
  box-shadow: var(--shadow-md);
}

.level-line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.level-badge .icon { color: var(--primary); width: 20px; height: 20px; }
/* nowrap : « 50 / 100 XP » doit rester d'un bloc. Sans ça, « XP » tombe
   seul à la ligne dès que le pseudo ou la langue élargit le bandeau. */
.level-xp { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 600; white-space: nowrap; }

/* ---- 8.4 Barre d'XP ----
   La largeur est portée par une variable --p (0→100) et animée via
   transform: scaleX, pas via width : scaleX est composité par le GPU et
   ne déclenche aucun reflow. */
.xpbar {
  position: relative;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.xpbar__fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: inherit;
  transition: transform 900ms var(--ease);
}
/* Reflet qui balaie la barre — signale « ça progresse » sans rien déplacer. */
.xpbar__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, white 45%, transparent), transparent);
  transform: translateX(-100%);
  animation: shine 2.6s var(--ease) infinite;
}
@keyframes shine {
  0%   { transform: translateX(-100%); }
  55%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

/* ---- 8.5 Anneau d'objectif quotidien ----
   Cercle SVG avec stroke-dashoffset animé. */
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--surface-2); }
.ring__bar {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: var(--circ);
  stroke-dashoffset: var(--offset);
  transition: stroke-dashoffset 900ms var(--ease), stroke var(--t-slow) var(--ease);
}
.ring__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.ring__num {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1;
}
.ring__label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.ring--done .ring__bar { stroke: var(--success); }

/* ---- 8.6 Série (streak) ---- */
.streak {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-base);
}
.streak__flame { color: var(--warning); }
/* La flamme respire quand la série est vivante ; elle s'éteint (grise, figée)
   quand elle est à zéro : l'état se lit d'un coup d'œil. */
.streak--live .streak__flame { animation: flicker 2.2s var(--ease) infinite; }
.streak--dead { opacity: 0.55; }
.streak--dead .streak__flame { color: var(--text-dim); }

@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  30%      { transform: scale(1.16) rotate(-4deg); }
  60%      { transform: scale(1.06) rotate(3deg); }
}

/* ---- 8.7 Grille de thèmes (topics) ---- */
.topics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: var(--sp-3);
}

.topic {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  min-height: 132px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  /* Entrée en cascade : --i est posé par app.js sur chaque carte. */
  animation: pop-in var(--t-slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 32ms);
}
/* Voile de la couleur signature du topic, révélé au survol/appui. */
.topic::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 100% 0%, var(--topic-color), transparent 68%);
  opacity: 0.10;
  transition: opacity var(--t-base) var(--ease);
  pointer-events: none;
}
.topic:active { transform: scale(0.97); }
@media (hover: hover) {
  .topic:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--topic-color) 45%, var(--border));
  }
  .topic:hover::before { opacity: 0.20; }
}

.topic__ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  color: var(--topic-color);
  background: color-mix(in srgb, var(--topic-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--topic-color) 22%, transparent);
  transition: transform var(--t-base) var(--spring);
}
@media (hover: hover) { .topic:hover .topic__ico { transform: scale(1.08) rotate(-4deg); } }

.topic__name {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.topic__meta {
  margin-top: auto;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-weight: 500;
}
/* Liseré de progression en pied de carte */
.topic__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--surface-2);
}
.topic__bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  background: var(--topic-color);
  transition: transform 700ms var(--ease);
}
.topic__done {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--success);
  color: var(--bg);
}
.topic__done .icon { width: 13px; height: 13px; stroke-width: 3; }

@keyframes pop-in {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* ---- 8.8 Liste de leçons ---- */
.lesson-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  padding: var(--sp-4);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
  animation: pop-in var(--t-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.lesson-item:active { transform: scale(0.985); }
@media (hover: hover) {
  .lesson-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
}
.lesson-item__num {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.lesson-item--done .lesson-item__num {
  background: var(--success);
  border-color: transparent;
  color: var(--bg);
}
/* display:block indispensable : ce sont des <span>, ils s'enchaîneraient
   sur la même ligne (« Titre 4 questions ») sans ça. */
.lesson-item__title { display: block; font-weight: 600; font-size: var(--fs-base); line-height: 1.3; }
.lesson-item__sub { display: block; font-size: var(--fs-xs); color: var(--text-dim); margin-top: 2px; }
.lesson-item__go { color: var(--text-dim); }

/* ---- 8.9 Contrôle segmenté (format 1 / 2 / 5 min) ----
   La pastille active glisse d'un segment à l'autre via translate : un seul
   élément se déplace, les libellés ne bougent jamais.
   ------------------------------------------------------------------------ */
.segmented {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
}
.segmented__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--n, 3));
  background: var(--surface);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  transform: translateX(calc(var(--idx, 0) * 100%));
  transition: transform var(--t-base) var(--ease);
}
.seg {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 40px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color var(--t-base) var(--ease);
}
.seg[aria-selected="true"] { color: var(--text); font-weight: 700; }

/* ---- 8.10 Lecteur de leçon ---- */
.reader { max-width: 65ch; margin-inline: auto; }

.reader__kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--topic-color, var(--primary));
  margin-bottom: var(--sp-3);
}
.reader__title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--sp-3);
}
.reader__lede {
  font-size: var(--fs-lg);
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: var(--sp-6);
}

.reader__body p {
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  margin-bottom: var(--sp-5);
  /* Entrée en cascade des paragraphes quand on change de format */
  animation: para-in var(--t-slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.reader__body p:last-child { margin-bottom: 0; }
.reader__body strong { font-weight: 700; color: var(--text); }

@keyframes para-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: none; }
}

/* Progression de lecture, collée sous l'encoche */
.readbar {
  position: fixed;
  top: var(--safe-t);
  left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: var(--z-sticky);
}
.readbar i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: transform 90ms linear;
}

.reader__foot {
  margin-top: var(--sp-10);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
}

/* ---- 8.11 Quiz ---- */
.quiz__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.quiz__count { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); }

.quiz__dots { display: flex; gap: 5px; }
.quiz__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color var(--t-base) var(--ease), transform var(--t-base) var(--spring);
}
.quiz__dot--on { background: var(--primary); border-color: transparent; transform: scale(1.3); }
.quiz__dot--ok { background: var(--success); border-color: transparent; }
.quiz__dot--ko { background: var(--danger); border-color: transparent; }

.quiz__q {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: var(--sp-6);
  animation: screen-in var(--t-slow) var(--ease) both;
}

.quiz__opts { display: flex; flex-direction: column; gap: var(--sp-3); }

.quiz-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 60px;
  padding: var(--sp-4);
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  font-size: var(--fs-base);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform var(--t-fast) var(--ease),
    border-color var(--t-base) var(--ease),
    background-color var(--t-base) var(--ease);
  animation: pop-in var(--t-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.quiz-opt:active:not(:disabled) { transform: scale(0.985); }
@media (hover: hover) {
  .quiz-opt:not(:disabled):hover { border-color: var(--primary); background: var(--surface-2); }
}

/* Lettre A/B/C/D — repère stable, utile quand on relit la correction */
.quiz-opt__key {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--text-muted);
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.quiz-opt__mark { margin-left: auto; opacity: 0; transform: scale(0.5); transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--spring); }

/* Correction : jamais la couleur seule — il y a AUSSI une icône (✓ / ✕)
   et un changement d'épaisseur de filet. */
.quiz-opt--correct {
  border-color: var(--success);
  background: var(--success-soft);
  animation: pulse-ok var(--t-slow) var(--ease);
}
.quiz-opt--correct .quiz-opt__key { background: var(--success); color: var(--bg); border-color: transparent; }
.quiz-opt--correct .quiz-opt__mark { opacity: 1; transform: none; color: var(--success); }

.quiz-opt--wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  animation: shake 420ms var(--ease);
}
.quiz-opt--wrong .quiz-opt__key { background: var(--danger); color: var(--bg); border-color: transparent; }
.quiz-opt--wrong .quiz-opt__mark { opacity: 1; transform: none; color: var(--danger); }

.quiz-opt:disabled { cursor: default; }
.quiz-opt--muted { opacity: 0.45; }

@keyframes pulse-ok {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Explication de la bonne réponse */
.explain {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  animation: slip-in var(--t-base) var(--ease);
}
.explain__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}
.explain__head .icon { width: 16px; height: 16px; color: var(--primary); }
.explain p { font-size: var(--fs-sm); line-height: 1.6; color: var(--text-muted); }

/* Barre d'action collante en bas du quiz */
.quiz__action {
  position: sticky;
  bottom: 0;
  margin-top: var(--sp-6);
  padding-block: var(--sp-4);
  padding-bottom: calc(var(--sp-4) + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}

/* ---- 8.12 Résultat de quiz ---- */
.result { text-align: center; padding-top: var(--sp-8); }
.result__score {
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(100deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result__label { color: var(--text-muted); margin-top: var(--sp-2); margin-bottom: var(--sp-6); }
.result__gains { display: flex; justify-content: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-8); }

.gain {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-sm);
  animation: pop-in var(--t-slow) var(--spring) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}

/* ---- 8.13 Statistiques ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
.stat {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  animation: pop-in var(--t-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
.stat__ico { color: var(--primary); margin-bottom: var(--sp-2); }
.stat__val {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat__label { font-size: var(--fs-xs); color: var(--text-dim); margin-top: var(--sp-1); font-weight: 500; }

/* ---- 8.14 Badges ---- */
.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--sp-3);
}
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-2);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: transform var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  animation: pop-in var(--t-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.badge:active { transform: scale(0.95); }
.badge__ico {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all var(--t-base) var(--ease);
}
.badge__name { font-size: 10.5px; font-weight: 700; line-height: 1.25; color: var(--text-dim); }

.badge--on { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.badge--on .badge__ico {
  background: linear-gradient(145deg, var(--primary), var(--accent));
  border-color: transparent;
  color: var(--primary-ink);
  box-shadow: var(--shadow-md), var(--glow, none);
}
.badge--on .badge__name { color: var(--text); }
@media (hover: hover) {
  .badge--on:hover { transform: translateY(-2px); }
  .badge--on:hover .badge__ico { transform: rotate(-6deg) scale(1.05); }
}

/* ---- 8.15 Sélecteur de thème ---- */
.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--sp-3);
}
.theme-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-base) var(--ease);
}
.theme-opt:active { transform: scale(0.96); }
.theme-opt[aria-checked="true"] { border-color: var(--primary); }
@media (hover: hover) { .theme-opt:hover { border-color: var(--border-strong); } }

/* Aperçu réel du thème : les 3 pastilles sont peintes avec les vraies
   couleurs du thème visé, pas une approximation. */
.theme-opt__preview {
  display: flex;
  gap: 4px;
  height: 34px;
  padding: 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.theme-opt__preview i { flex: 1; border-radius: 3px; }
.theme-opt__name { font-size: var(--fs-xs); font-weight: 600; text-align: center; }
.theme-opt__check {
  position: absolute;
  top: -7px; right: -7px;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--spring);
}
.theme-opt__check .icon { width: 13px; height: 13px; stroke-width: 3.5; }
.theme-opt[aria-checked="true"] .theme-opt__check { opacity: 1; transform: none; }

/* ---- 8.16 Réglages ---- */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.setting:last-child { border-bottom: none; }
.setting__label { font-weight: 600; font-size: var(--fs-base); }
.setting__hint { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 2px; }

/* ---- 8.17 Écran d'authentification ---- */
.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin-inline: auto;
  padding-block: var(--sp-10);
}
.auth__brand { text-align: center; margin-bottom: var(--sp-8); }
.auth__logo {
  display: inline-grid;
  place-items: center;
  width: 68px; height: 68px;
  border-radius: 21px;         /* squircle iOS-like */
  background: linear-gradient(145deg, var(--primary), var(--accent));
  color: var(--primary-ink);
  box-shadow: var(--shadow-lg), var(--glow, none);
  margin-bottom: var(--sp-4);
  animation: logo-in 700ms var(--spring) both;
}
@keyframes logo-in {
  from { opacity: 0; transform: scale(0.6) rotate(-12deg); }
  to   { opacity: 1; transform: none; }
}
.auth__name {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: var(--sp-2);
}
.auth__tag { color: var(--text-muted); font-size: var(--fs-sm); }

.auth__tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  margin-bottom: var(--sp-6);
  position: relative;
}
.auth__foot { margin-top: var(--sp-6); text-align: center; font-size: var(--fs-xs); color: var(--text-dim); line-height: 1.6; }

/* ---- 8.18 Notifications (toasts) ---- */
.toasts {
  position: fixed;
  left: 50%;
  translate: -50% 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--sp-4));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(440px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in var(--t-base) var(--ease) both;
}
.toast--out { animation: toast-out var(--t-fast) var(--ease-in) both; }
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--error .icon { color: var(--danger); }
.toast--success { border-color: var(--success); }
.toast--success .icon { color: var(--success); }
.toast .icon { flex: none; }

@keyframes toast-in {
  from { opacity: 0; transform: translate3d(0, 16px, 0) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.98); }
}

/* ---- 8.19 Célébration (level up / badge) ---- */
.celebration {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  /* Voile assez opaque pour isoler la carte du contenu derrière */
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fade-in var(--t-base) var(--ease);
}
.celebration[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.celebration__canvas { position: absolute; inset: 0; pointer-events: none; }

.celebration__card {
  position: relative;
  text-align: center;
  max-width: 340px;
  padding: var(--sp-8) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  animation: celebrate-in 620ms var(--spring) both;
}
@keyframes celebrate-in {
  from { opacity: 0; transform: scale(0.8) translate3d(0, 24px, 0); }
  to   { opacity: 1; transform: none; }
}

.celebration__medal {
  display: inline-grid;
  place-items: center;
  width: 92px; height: 92px;
  border-radius: 50%;
  margin-bottom: var(--sp-5);
  background: linear-gradient(145deg, var(--primary), var(--accent));
  color: var(--primary-ink);
  box-shadow: var(--shadow-lg), var(--glow, none);
  animation: medal-in 800ms var(--spring) 120ms both;
}
.celebration__medal .icon { width: 44px; height: 44px; }
@keyframes medal-in {
  from { opacity: 0; transform: scale(0.3) rotate(-160deg); }
  to   { opacity: 1; transform: none; }
}

.celebration__kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin-bottom: var(--sp-2);
}
.celebration__title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-2);
}
.celebration__text { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-6); }

/* ---- 8.20 États vides & squelettes ---- */
.empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
}
.empty__ico {
  display: inline-grid;
  place-items: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  margin-bottom: var(--sp-4);
}
.empty__title { font-size: var(--fs-lg); font-weight: 700; margin-bottom: var(--sp-2); }
.empty__text { color: var(--text-muted); font-size: var(--fs-sm); max-width: 34ch; margin-inline: auto; margin-bottom: var(--sp-5); }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: sk 1.4s linear infinite;
  border-radius: var(--r-md);
}
@keyframes sk { to { background-position: -200% 0; } }
.skeleton--card { height: 132px; border-radius: var(--r-xl); }

/* Écran de chargement initial */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
}


/* ============================================================================
   8.21 PARCOURS — le chemin sinueux
   ----------------------------------------------------------------------------
   Les positions des nœuds sont calculées en JS (sinusoïde) et servent à la
   fois à placer les boutons ET à tracer le trait SVG qui les relie : une
   seule source de vérité, aucune lecture de layout, donc aucun reflow.
   ========================================================================= */
.path {
  position: relative;
  margin-inline: auto;
  max-width: 420px;
}

/* Le trait passe DERRIÈRE les nœuds */
.path__line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.path__line-bg {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 10;
  stroke-linecap: round;
}
/* Portion déjà parcourue : révélée par stroke-dashoffset */
.path__line-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 0.85;
  transition: stroke-dashoffset 1.2s var(--ease);
}

.node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;   /* centre le nœud sur sa coordonnée */
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border: none;
  background: none;
  transition: transform var(--t-base) var(--spring);
  animation: pop-in var(--t-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.node:active { transform: scale(0.9); }

/* Le disque : une pastille épaisse avec une ombre portée « 3D » */
.node__disc {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  color: var(--text-dim);
  /* Ombre dure vers le bas : donne l'épaisseur d'un vrai bouton physique */
  box-shadow: 0 4px 0 var(--border);
  transition: background-color var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              color var(--t-base) var(--ease);
}
.node:active .node__disc { box-shadow: 0 1px 0 var(--border); }

/* Étape franchie */
.node--done .node__disc {
  background: var(--topic-color, var(--primary));
  border-color: transparent;
  color: var(--bg);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--topic-color, var(--primary)) 55%, black);
}

/* Étape courante : la seule qui pulse. Une seule cible d'attention. */
.node--current .node__disc {
  background: var(--surface);
  border-color: var(--topic-color, var(--primary));
  color: var(--topic-color, var(--primary));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--topic-color, var(--primary)) 40%, transparent),
              var(--glow, none);
}
.node--current::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--topic-color, var(--primary));
  animation: halo 2.2s var(--ease) infinite;
}
@keyframes halo {
  0%   { transform: scale(1); opacity: 0.9; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Étape verrouillée */
.node--locked { cursor: not-allowed; }
.node--locked .node__disc { opacity: 0.45; }

/* Étape « cadeau » : un palier tous les 5 nœuds */
.node--gift .node__disc {
  background: linear-gradient(145deg, var(--primary), var(--accent));
  border-color: transparent;
  color: var(--primary-ink);
}

.node__num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-base);
}

/* Bulle « Commencer » au-dessus de l'étape courante */
.node__bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  translate: -50% 0;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--topic-color, var(--primary));
  color: var(--bg);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  animation: bob 2.4s var(--ease) infinite;
}
.node__bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% -1px;
  border: 6px solid transparent;
  border-top-color: var(--topic-color, var(--primary));
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* Bandeau de section (un par thème traversé).
   margin:0 obligatoire — il est positionné en absolu par JS, et une marge
   viendrait s'ajouter au `top` calculé, décalant le bandeau sur la bulle
   « Commencer » du nœud. La position doit être dictée par le seul JS. */
.path-section {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--topic-color) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--topic-color) 30%, var(--border));
}
.path-section__ico {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--topic-color) 20%, transparent);
  color: var(--topic-color);
}
.path-section__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-base);
  line-height: 1.2;
}
.path-section__meta { font-size: var(--fs-xs); color: var(--text-muted); }


/* ============================================================================
   8.22 DÉCOUVRIR — le deck à swiper
   ========================================================================= */
.deck {
  position: relative;
  height: min(56vh, 440px);
  margin-block: var(--sp-5);
  perspective: 1000px;
}

.deck__card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* pan-y : on garde le scroll vertical de la page, on ne capte que
     l'horizontale. Sans ça, le geste vole le défilement au navigateur. */
  touch-action: pan-y;
  will-change: transform;
}
.deck__card:active { cursor: grabbing; }

/* Voile de la couleur du thème */
.deck__card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, var(--topic-color), transparent 70%);
  opacity: 0.14;
  pointer-events: none;
}

/* Les cartes du dessous : décalées et réduites, elles donnent l'épaisseur du paquet */
.deck__card--behind {
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.deck__topic {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  align-self: flex-start;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--topic-color) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--topic-color) 30%, transparent);
  color: var(--topic-color);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.deck__topic .icon { width: 15px; height: 15px; }

/* Le titre, et rien d'autre : c'est tout l'intérêt du deck. */
.deck__title {
  margin: auto 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6.5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-wrap: balance;
}

.deck__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-weight: 500;
}
/* Les .icon sont en display:block (reset) : dans un span, elles forceraient
   un retour à la ligne et « 2 min » passerait sous son horloge. */
.deck__foot > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Tampons OUI / NON révélés pendant le glissement */
.deck__stamp {
  position: absolute;
  top: var(--sp-6);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  border: 3px solid currentColor;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms linear;
}
.deck__stamp--read { right: var(--sp-6); color: var(--success); rotate: 12deg; }
.deck__stamp--skip { left: var(--sp-6); color: var(--danger); rotate: -12deg; }

.deck__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
}

/* Boutons ronds — l'alternative obligatoire au geste :
   on ne rend JAMAIS une action accessible uniquement au swipe. */
.deck-btn {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: var(--shadow-md);
  transition: transform var(--t-fast) var(--ease), border-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.deck-btn:active { transform: scale(0.88); }
.deck-btn--read {
  width: 72px; height: 72px;
  background: var(--primary);
  border-color: transparent;
  color: var(--primary-ink);
  box-shadow: var(--shadow-lg), var(--glow, none);
}
.deck-btn--fav[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
@media (hover: hover) {
  .deck-btn:hover { border-color: var(--text-dim); color: var(--text); }
  .deck-btn--read:hover { filter: brightness(1.08); color: var(--primary-ink); }
}

.deck__hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--text-dim);
}


/* ============================================================================
   8.23 ONBOARDING — choix des thèmes
   ========================================================================= */
/* 96px : à 375px de large (335px utiles), 104px ne tenait que 2 colonnes —
   il manquait 1px. 96 en fait tenir 3, ce qui rend les 22 thèmes lisibles
   sans défilement interminable. */
.pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--sp-2);
}
.pick__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-2);
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
  animation: pop-in var(--t-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 25ms);
}
.pick__item:active { transform: scale(0.94); }
.pick__item[aria-pressed="true"] {
  border-color: var(--topic-color);
  background: color-mix(in srgb, var(--topic-color) 10%, var(--surface));
}
.pick__ico {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  color: var(--topic-color);
  background: color-mix(in srgb, var(--topic-color) 14%, transparent);
  transition: transform var(--t-base) var(--spring);
}
.pick__item[aria-pressed="true"] .pick__ico { transform: scale(1.08); }
.pick__name { font-size: var(--fs-xs); font-weight: 600; line-height: 1.2; }
.pick__check {
  position: absolute;
  top: -8px; right: -8px;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--topic-color);
  color: var(--bg);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--spring);
}
.pick__check .icon { width: 14px; height: 14px; stroke-width: 3.5; }
.pick__item[aria-pressed="true"] .pick__check { opacity: 1; transform: none; }

/* Barre d'action collante de l'onboarding */
.pick__bar {
  position: sticky;
  bottom: 0;
  margin-top: var(--sp-6);
  padding-block: var(--sp-4);
  padding-bottom: calc(var(--sp-4) + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}


/* ============================================================================
   8.24 LECTURE VOCALE & TAILLE DU TEXTE
   ========================================================================= */

/* --font-scale multiplie la typographie du lecteur — et RIEN d'autre.
   Grossir toute l'interface casserait les cibles tactiles et la tabbar ;
   ici seul le texte lu grandit, ce qui est le besoin réel. */
.reader { font-size: calc(1rem * var(--font-scale, 1)); }
.reader__title { font-size: calc(var(--fs-2xl) * var(--font-scale, 1)); }
.reader__lede  { font-size: calc(var(--fs-lg) * var(--font-scale, 1)); }
.reader__body p { font-size: calc(var(--fs-md) * var(--font-scale, 1)); }

/* Paragraphe en cours de lecture vocale */
.reader__body p.is-speaking {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: -12px 0 0 color-mix(in srgb, var(--primary) 12%, transparent),
               12px 0 0 color-mix(in srgb, var(--primary) 12%, transparent);
  border-radius: 2px;
  transition: background-color var(--t-base) var(--ease);
}

/* Barre d'outils du lecteur : écouter / taille du texte / favori */
.readtools {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
}
.readtools__sep { width: 1px; height: 24px; background: var(--border); flex: none; }

/* Bouton « Écouter » : s'étend quand la lecture est active */
.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding-inline: var(--sp-4);
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease), transform var(--t-fast) var(--ease);
}
.speak-btn:active { transform: scale(0.94); }
.speak-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }

/* Égaliseur animé pendant la lecture vocale */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i {
  width: 3px;
  border-radius: 2px;
  background: currentColor;
  animation: eq 900ms var(--ease) infinite;
}
.eq i:nth-child(1) { height: 40%; animation-delay: 0ms; }
.eq i:nth-child(2) { height: 100%; animation-delay: 150ms; }
.eq i:nth-child(3) { height: 65%; animation-delay: 300ms; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1); }
}

/* Sélecteur de taille : les A grandissent réellement — l'aperçu ne ment pas */
.sizer { display: inline-flex; align-items: center; gap: 2px; }
.sizer__btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.sizer__btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }

.fav-btn[aria-pressed="true"] { color: var(--accent); }
.fav-btn[aria-pressed="true"] .icon { fill: var(--accent); }


/* ============================================================================
   8.25 RECHERCHE
   ========================================================================= */
.search { position: relative; margin-bottom: var(--sp-5); }
.search__ico {
  position: absolute;
  left: var(--sp-4);
  top: 50%;
  translate: 0 -50%;
  color: var(--text-dim);
  pointer-events: none;
}
.search .input { padding-left: calc(var(--sp-4) * 2 + 20px); }
.search__clear {
  position: absolute;
  right: 6px;
  top: 50%;
  translate: 0 -50%;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
}

.result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color var(--t-base) var(--ease), transform var(--t-fast) var(--ease);
}
.result-item:active { transform: scale(0.985); }
.result-item mark {
  background: color-mix(in srgb, var(--primary) 28%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}
.result-item__ico { color: var(--topic-color); flex: none; }
.result-item__title { display: block; font-weight: 600; font-size: var(--fs-sm); line-height: 1.3; }
.result-item__topic { display: block; font-size: var(--fs-xs); color: var(--text-dim); margin-top: 1px; }


/* ============================================================================
   8.26 COMBO — multiplicateur d'XP dans le quiz
   ========================================================================= */
.combo {
  position: fixed;
  top: calc(var(--safe-t) + var(--sp-4));
  left: 50%;
  translate: -50% 0;
  z-index: var(--z-sticky);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: linear-gradient(100deg, var(--primary), var(--accent));
  color: var(--primary-ink);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-lg), var(--glow, none);
  pointer-events: none;
  animation: combo-in 420ms var(--spring) both;
}
@keyframes combo-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.7); }
  to   { opacity: 1; transform: none; }
}
.combo--out { animation: combo-out 220ms var(--ease-in) both; }
@keyframes combo-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.9); }
}

/* ============================================================================
   8.27 XP VOLANT — le gain décolle du point où il a été gagné
   ========================================================================= */
.flyxp {
  position: fixed;
  z-index: var(--z-toast);
  translate: -50% 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--primary);
  text-shadow: 0 2px 12px var(--shadow-color);
  pointer-events: none;
  animation: flyxp 1100ms var(--ease) both;
}
@keyframes flyxp {
  0%   { opacity: 0; transform: translateY(0) scale(0.6); }
  18%  { opacity: 1; transform: translateY(-14px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-72px) scale(1); }
}

/* ============================================================================
   8.28 RANG
   ========================================================================= */
.rank {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  background: linear-gradient(100deg, var(--primary-soft), transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rank .icon { width: 14px; height: 14px; }

/* ============================================================================
   8.29 MAÎTRISE PAR THÈME
   ========================================================================= */
.mastery { display: flex; flex-direction: column; gap: var(--sp-3); }
.mastery__row { display: flex; align-items: center; gap: var(--sp-3); }
.mastery__ico {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: var(--r-sm);
  color: var(--topic-color);
  background: color-mix(in srgb, var(--topic-color) 14%, transparent);
}
/* display:block indispensable : ce sont des <span>, donc inline par défaut —
   `height` y est ignoré et la barre se réduisait à un trait vertical. */
.mastery__name { display: block; font-size: var(--fs-xs); font-weight: 600; }
.mastery__bar {
  display: block;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 4px;
}
.mastery__bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  background: var(--topic-color);
  transition: transform 900ms var(--ease);
}
.mastery__num {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-weight: 700;
  flex: none;
  min-width: 34px;
  text-align: right;
}

/* ============================================================================
   9. ANIMATIONS UTILITAIRES
   ========================================================================= */
/* Secousse d'erreur sur le formulaire d'auth */
.shake { animation: shake 420ms var(--ease); }

/* Compteur qui « tique » quand sa valeur change */
.tick { animation: tick 380ms var(--spring); }
@keyframes tick {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}


/* ============================================================================
   10. ACCESSIBILITÉ & RESPONSIVE
   ========================================================================= */

/* ---- Mouvement réduit ---------------------------------------------------
   On ne coupe pas tout : on ramène les animations à ~1 frame. L'interface
   reste fonctionnelle et les états restent lisibles, mais plus rien ne
   bouge — y compris les halos d'ambiance et le reflet de la barre d'XP,
   qui tournent en boucle et sont les plus gênants en cas de sensibilité.
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ambient__blob { animation: none; }
  .xpbar__shine { display: none; }
  .streak--live .streak__flame { animation: none; }
  /* Les boucles infinies sont les plus gênantes : on les coupe franchement
     plutôt que de les accélérer à 0,01 ms (ce qui ferait vibrer). */
  .node--current::before { animation: none; opacity: 0.6; }
  .node__bubble { animation: none; }
  .eq i { animation: none; transform: scaleY(0.7); }
}

/* ---- Contraste renforcé ---- */
@media (prefers-contrast: more) {
  .card, .topic, .quiz-opt, .input { border-width: 2px; }
  :root { --text-muted: var(--text); }
}

/* ---- Tablette ---- */
@media (min-width: 640px) {
  .topics { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--sp-4); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .hero__greet { font-size: var(--fs-3xl); }
  .reader__title { font-size: var(--fs-3xl); }
}

/* ---- Desktop : la tabbar devient une barre flottante centrée ---------- */
@media (min-width: 900px) {
  .tabbar {
    left: 50%;
    right: auto;
    bottom: var(--sp-5);
    translate: -50% 0;
    height: var(--tabbar-h);
    padding: var(--sp-1);
    padding-bottom: var(--sp-1);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-xl);
    gap: var(--sp-1);
  }
  .tab { height: 56px; max-width: 96px; }
  .view { padding-bottom: calc(var(--tabbar-h) + var(--sp-12)); }
  .toasts { bottom: calc(var(--tabbar-h) + var(--sp-10)); }
}

/* ---- Paysage sur petit écran : on récupère de la hauteur ---- */
@media (max-height: 480px) and (orientation: landscape) {
  .auth { min-height: auto; padding-block: var(--sp-6); }
  .auth__logo { width: 48px; height: 48px; margin-bottom: var(--sp-2); }
  .auth__brand { margin-bottom: var(--sp-4); }
}

/* ---- Impression ---- */
@media print {
  .ambient, .tabbar, .toasts, .readbar, .quiz__action { display: none !important; }
  body { background: #fff; color: #000; }
}
