/* ==========================================================================
   PASS — design system (styles.css)
   Mobile-first, clair / sombre, sans build. Inspiré de CardioR2C, identité
   propre : accent indigo, série = flamme orange, XP = ambre/or.

   SOMMAIRE
     1. Tokens (:root clair) + thème sombre
     2. Base (body, liens, focus, typographie)
     3. Shell historique (.wrap, .site-header, .rubric-row, .panel, .btn, …)
        — noms de classes conservés, couleurs passées sur les tokens
     4. Barre d'onglets (.tabbar — js/shell-tabbar.js)
     5. Couche composants .ui-*  (à utiliser pour les nouvelles pages)
     6. Mouvement (animations, prefers-reduced-motion)
     7. Compatibilité sombre des pages non migrées (couleurs codées en dur)

   ── TOKENS ────────────────────────────────────────────────────────────────
   Surfaces   --bg  --bg-accent  --surface (= --card)  --surface-2  --surface-3
   Texte      --ink  --ink-2  --deep (titres)  --muted  --soon  --line  --line-strong
   Accent     --accent  --accent-ink (texte SUR accent)  --accent-soft  --accent-strong
              --pressed-bg  --pressed-ink  --focus
   Motivation --flame --flame-ink --flame-soft (série)   --xp --xp-ink --xp-soft (XP)
   Sémantique --ok --ok-bg (= --ok-soft)  --bad --bad-bg (= --bad-soft)  --warn --warn-soft
              --info --info-soft
   Héros      --hero-1 --hero-2 --hero-3 (dégradé)  --hero-ink  --hero-muted
   Heatmap    --heat-0 … --heat-4
   Type       --font (= --font-body, IBM Plex Sans)  --font-display (Bricolage Grotesque)
              --font-mono (IBM Plex Mono)
   Rayons     --radius-sm 8  --radius-md 12  --radius-lg 14  --radius 16  --radius-xl 22
              --radius-pill  (alias DESIGN : --r-s --r-m --r-l)
   Ombres     --shadow (trait)  --shadow-1  --shadow-2  --shadow-pressed
   Mouvement  --dur-1 160ms  --dur-2 200ms  --dur-3 220ms  --ease-out  --ease (durée+courbe)
   Mise en page --max 40rem  --maxw  --gutter  --tap-min 44px  --tabbar-h  --actionbar-h

   Thème : <html data-theme="light|dark"> force ; absent = système
   (js/icons.js lit localStorage "pass-theme" et expose PASS_ICONS.setTheme).
   Les fiches (matiere/fiche.css) suivent aussi le mode sombre (tokens).

   ── COMPOSANTS (.ui-*) ─────────────────────────────────────────────────────
   .ui-card (.is-raised .is-hero .is-flat .is-tight)       bloc surface
   .ui-btn  (.is-primary .is-ghost .is-soft .is-danger .is-block .is-sm .is-lg)
   .ui-pill (.is-accent .is-ok .is-bad .is-warn .is-xp .is-flame)   étiquette inline
   .ui-chip (.is-on | [aria-pressed="true"])              filtre / action rapide
   .ui-bar > .ui-bar__fill (style="width:40%")  (.is-ok .is-xp .is-flame .is-thin)
   .ui-ring  > svg (.ui-ring__track .ui-ring__fill) + .ui-ring__label — PASS_ICONS.ring()
   .ui-opt  > .ui-opt__key (A–E) + .ui-opt__text + .ui-opt__why
            états .is-selected .is-correct .is-wrong .is-missed .is-neutral ; parent .is-revealed
   .ui-strip > i  (.is-ok .is-bad .is-current)            bande de progression par question
   .ui-actionbar > .ui-actionbar__inner                    barre d'action collante 56px
            (au-dessus de .tabbar si body.has-tabbar ; ajoute body.has-actionbar)
   .ui-toast-host > .ui-toast (.is-ok .is-xp .is-flame .is-bad)   (créés par js/game.js)
   .ui-scrim + .ui-sheet (.is-open) > .ui-sheet__grip        feuille bas (mobile) / modale (desktop)
   .ui-tile > .ui-tile__label + .ui-tile__value (+ .ui-tile__sub)
   .ui-heat (grille 7 lignes) > .ui-heat__cell[data-l="0..4"]  — PASS_GAME.heatmap()
   .ui-stat > .ui-stat__icon + .ui-stat__value + .ui-stat__label (.is-flame .is-xp .is-accent)
   .ui-badge (.is-earned | .is-locked) > .ui-badge__icon + .ui-badge__title + .ui-badge__desc
   .ui-flame (.is-alive .is-out)                          icône flamme de série
   .ui-xp-pop                                             « +10 XP » qui monte et s'efface
   .ui-icon (.is-sm .is-lg)                               taille d'une icône PASS_ICONS
   Utilitaires : .ui-eyebrow .ui-num (chiffres tabulaires) .ui-mono .ui-muted .ui-stack .ui-row
                 .ui-grid-2 .ui-grid-3 .ui-sr (texte lecteur d'écran)
   ========================================================================== */

/* 1. TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  --pass-ui: 1; /* marqueur : styles.css chargé (js/game.js s'en sert) */
  color-scheme: light;

  /* Surfaces (neutre froid, léger biais violet) */
  --bg: #f4f5fa;
  --bg-accent: #e7e8fb;
  --surface: #ffffff;
  --card: var(--surface);
  --surface-2: #eef0f7;
  --surface-3: #e1e4ef;

  /* Texte */
  --ink: #161a2e;
  --ink-2: #3d4260;
  --deep: #1b1740;
  --muted: #5e6480;
  --soon: #7c819c;
  --line: #dcdfeb;
  --line-strong: #c4c8da;

  /* Accent indigo */
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --accent-strong: #3730a3;
  --accent-line: #c7cbf7;
  --focus: #4f46e5;
  --pressed-bg: var(--accent-soft);
  --pressed-ink: var(--accent-strong);

  /* Motivation */
  --flame: #f97316;
  --flame-ink: #c2410c;
  --flame-soft: #ffedd5;
  --flame-line: #fdc9a0;
  --xp: #f59e0b;
  --xp-ink: #b45309;
  --xp-soft: #fef3c7;
  --xp-line: #fcd98a;

  /* Sémantique */
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --ok-soft: var(--ok-bg);
  --ok-line: #86efac;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --bad-soft: var(--bad-bg);
  --bad-line: #fca5a5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --warn-line: #f5d58a;
  --info: var(--accent);
  --info-soft: var(--accent-soft);

  /* Carte héros (dégradé indigo, texte blanc) */
  --hero-1: #5b54e8;
  --hero-2: #4338ca;
  --hero-3: #25206b;
  --hero-ink: #ffffff;
  --hero-muted: #d6d8ff;

  /* Heatmap (0 = rien → 4 = beaucoup) */
  --heat-0: #e4e6f0;
  --heat-1: #c9ccf8;
  --heat-2: #9aa0f2;
  --heat-3: #6760de;
  --heat-4: #4338ca;

  /* Rayons */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;
  --r-s: var(--radius-sm);
  --r-m: var(--radius-lg);
  --r-l: var(--radius-xl);

  /* Ombres */
  --shadow: 0 1px 0 rgba(22, 26, 46, 0.04);
  --shadow-1: 0 1px 2px rgba(22, 26, 46, 0.06), 0 1px 1px rgba(22, 26, 46, 0.04);
  --shadow-2: 0 8px 24px rgba(30, 27, 75, 0.12);
  --shadow-pressed: inset 0 0 0 1px var(--accent);

  /* Mouvement */
  --dur-1: 160ms;
  --dur-2: 200ms;
  --dur-3: 220ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease: 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Type */
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: var(--font);
  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Mise en page */
  --max: 40rem;
  --maxw: 45rem;
  --gutter: 16px;
  --tap-min: 44px;
  --tabbar-h: 64px;
  --actionbar-h: 56px;
}

/* Thème sombre — mêmes valeurs dans les deux blocs (système / forcé).
   Les fiches (matiere/fiche.css) en profitent aussi. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f1a;
    --bg-accent: #1a1b3a;
    --surface: #161927;
    --surface-2: #1e2233;
    --surface-3: #2a2f45;
    --ink: #e9ebf5;
    --ink-2: #c3c7db;
    --deep: #f1f1ff;
    --muted: #979db8;
    --soon: #7d839f;
    --line: #2c3148;
    --line-strong: #3b4160;
    --accent: #a5acff;
    --accent-ink: #0d0f1a;
    --accent-soft: #23264a;
    --accent-strong: #c3c7ff;
    --accent-line: #3c4180;
    --focus: #b9beff;
    --flame: #fb923c;
    --flame-ink: #fdba74;
    --flame-soft: #3a2112;
    --flame-line: #6b3a1a;
    --xp: #fbbf24;
    --xp-ink: #fcd34d;
    --xp-soft: #362a0e;
    --xp-line: #6a5316;
    --ok: #4ade80;
    --ok-bg: #12301f;
    --ok-line: #256b41;
    --bad: #f87171;
    --bad-bg: #3a1618;
    --bad-line: #7a2c2c;
    --warn: #fbbf24;
    --warn-soft: #34290f;
    --warn-line: #6a5316;
    --hero-1: #4c45d6;
    --hero-2: #3730a3;
    --hero-3: #1a1650;
    --hero-ink: #ffffff;
    --hero-muted: #cfd2ff;
    --heat-0: #22263a;
    --heat-1: #2f3370;
    --heat-2: #4a4fb0;
    --heat-3: #7178e6;
    --heat-4: #a5acff;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 10px 28px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f1a;
  --bg-accent: #1a1b3a;
  --surface: #161927;
  --surface-2: #1e2233;
  --surface-3: #2a2f45;
  --ink: #e9ebf5;
  --ink-2: #c3c7db;
  --deep: #f1f1ff;
  --muted: #979db8;
  --soon: #7d839f;
  --line: #2c3148;
  --line-strong: #3b4160;
  --accent: #a5acff;
  --accent-ink: #0d0f1a;
  --accent-soft: #23264a;
  --accent-strong: #c3c7ff;
  --accent-line: #3c4180;
  --focus: #b9beff;
  --flame: #fb923c;
  --flame-ink: #fdba74;
  --flame-soft: #3a2112;
  --flame-line: #6b3a1a;
  --xp: #fbbf24;
  --xp-ink: #fcd34d;
  --xp-soft: #362a0e;
  --xp-line: #6a5316;
  --ok: #4ade80;
  --ok-bg: #12301f;
  --ok-line: #256b41;
  --bad: #f87171;
  --bad-bg: #3a1618;
  --bad-line: #7a2c2c;
  --warn: #fbbf24;
  --warn-soft: #34290f;
  --warn-line: #6a5316;
  --hero-1: #4c45d6;
  --hero-2: #3730a3;
  --hero-3: #1a1650;
  --hero-ink: #ffffff;
  --hero-muted: #cfd2ff;
  --heat-0: #22263a;
  --heat-1: #2f3370;
  --heat-2: #4a4fb0;
  --heat-3: #7178e6;
  --heat-4: #a5acff;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 10px 28px rgba(0, 0, 0, 0.5);
}

/* 2. BASE ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(90% 55% at 100% 0%, var(--bg-accent), transparent 55%),
    var(--bg);
  background-color: var(--bg);
}

a { color: var(--accent); }

h1, h2, h3 { text-wrap: balance; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* 3. SHELL HISTORIQUE ─────────────────────────────────────────────────────── */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding:
    max(0.85rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(2.75rem, calc(1.5rem + env(safe-area-inset-bottom, 0px)))
    max(1rem, env(safe-area-inset-left, 0px));
}

body.has-tabbar .wrap {
  padding-bottom: calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom, 0px));
}

body.has-tabbar.has-actionbar .wrap {
  padding-bottom: calc(var(--tabbar-h) + var(--actionbar-h) + 2rem + env(safe-area-inset-bottom, 0px));
}

body.has-actionbar:not(.has-tabbar) .wrap {
  padding-bottom: calc(var(--actionbar-h) + 2rem + env(safe-area-inset-bottom, 0px));
}

body.has-tabbar .nav-chips { display: none; }

/* ——— En-tête + chips ——— */
.site-header { margin-bottom: 1rem; }

.site-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--deep);
  font-size: 1.3rem;
  line-height: 1;
}

.brand::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--hero-1), var(--accent));
  transform: rotate(45deg);
  flex-shrink: 0;
}

.site-pill {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.6rem;
}

.nav-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-chips li { flex: 0 0 auto; }

.nav-chips a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.75rem;
  min-height: var(--tap-min);
  white-space: nowrap;
  line-height: 1.2;
  touch-action: manipulation;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.nav-chips a:hover { color: var(--deep); border-color: var(--line-strong); }
.nav-chips a:active { transform: translateY(1px); }

.nav-chips a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/* Legacy topnav aliases */
.topnav {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.topnav .brand { align-self: flex-start; }

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: inline-block;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.7rem;
  white-space: nowrap;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 6.5vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  line-height: 1.08;
  color: var(--deep);
}

.hero-lead {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 28rem;
}

.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  margin: 0 0 0.95rem;
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  letter-spacing: -0.03em;
  color: var(--deep);
  line-height: 1.12;
}

.page-sub {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice-warn,
.notice-beta,
.notice-important {
  margin: 0 0 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.4;
}

.notice-warn { border: 1px solid var(--warn-line); background: var(--warn-soft); }
.notice-warn strong { color: var(--warn); }
.notice-beta { border: 1px solid var(--accent-line); background: var(--accent-soft); }
.notice-beta strong { color: var(--accent); }
.notice-important { border: 1px solid var(--xp-line); background: var(--xp-soft); }
.notice-important strong { color: var(--xp-ink); }

.page-sub + .page-title { margin-top: 0.15rem; }

.block-label,
.eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ——— Rubriques / listes ——— */
.rubric-panel,
.panel.tight {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.15rem;
  padding: 0;
  box-shadow: var(--shadow-1);
}

.continue-card {
  margin: 0 0 1.15rem;
  padding: 1.15rem 1.1rem 1.05rem;
  border: 0;
  border-radius: calc(var(--radius) + 4px);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(160deg, var(--hero-1) 0%, var(--hero-2) 48%, var(--hero-3) 100%);
  color: var(--hero-ink);
  box-shadow: var(--shadow-2);
}

.continue-card[hidden] { display: none !important; }

.continue-card .continue-kicker {
  margin: 0 0 0.3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hero-muted);
}

.continue-card .continue-kicker svg {
  width: 0.95rem;
  height: 0.95rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.continue-card .continue-title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--hero-ink);
}

.continue-card .continue-meta {
  margin: 0 0 0.9rem;
  font-size: 0.86rem;
  color: var(--hero-muted);
}

.continue-card .continue-meta:empty { display: none; }

.continue-card .continue-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 0.4rem;
}

.continue-card .btn {
  background: #ffffff;
  color: #25206b;
  border-color: #ffffff;
  font-weight: 700;
}

.continue-card .btn:hover { background: #eef0ff; border-color: #eef0ff; color: #25206b; }

.continue-card .btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
}

.continue-card .btn.secondary:hover { background: rgba(255, 255, 255, 0.2); color: #ffffff; }

.rubric-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  min-height: var(--tap-min);
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
  touch-action: manipulation;
  transition: background var(--ease);
}

.rubric-row:last-child { border-bottom: 0; }
.rubric-row:hover { background: var(--surface-2); }
.rubric-row:active { background: var(--pressed-bg); }

.rubric-row .row-ico {
  width: 1.2rem;
  height: 1.2rem;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0.9;
}

.rubric-row .row-body { flex: 1; min-width: 0; }

.rubric-row h2,
.rubric-row h3 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--deep);
}

.rubric-row p {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.rubric-row .row-chev,
.row-chev {
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1;
  opacity: 0.85;
}

.badge {
  display: inline-block;
  align-self: start;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 0.2rem 0.5rem;
}

.badge.soon { color: var(--soon); background: transparent; }

/* Tuiles */
.grid { display: grid; gap: 0.75rem; }

@media (min-width: 540px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
}

.tile {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  transition: border-color var(--ease), background var(--ease);
}

.tile:hover { border-color: var(--accent-line); background: var(--surface-2); }

.tile h2 {
  margin: 0 0 0.25rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--deep);
}

.tile p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.tile .badge { margin-top: 0.65rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-1);
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  color: var(--deep);
}

.panel p,
.panel li { color: var(--muted); font-size: 0.92rem; }

.panel ul { margin: 0.4rem 0 0; padding-left: 1.15rem; }

.panel.list-panel { padding: 0; overflow: hidden; }
.panel.list-panel > .panel-head { padding: 0.95rem 1.05rem 0.65rem; }
.panel.list-panel > .panel-head h2 { margin-bottom: 0.25rem; }
.panel.list-panel > .panel-head p { margin: 0; }

.chapter-link {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0.75rem 1.05rem;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--deep);
  font-size: 0.92rem;
  font-weight: 600;
  touch-action: manipulation;
}

.chapter-link:hover { background: var(--surface-2); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-pill);
  padding: 0.55rem 1.05rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-min);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease), color var(--ease);
}

.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-pressed);
}

.btn.secondary {
  background: var(--surface);
  color: var(--deep);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.btn.secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn.secondary:active { background: var(--pressed-bg); color: var(--pressed-ink); }

.note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 1.25rem;
}

.suivi-legend { list-style: none; margin: 0; padding: 0; }

.suivi-legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  flex-shrink: 0;
  vertical-align: middle;
}

.pill-none { background: var(--surface-3); }
.pill-red { background: #dc2626; border-color: #b91c1c; }
.pill-blue { background: #4f6bed; border-color: #3b55d9; }
.pill-green { background: #16a34a; border-color: #15803d; }

.table-wrap { overflow-x: auto; margin-top: 0.5rem; }

.suivi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.suivi-table th,
.suivi-table td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.suivi-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.suivi-table td:nth-child(2),
.suivi-table td:nth-child(3) { text-align: center; width: 3.5rem; }

.suivi-detail { font-size: 0.82rem; color: var(--muted); }

.hint { font-size: 0.85rem; color: var(--muted); margin: 0.65rem 0 0; }

.plan-bank { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.plan-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: grab;
}

.plan-chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--deep);
}

.plan-week-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.plan-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.4rem;
}

@media (max-width: 720px) {
  .plan-week { grid-template-columns: 1fr; }
}

.plan-day {
  min-height: 6.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.45rem;
  cursor: pointer;
}

.plan-day.drag-over { border-color: var(--accent); background: var(--accent-soft); }

.plan-day-head {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.plan-day-list { display: flex; flex-direction: column; gap: 0.3rem; }

.plan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.4rem;
  font-size: 0.78rem;
  cursor: grab;
}

.plan-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
}

.hidden { display: none !important; }

/* ——— Suivi (cartes) ——— */
.review-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--bad);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.review-box h2 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--deep);
}
.review-list { display: grid; gap: 0.45rem; }
.review-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}
.review-item .name {
  font-weight: 700;
  color: var(--deep);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.legend-fold {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
}
.legend-fold summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--deep);
  font-size: 0.9rem;
}
.ch-cards { display: grid; gap: 0.55rem; }
.ch-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.85rem 0.95rem;
}
.ch-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.35rem;
}
.ch-card h3 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--deep);
}
.ch-card .meta { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--muted); }
.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  align-items: center;
  margin: 0.55rem 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.pills-row > span { display: inline-flex; align-items: center; gap: 0.3rem; }
.ch-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.btn.tiny { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.empty-state {
  text-align: center;
  padding: 1.25rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ——— Planning (liste semaine) ——— */
.today-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.today-box h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--deep);
}
.today-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-top: 1px solid var(--accent-line);
}
.today-item:first-of-type { border-top: 0; }
.today-item.is-target { border-top: 0; }
.today-name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  color: var(--deep);
}
.today-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.sel-bar {
  background: var(--deep);
  color: var(--bg);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.plan-step { font-size: 0.95rem; margin: 0.85rem 0 0.5rem; color: var(--deep); }
.plan-day-stack { display: grid; gap: 0.55rem; }
.plan-day-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.85rem;
  min-height: 4.2rem;
  cursor: pointer;
}
.plan-day-row.is-today {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.plan-day-row.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.day-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  font-weight: 700;
}
.day-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.day-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.45rem 0.3rem 0.55rem;
  color: var(--deep);
  cursor: grab;
}

/* ——— Bandeau flashcards dues ——— */
.flash-due-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--flame-line);
  background: var(--flame-soft);
  text-decoration: none;
  color: var(--deep);
  box-shadow: var(--shadow);
}

.flash-due-banner-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--flame-ink);
  flex: 0 0 auto;
}

.flash-due-banner-body {
  flex: 1 1 auto;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
}

.flash-due-banner-body strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--flame-ink);
}

.flash-due-banner-go {
  flex: 0 0 auto;
  font-size: 1.2rem;
  color: var(--flame-ink);
  opacity: 0.8;
}

.flash-due-banner-cap {
  display: block;
  flex: 1 1 100%;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--flame-ink);
  opacity: 0.9;
}

.rubric-row--hot {
  border-color: var(--flame-line);
  background: linear-gradient(180deg, var(--flame-soft) 0%, var(--surface) 100%);
  box-shadow: inset 3px 0 0 var(--flame);
}

.rubric-row .row-body p.row-detail {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

/* ——— Progression (Accueil / Suivi) ——— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0 0 1.1rem;
}

.stat-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.45rem;
  text-align: center;
  box-shadow: var(--shadow-1);
}

.stat-cell b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--deep);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-cell span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.rubric-row .row-body h2 { margin: 0; }

.rubric-row .row-body p {
  margin: 0.12rem 0 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}

.row-badge {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.rubric-row .row-ico.warn,
.row-badge.warn {
  background: var(--flame-soft);
  color: var(--flame-ink);
}

/* 4. BARRE D'ONGLETS (js/shell-tabbar.js) ─────────────────────────────────── */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 0.3rem max(0.4rem, env(safe-area-inset-right, 0px)) calc(0.3rem + env(safe-area-inset-bottom, 0px)) max(0.4rem, env(safe-area-inset-left, 0px));
  box-shadow: 0 -6px 24px rgba(22, 26, 46, 0.06);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .tabbar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
  }
}

.tabbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.15rem;
}

.tabbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  min-height: 3.2rem;
  border-radius: 14px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--ease), background var(--ease);
}

.tabbar a:hover { color: var(--ink); }

.tabbar .tab-ico-wrap {
  display: grid;
  place-items: center;
  width: 3.1rem;
  height: 1.85rem;
  border-radius: var(--radius-pill);
  transition: background var(--ease), transform var(--ease);
}

.tabbar .tab-ico,
.tabbar svg {
  width: 1.4rem;
  height: 1.4rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

.tabbar a[aria-current="page"] .tab-ico-wrap { background: var(--accent-soft); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.1; }

/* Ancien marquage (sans .tab-ico-wrap) : fond doux sur l'onglet */
.tabbar a[aria-current="page"]:not(:has(.tab-ico-wrap)) { background: var(--accent-soft); }

.tabbar a:active .tab-ico-wrap { transform: scale(0.94); }

.tabbar .tab-badge {
  position: absolute;
  top: 0.15rem;
  right: calc(50% - 1.6rem);
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: var(--radius-pill);
  background: var(--flame-ink);
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tabbar .tab-badge {
    background: var(--flame);
    color: #1a0e05;
  }
}
:root[data-theme="dark"] .tabbar .tab-badge {
  background: var(--flame);
  color: #1a0e05;
}

/* Desktop : barre flottante centrée */
@media (min-width: 720px) {
  .tabbar {
    left: 50%;
    right: auto;
    bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    width: min(34rem, calc(100% - 2rem));
    transform: translateX(-50%);
    padding: 0.3rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-2);
  }
  .tabbar a { flex-direction: row; gap: 0.4rem; font-size: 0.78rem; min-height: 2.9rem; }
  .tabbar .tab-ico-wrap { width: auto; height: auto; background: none !important; }
  .tabbar a[aria-current="page"] { background: var(--accent-soft); }
  .tabbar .tab-badge { top: 0.2rem; right: 0.3rem; }
  body.has-tabbar .wrap {
    padding-bottom: calc(var(--tabbar-h) + 2.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* 5. COMPOSANTS .ui-* ───────────────────────────────────────────────────── */

/* Icône */
.ui-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  vertical-align: -0.2em;
}
.ui-icon.is-sm { width: 1rem; height: 1rem; }
.ui-icon.is-lg { width: 1.6rem; height: 1.6rem; }

/* Utilitaires */
.ui-eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.ui-num { font-variant-numeric: tabular-nums; }
.ui-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ui-muted { color: var(--muted); }
.ui-stack { display: grid; gap: 0.75rem; }
.ui-row { display: flex; align-items: center; gap: 0.6rem; }
.ui-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.ui-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.ui-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Carte */
.ui-card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-1);
}
.ui-card.is-tight { padding: 0.75rem; }
.ui-card.is-flat { box-shadow: none; }
.ui-card.is-raised { box-shadow: var(--shadow-2); border-color: transparent; }
.ui-card.is-hero {
  border: 0;
  color: var(--hero-ink);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(160deg, var(--hero-1) 0%, var(--hero-2) 48%, var(--hero-3) 100%);
  box-shadow: var(--shadow-2);
}
.ui-card.is-hero .ui-muted,
.ui-card.is-hero .ui-eyebrow { color: var(--hero-muted); }

/* Bouton */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--tap-min);
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.ui-btn:hover { border-color: var(--line-strong); }
.ui-btn:active { transform: translateY(1px) scale(0.99); }
.ui-btn:disabled,
.ui-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.ui-btn.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent);
}
.ui-btn.is-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.ui-btn.is-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.ui-btn.is-ghost:hover { background: var(--accent-soft); }
.ui-btn.is-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.ui-btn.is-danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.ui-btn.is-block { display: flex; width: 100%; }
.ui-btn.is-sm { min-height: 2.25rem; padding: 0.35rem 0.75rem; font-size: 0.85rem; border-radius: var(--radius-sm); }
.ui-btn.is-lg { min-height: 3.25rem; padding: 0.75rem 1.3rem; font-size: 1.05rem; border-radius: var(--radius); }
.ui-btn .ui-icon { width: 1.15em; height: 1.15em; }

/* Pastille inline */
.ui-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}
.ui-pill .ui-icon { width: 0.95em; height: 0.95em; }
.ui-pill.is-accent { background: var(--accent-soft); color: var(--accent); }
.ui-pill.is-ok { background: var(--ok-bg); color: var(--ok); }
.ui-pill.is-bad { background: var(--bad-bg); color: var(--bad); }
.ui-pill.is-warn { background: var(--warn-soft); color: var(--warn); }
.ui-pill.is-xp { background: var(--xp-soft); color: var(--xp-ink); }
.ui-pill.is-flame { background: var(--flame-soft); color: var(--flame-ink); }

/* Chip (filtre / action rapide) */
.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--tap-min);
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.ui-chip:hover { border-color: var(--line-strong); }
.ui-chip.is-on,
.ui-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.ui-chip:disabled { opacity: 0.45; cursor: not-allowed; }

/* Barre de progression */
.ui-bar {
  position: relative;
  display: block;
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.ui-bar.is-thin { height: 0.3rem; }
.ui-bar__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 600ms var(--ease-out);
}
.ui-bar.is-ok .ui-bar__fill { background: var(--ok); }
.ui-bar.is-xp .ui-bar__fill { background: linear-gradient(90deg, var(--xp), var(--flame)); }
.ui-bar.is-flame .ui-bar__fill { background: var(--flame); }

/* Anneau (SVG) — markup : PASS_ICONS.ring(pct, {size, stroke, label}) */
.ui-ring {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--ring-size, 96px);
  height: var(--ring-size, 96px);
  flex-shrink: 0;
}
.ui-ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ui-ring__track { fill: none; stroke: var(--surface-3); }
.ui-ring__fill {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dasharray 600ms var(--ease-out), stroke var(--dur-2) var(--ease-out);
}
.ui-ring.is-done .ui-ring__fill { stroke: var(--ok); }
.ui-ring.is-xp .ui-ring__fill { stroke: var(--xp); }
.ui-ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.05;
}
.ui-ring__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--ring-size, 96px) * 0.26);
  font-variant-numeric: tabular-nums;
  color: var(--deep);
}
.ui-ring__sub { font-size: 0.68rem; font-weight: 600; color: var(--muted); }
.ui-card.is-hero .ui-ring__track { stroke: rgba(255, 255, 255, 0.22); }
.ui-card.is-hero .ui-ring__fill { stroke: #ffffff; }
.ui-card.is-hero .ui-ring__value { color: var(--hero-ink); }
.ui-card.is-hero .ui-ring__sub { color: var(--hero-muted); }

/* Ligne d'option QCM */
.ui-opt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  min-height: 52px;
  margin: 0 0 0.5rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.ui-opt:hover { border-color: var(--line-strong); }
.ui-opt > input { position: absolute; opacity: 0; pointer-events: none; }
.ui-opt__key {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.ui-opt__text { flex: 1; min-width: 0; padding-top: 0.2rem; line-height: 1.45; }
.ui-opt__why { display: none; margin-top: 0.4rem; font-size: 0.88rem; color: var(--muted); }
.is-revealed .ui-opt__why,
.ui-opt.is-revealed .ui-opt__why { display: block; }
.ui-opt.is-selected,
.ui-opt:not(.is-correct):not(.is-wrong):not(.is-missed):not(.is-neutral):has(> input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.ui-opt.is-selected .ui-opt__key,
.ui-opt:not(.is-correct):not(.is-wrong):not(.is-missed):not(.is-neutral):has(> input:checked) .ui-opt__key { background: var(--accent); color: var(--accent-ink); }
.ui-opt.is-correct { border-color: var(--ok); background: var(--ok-bg); box-shadow: inset 0 0 0 1px var(--ok); }
.ui-opt.is-correct .ui-opt__key { background: var(--ok); color: var(--surface); }
.ui-opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: inset 0 0 0 1px var(--bad); }
.ui-opt.is-wrong .ui-opt__key { background: var(--bad); color: var(--surface); }
.ui-opt.is-wrong { animation: ui-shake 260ms var(--ease-out) 1; }
.ui-opt.is-missed { border-color: var(--ok); border-style: dashed; background: var(--surface); }
.ui-opt.is-missed .ui-opt__key { background: var(--ok-bg); color: var(--ok); }
.ui-opt.is-neutral { opacity: 0.72; }
.ui-opt:disabled,
.ui-opt[aria-disabled="true"] { cursor: default; }

/* Bande de progression (1 segment par question) */
.ui-strip {
  display: flex;
  gap: 3px;
  width: 100%;
  height: 6px;
}
.ui-strip > i {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.ui-strip > i.is-ok { background: var(--ok); }
.ui-strip > i.is-bad { background: var(--bad); }
.ui-strip > i.is-current { background: var(--accent); transform: scaleY(1.5); }

/* Barre d'action collante (56px) — au-dessus de la barre d'onglets */
.ui-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 38;
  padding: 0.5rem max(var(--gutter), env(safe-area-inset-right, 0px)) calc(0.5rem + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(22, 26, 46, 0.06);
}
.ui-actionbar__inner {
  max-width: var(--max);
  min-height: var(--actionbar-h);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ui-actionbar__inner > .ui-btn { flex: 1 1 0; min-height: 48px; }
body.has-tabbar .ui-actionbar {
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) {
  .ui-actionbar {
    left: 50%;
    right: auto;
    width: min(40rem, calc(100% - 2rem));
    transform: translateX(-50%);
    bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0.4rem 0.6rem;
    box-shadow: var(--shadow-2);
  }
  body.has-tabbar .ui-actionbar { bottom: calc(var(--tabbar-h) + 1.6rem + env(safe-area-inset-bottom, 0px)); }
}

/* Toasts (créés par js/game.js) — ne bloquent jamais l'interaction */
.ui-toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0 var(--gutter);
  pointer-events: none;
}
body.has-tabbar .ui-toast-host { bottom: calc(var(--tabbar-h) + 0.75rem + env(safe-area-inset-bottom, 0px)); }
body.has-actionbar .ui-toast-host { bottom: calc(var(--tabbar-h) + var(--actionbar-h) + 1.5rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 720px) {
  body.has-tabbar .ui-toast-host { bottom: calc(var(--tabbar-h) + 1.75rem + env(safe-area-inset-bottom, 0px)); }
}
.ui-toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: min(26rem, 100%);
  padding: 0.65rem 1rem 0.65rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--deep);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: var(--shadow-2);
  pointer-events: none;
  animation: ui-toast-in var(--dur-3) var(--ease-out) both;
}
.ui-toast.is-leaving { animation: ui-toast-out var(--dur-2) var(--ease-out) both; }
.ui-toast__icon {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 16%, transparent);
}
.ui-toast__icon svg { width: 1.1rem; height: 1.1rem; }
.ui-toast.is-ok .ui-toast__icon { background: var(--ok); color: #ffffff; }
.ui-toast.is-xp .ui-toast__icon { background: var(--xp); color: #2a1a00; }
.ui-toast.is-flame .ui-toast__icon { background: var(--flame); color: #2a1200; }
.ui-toast.is-bad .ui-toast__icon { background: var(--bad); color: #ffffff; }

/* Feuille (bas sur mobile, modale au centre sur desktop) */
.ui-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(10, 12, 24, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out);
}
.ui-scrim.is-open { opacity: 1; pointer-events: auto; }
.ui-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  max-height: 88vh;
  overflow: auto;
  padding: 0.5rem var(--gutter) calc(1rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
}
.ui-sheet.is-open { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease-out); }
.ui-sheet__grip {
  width: 2.5rem;
  height: 4px;
  margin: 0.25rem auto 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
}
@media (min-width: 720px) {
  .ui-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(32rem, calc(100% - 2rem));
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    transform: translate(-50%, -46%);
    opacity: 0;
    transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  .ui-sheet.is-open { transform: translate(-50%, -50%); opacity: 1; }
  .ui-sheet__grip { display: none; }
}

/* Tuile statistique */
.ui-tile {
  display: grid;
  gap: 0.15rem;
  padding: 0.8rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  color: inherit;
  text-decoration: none;
}
.ui-tile__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ui-tile__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--deep);
}
.ui-tile__sub { font-size: 0.78rem; color: var(--muted); }

/* Heatmap : 7 lignes (lun → dim), colonnes = semaines ; remplir colonne par colonne */
.ui-heat {
  display: grid;
  grid-template-rows: repeat(7, var(--heat-cell, 12px));
  grid-auto-flow: column;
  grid-auto-columns: var(--heat-cell, 12px);
  gap: 3px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}
.ui-heat__cell {
  width: var(--heat-cell, 12px);
  height: var(--heat-cell, 12px);
  border-radius: 3px;
  background: var(--heat-0);
}
.ui-heat__cell[data-l="1"] { background: var(--heat-1); }
.ui-heat__cell[data-l="2"] { background: var(--heat-2); }
.ui-heat__cell[data-l="3"] { background: var(--heat-3); }
.ui-heat__cell[data-l="4"] { background: var(--heat-4); }
.ui-heat__cell.is-today { box-shadow: 0 0 0 1.5px var(--flame); }
.ui-heat__cell.is-future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); } /* jours à venir de la semaine : case vide mais visible, la colonne reste complète */

/* Stat inline (icône + nombre + libellé) — ex. série, XP dans l'en-tête */
.ui-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.65rem 0.25rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.86rem;
  text-decoration: none;
}
.ui-stat__icon { display: grid; place-items: center; }
.ui-stat__icon svg { width: 1.15rem; height: 1.15rem; }
.ui-stat__value { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
.ui-stat__label { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.ui-stat.is-flame { background: var(--flame-soft); border-color: var(--flame-line); }
.ui-stat.is-flame .ui-stat__icon,
.ui-stat.is-flame .ui-stat__value { color: var(--flame-ink); }
.ui-stat.is-xp { background: var(--xp-soft); border-color: var(--xp-line); }
.ui-stat.is-xp .ui-stat__icon,
.ui-stat.is-xp .ui-stat__value { color: var(--xp-ink); }
.ui-stat.is-accent { background: var(--accent-soft); border-color: var(--accent-line); }
.ui-stat.is-accent .ui-stat__icon,
.ui-stat.is-accent .ui-stat__value { color: var(--accent); }

/* Badge (médaille) */
.ui-badge {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}
.ui-badge__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--xp), var(--flame));
  color: #2a1600;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--xp) 35%, transparent);
}
.ui-badge__icon svg { width: 1.45rem; height: 1.45rem; }
.ui-badge__title { font-weight: 700; font-size: 0.82rem; line-height: 1.2; color: var(--deep); }
.ui-badge__desc { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }
.ui-badge.is-locked .ui-badge__icon {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
}
.ui-badge.is-locked .ui-badge__title { color: var(--muted); }

/* Flamme de série */
.ui-flame {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  transform-origin: 50% 90%;
}
.ui-flame svg { width: 1.3em; height: 1.3em; }
.ui-flame.is-alive { color: var(--flame); animation: ui-flicker 2.4s ease-in-out infinite; }
.ui-flame.is-alive svg { fill: color-mix(in srgb, var(--flame) 22%, transparent); }
.ui-flame.is-out { color: var(--muted); opacity: 0.6; }

/* « +10 XP » qui monte */
.ui-xp-pop {
  position: absolute;
  z-index: 5;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--xp-soft);
  color: var(--xp-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  pointer-events: none;
  white-space: nowrap;
  animation: ui-xp-pop 900ms var(--ease-out) forwards;
}

/* 6. MOUVEMENT ──────────────────────────────────────────────────────────── */
@keyframes ui-toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes ui-toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(6px); }
}
@keyframes ui-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
}
@keyframes ui-flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.06) rotate(-2deg); }
  70% { transform: scale(0.98) rotate(1.5deg); }
}
@keyframes ui-xp-pop {
  0% { opacity: 0; transform: translateY(6px) scale(0.9); }
  20% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateY(-28px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .ui-opt.is-wrong,
  .ui-flame.is-alive { animation: none !important; }
}

/* 7. COMPAT SOMBRE DES PAGES NON MIGRÉES ─────────────────────────────────────
   Les <style> des pages codent certains fonds/textes en dur (#fff, #f7f4ee…).
   En sombre, on les remet sur les tokens. À SUPPRIMER quand la page est refaite. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .session-block,
  :root:not([data-theme="light"]) .ue-sub-list,
  :root:not([data-theme="light"]) .score-box { background: var(--surface-2); }
  :root:not([data-theme="light"]) .pool-stat,
  :root:not([data-theme="light"]) .fc-forecast,
  :root:not([data-theme="light"]) input[type="number"],
  :root:not([data-theme="light"]) select { background: var(--surface); color: var(--ink); }
  :root:not([data-theme="light"]) .fc-forecast--empty { background: transparent; }
  :root:not([data-theme="light"]) .fc-forecast-track { background: var(--surface-3); }
  :root:not([data-theme="light"]) .fc-forecast-fill { background: var(--line-strong); }
  :root:not([data-theme="light"]) .fc-forecast-row--today .fc-forecast-fill { background: var(--accent); }
  :root:not([data-theme="light"]) .flash-resume { background: var(--flame-soft); border-color: var(--flame-line); }
  :root:not([data-theme="light"]) .flash-resume-title { color: var(--flame-ink); }
  :root:not([data-theme="light"]) .choice.reveal-ok { border-color: var(--ok-line); }
  :root:not([data-theme="light"]) .choice.reveal-bad { border-color: var(--bad-line); }
  :root:not([data-theme="light"]) .chip,
  :root:not([data-theme="light"]) .next-links .review-chip { background: var(--warn-soft); border-color: var(--warn-line); color: var(--ink); }
  :root:not([data-theme="light"]) .chip.ch { background: var(--accent-soft); border-color: var(--accent); }
  :root:not([data-theme="light"]) .mode-btn[aria-pressed="true"],
  :root:not([data-theme="light"]) .prio-btn[aria-pressed="true"],
  :root:not([data-theme="light"]) .kind-btn[aria-pressed="true"],
  :root:not([data-theme="light"]) .review-btn,
  :root:not([data-theme="light"]) .next-links a.primary-next { color: var(--accent-ink); }
  :root:not([data-theme="light"]) .score-line { color: var(--accent); }
  :root:not([data-theme="light"]) .score-line.empty { color: var(--muted); }
}
:root[data-theme="dark"] .session-block,
:root[data-theme="dark"] .ue-sub-list,
:root[data-theme="dark"] .score-box { background: var(--surface-2); }
:root[data-theme="dark"] .pool-stat,
:root[data-theme="dark"] .fc-forecast,
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] select { background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] .fc-forecast--empty { background: transparent; }
:root[data-theme="dark"] .fc-forecast-track { background: var(--surface-3); }
:root[data-theme="dark"] .fc-forecast-fill { background: var(--line-strong); }
:root[data-theme="dark"] .fc-forecast-row--today .fc-forecast-fill { background: var(--accent); }
:root[data-theme="dark"] .flash-resume { background: var(--flame-soft); border-color: var(--flame-line); }
:root[data-theme="dark"] .flash-resume-title { color: var(--flame-ink); }
:root[data-theme="dark"] .choice.reveal-ok { border-color: var(--ok-line); }
:root[data-theme="dark"] .choice.reveal-bad { border-color: var(--bad-line); }
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .next-links .review-chip { background: var(--warn-soft); border-color: var(--warn-line); color: var(--ink); }
:root[data-theme="dark"] .chip.ch { background: var(--accent-soft); border-color: var(--accent); }
:root[data-theme="dark"] .mode-btn[aria-pressed="true"],
:root[data-theme="dark"] .prio-btn[aria-pressed="true"],
:root[data-theme="dark"] .kind-btn[aria-pressed="true"],
:root[data-theme="dark"] .review-btn,
:root[data-theme="dark"] .next-links a.primary-next { color: var(--accent-ink); }
:root[data-theme="dark"] .score-line { color: var(--accent); }
:root[data-theme="dark"] .score-line.empty { color: var(--muted); }
