/*
  Amilcar Classrooms — système de design
  Fichier : public/theme.css (chantier B). Mode d'emploi complet : DESIGN_SYSTEM.md.

  - Chargé par toutes les pages, AVANT leurs propres feuilles.
  - Préfixe des classes : « ui- » (bloc ui-xxx, élément ui-xxx__yyy, variante ui-xxx--zzz).
  - Les états passent par les attributs HTML et ARIA (aria-current, aria-selected,
    aria-invalid, aria-busy, aria-sort, aria-expanded, [open], :disabled, data-state).
  - Couleurs en OKLCH, avec un repli sRGB pour les navigateurs qui ne le lisent pas.
  - Les règles de base sont écrites avec :where() : spécificité nulle, toute feuille
    de page peut les remplacer sans surenchère.
*/

/* ==========================================================================
   0. Polices — auto-hébergées dans /fonts (licence SIL OFL 1.1, voir fonts/LISEZMOI.md)
   ========================================================================== */

@font-face {
  font-family: "Radio Canada";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/radio-canada-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: "Radio Canada";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/radio-canada-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: "Radio Canada";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/radio-canada-italic-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: "Radio Canada";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/radio-canada-italic-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: "Castoro Titling";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/castoro-titling-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: "Castoro Titling";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/castoro-titling-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;
}
/* Replis aux métriques ajustées : le texte ne saute pas quand la police arrive. */
@font-face {
  font-family: "Radio Canada Repli";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Roboto");
  size-adjust: 104.78%;
  ascent-override: 90.18%;
  descent-override: 24.34%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Castoro Titling Repli";
  src: local("Georgia"), local("Times New Roman"), local("Liberation Serif");
  size-adjust: 103.12%;
  ascent-override: 73.22%;
  descent-override: 23.76%;
  line-gap-override: 32%;
}

/* ==========================================================================
   1. Jetons primitifs (couleurs). Repli sRGB puis valeurs OKLCH de référence.
   Ne pas utiliser les primitives dans les écrans : passer par les jetons
   sémantiques (section 2), sauf mention contraire dans DESIGN_SYSTEM.md.
   ========================================================================== */

:root {
  /* Papier ivoire (teinté vers l'or, h 85-88) */
  --paper-0: #fdfbf7;
  --paper-1: #f8f4ec;
  --paper-2: #f1ece1;
  --paper-3: #e7e1d5;
  --line-1: #dad4c8;
  --line-2: #c4bdb0;
  /* Encre bleu nuit (logo #131e30, h 260) */
  --ink-950: #0b1423;
  --ink-900: #131e30;
  --ink-800: #222e42;
  --ink-700: #374356;
  --ink-600: #515b6c;
  --ink-500: #6c7584;
  --ink-400: #9199a5;
  --ink-300: #b8bec8;
  --ink-200: #d3d8e0;
  /* Or du blason (logo #c2a65c, h 89 -> 76 en profondeur) */
  --gold-100: #f7efd9;
  --gold-200: #eeddb1;
  --gold-300: #dec587;
  --gold-400: #c2a65c;
  --gold-500: #b4944a;
  --gold-600: #9c7a37;
  --gold-700: #7f5e25;
  --gold-800: #63471c;
  /* Information (h 248-252) */
  --info-100: #e5f1fc;
  --info-300: #a9c8e7;
  --info-600: #316ca5;
  --info-700: #295788;
  --info-night: #95c3ef;
  /* Succès (h 152) */
  --succes-100: #e1f5e5;
  --succes-300: #a3d2ae;
  --succes-600: #2d7b48;
  --succes-700: #28633c;
  --succes-night: #86d29b;
  /* Attention (h 58-78) */
  --attention-100: #fdeed7;
  --attention-300: #efc189;
  --attention-600: #b16512;
  --attention-700: #894c14;
  --attention-night: #f2b966;
  /* Critique (h 25-27) */
  --critique-100: #fde9e7;
  --critique-300: #eeb3ad;
  --critique-600: #b6322d;
  --critique-700: #9e2d28;
  --critique-night: #f69b94;
  /* Avatars (fonds doux) */
  --avatar-1: #d3dff3;
  --avatar-2: #edddb5;
  --avatar-3: #c7e7d7;
  --avatar-4: #f3d3c7;
  --avatar-5: #e1daf0;
  /* Ombres sobres, teintées d'encre ; voile des panneaux */
  --shadow-xs: 0 1px 0 rgb(19 30 48 / 0.05);
  --shadow-sm: 0 1px 2px rgb(19 30 48 / 0.08), 0 1px 1px rgb(19 30 48 / 0.04);
  --shadow-md: 0 6px 16px -4px rgb(19 30 48 / 0.14), 0 2px 4px -2px rgb(19 30 48 / 0.08);
  --shadow-lg: 0 24px 48px -12px rgb(11 20 35 / 0.28), 0 4px 12px -4px rgb(11 20 35 / 0.12);
  --shadow-up: 0 -8px 24px -12px rgb(19 30 48 / 0.16);
  --scrim: rgb(11 20 35 / 0.42);
  /* Chevron des listes déroulantes : un <select> n'a pas de pseudo-élément, la couleur est
     donc inscrite dans l'image (ink-600 ici, ink-300 dans la portée nuit, section 29) */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23515b6c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 9.5l5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  --select-chevron-night: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b8bec8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 9.5l5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
}

@supports (color: oklch(0% 0 0)) {
  :root {
    /* Papier ivoire (teinté vers l'or, h 85-88) */
    --paper-0: oklch(98.8% 0.006 88);
    --paper-1: oklch(96.8% 0.012 87);
    --paper-2: oklch(94.4% 0.015 86);
    --paper-3: oklch(91.2% 0.018 85);
    --line-1: oklch(87.2% 0.018 84);
    --line-2: oklch(80% 0.02 82);
    /* Encre bleu nuit (logo #131e30, h 260) */
    --ink-950: oklch(19% 0.034 260);
    --ink-900: oklch(23.4% 0.038 260);
    --ink-800: oklch(30% 0.04 260);
    --ink-700: oklch(38% 0.036 260);
    --ink-600: oklch(47% 0.03 260);
    --ink-500: oklch(56% 0.026 260);
    --ink-400: oklch(68% 0.02 260);
    --ink-300: oklch(80% 0.016 260);
    --ink-200: oklch(88% 0.012 260);
    /* Or du blason (logo #c2a65c, h 89 -> 76 en profondeur) */
    --gold-100: oklch(95.2% 0.03 90);
    --gold-200: oklch(90% 0.06 89);
    --gold-300: oklch(83% 0.085 89);
    --gold-400: oklch(73.4% 0.099 89);
    --gold-500: oklch(68% 0.1 86);
    --gold-600: oklch(60% 0.095 82);
    --gold-700: oklch(50.5% 0.085 78);
    --gold-800: oklch(42% 0.07 76);
    /* Information (h 248-252) */
    --info-100: oklch(95.2% 0.02 248);
    --info-300: oklch(82% 0.055 248);
    --info-600: oklch(52% 0.11 250);
    --info-700: oklch(45% 0.095 252);
    --info-night: oklch(80% 0.08 248);
    /* Succès (h 152) */
    --succes-100: oklch(95.2% 0.03 152);
    --succes-300: oklch(82% 0.07 152);
    --succes-600: oklch(52% 0.11 152);
    --succes-700: oklch(45% 0.09 152);
    --succes-night: oklch(80% 0.11 152);
    /* Attention (h 58-78) */
    --attention-100: oklch(95.5% 0.034 78);
    --attention-300: oklch(84% 0.09 72);
    --attention-600: oklch(58% 0.13 60);
    --attention-700: oklch(48% 0.105 58);
    --attention-night: oklch(82% 0.12 75);
    /* Critique (h 25-27) */
    --critique-100: oklch(95% 0.022 25);
    --critique-300: oklch(82% 0.07 25);
    --critique-600: oklch(52% 0.17 27);
    --critique-700: oklch(47% 0.15 27);
    --critique-night: oklch(78% 0.11 25);
    /* Avatars (fonds doux) */
    --avatar-1: oklch(90% 0.03 260);
    --avatar-2: oklch(90% 0.055 89);
    --avatar-3: oklch(90% 0.04 165);
    --avatar-4: oklch(89% 0.04 40);
    --avatar-5: oklch(90% 0.03 300);
    /* Ombres sobres, teintées d'encre ; voile des panneaux */
    --shadow-xs: 0 1px 0 oklch(23.4% 0.038 260 / 0.05);
    --shadow-sm: 0 1px 2px oklch(23.4% 0.038 260 / 0.08), 0 1px 1px oklch(23.4% 0.038 260 / 0.04);
    --shadow-md: 0 6px 16px -4px oklch(23.4% 0.038 260 / 0.14), 0 2px 4px -2px oklch(23.4% 0.038 260 / 0.08);
    --shadow-lg: 0 24px 48px -12px oklch(19% 0.034 260 / 0.28), 0 4px 12px -4px oklch(19% 0.034 260 / 0.12);
    --shadow-up: 0 -8px 24px -12px oklch(23.4% 0.038 260 / 0.16);
    --scrim: oklch(19% 0.034 260 / 0.42);
  }
}

/* ==========================================================================
   2. Jetons sémantiques et jetons de mise en forme
   ========================================================================== */

:root {
  color-scheme: light;

  /* Fonds et surfaces */
  --color-bg: var(--paper-1);              /* fond de page : papier ivoire */
  --color-bg-sunken: var(--paper-2);       /* barre latérale, puits, en-têtes de tableau */
  --color-surface: var(--paper-0);         /* tableaux, panneaux, champs, surfaces posées */
  --color-surface-hover: var(--paper-2);
  --color-surface-pressed: var(--paper-3);
  --color-surface-selected: var(--gold-100);
  --color-line: var(--line-1);             /* filets décoratifs */
  --color-line-strong: var(--line-2);      /* séparations marquées, pointillés */
  --color-control-border: var(--ink-500);  /* bord des champs : 3:1 au moins */
  --color-control-border-hover: var(--ink-700); /* bord au survol : plus marqué, jamais plus faible */
  --color-switch-thumb: var(--ink-600);    /* pouce de l'interrupteur éteint : 3:1 sur la piste */
  --color-scrim: var(--scrim);

  /* Texte */
  --color-text: var(--ink-900);
  --color-text-muted: var(--ink-600);
  --color-text-nav: var(--ink-700);
  --color-text-disabled: var(--ink-400);
  --color-text-inverse: var(--paper-0);

  /* Encre pleine (cases cochées, puces choisies, pastilles) */
  --color-ink-fill: var(--ink-900);
  --color-ink-fill-hover: var(--ink-800);

  /* Or : accent rare (action principale, état actif, moment important) */
  --color-accent: var(--gold-400);
  --color-accent-hover: var(--gold-500);
  --color-accent-line: var(--gold-600);    /* indicateurs et filets or : 3:1 */
  --color-accent-text: var(--gold-700);    /* texte or sur ivoire : 4.5:1 */
  --color-accent-tint: var(--gold-100);
  --color-accent-soft: var(--gold-200);
  --color-accent-border: var(--gold-300);  /* filet du badge or */
  --color-accent-text-strong: var(--gold-800); /* texte sur teinte or (badge or) : 4.5:1 */
  --color-on-accent: var(--ink-900);

  --color-focus: var(--ink-900);

  /* États (noms identiques aux gravités de l'API : info, succes, attention, critique) */
  --color-info-tint: var(--info-100);
  --color-info-line: var(--info-300);
  --color-info-icon: var(--info-600);
  --color-info-text: var(--info-700);
  --color-succes-tint: var(--succes-100);
  --color-succes-line: var(--succes-300);
  --color-succes-icon: var(--succes-600);
  --color-succes-text: var(--succes-700);
  --color-attention-tint: var(--attention-100);
  --color-attention-line: var(--attention-300);
  --color-attention-icon: var(--attention-600);
  --color-attention-text: var(--attention-700);
  --color-critique-tint: var(--critique-100);
  --color-critique-line: var(--critique-300);
  --color-critique-icon: var(--critique-600);
  --color-critique-text: var(--critique-700);
  --color-critique-fill: var(--critique-600);
  --color-critique-fill-hover: var(--critique-700);

  /* Typographie */
  --font-text: "Radio Canada", "Radio Canada Repli", "Segoe UI", system-ui, sans-serif;
  --font-titling: "Castoro Titling", "Castoro Titling Repli", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.75rem;     /* 12 px : capitales d'étiquette, pastilles */
  --text-sm: 0.875rem;    /* 14 px : métadonnées, aides, libellés */
  --text-base: 1rem;      /* 16 px : texte courant, champs, tableaux */
  --text-lg: 1.25rem;     /* 20 px : titres de section et de panneau */
  --text-xl: 1.75rem;     /* 28 px (32 px au-delà de 40rem) : titre de page (capitales de titrage) */
  --text-2xl: 2.5rem;     /* 40 px : chiffre ou horaire du moment (prochain cours) */
  /* Échelle fluide, réservée à la page d'accueil publique */
  --text-lead: clamp(1.125rem, 1.02rem + 0.45vw, 1.375rem);
  --text-display: clamp(2.25rem, 1.55rem + 3vw, 4rem);
  --text-display-lg: clamp(2.75rem, 1.6rem + 4.9vw, 5.5rem);

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-normal: 1.5;
  --tracking-titling: 0.04em;
  --tracking-caps: 0.07em;
  --measure: 65ch;

  /* Espacements : échelle de 4 pt */
  --space-2xs: 0.25rem;   /*  4 px */
  --space-xs: 0.5rem;     /*  8 px */
  --space-sm: 0.75rem;    /* 12 px */
  --space-md: 1rem;       /* 16 px */
  --space-lg: 1.5rem;     /* 24 px */
  --space-xl: 2rem;       /* 32 px */
  --space-2xl: 3rem;      /* 48 px */
  --space-3xl: 4rem;      /* 64 px */
  --space-4xl: 6rem;      /* 96 px */
  --space-section: clamp(3rem, 1.8rem + 5vw, 6rem); /* accueil public seulement */

  /* Rayons : nets, comme une gravure */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-full: 999px;

  /* Dimensions */
  --control-height: 2.75rem;     /* 44 px : cible tactile */
  --control-height-sm: 2.75rem;  /* au doigt, même les petits boutons gardent 44 px */
  --sidebar-width: 16.5rem;
  --topbar-height: 3.5rem;
  --tabbar-height: 4rem;
  --page-width: 80rem;

  /* Mouvement */
  --duration-instant: 90ms;
  --duration-fast: 140ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
  --duration-slower: 480ms;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);        /* quart : entrées, retours */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);   /* panneaux, feuilles */
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);         /* sorties */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);    /* bascules */

  /* Plans (les dialogues et panneaux <dialog> sont dans la couche supérieure du navigateur) */
  --z-raised: 1;
  --z-sticky: 100;
  --z-nav: 200;
  --z-drawer: 300;
  --z-dropdown: 400;
  --z-toast: 600;
  --z-skip: 700;

  /* Décalage bas pour les éléments fixes (barre d'onglets mobile) */
  --ui-bottom-inset: 0px;
}

/* Pointeur précis seulement (souris, pavé) : commandes un peu plus denses.
   Un ordinateur à écran tactile (any-pointer: coarse) garde les cibles de 44 px. */
@media (pointer: fine) and (not (any-pointer: coarse)) {
  :root {
    --control-height: 2.5rem;
    --control-height-sm: 2rem;
  }
}

/* Au-delà du téléphone, le titre de page gagne une marche sur le titre de section (20 -> 32 px) */
@media (min-width: 40rem) {
  :root {
    --text-xl: 2rem;
  }
}

/* ==========================================================================
   3. Base : remise à zéro légère, typographie, focus, sélection, liens
   ========================================================================== */

/* Les pseudo-éléments ne peuvent pas figurer dans :where() : sélecteur universel simple */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:where(html) {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-block: var(--space-xl);
}

:where(body) {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-text);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  font-kerning: normal;
  font-synthesis-weight: none;
  -webkit-tap-highlight-color: transparent;
}

:where(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd) {
  margin: 0;
}

:where(h1, h2, h3, h4, h5, h6) {
  text-wrap: balance;
}

:where(p, li, dd, figcaption) {
  text-wrap: pretty;
}

:where(h1) {
  font-family: var(--font-titling);
  font-size: var(--text-xl);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-titling);
  text-transform: uppercase;
}

:where(h2) {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

:where(h3) {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

:where(h4, h5, h6) {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

:where(img, video) {
  max-width: 100%;
  height: auto;
}

:where(img, svg, video, canvas) {
  vertical-align: middle;
}

:where(input, button, textarea, select) {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

:where(button:not(:disabled), [role="button"]:not([aria-disabled="true"]), summary, label:has(input:not(:disabled))) {
  cursor: pointer;
}

:where(table) {
  border-collapse: collapse;
}

:where(hr) {
  height: 0;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--color-line);
}

:where(abbr[title]) {
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
}

:where(code, kbd, samp, pre) {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:where(strong, b) {
  font-weight: var(--weight-semibold);
}

:where(time, .ui-num) {
  font-variant-numeric: tabular-nums lining-nums;
}

:where(a) {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--color-accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color var(--duration-fast) var(--ease-out);
}

/* Les survols sont réservés aux appareils qui survolent : sur un écran tactile,
   un survol resterait affiché après le toucher. */
@media (hover: hover) {
  :where(a:hover) {
    text-decoration-color: currentColor;
  }
}

/* Focus visible : anneau d'encre, décalé, identique partout */
:where(:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Un titre ou un conteneur qui reçoit le focus par programme (changement de rubrique) */
:where([tabindex="-1"]:focus:not(:focus-visible)) {
  outline: none;
}

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

[hidden] {
  display: none !important;
}

/* ==========================================================================
   4. Utilitaires
   ========================================================================== */

.ui-sr-only,
.ui-sr-only-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ui-skip-link {
  position: fixed;
  z-index: var(--z-skip);
  top: var(--space-sm);
  left: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--ink-900);
  color: var(--paper-0);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-xl)));
  transition: transform var(--duration-fast) var(--ease-out);
}

.ui-skip-link:focus {
  transform: none;
  outline: 2px solid var(--gold-300);
  outline-offset: 2px;
}

.ui-text-muted { color: var(--color-text-muted); }
.ui-text-sm { font-size: var(--text-sm); }
.ui-text-xs { font-size: var(--text-xs); }
.ui-num { font-variant-numeric: tabular-nums lining-nums; }
.ui-nowrap { white-space: nowrap; }
.ui-measure { max-width: var(--measure); }

.ui-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ui-titling {
  font-family: var(--font-titling);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-titling);
  text-transform: uppercase;
  line-height: var(--leading-tight);
}

.ui-overline {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  line-height: var(--leading-snug);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Horaire ou chiffre du moment (prochain cours, compte à rebours) : un par écran */
.ui-figure {
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums lining-nums;
}

.ui-link {
  color: var(--color-text);
  font-weight: var(--weight-medium);
  text-decoration-line: underline;
  text-decoration-color: var(--color-accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

/* Lien discret : sans soulignement au repos, donc jamais au milieu d'un texte courant
   (la couleur seule ne le distinguerait pas). Listes, méta, pieds de section seulement. */
.ui-link--quiet {
  color: var(--color-text-muted);
  text-decoration-color: transparent;
}

@media (hover: hover) {
  .ui-link:hover {
    text-decoration-color: currentColor;
  }

  .ui-link--quiet:hover {
    color: var(--color-text);
    text-decoration-color: currentColor;
  }
}

/* Lien suivi d'une flèche : « Voir l'emploi du temps » */
.ui-link--arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  text-decoration-color: transparent;
}

.ui-link--arrow::after {
  content: "";
  inline-size: 1em;
  block-size: 1em;
  background-color: currentColor;
  -webkit-mask: var(--glyph-arrow-right) center / contain no-repeat;
  mask: var(--glyph-arrow-right) center / contain no-repeat;
  transition: transform var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .ui-link--arrow:hover {
    text-decoration-color: currentColor;
  }

  .ui-link--arrow:hover::after {
    transform: translateX(2px);
  }
}

/* Ornement de marque : filet à losange or. Accueil public et écrans de connexion seulement
   (l'état vide a le sien, en encre : section 17). */
.ui-ornament {
  display: block;
  inline-size: 3rem;
  block-size: 0.75rem;
  background-color: var(--color-accent-line);
  -webkit-mask: var(--glyph-ornament) center / contain no-repeat;
  mask: var(--glyph-ornament) center / contain no-repeat;
}

/* ==========================================================================
   5. Pictogrammes (glyphes) : <span class="ui-glyph ui-glyph--calendar" aria-hidden="true"></span>
   La couleur suit le texte (currentColor). Taille : --glyph-size (1.25em par défaut).
   ========================================================================== */

:root {
  --glyph-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 6.5l11 11M17.5 6.5l-11 11'/%3E%3C/svg%3E");
  --glyph-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --glyph-minus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
  --glyph-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5.5v13M5.5 12h13'/%3E%3C/svg%3E");
  --glyph-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 9.5l5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  --glyph-chevron-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.5 14.5L12 9l5.5 5.5'/%3E%3C/svg%3E");
  --glyph-chevron-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 6.5L9 12l5.5 5.5'/%3E%3C/svg%3E");
  --glyph-chevron-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6.5L15 12l-5.5 5.5'/%3E%3C/svg%3E");
  --glyph-arrow-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5.5M6.5 11L12 5.5 17.5 11'/%3E%3C/svg%3E");
  --glyph-arrow-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v13.5M6.5 13l5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  --glyph-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h13.5M13 6.5l5.5 5.5-5.5 5.5'/%3E%3C/svg%3E");
  --glyph-sort: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 9.5l4-4 4 4M8 14.5l4 4 4-4'/%3E%3C/svg%3E");
  --glyph-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6'/%3E%3Cpath d='M15 15l5 5'/%3E%3C/svg%3E");
  --glyph-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E");
  --glyph-more: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12h.01' stroke-width='2.6'/%3E%3Cpath d='M12 12h.01' stroke-width='2.6'/%3E%3Cpath d='M18 12h.01' stroke-width='2.6'/%3E%3C/svg%3E");
  --glyph-edit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 19.5l1-4L15.8 5.2a2 2 0 0 1 2.8 0l.2.2a2 2 0 0 1 0 2.8L8.5 18.5zM13.8 7.2l3 3'/%3E%3C/svg%3E");
  --glyph-external: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.5 4.5h6v6M19.5 4.5L11 13M17 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-10A1.5 1.5 0 0 1 4 18.5v-10A1.5 1.5 0 0 1 5.5 7H10'/%3E%3C/svg%3E");
  --glyph-filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5.5h16l-6.2 7.3v5.6l-3.6 1.9v-7.5z'/%3E%3C/svg%3E");
  --glyph-refresh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19.5 12a7.5 7.5 0 1 1-2.2-5.3M19.5 4.5v4h-4'/%3E%3C/svg%3E");
  --glyph-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15.5V4.5M7.5 9L12 4.5 16.5 9M4.5 15v3.5A1.5 1.5 0 0 0 6 20h12a1.5 1.5 0 0 0 1.5-1.5V15'/%3E%3C/svg%3E");
  --glyph-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4.5v11M7.5 11l4.5 4.5 4.5-4.5M4.5 15v3.5A1.5 1.5 0 0 0 6 20h12a1.5 1.5 0 0 0 1.5-1.5V15'/%3E%3C/svg%3E");
  --glyph-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 3.5h7l5 5v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-15a1 1 0 0 1 1-1zM14 3.5v5h5M9 13h6M9 16.5h6'/%3E%3C/svg%3E");
  --glyph-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 11.5L20 4.5 16.5 20l-4.5-6.5zM12 13.5l8-9'/%3E%3C/svg%3E");
  --glyph-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.75'/%3E%3Cpath d='M12 11v5.5'/%3E%3Cpath d='M12 7.75h.01' stroke-width='2.4'/%3E%3C/svg%3E");
  --glyph-succes: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.75'/%3E%3Cpath d='M8 12.4l2.7 2.7 5.3-5.6'/%3E%3C/svg%3E");
  --glyph-attention: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3.75l9.25 16H2.75zM12 10v4.25'/%3E%3Cpath d='M12 17h.01' stroke-width='2.4'/%3E%3C/svg%3E");
  --glyph-critique: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8.3 3.25h7.4l5.05 5.05v7.4l-5.05 5.05H8.3l-5.05-5.05V8.3zM12 7.5v5.25'/%3E%3Cpath d='M12 16.25h.01' stroke-width='2.4'/%3E%3C/svg%3E");
  --glyph-inconnu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.75' stroke-dasharray='2.6 2.6'/%3E%3Cpath d='M9.75 9.75a2.3 2.3 0 0 1 4.5.6c0 1.5-2.25 1.9-2.25 3.4'/%3E%3Cpath d='M12 16.75h.01' stroke-width='2.4'/%3E%3C/svg%3E");
  --glyph-home: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10.5L12 4l8 6.5V20h-5.5v-5.5h-5V20H4z'/%3E%3C/svg%3E");
  --glyph-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='1.5'/%3E%3Cpath d='M3.5 9.75h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  --glyph-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.75'/%3E%3Cpath d='M12 7.25V12l3.25 2'/%3E%3C/svg%3E");
  --glyph-student: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 9L12 4.5 21.5 9 12 13.5zM6.5 11v4.25c0 1.6 2.5 3 5.5 3s5.5-1.4 5.5-3V11M21.5 9v5'/%3E%3C/svg%3E");
  --glyph-teacher: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4' width='17' height='11' rx='1'/%3E%3Cpath d='M8 20l4-5 4 5M7.5 8.5h6M7.5 11.25h4'/%3E%3C/svg%3E");
  --glyph-users: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8.5' r='3.25'/%3E%3Cpath d='M3 19.5c0-3.3 2.7-5.75 6-5.75s6 2.45 6 5.75M15.5 5.4a3.25 3.25 0 0 1 0 6.2M17.25 14.1c2.2.6 3.75 2.6 3.75 5.4'/%3E%3C/svg%3E");
  --glyph-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='3.75'/%3E%3Cpath d='M4.75 20c0-4 3.25-6.75 7.25-6.75S19.25 16 19.25 20'/%3E%3C/svg%3E");
  --glyph-book: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5.5c2.6-1 5.4-1 8 .9 2.6-1.9 5.4-1.9 8-.9V19c-2.6-1-5.4-1-8 .9-2.6-1.9-5.4-1.9-8-.9zM12 6.4v13.5'/%3E%3C/svg%3E");
  --glyph-checklist: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 6.5h10M10 12h10M10 17.5h10M3.75 6.5l1.5 1.5 2.5-2.75M3.75 12l1.5 1.5 2.5-2.75M3.75 17.5l1.5 1.5 2.5-2.75'/%3E%3C/svg%3E");
  --glyph-receipt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5h12v17l-2-1.4-2 1.4-2-1.4-2 1.4-2-1.4-2 1.4zM9 8h6M9 11.5h6M9 15h3.5'/%3E%3C/svg%3E");
  --glyph-history: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.75 12a8.25 8.25 0 1 0 2.4-5.85M3.75 4.75v3.5h3.5M12 8v4.5l3 1.75'/%3E%3C/svg%3E");
  --glyph-bell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 2h-15zM10 20.75a2 2 0 0 0 4 0'/%3E%3C/svg%3E");
  --glyph-archive: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='4' rx='1'/%3E%3Cpath d='M5 8.5v10.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8.5M10 12.5h4'/%3E%3C/svg%3E");
  --glyph-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16M7 16.5v-5M12 16.5v-9M17 16.5v-6.5'/%3E%3C/svg%3E");
  --glyph-journal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5h11.5a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1.5 1.5 0 0 1-1.5-1.5V5A1.5 1.5 0 0 1 6 3.5zM8.5 8h6.5M8.5 11.5h6.5M8.5 15H13'/%3E%3C/svg%3E");
  --glyph-pulse: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12.5h4l2.25-5.5 4.5 11 2.25-5.5H21'/%3E%3C/svg%3E");
  --glyph-institution: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 9.5h18L12 4.25zM5.5 9.5v8M9.8 9.5v8M14.2 9.5v8M18.5 9.5v8M3.5 20.25h17M4 17.5h16'/%3E%3C/svg%3E");
  --glyph-layers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4l8.5 4.5L12 13 3.5 8.5zM3.5 12.5L12 17l8.5-4.5M3.5 16.25L12 20.75l8.5-4.5'/%3E%3C/svg%3E");
  --glyph-server: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='16' height='6.5' rx='1'/%3E%3Crect x='4' y='13.5' width='16' height='6.5' rx='1'/%3E%3Cpath d='M7.75 7.25h.01' stroke-width='2.4'/%3E%3Cpath d='M7.75 16.75h.01' stroke-width='2.4'/%3E%3C/svg%3E");
  --glyph-mail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5.5' width='17' height='13' rx='1.5'/%3E%3Cpath d='M4 6.5l8 6.25 8-6.25'/%3E%3C/svg%3E");
  --glyph-sliders: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h9M17 7h3M15 4.5v5M4 17h3M11 17h9M9 14.5v5'/%3E%3C/svg%3E");
  --glyph-logout: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 4.5h-4A1.5 1.5 0 0 0 4 6v12a1.5 1.5 0 0 0 1.5 1.5h4M15 16l4-4-4-4M19 12H9.5'/%3E%3C/svg%3E");
  --glyph-video: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='6.5' width='12.5' height='11' rx='1.5'/%3E%3Cpath d='M15.5 10.5l5.5-3v9l-5.5-3'/%3E%3C/svg%3E");
  --glyph-video-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='6.5' width='12.5' height='11' rx='1.5'/%3E%3Cpath d='M15.5 10.5l5.5-3v9l-5.5-3M3.5 3.5l17 17'/%3E%3C/svg%3E");
  --glyph-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3.5' width='6' height='10.5' rx='3'/%3E%3Cpath d='M5.75 11a6.25 6.25 0 0 0 12.5 0M12 17.25v3.25'/%3E%3C/svg%3E");
  --glyph-mic-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3.5' width='6' height='10.5' rx='3'/%3E%3Cpath d='M5.75 11a6.25 6.25 0 0 0 12.5 0M12 17.25v3.25M3.5 3.5l17 17'/%3E%3C/svg%3E");
  --glyph-hand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8.5 12.5V6.75a1.5 1.5 0 0 1 3 0V11M11.5 10.5V5.25a1.5 1.5 0 0 1 3 0v5.25M14.5 10.5V6.75a1.5 1.5 0 0 1 3 0V13.5c0 3.9-2.7 7-6.5 7h-.5c-2.2 0-3.6-.9-4.8-2.6L3.6 15.1a1.4 1.4 0 0 1 2.2-1.7l2.7 2.6'/%3E%3C/svg%3E");
  --glyph-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 5.5h15v10h-8l-4.5 3.75V15.5H4.5z'/%3E%3C/svg%3E");
  --glyph-screen: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4.5' width='18' height='12' rx='1.5'/%3E%3Cpath d='M8.5 20h7M12 16.5V20'/%3E%3C/svg%3E");
  --glyph-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='1.5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5'/%3E%3C/svg%3E");
  --glyph-unlock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='1.5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 7.6-1.75'/%3E%3C/svg%3E");
  --glyph-spotlight: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3.5l2.6 5.3 5.9.85-4.25 4.15 1 5.85L12 16.9l-5.25 2.75 1-5.85L3.5 9.65l5.9-.85z'/%3E%3C/svg%3E");
  --glyph-megaphone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10v4.5h3l7.5 4V5.5L7 10zM7 14.5l1.25 5h2.25l-1-5M17.5 9.5a3.5 3.5 0 0 1 0 5'/%3E%3C/svg%3E");
  --glyph-ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 12' fill='none' stroke='%23000' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 6h17.5M29.5 6H47'/%3E%3Cpath d='M24 1.75L28.25 6 24 10.25 19.75 6z'/%3E%3C/svg%3E");
}

.ui-glyph {
  display: inline-block;
  flex: none;
  inline-size: var(--glyph-size, 1.25em);
  block-size: var(--glyph-size, 1.25em);
  vertical-align: -0.25em;
  background-color: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}

.ui-glyph--close { --glyph: var(--glyph-close); }
.ui-glyph--check { --glyph: var(--glyph-check); }
.ui-glyph--minus { --glyph: var(--glyph-minus); }
.ui-glyph--plus { --glyph: var(--glyph-plus); }
.ui-glyph--chevron-down { --glyph: var(--glyph-chevron-down); }
.ui-glyph--chevron-up { --glyph: var(--glyph-chevron-up); }
.ui-glyph--chevron-left { --glyph: var(--glyph-chevron-left); }
.ui-glyph--chevron-right { --glyph: var(--glyph-chevron-right); }
.ui-glyph--arrow-up { --glyph: var(--glyph-arrow-up); }
.ui-glyph--arrow-down { --glyph: var(--glyph-arrow-down); }
.ui-glyph--arrow-right { --glyph: var(--glyph-arrow-right); }
.ui-glyph--sort { --glyph: var(--glyph-sort); }
.ui-glyph--search { --glyph: var(--glyph-search); }
.ui-glyph--menu { --glyph: var(--glyph-menu); }
.ui-glyph--more { --glyph: var(--glyph-more); }
.ui-glyph--edit { --glyph: var(--glyph-edit); }
.ui-glyph--external { --glyph: var(--glyph-external); }
.ui-glyph--filter { --glyph: var(--glyph-filter); }
.ui-glyph--refresh { --glyph: var(--glyph-refresh); }
.ui-glyph--upload { --glyph: var(--glyph-upload); }
.ui-glyph--download { --glyph: var(--glyph-download); }
.ui-glyph--file { --glyph: var(--glyph-file); }
.ui-glyph--send { --glyph: var(--glyph-send); }
.ui-glyph--info { --glyph: var(--glyph-info); }
.ui-glyph--succes { --glyph: var(--glyph-succes); }
.ui-glyph--attention { --glyph: var(--glyph-attention); }
.ui-glyph--critique { --glyph: var(--glyph-critique); }
.ui-glyph--inconnu { --glyph: var(--glyph-inconnu); }
.ui-glyph--home { --glyph: var(--glyph-home); }
.ui-glyph--calendar { --glyph: var(--glyph-calendar); }
.ui-glyph--clock { --glyph: var(--glyph-clock); }
.ui-glyph--student { --glyph: var(--glyph-student); }
.ui-glyph--teacher { --glyph: var(--glyph-teacher); }
.ui-glyph--users { --glyph: var(--glyph-users); }
.ui-glyph--user { --glyph: var(--glyph-user); }
.ui-glyph--book { --glyph: var(--glyph-book); }
.ui-glyph--checklist { --glyph: var(--glyph-checklist); }
.ui-glyph--receipt { --glyph: var(--glyph-receipt); }
.ui-glyph--history { --glyph: var(--glyph-history); }
.ui-glyph--bell { --glyph: var(--glyph-bell); }
.ui-glyph--archive { --glyph: var(--glyph-archive); }
.ui-glyph--chart { --glyph: var(--glyph-chart); }
.ui-glyph--journal { --glyph: var(--glyph-journal); }
.ui-glyph--pulse { --glyph: var(--glyph-pulse); }
.ui-glyph--institution { --glyph: var(--glyph-institution); }
.ui-glyph--layers { --glyph: var(--glyph-layers); }
.ui-glyph--server { --glyph: var(--glyph-server); }
.ui-glyph--mail { --glyph: var(--glyph-mail); }
.ui-glyph--sliders { --glyph: var(--glyph-sliders); }
.ui-glyph--logout { --glyph: var(--glyph-logout); }
.ui-glyph--video { --glyph: var(--glyph-video); }
.ui-glyph--video-off { --glyph: var(--glyph-video-off); }
.ui-glyph--mic { --glyph: var(--glyph-mic); }
.ui-glyph--mic-off { --glyph: var(--glyph-mic-off); }
.ui-glyph--hand { --glyph: var(--glyph-hand); }
.ui-glyph--chat { --glyph: var(--glyph-chat); }
.ui-glyph--screen { --glyph: var(--glyph-screen); }
.ui-glyph--lock { --glyph: var(--glyph-lock); }
.ui-glyph--unlock { --glyph: var(--glyph-unlock); }
.ui-glyph--spotlight { --glyph: var(--glyph-spotlight); }
.ui-glyph--megaphone { --glyph: var(--glyph-megaphone); }

/* ==========================================================================
   6. Mise en page : coquille, barre latérale, barre du haut, barre d'onglets
   ========================================================================== */

/* Sous 64rem la coquille reste un simple bloc : la barre du haut, collante, suit toute la page. */
.ui-shell {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
}

.ui-main {
  display: block;
  min-width: 0;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
}

.ui-main:focus {
  outline: none;
}

.ui-page {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
}

.ui-page--narrow { --page-width: 48rem; }
.ui-page--full { --page-width: none; }

/* Barre du haut (téléphone et tablette) */
.ui-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  /* hauteur exacte (encoche comprise) : les en-têtes de tableau collent juste dessous */
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
  padding: 0 var(--space-xs) 0 var(--space-md);
  padding-top: env(safe-area-inset-top);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-line);
}

/* Sous 64rem, la barre du haut couvre le haut de la page : les en-têtes de tableau
   collants se placent sous elle. Dans un cadre qui défile (tableau --scroll, panneau,
   dialogue), ils collent en haut du cadre. */
@media (max-width: 63.999rem) {
  :root:has(.ui-shell > .ui-topbar) {
    --table-sticky-top: calc(var(--topbar-height) + env(safe-area-inset-top));
  }
}

.ui-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
  min-height: var(--control-height-sm);
  margin-inline-end: auto;
  color: var(--color-text);
  text-decoration: none;
}

.ui-topbar__brand img {
  inline-size: 1.75rem;
  block-size: auto;
}

.ui-topbar__name {
  font-family: var(--font-titling);
  font-size: 0.9375rem;
  letter-spacing: var(--tracking-titling);
  text-transform: uppercase;
  white-space: nowrap;
}

/* Barre latérale (ordinateur) ; tiroir à gauche sous 64rem pour l'administration */
.ui-sidebar {
  position: fixed;
  z-index: var(--z-drawer);
  inset-block: 0;
  inset-inline-start: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  inline-size: min(20rem, 86vw);
  padding: var(--space-lg) var(--space-md) var(--space-md);
  padding-top: max(var(--space-lg), env(safe-area-inset-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-bg-sunken);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--duration-slow) var(--ease-out-expo), visibility 0s linear var(--duration-slow);
}

.ui-sidebar[data-open="true"] {
  transform: none;
  visibility: visible;
  transition: transform var(--duration-slow) var(--ease-out-expo), visibility 0s;
}

.ui-scrim {
  position: fixed;
  z-index: calc(var(--z-drawer) - 1);
  inset: 0;
  border: 0;
  padding: 0;
  background: var(--color-scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-base) var(--ease-out), visibility 0s linear var(--duration-base);
}

.ui-scrim[data-open="true"] {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--duration-base) var(--ease-out), visibility 0s;
}

/* Fermer le tiroir : visible seulement quand la barre latérale est un tiroir */
.ui-sidebar__close {
  position: absolute;
  top: max(var(--space-sm), env(safe-area-inset-top));
  right: var(--space-sm);
}

.ui-sidebar__brand {
  display: block;
  padding: var(--space-2xs) var(--space-sm) var(--space-xs);
  text-decoration: none;
}

.ui-sidebar__brand img {
  display: block;
  inline-size: 8.5rem;
  block-size: auto;
}

.ui-sidebar__footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-line);
}

/* Bloc « personne connectée » en pied de barre latérale */
.ui-identity {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  padding: var(--space-2xs) var(--space-sm);
}

.ui-identity__text {
  display: grid;
  min-width: 0;
  line-height: var(--leading-snug);
}

.ui-identity__name {
  overflow: hidden;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-identity__role {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Navigation (dans la barre latérale) */
.ui-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
}

.ui-nav__group {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-nav__heading {
  padding: 0 var(--space-sm) var(--space-2xs);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Lien ou bouton (« Se déconnecter ») : même rendu, styles du bouton natif remis à zéro */
.ui-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  inline-size: 100%;
  min-height: var(--control-height);
  margin: 0;
  padding: 0 var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-nav);
  font: inherit;
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  text-align: start;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.ui-nav__item .ui-glyph {
  --glyph-size: 1.25rem;
  color: var(--color-text-muted);
}

@media (hover: hover) {
  .ui-nav__item:hover {
    background: var(--color-surface-pressed);
    color: var(--color-text);
  }
}

.ui-nav__item[aria-current]:not([aria-current="false"]) {
  background: var(--color-surface);
  border-color: var(--color-line);
  box-shadow: var(--shadow-xs);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.ui-nav__item[aria-current]:not([aria-current="false"]) .ui-glyph {
  color: var(--color-accent-text);
}

/* Losange or : marque de la rubrique courante (forme, pas seulement couleur) */
.ui-nav__item[aria-current]:not([aria-current="false"])::after {
  content: "";
  flex: none;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  margin-inline-start: auto;
  background: var(--color-accent-line);
  transform: rotate(45deg);
}

.ui-nav__item[aria-current]:not([aria-current="false"]):has(.ui-count)::after {
  margin-inline-start: var(--space-2xs);
}

.ui-nav__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-nav__item .ui-count {
  margin-inline-start: auto;
}

/* Barre d'onglets en bas (téléphone, étudiants et enseignants) */
.ui-tabbar {
  position: fixed;
  z-index: var(--z-nav);
  inset-inline: 0;
  bottom: 0;
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-line);
  box-shadow: 0 -1px 0 var(--color-line), var(--shadow-up);
}

.ui-tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-height);
  padding: var(--space-2xs);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.ui-tabbar__item .ui-glyph {
  --glyph-size: 1.5rem;
}

.ui-tabbar__item[aria-current]:not([aria-current="false"]) {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.ui-tabbar__item[aria-current]:not([aria-current="false"]) .ui-glyph {
  color: var(--color-accent-text);
}

.ui-tabbar__item[aria-current]:not([aria-current="false"])::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 28%;
  block-size: 2px;
  background: var(--color-accent-line);
}

.ui-tabbar__item .ui-count {
  position: absolute;
  top: var(--space-2xs);
  left: calc(50% + 0.375rem);
}

.ui-tabbar__item:focus-visible {
  outline-offset: -4px;
}

/* La barre d'onglets réserve sa place en bas de page, et décale les toasts */
.ui-shell--tabbar .ui-main {
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-2xl));
}

@media (max-width: 63.999rem) {
  :root:has(.ui-shell--tabbar) {
    --ui-bottom-inset: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  }

  /* Étudiants et enseignants : pas de tiroir, la barre d'onglets suffit */
  .ui-shell--tabbar .ui-sidebar,
  .ui-shell--tabbar .ui-scrim,
  .ui-shell--tabbar .ui-topbar__menu {
    display: none;
  }
}

@media (min-width: 40rem) {
  .ui-main {
    padding: var(--space-xl) var(--space-xl) var(--space-3xl);
  }
}

@media (min-width: 64rem) {
  .ui-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-areas: "sidebar main";
  }

  .ui-main {
    grid-area: main;
  }

  .ui-topbar,
  .ui-tabbar,
  .ui-scrim,
  .ui-sidebar .ui-sidebar__close {
    display: none;
  }

  .ui-sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    z-index: auto;
    inline-size: auto;
    height: 100vh;
    height: 100dvh;
    box-shadow: none;
    transform: none;
    visibility: visible;
    transition: none;
  }

  .ui-shell--tabbar .ui-main {
    padding-bottom: var(--space-3xl);
  }

  .ui-main {
    padding: var(--space-xl) var(--space-2xl) var(--space-3xl);
  }
}

/* En-tête de page avec fil d'Ariane */
.ui-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-line);
}

.ui-page-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md) var(--space-lg);
}

.ui-page-header__titles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
  min-width: 0;
  max-width: var(--measure);
}

.ui-page-title {
  font-family: var(--font-titling);
  font-size: var(--text-xl);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-titling);
  text-transform: uppercase;
  color: var(--color-text);
}

.ui-page-header__lede {
  color: var(--color-text-muted);
}

.ui-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.ui-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.ui-breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
}

.ui-breadcrumb li + li::before {
  content: "";
  inline-size: 0.875rem;
  block-size: 0.875rem;
  background-color: var(--color-text-muted);
  -webkit-mask: var(--glyph-chevron-right) center / contain no-repeat;
  mask: var(--glyph-chevron-right) center / contain no-repeat;
}

.ui-breadcrumb a {
  position: relative;
  color: var(--color-text-muted);
  text-decoration-color: transparent;
}

/* Zone de contact de 44 px de haut au doigt, sans agrandir le dessin du lien */
.ui-breadcrumb a::after {
  content: "";
  position: absolute;
  inset: calc(50% - var(--control-height-sm) / 2) calc(-1 * var(--space-2xs));
}

@media (hover: hover) {
  .ui-breadcrumb a:hover {
    color: var(--color-text);
    text-decoration-color: currentColor;
  }
}

.ui-breadcrumb [aria-current="page"] {
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

/* Sections d'une page */
.ui-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-md);
}

.ui-section + .ui-section {
  margin-top: var(--space-2xl);
}

.ui-section__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-xs) var(--space-md);
}

.ui-section__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.ui-section__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.ui-section__description {
  grid-column: 1 / -1;
  max-width: var(--measure);
  color: var(--color-text-muted);
}

/* Primitives de disposition */
.ui-stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-md));
}

.ui-stack--xs { --stack-gap: var(--space-xs); }
.ui-stack--sm { --stack-gap: var(--space-sm); }
.ui-stack--lg { --stack-gap: var(--space-lg); }
.ui-stack--xl { --stack-gap: var(--space-xl); }
.ui-stack--2xl { --stack-gap: var(--space-2xl); }

.ui-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-sm));
}

.ui-cluster--between { justify-content: space-between; }
.ui-cluster--end { justify-content: flex-end; }
.ui-cluster--start { align-items: flex-start; }

.ui-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, 16rem)), 1fr));
  gap: var(--grid-gap, var(--space-lg));
}

.ui-split {
  display: grid;
  gap: var(--space-xl);
}

@media (min-width: 64rem) {
  .ui-split {
    grid-template-columns: minmax(0, 1fr) var(--split-aside, 20rem);
    align-items: start;
  }
}

/* Surfaces : à utiliser avec retenue (pas de surface dans une surface) */
.ui-surface {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.ui-surface--flush { padding: 0; }

.ui-surface--sunken {
  background: var(--color-bg-sunken);
  border-color: transparent;
}

/* Le « moment » : double filet de l'écusson (encre puis or), une fois par écran au plus.
   Jetons sémantiques : dans la portée nuit, le premier filet passe à l'ivoire. */
.ui-surface--moment {
  margin: 4px;
  border: 2px solid var(--color-text);
  box-shadow: 0 0 0 3px var(--color-bg), 0 0 0 4px var(--color-accent);
}

/* Barre d'outils au-dessus d'un tableau : recherche, filtres, actions */
.ui-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm) var(--space-md);
}

.ui-toolbar > .ui-field {
  flex: 1 1 9rem;
  max-width: 16rem;
}

.ui-toolbar__search {
  flex: 1 1 16rem;
}

.ui-toolbar__end {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-inline-start: auto;
}

@media (max-width: 39.999rem) {
  .ui-toolbar > .ui-field {
    max-width: none;
  }

  .ui-toolbar__end {
    margin-inline-start: 0;
  }
}

/* Écran de connexion */
.ui-auth {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: var(--space-xl) var(--space-md);
}

.ui-auth__card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  inline-size: min(26rem, 100%);
}

.ui-auth__logo {
  inline-size: 10rem;
  block-size: auto;
  margin-inline: auto;
}

/* ==========================================================================
   7. Boutons
   Un seul bouton principal (ui-button--primary) par zone. Sans variante,
   un ui-button est un bouton secondaire.
   ========================================================================== */

.ui-button {
  --button-bg: var(--color-surface);
  --button-bg-hover: var(--color-surface-hover);
  --button-bg-active: var(--color-surface-pressed);
  --button-fg: var(--color-text);
  --button-border: var(--color-control-border);
  --button-border-hover: var(--color-control-border-hover);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: var(--control-height);
  margin: 0;
  padding: 0 var(--space-md);
  border: 1px solid var(--button-border);
  border-radius: var(--radius-sm);
  background: var(--button-bg);
  color: var(--button-fg);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  letter-spacing: 0.005em;
  text-align: center;
  text-decoration: none;
  text-wrap: balance;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-instant) var(--ease-out);
}

@media (hover: hover) {
  .ui-button:hover {
    background: var(--button-bg-hover);
    border-color: var(--button-border-hover);
  }
}

.ui-button:active {
  background: var(--button-bg-active);
  transform: translateY(1px);
}

.ui-button .ui-glyph {
  --glyph-size: 1.25rem;
}

.ui-button--primary {
  --button-bg: var(--color-accent);
  --button-bg-hover: var(--color-accent-hover);
  --button-bg-active: var(--color-accent-hover);
  --button-fg: var(--color-on-accent);
  --button-border: var(--color-accent-line);
  --button-border-hover: var(--gold-700);
}

.ui-button--secondary {
  /* valeurs par défaut : nommée pour les écrans qui veulent l'écrire explicitement */
}

.ui-button--quiet {
  --button-bg: transparent;
  --button-bg-hover: var(--color-surface-hover);
  --button-fg: var(--color-text);
  --button-border: transparent;
  --button-border-hover: transparent;
}

.ui-button--danger {
  --button-bg: var(--color-critique-fill);
  --button-bg-hover: var(--color-critique-fill-hover);
  --button-bg-active: var(--color-critique-fill-hover);
  --button-fg: var(--paper-0);
  --button-border: var(--color-critique-fill-hover);
  --button-border-hover: var(--color-critique-fill-hover);
}

.ui-button--danger.ui-button--quiet {
  --button-bg: transparent;
  --button-bg-hover: var(--color-critique-tint);
  --button-bg-active: var(--color-critique-tint);
  --button-fg: var(--color-critique-text);
  --button-border: transparent;
  --button-border-hover: transparent;
}

.ui-button--small {
  min-height: var(--control-height-sm);
  padding: 0 var(--space-sm);
  font-size: var(--text-sm);
}

.ui-button--large {
  min-height: 3.25rem;
  padding: 0 var(--space-lg);
  font-size: var(--text-base);
}

.ui-button--icon {
  inline-size: var(--control-height);
  padding: 0;
}

.ui-button--icon.ui-button--small {
  inline-size: var(--control-height-sm);
}

.ui-button--block {
  display: flex;
  inline-size: 100%;
}

/* Pastille de nombre posée sur un bouton icône (la cloche). Le nombre est dans l'aria-label
   du bouton : la pastille est aria-hidden. */
.ui-button--icon > .ui-count {
  position: absolute;
  top: 0.125rem;
  inset-inline-end: 0.125rem;
  box-shadow: 0 0 0 2px var(--color-bg);
  pointer-events: none;
}

/* Bouton bascule (micro, caméra, main levée, verrou de la salle) : aria-pressed, libellé
   stable qui nomme la fonction (« Micro »), encre pleine quand la fonction est active. */
.ui-button[aria-pressed="true"] {
  --button-bg: var(--color-ink-fill);
  --button-bg-hover: var(--color-ink-fill-hover);
  --button-bg-active: var(--color-ink-fill-hover);
  --button-fg: var(--color-text-inverse);
  --button-border: var(--color-ink-fill);
  --button-border-hover: var(--color-ink-fill-hover);
}

/* Pictogramme barré quand la fonction est coupée : rien à changer dans le balisage */
.ui-button[aria-pressed="false"] > .ui-glyph--mic { --glyph: var(--glyph-mic-off); }
.ui-button[aria-pressed="false"] > .ui-glyph--video { --glyph: var(--glyph-video-off); }

.ui-button:disabled,
.ui-button[aria-disabled="true"] {
  --button-bg: var(--color-surface-pressed);
  --button-bg-hover: var(--color-surface-pressed);
  --button-fg: var(--color-text-disabled);
  --button-border: var(--color-line-strong);
  --button-border-hover: var(--color-line-strong);
  cursor: not-allowed;
  transform: none;
}

.ui-button--quiet:disabled,
.ui-button--quiet[aria-disabled="true"] {
  --button-bg: transparent;
  --button-border: transparent;
}

/* En cours : aria-busy="true" ET aria-disabled="true", jamais l'attribut disabled
   (un bouton désactivé perd le focus clavier, qui retombe sur <body>). Le script ignore
   les clics et l'envoi tant que aria-busy vaut "true" (DESIGN_SYSTEM.md, 5.4).
   Le bouton garde ses couleurs, survol compris ; un indicateur tourne devant le libellé. */
.ui-button[aria-busy="true"] {
  --button-bg: var(--color-surface-hover);
  --button-bg-hover: var(--color-surface-hover);
  --button-bg-active: var(--color-surface-hover);
  --button-fg: var(--color-text);
  --button-border: var(--color-control-border);
  --button-border-hover: var(--color-control-border);
  cursor: progress;
  transform: none;
}

.ui-button--quiet[aria-busy="true"] {
  --button-bg: transparent;
  --button-bg-hover: transparent;
  --button-bg-active: transparent;
  --button-border: transparent;
  --button-border-hover: transparent;
}

.ui-button--primary[aria-busy="true"] {
  --button-bg: var(--color-accent);
  --button-bg-hover: var(--color-accent);
  --button-bg-active: var(--color-accent);
  --button-fg: var(--color-on-accent);
  --button-border: var(--color-accent-line);
  --button-border-hover: var(--color-accent-line);
}

.ui-button--danger[aria-busy="true"] {
  --button-bg: var(--color-critique-fill);
  --button-bg-hover: var(--color-critique-fill);
  --button-bg-active: var(--color-critique-fill);
  --button-fg: var(--paper-0);
  --button-border: var(--color-critique-fill-hover);
  --button-border-hover: var(--color-critique-fill-hover);
}

.ui-button--danger.ui-button--quiet[aria-busy="true"] {
  --button-bg: transparent;
  --button-bg-hover: transparent;
  --button-bg-active: transparent;
  --button-fg: var(--color-critique-text);
  --button-border: transparent;
  --button-border-hover: transparent;
}

.ui-button[aria-busy="true"]::before {
  content: "";
  flex: none;
  inline-size: 1em;
  block-size: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ui-spin 0.8s linear infinite;
}

.ui-button[aria-busy="true"] > .ui-glyph {
  display: none;
}

/* Groupes de boutons. Écrire le secondaire d'abord, le principal en dernier. */
.ui-button-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.ui-button-group--end {
  justify-content: flex-end;
}

/* Sur téléphone : boutons pleine largeur, le principal en haut */
@media (max-width: 39.999rem) {
  .ui-button-group--stack {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .ui-button-group--stack > .ui-button {
    inline-size: 100%;
  }
}

/* Boutons accolés (barre d'outils, précédent / aujourd'hui / suivant) */
.ui-button-group--joined {
  flex-wrap: nowrap;
  gap: 0;
}

.ui-button-group--joined > .ui-button {
  border-radius: 0;
}

.ui-button-group--joined > .ui-button + .ui-button {
  margin-inline-start: -1px;
}

.ui-button-group--joined > .ui-button:first-child {
  border-start-start-radius: var(--radius-sm);
  border-end-start-radius: var(--radius-sm);
}

.ui-button-group--joined > .ui-button:last-child {
  border-start-end-radius: var(--radius-sm);
  border-end-end-radius: var(--radius-sm);
}

.ui-button-group--joined > .ui-button:focus-visible {
  z-index: var(--z-raised);
}

@media (hover: hover) {
  .ui-button-group--joined > .ui-button:hover {
    z-index: var(--z-raised);
  }
}

/* ==========================================================================
   8. Formulaires : champs, libellés, aides, erreurs
   ========================================================================== */

.ui-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
}

.ui-form__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: var(--space-lg) var(--space-md);
}

.ui-form__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.ui-fieldset {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-md);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ui-fieldset > legend {
  padding: 0;
  margin-bottom: var(--space-sm);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.ui-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
  min-width: 0;
  align-content: start;
}

.ui-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--color-text);
}

.ui-label__optional {
  margin-inline-start: var(--space-2xs);
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
}

.ui-hint {
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
}

.ui-field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  color: var(--color-critique-text);
}

.ui-field__error::before {
  content: "";
  flex: none;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  background-color: var(--color-critique-icon);
  -webkit-mask: var(--glyph-critique) center / contain no-repeat;
  mask: var(--glyph-critique) center / contain no-repeat;
}

.ui-field__error:empty {
  display: none;
}

.ui-input,
.ui-select,
.ui-textarea {
  display: block;
  inline-size: 100%;
  min-height: var(--control-height);
  margin: 0;
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-base); /* 16 px : pas de zoom automatique sur iPhone */
  line-height: var(--leading-snug);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .ui-input:hover,
  .ui-select:hover,
  .ui-textarea:hover {
    border-color: var(--color-control-border-hover);
  }
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus {
  border-color: var(--color-focus);
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

.ui-input::placeholder,
.ui-textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.ui-input[aria-invalid="true"],
.ui-select[aria-invalid="true"],
.ui-textarea[aria-invalid="true"] {
  border-color: var(--color-critique-icon);
  box-shadow: inset 0 0 0 1px var(--color-critique-icon);
}

.ui-input:disabled,
.ui-select:disabled,
.ui-textarea:disabled {
  border-color: var(--color-line-strong);
  background-color: var(--color-surface-pressed);
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

/* Lecture seule : focalisable et sélectionnable, donc un bord à 3:1, mais en tirets
   sur fond enfoncé pour dire qu'on ne peut pas le modifier. */
.ui-input[readonly],
.ui-textarea[readonly] {
  background-color: var(--color-bg-sunken);
  border-style: dashed;
  border-color: var(--color-control-border);
}

.ui-textarea {
  min-height: 6.5rem;
  padding-block: var(--space-xs);
  resize: vertical;
}

.ui-select {
  padding-inline-end: 2.5rem;
  background-image: var(--select-chevron);
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  text-overflow: ellipsis;
}

.ui-select[multiple] {
  padding: var(--space-2xs);
  background-image: none;
}

/* Date et heure natives : aligner la valeur, garder le sélecteur du système */
.ui-input[type="date"],
.ui-input[type="time"],
.ui-input[type="datetime-local"],
.ui-input[type="month"] {
  font-variant-numeric: tabular-nums;
}

.ui-input::-webkit-date-and-time-value {
  min-height: 1.3em;
  text-align: start;
}

.ui-input::-webkit-calendar-picker-indicator {
  opacity: 0.75;
  cursor: pointer;
}

/* Champ « choisir ou taper » (<input class="ui-input" list="…"> + <datalist>) : même
   chevron qu'une liste ; l'indicateur natif reste cliquable mais transparent. */
.ui-input[list] {
  padding-inline-end: 2.5rem;
  background-image: var(--select-chevron);
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
}

.ui-input[list]::-webkit-calendar-picker-indicator {
  opacity: 0;
}

.ui-input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.ui-input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* Champ de recherche avec loupe */
.ui-search {
  position: relative;
  display: block;
}

.ui-search > .ui-glyph {
  position: absolute;
  top: 50%;
  left: var(--space-sm);
  --glyph-size: 1.125rem;
  color: var(--color-text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.ui-search > .ui-input {
  padding-inline-start: 2.375rem;
}

/* Champ avec unité (TND, minutes) */
.ui-input-group {
  display: flex;
  align-items: stretch;
}

.ui-input-group > .ui-input {
  min-width: 0;
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

.ui-input-group__addon {
  display: inline-flex;
  align-items: center;
  margin-inline-start: -1px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-control-border);
  border-start-end-radius: var(--radius-sm);
  border-end-end-radius: var(--radius-sm);
  background: var(--color-bg-sunken);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

/* Cases à cocher et boutons radio */
.ui-check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-sm);
  min-height: var(--control-height-sm);
  padding-block: calc((var(--control-height-sm) - 1.5rem) / 2);
  line-height: var(--leading-normal);
}

.ui-check > input {
  display: inline-grid;
  place-content: center;
  flex: none;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin: 0.125rem 0 0;
  border: 1.5px solid var(--color-control-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.ui-check > input[type="radio"] {
  border-radius: 50%;
}

@media (hover: hover) {
  .ui-check > input:hover {
    border-color: var(--color-control-border-hover);
  }
}

.ui-check > input:checked,
.ui-check > input:indeterminate {
  border-color: var(--color-ink-fill);
  background: var(--color-ink-fill);
}

.ui-check > input[type="checkbox"]::before {
  content: "";
  inline-size: 0.9375rem;
  block-size: 0.9375rem;
  background-color: var(--color-text-inverse);
  -webkit-mask: var(--glyph-check) center / contain no-repeat;
  mask: var(--glyph-check) center / contain no-repeat;
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
}

.ui-check > input[type="checkbox"]:checked::before {
  transform: scale(1);
}

.ui-check > input[type="checkbox"]:indeterminate::before {
  -webkit-mask-image: var(--glyph-minus);
  mask-image: var(--glyph-minus);
  transform: scale(1);
}

.ui-check > input[type="radio"]:checked {
  box-shadow: inset 0 0 0 0.25rem var(--color-surface);
}

.ui-check > input:disabled {
  border-color: var(--color-line-strong);
  background: var(--color-surface-pressed);
  cursor: not-allowed;
}

.ui-check > input:disabled + * {
  color: var(--color-text-disabled);
}

.ui-check__text {
  display: grid;
}

.ui-check__hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Interrupteur : <input type="checkbox" role="switch"> */
.ui-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--control-height-sm);
}

.ui-switch > input {
  position: relative;
  flex: none;
  inline-size: 2.5rem;
  block-size: 1.5rem;
  margin: 0;
  border: 1.5px solid var(--color-control-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-pressed);
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}

.ui-switch > input::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  inline-size: 1.0625rem;
  block-size: 1.0625rem;
  border-radius: 50%;
  background: var(--color-switch-thumb);
  transform: translateY(-50%);
  transition: transform var(--duration-base) var(--ease-out), background-color var(--duration-base) var(--ease-out);
}

.ui-switch > input:checked {
  border-color: var(--color-ink-fill);
  background: var(--color-ink-fill);
}

.ui-switch > input:checked::before {
  background: var(--color-text-inverse);
  transform: translate(1rem, -50%);
}

.ui-switch > input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-switch__label {
  line-height: var(--leading-snug);
}

/* Bandeau d'erreurs en tête de formulaire : voir ui-banner--critique et ui-banner__list */

/* ==========================================================================
   9. Puces : sélection multiple (cases déguisées) et jetons retirables
   ========================================================================== */

.ui-chips {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ui-chips > legend {
  padding: 0;
  margin-bottom: var(--space-xs);
}

.ui-chips__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.ui-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: var(--control-height-sm);
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  user-select: none;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.ui-chip > input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

/* Coche de la puce choisie : la place apparaît d'un coup, seule la coche s'anime
   (transform, jamais une propriété de mise en page) */
.ui-chip::before {
  content: "";
  flex: none;
  inline-size: 0;
  block-size: 1rem;
  margin-inline-end: calc(-1 * var(--space-2xs));
  background-color: currentColor;
  -webkit-mask: var(--glyph-check) center / contain no-repeat;
  mask: var(--glyph-check) center / contain no-repeat;
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .ui-chip:hover {
    background: var(--color-surface-hover);
  }
}

.ui-chip:has(> input:checked) {
  border-color: var(--color-ink-fill);
  background: var(--color-ink-fill);
  color: var(--color-text-inverse);
}

.ui-chip:has(> input:checked)::before {
  inline-size: 1rem;
  margin-inline-end: 0;
  transform: none;
}

.ui-chip:has(> input:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.ui-chip:has(> input:disabled) {
  border-color: var(--color-line-strong);
  color: var(--color-text-disabled);
}

.ui-chip:has(> input:disabled) > input {
  cursor: not-allowed;
}

.ui-chip__meta {
  font-weight: var(--weight-regular);
  opacity: 0.8;
}

/* Jeton retirable (choix déjà faits, par exemple les classes d'un cours) */
.ui-token {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 2rem;
  padding-inline: var(--space-sm) var(--space-2xs);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-full);
  background: var(--color-bg-sunken);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.ui-token__remove {
  position: relative;
  display: inline-grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
}

.ui-token__remove::after {
  content: "";
  position: absolute;
  inset: -0.625rem; /* cible tactile de 44 px */
}

@media (hover: hover) {
  .ui-token__remove:hover {
    background: var(--color-surface-pressed);
    color: var(--color-text);
  }
}

/* ==========================================================================
   10. Tableaux de données
   ========================================================================== */

.ui-table-wrap {
  container: ui-table / inline-size;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
}

/* Tableau très large ou très long : défilement dans son cadre (en-tête collant dedans) */
.ui-table-wrap--scroll {
  --table-sticky-top: 0px;
  max-height: var(--table-max-height, 70vh);
  overflow: auto;
  overscroll-behavior: contain;
}

.ui-table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums lining-nums;
}

.ui-table caption {
  padding: var(--space-md) var(--space-md) var(--space-xs);
  font-weight: var(--weight-semibold);
  text-align: start;
}

.ui-table th,
.ui-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-line);
  text-align: start;
  vertical-align: middle;
}

/* En-tête : casse normale, 14 px (les petites capitales restent aux étiquettes et aux badges) */
.ui-table thead th {
  position: sticky;
  top: var(--table-sticky-top, 0px);
  z-index: var(--z-raised);
  padding-block: var(--space-xs);
  background: var(--color-bg-sunken);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  white-space: nowrap;
}

.ui-table thead th:first-child { border-start-start-radius: calc(var(--radius-md) - 1px); }
.ui-table thead th:last-child { border-start-end-radius: calc(var(--radius-md) - 1px); }

.ui-table tbody tr:last-child > * {
  border-bottom: 0;
}

.ui-table tbody th {
  font-weight: var(--weight-semibold);
}

.ui-table__num {
  text-align: end !important;
  white-space: nowrap;
}

.ui-table__sub {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.ui-table__actions {
  inline-size: 1%;
  white-space: nowrap;
  text-align: end !important;
}

.ui-table--compact th,
.ui-table--compact td {
  padding: var(--space-xs) var(--space-sm);
}

/* Tri : <th aria-sort="ascending|descending|none"><button class="ui-sort">Nom</button></th> */
.ui-sort {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 1.75rem;
  margin: 0 calc(-1 * var(--space-2xs));
  padding: 0 var(--space-2xs);
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

/* Zone de contact : 44 px au doigt (32 px à la souris), sans grandir l'en-tête */
.ui-sort::before {
  content: "";
  position: absolute;
  inset: calc(50% - var(--control-height-sm) / 2) calc(-1 * var(--space-2xs));
}

/* Double flèche au repos (seul indice qu'une colonne se trie) : pleine couleur, 3:1 au moins */
.ui-sort::after {
  content: "";
  inline-size: 0.875rem;
  block-size: 0.875rem;
  background-color: currentColor;
  -webkit-mask: var(--glyph-sort) center / contain no-repeat;
  mask: var(--glyph-sort) center / contain no-repeat;
}

@media (hover: hover) {
  .ui-sort:hover {
    color: var(--color-text);
  }
}

th[aria-sort="ascending"],
th[aria-sort="descending"] {
  color: var(--color-text) !important;
}

th[aria-sort="ascending"] .ui-sort::after {
  -webkit-mask-image: var(--glyph-arrow-up);
  mask-image: var(--glyph-arrow-up);
}

th[aria-sort="descending"] .ui-sort::after {
  -webkit-mask-image: var(--glyph-arrow-down);
  mask-image: var(--glyph-arrow-down);
}

/* Ligne cliquable : le premier bouton de la ligne (ui-table__action) porte l'action ;
   un écouteur délégué rend toute la ligne cliquable (voir DESIGN_SYSTEM.md). */
.ui-table__row-link {
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.ui-table__row-link:has(.ui-table__action:focus-visible) {
  background: var(--color-surface-hover);
}

@media (hover: hover) {
  .ui-table__row-link:hover {
    background: var(--color-surface-hover);
  }
}

.ui-table tr[aria-selected="true"] {
  background: var(--color-surface-selected);
}

.ui-table__action {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-weight: var(--weight-semibold);
  text-align: start;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.22em;
  cursor: pointer;
}

@media (hover: hover) {
  .ui-table__row-link:hover .ui-table__action,
  .ui-table__action:hover {
    text-decoration-color: var(--color-accent-line);
  }
}

/* Empilement sur téléphone (selon la largeur du cadre, pas de l'écran).
   Les en-têtes sont masqués (chaque cellule affiche son data-label), sauf ceux qu'on peut
   trier (th[aria-sort]) : l'en-tête devient une barre « Trier par » visible. Rien n'est
   retiré, et aucun bouton focalisable n'est caché. */
@container ui-table (max-width: 40rem) {
  .ui-table--stack thead,
  .ui-table--stack thead th:not([aria-sort]) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .ui-table--stack thead:has(th[aria-sort]) {
    position: static;
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }

  .ui-table--stack thead:has(th[aria-sort]) tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-md);
    padding: var(--space-2xs) var(--space-md);
    border-bottom: 1px solid var(--color-line);
    border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0;
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .ui-table--stack thead:has(th[aria-sort]) tr::before {
    content: "Trier par";
    content: "Trier par" / "";
  }

  .ui-table--stack thead th[aria-sort] {
    position: static;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .ui-table--stack thead th[aria-sort] .ui-sort {
    min-height: var(--control-height-sm);
  }

  .ui-table--stack,
  .ui-table--stack tbody,
  .ui-table--stack tr {
    display: block;
  }

  .ui-table--stack tr {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-line);
  }

  .ui-table--stack tbody tr:last-child {
    border-bottom: 0;
  }

  .ui-table--stack td,
  .ui-table--stack tbody th {
    display: grid;
    grid-template-columns: minmax(6.5rem, 36%) minmax(0, 1fr);
    justify-items: start;
    gap: var(--space-sm);
    padding: var(--space-2xs) 0;
    border: 0;
    text-align: start !important;
  }

  .ui-table--stack td::before,
  .ui-table--stack tbody th::before {
    content: attr(data-label);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
  }

  .ui-table--stack td:not([data-label]),
  .ui-table--stack td[data-label=""],
  .ui-table--stack tbody th:not([data-label]) {
    display: block;
    padding-bottom: var(--space-2xs);
    font-size: var(--text-base);
  }

  .ui-table--stack td:not([data-label])::before,
  .ui-table--stack td[data-label=""]::before,
  .ui-table--stack tbody th:not([data-label])::before {
    content: none;
  }

  .ui-table--stack .ui-table__actions {
    display: flex;
    inline-size: auto;
    justify-content: flex-start;
    padding-top: var(--space-xs);
  }

  .ui-table--stack .ui-table__actions::before {
    content: none;
  }
}

/* ==========================================================================
   11. Onglets et bascule segmentée
   ========================================================================== */

.ui-tablist {
  display: flex;
  gap: var(--space-lg);
  overflow-x: auto;
  border-bottom: 1px solid var(--color-line);
  scrollbar-width: none;
}

.ui-tablist::-webkit-scrollbar {
  display: none;
}

/* Un libellé long passe sur deux lignes plutôt que d'être coupé hors du cadre ;
   le défilement horizontal ne sert qu'en dernier recours (beaucoup d'onglets). */
.ui-tab {
  position: relative;
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: var(--space-xs);
  min-inline-size: min-content;
  min-height: var(--control-height);
  margin: 0;
  padding: 0 var(--space-2xs);
  border: 0;
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-align: start;
  text-wrap: balance;
  transition: color var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .ui-tab:hover {
    color: var(--color-text);
  }
}

@media (max-width: 39.999rem) {
  .ui-tablist {
    gap: var(--space-md);
  }
}

.ui-tab[aria-selected="true"] {
  color: var(--color-text);
}

.ui-tab::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  block-size: 2px;
  background: var(--color-accent-line);
  transform: scaleX(0);
  transition: transform var(--duration-base) var(--ease-out);
}

.ui-tab[aria-selected="true"]::after {
  transform: none;
}

.ui-tab:focus-visible {
  outline-offset: -2px;
  border-radius: var(--radius-xs);
}

.ui-tabpanel {
  padding-top: var(--space-lg);
}

.ui-tabpanel:focus-visible {
  outline-offset: 4px;
}

/* Bascule segmentée : groupe radio (flèches du clavier natives) */
.ui-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  margin: 0;
  border: 1px solid var(--color-line-strong);
  border-radius: calc(var(--radius-sm) + 3px);
  background: var(--color-bg-sunken);
}

.ui-segmented > label {
  position: relative;
  display: flex;
}

/* Zone de contact de toute la hauteur du groupe (44 px au doigt) : le segment dessiné
   est plus petit à cause du liseré, le libellé déborde jusqu'au bord du groupe. */
.ui-segmented > label::after {
  content: "";
  position: absolute;
  inset: -4px -1px;
}

.ui-segmented input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.ui-segmented span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: calc(var(--control-height) - 8px);
  padding: 0 var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--color-text-nav);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .ui-segmented label:hover span {
    background: var(--color-surface-pressed);
    color: var(--color-text);
  }
}

.ui-segmented input:checked + span {
  background: var(--color-ink-fill);
  color: var(--color-text-inverse);
}

.ui-segmented input:focus-visible + span {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.ui-segmented--block {
  display: flex;
}

.ui-segmented--block > label {
  flex: 1;
}

.ui-segmented--block span {
  justify-content: center;
  inline-size: 100%;
}

/* ==========================================================================
   12. Panneau latéral (<dialog class="ui-panel">) : tiroir à droite sur ordinateur,
   feuille en bas d'écran sur téléphone. Ouvert par showModal() : focus piégé,
   Échap, couche supérieure. Préféré aux modales pour toute édition.
   ========================================================================== */

.ui-panel {
  --panel-width: 30rem;
  --table-sticky-top: 0px; /* un tableau du panneau colle en haut du corps qui défile */
  position: fixed;
  inset: 0 0 0 auto;
  inline-size: min(var(--panel-width), 100vw);
  max-inline-size: 100vw;
  block-size: 100vh;
  block-size: 100dvh;
  max-block-size: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.ui-panel[open] {
  display: flex;
  flex-direction: column;
  animation: ui-panel-in var(--duration-slow) var(--ease-out-expo);
}

.ui-panel--large {
  --panel-width: 48rem;
}

/* Voile : jeton --color-scrim, avec une valeur de secours écrite en clair, car les
   navigateurs d'avant 2024 ne transmettent pas les variables à ::backdrop. */
.ui-panel::backdrop {
  background: var(--color-scrim, rgb(11 20 35 / 0.42));
}

.ui-panel[open]::backdrop {
  animation: ui-fade-in var(--duration-base) var(--ease-out);
}

.ui-panel.is-closing {
  animation: ui-panel-out var(--duration-base) var(--ease-in) forwards;
}

.ui-panel.is-closing::backdrop {
  animation: ui-fade-out var(--duration-base) var(--ease-in) forwards;
}

.ui-panel__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-md) var(--space-md) var(--space-lg);
  padding-top: max(var(--space-lg), env(safe-area-inset-top));
  border-bottom: 1px solid var(--color-line);
}

.ui-panel__heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2xs);
  min-width: 0;
  flex: 1;
}

.ui-panel__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.ui-panel__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.ui-panel__close {
  flex: none;
  margin-block: calc(-1 * var(--space-2xs));
}

.ui-panel__form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}

.ui-panel__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1 1 auto;
  align-content: start;
  gap: var(--space-lg);
  min-height: 0;
  padding: var(--space-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ui-panel__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-line);
  background: var(--color-surface);
}

/* Action destructive du panneau (Archiver) : à gauche, loin du bouton principal */
.ui-panel__footer-start {
  margin-inline-end: auto;
}

@media (max-width: 39.999rem) {
  .ui-panel {
    inset: auto 0 0 0;
    inline-size: 100vw;
    block-size: auto;
    max-block-size: calc(100dvh - var(--space-lg));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .ui-panel[open] {
    animation-name: ui-sheet-in;
  }

  .ui-panel.is-closing {
    animation-name: ui-sheet-out;
  }

  .ui-panel__header {
    padding-top: var(--space-lg);
  }

  .ui-panel__footer > .ui-button {
    flex: 1 1 auto;
  }

  .ui-panel__footer-start {
    flex-basis: 100%;
    order: 2;
  }
}

/* ==========================================================================
   13. Dialogue de confirmation (<dialog class="ui-dialog" role="alertdialog">)
   Seulement pour l'irréversible, le coûteux ou le groupé. Sinon : toast avec Annuler.
   ========================================================================== */

.ui-dialog {
  --table-sticky-top: 0px;
  inline-size: min(28rem, calc(100vw - 2 * var(--space-md)));
  max-block-size: calc(100dvh - 2 * var(--space-md));
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}

.ui-dialog[open] {
  display: grid;
  animation: ui-dialog-in var(--duration-base) var(--ease-out);
}

.ui-dialog::backdrop {
  background: var(--color-scrim, rgb(11 20 35 / 0.42)); /* secours : voir .ui-panel::backdrop */
}

.ui-dialog[open]::backdrop {
  animation: ui-fade-in var(--duration-base) var(--ease-out);
}

.ui-dialog__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

.ui-dialog__title {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.ui-dialog--critique .ui-dialog__title::before,
.ui-dialog--attention .ui-dialog__title::before {
  content: "";
  flex: none;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin-top: -1px;
  background-color: var(--color-critique-icon);
  -webkit-mask: var(--glyph-critique) center / contain no-repeat;
  mask: var(--glyph-critique) center / contain no-repeat;
}

.ui-dialog--attention .ui-dialog__title::before {
  background-color: var(--color-attention-icon);
  -webkit-mask-image: var(--glyph-attention);
  mask-image: var(--glyph-attention);
}

.ui-dialog__message {
  color: var(--color-text-nav);
}

.ui-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

@media (max-width: 39.999rem) {
  .ui-dialog__actions {
    flex-direction: column-reverse;
  }

  .ui-dialog__actions > .ui-button {
    inline-size: 100%;
  }
}

/* ==========================================================================
   14. Toasts (avec action « Annuler »)
   ========================================================================== */

.ui-toaster {
  position: fixed;
  z-index: var(--z-toast);
  inset-inline: var(--space-md);
  bottom: calc(var(--ui-bottom-inset) + var(--space-md) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

@media (min-width: 40rem) {
  .ui-toaster {
    inset-inline: auto var(--space-lg);
    bottom: calc(var(--ui-bottom-inset) + var(--space-lg));
    inline-size: 25rem;
  }
}

.ui-toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: ui-toast-in var(--duration-slow) var(--ease-out-expo);
}

.ui-toast.is-leaving {
  animation: ui-toast-out var(--duration-base) var(--ease-in) forwards;
}

.ui-toast__icon {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  background-color: var(--color-info-icon);
  -webkit-mask: var(--glyph-info) center / contain no-repeat;
  mask: var(--glyph-info) center / contain no-repeat;
}

.ui-toast--succes .ui-toast__icon {
  background-color: var(--color-succes-icon);
  -webkit-mask-image: var(--glyph-succes);
  mask-image: var(--glyph-succes);
}

.ui-toast--erreur .ui-toast__icon {
  background-color: var(--color-critique-icon);
  -webkit-mask-image: var(--glyph-critique);
  mask-image: var(--glyph-critique);
}

.ui-toast__message {
  padding-block: var(--space-xs);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.ui-toast__action {
  min-height: var(--control-height-sm);
  padding: 0 var(--space-sm);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-accent-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

@media (hover: hover) {
  .ui-toast__action:hover {
    background: var(--color-surface-hover);
  }
}

.ui-toast__close {
  display: inline-grid;
  place-items: center;
  inline-size: var(--control-height-sm);
  block-size: var(--control-height-sm);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
}

@media (hover: hover) {
  .ui-toast__close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
  }
}

/* ==========================================================================
   15. Bandeaux d'état (info, succès, attention, critique) : filet complet d'un
   pixel, pictogramme de forme distincte par gravité. Le fond teinté est réservé
   à ce qui demande d'agir (attention, critique) ; info et succès restent sur la
   surface claire, le pictogramme suffit.
   ========================================================================== */

.ui-banner {
  --banner-tint: var(--color-surface);
  --banner-line: var(--color-line);
  --banner-icon: var(--color-info-icon);
  --banner-glyph: var(--glyph-info);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border: 1px solid var(--banner-line);
  border-radius: var(--radius-md);
  background: var(--banner-tint);
  color: var(--color-text);
}

.ui-banner::before {
  content: "";
  flex: none;
  inline-size: 1.375rem;
  block-size: 1.375rem;
  margin-top: 1px;
  background-color: var(--banner-icon);
  -webkit-mask: var(--banner-glyph) center / contain no-repeat;
  mask: var(--banner-glyph) center / contain no-repeat;
}

.ui-banner--succes {
  --banner-icon: var(--color-succes-icon);
  --banner-glyph: var(--glyph-succes);
}

.ui-banner--attention {
  --banner-tint: var(--color-attention-tint);
  --banner-line: var(--color-attention-line);
  --banner-icon: var(--color-attention-icon);
  --banner-glyph: var(--glyph-attention);
}

.ui-banner--critique {
  --banner-tint: var(--color-critique-tint);
  --banner-line: var(--color-critique-line);
  --banner-icon: var(--color-critique-icon);
  --banner-glyph: var(--glyph-critique);
}

.ui-banner__body {
  grid-column: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2xs);
  min-width: 0;
  color: var(--color-text-nav);
}

.ui-banner__title {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.ui-banner__list {
  margin: var(--space-2xs) 0 0;
  padding-inline-start: 1.25rem;
}

.ui-banner__list a {
  color: var(--color-text);
}

/* Les actions se placent sous le texte, alignées sur lui */
.ui-banner__actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

/* Bandeau compact, sur une ligne (état de la plateforme en tête de supervision) :
   pictogramme, texte, puis un dernier élément facultatif aligné à droite */
.ui-banner--compact {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
}

.ui-banner--compact > :nth-child(2) {
  grid-column: 3;
}

.ui-banner--compact::before {
  margin-top: 0;
}

/* Sur téléphone, l'élément de droite passe sous le texte au lieu de l'écraser. */
@media (max-width: 40rem) {
  .ui-banner--compact {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .ui-banner--compact > :nth-child(2) {
    grid-column: 2;
  }
}

/* ==========================================================================
   16. Badges, pastilles de nombre, points
   ========================================================================== */

.ui-badge {
  --badge-bg: var(--color-bg-sunken);
  --badge-line: var(--color-line-strong);
  --badge-fg: var(--color-text-nav);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 1.5rem;
  padding: 0 var(--space-xs);
  border: 1px solid var(--badge-line);
  border-radius: var(--radius-xs);
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}

.ui-badge--info { --badge-bg: var(--color-info-tint); --badge-line: var(--color-info-line); --badge-fg: var(--color-info-text); }
.ui-badge--succes { --badge-bg: var(--color-succes-tint); --badge-line: var(--color-succes-line); --badge-fg: var(--color-succes-text); }
.ui-badge--attention { --badge-bg: var(--color-attention-tint); --badge-line: var(--color-attention-line); --badge-fg: var(--color-attention-text); }
.ui-badge--critique { --badge-bg: var(--color-critique-tint); --badge-line: var(--color-critique-line); --badge-fg: var(--color-critique-text); }
.ui-badge--or { --badge-bg: var(--color-accent-tint); --badge-line: var(--color-accent-border); --badge-fg: var(--color-accent-text-strong); }

/* En direct : encre pleine, point or qui respire */
.ui-badge--direct {
  --badge-bg: var(--ink-900);
  --badge-line: var(--ink-900);
  --badge-fg: var(--paper-0);
}

.ui-badge--direct::before {
  content: "";
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--gold-400);
  animation: ui-breathe 1.8s var(--ease-in-out) infinite;
}

.ui-badge .ui-glyph {
  --glyph-size: 0.875rem;
}

/* Pastille de nombre (navigation, cloche, onglets) : ajouter le sens en texte masqué */
.ui-count {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-inline-size: 1.25rem;
  block-size: 1.25rem;
  padding: 0 0.3125rem;
  border-radius: var(--radius-full);
  background: var(--color-ink-fill);
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ui-count--critique {
  background: var(--color-critique-fill);
  color: var(--paper-0);
}

.ui-count--muted {
  background: var(--color-surface-pressed);
  color: var(--color-text-nav);
}

/* Point (non lu, en ligne) : toujours doublé d'un texte masqué */
.ui-dot {
  display: inline-block;
  flex: none;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--color-accent-line);
  vertical-align: middle;
}

.ui-dot--succes { background: var(--color-succes-icon); }
.ui-dot--critique { background: var(--color-critique-icon); }

/* Hors ligne, absent : un cercle vide (forme distincte du point plein), bord à 3:1 */
.ui-dot--muted {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--color-control-border);
}

/* ==========================================================================
   17. État vide qui enseigne
   ========================================================================== */

.ui-empty {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-lg);
  border: 1px dashed var(--color-line-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

/* Filet à losange gravé, à l'encre des filets (décoratif : pas d'or) */
.ui-empty::before {
  content: "";
  inline-size: 3rem;
  block-size: 0.75rem;
  margin-bottom: var(--space-2xs);
  background-color: var(--color-line-strong);
  -webkit-mask: var(--glyph-ornament) left center / contain no-repeat;
  mask: var(--glyph-ornament) left center / contain no-repeat;
}

.ui-empty__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.ui-empty__text {
  max-width: 60ch;
  color: var(--color-text-nav);
}

.ui-empty__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

/* Variante sans cadre, dans un tableau, un panneau ou une liste */
.ui-empty--compact {
  padding: var(--space-lg) 0;
  border: 0;
  background: none;
}

/* ==========================================================================
   18. Chargement : squelettes, indicateur
   ========================================================================== */

.ui-skeleton-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
}

.ui-skeleton {
  display: block;
  inline-size: var(--skeleton-width, 100%);
  block-size: 1rem;
  border-radius: var(--radius-xs);
  background: var(--color-surface-pressed);
  animation: ui-pulse 1.6s var(--ease-in-out) infinite;
}

.ui-skeleton--text { block-size: 0.875rem; }
.ui-skeleton--text:nth-child(3n + 2) { --skeleton-width: 86%; }
.ui-skeleton--text:nth-child(3n) { --skeleton-width: 64%; }
.ui-skeleton--title { block-size: 1.5rem; --skeleton-width: 42%; }
.ui-skeleton--row { block-size: var(--control-height); }
.ui-skeleton--block { block-size: 8rem; border-radius: var(--radius-md); }

.ui-skeleton--avatar {
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: 50%;
}

.ui-spinner {
  display: inline-block;
  flex: none;
  inline-size: 1.25em;
  block-size: 1.25em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -0.25em;
  animation: ui-spin 0.8s linear infinite;
}

.ui-loading {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  color: var(--color-text-muted);
}

/* ==========================================================================
   19. Listes de définition
   ========================================================================== */

.ui-dl {
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
}

.ui-dl__row {
  display: grid;
  gap: 2px var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-line);
}

.ui-dl__row:first-child {
  padding-top: 0;
}

.ui-dl__row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.ui-dl dt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.ui-dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@container (min-width: 28rem) {
  .ui-dl__row {
    grid-template-columns: minmax(8rem, 1fr) 2fr;
    align-items: baseline;
  }
}

/* Méta en ligne : « Lundi · 18:30 – 20:00 · B3 Gestion » */
.ui-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs) var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.ui-meta > li {
  display: block;
}

/* Le point médian termine l'élément (jamais en tête de ligne après un retour) */
.ui-meta > li:not(:last-child)::after {
  content: "·";
  content: "·" / "";
  margin-inline-start: var(--space-xs);
  color: var(--color-text-muted);
  font-weight: var(--weight-bold);
}

/* ==========================================================================
   20. Indicateurs de santé (supervision) : seuil, état écrit, forme distincte
   ========================================================================== */

.ui-health {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 0 var(--space-xl);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-health__item {
  --tone-icon: var(--color-succes-icon);
  --tone-text: var(--color-succes-text);
  --tone-glyph: var(--glyph-succes);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name state" "value value" "meter meter" "hint hint";
  gap: var(--space-2xs) var(--space-sm);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-line);
}

.ui-health__item[data-state="attention"] {
  --tone-icon: var(--color-attention-icon);
  --tone-text: var(--color-attention-text);
  --tone-glyph: var(--glyph-attention);
}

.ui-health__item[data-state="critique"] {
  --tone-icon: var(--color-critique-icon);
  --tone-text: var(--color-critique-text);
  --tone-glyph: var(--glyph-critique);
}

.ui-health__item[data-state="inconnu"] {
  --tone-icon: var(--color-text-muted);
  --tone-text: var(--color-text-muted);
  --tone-glyph: var(--glyph-inconnu);
}

.ui-health__name {
  grid-area: name;
  font-weight: var(--weight-semibold);
}

.ui-health__state {
  grid-area: state;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  color: var(--tone-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.ui-health__state::before {
  content: "";
  inline-size: 1.125rem;
  block-size: 1.125rem;
  background-color: var(--tone-icon);
  -webkit-mask: var(--tone-glyph) center / contain no-repeat;
  mask: var(--tone-glyph) center / contain no-repeat;
}

.ui-health__value {
  grid-area: value;
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-snug);
}

.ui-health__item > .ui-meter {
  grid-area: meter;
  margin-block: var(--space-2xs);
}

.ui-health__hint {
  grid-area: hint;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Jauge : style="--value: 62%" ; seuil : <span class="ui-meter__threshold" style="--at: 85%">.
   La piste porte un liseré à 3:1 : on voit où sont 0 et 100 %, de jour comme de nuit. */
.ui-meter {
  position: relative;
  display: block;
  block-size: 0.5rem;
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-pressed);
}

.ui-meter::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: clamp(0%, var(--value, 0%), 100%);
  border-radius: inherit;
  background: var(--tone-icon, var(--color-ink-fill));
}

.ui-meter__threshold {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: var(--at, 100%);
  inline-size: 2px;
  margin-left: -1px;
  background: var(--color-text);
}

/* ==========================================================================
   21. Zone de dépôt de fichier
   ========================================================================== */

.ui-dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-xs);
  padding: var(--space-xl) var(--space-lg);
  border: 1px dashed var(--color-control-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  text-align: center;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .ui-dropzone:hover {
    border-color: var(--color-control-border-hover);
    background: var(--color-surface-hover);
  }
}

.ui-dropzone:has(.ui-dropzone__input:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.ui-dropzone[data-dragover="true"] {
  border-style: solid;
  border-color: var(--color-accent-line);
  background: var(--color-accent-tint);
}

.ui-dropzone[data-state="error"] {
  border-color: var(--color-critique-icon);
  background: var(--color-critique-tint);
}

.ui-dropzone__input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.ui-dropzone__icon {
  inline-size: 2.25rem;
  block-size: 2.25rem;
  margin-bottom: var(--space-2xs);
  background-color: var(--color-text-muted);
  -webkit-mask: var(--glyph-upload) center / contain no-repeat;
  mask: var(--glyph-upload) center / contain no-repeat;
}

/* Dépôt en cours (fichier au-dessus de la zone) : l'or marque l'état actif */
.ui-dropzone[data-dragover="true"] .ui-dropzone__icon {
  background-color: var(--color-accent-text);
}

/* Erreur dans la zone (texte centré) : le pictogramme suit le texte, en ligne */
.ui-dropzone .ui-field__error {
  display: block;
  text-wrap: balance;
}

.ui-dropzone .ui-field__error::before {
  display: inline-block;
  margin-inline-end: var(--space-2xs);
  vertical-align: -0.2em;
}

.ui-dropzone__title {
  font-weight: var(--weight-semibold);
}

.ui-dropzone__browse {
  text-decoration: underline;
  text-decoration-color: var(--color-accent-line);
  text-underline-offset: 0.22em;
}

.ui-dropzone__hint {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* « ou faites-le glisser ici » : seulement avec une souris */
.ui-dropzone__drag {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .ui-dropzone__drag {
    display: inline;
  }
}

/* Fichier choisi */
.ui-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.ui-file::before {
  content: "";
  flex: none;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  background-color: var(--color-text-muted);
  -webkit-mask: var(--glyph-file) center / contain no-repeat;
  mask: var(--glyph-file) center / contain no-repeat;
}

.ui-file__name {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: var(--weight-semibold);
}

.ui-file__meta {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ==========================================================================
   22. Pagination
   ========================================================================== */

.ui-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
}

.ui-pagination__status {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.ui-pagination__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-pagination__link {
  display: inline-grid;
  place-items: center;
  min-inline-size: var(--control-height-sm);
  min-block-size: var(--control-height-sm);
  padding: 0 var(--space-xs);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

@media (hover: hover) {
  .ui-pagination__link:hover {
    background: var(--color-surface-hover);
  }
}

.ui-pagination__link[aria-current="page"] {
  border-color: var(--color-ink-fill);
  background: var(--color-ink-fill);
  color: var(--color-text-inverse);
}

.ui-pagination__link:disabled,
.ui-pagination__link[aria-disabled="true"] {
  color: var(--color-text-disabled);
  cursor: not-allowed;
  background: transparent;
}

.ui-pagination__gap {
  display: inline-grid;
  place-items: center;
  min-inline-size: 1.5rem;
  color: var(--color-text-muted);
}

/* Sur téléphone : précédent, page courante, suivant */
@media (max-width: 39.999rem) {
  .ui-pagination__page:not(:has([aria-current="page"])),
  .ui-pagination__gap {
    display: none;
  }
}

/* ==========================================================================
   23. Chronologie (historique d'une présence, journal, déroulé du jour)
   ========================================================================== */

.ui-timeline {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-timeline__item {
  --tone: var(--color-text-muted);
  position: relative;
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  gap: var(--space-sm);
  padding-bottom: var(--space-lg);
}

.ui-timeline__item:last-child {
  padding-bottom: 0;
}

/* Le fil vertical : un trait d'un pixel dessiné, pas une bordure */
.ui-timeline__item::before {
  content: "";
  position: absolute;
  top: 1.5rem;
  bottom: 0;
  left: calc(0.75rem - 0.5px);
  inline-size: 1px;
  background: var(--color-line-strong);
}

.ui-timeline__item:last-child::before {
  content: none;
}

.ui-timeline__item[data-tone="succes"] { --tone: var(--color-succes-icon); }
.ui-timeline__item[data-tone="attention"] { --tone: var(--color-attention-icon); }
.ui-timeline__item[data-tone="critique"] { --tone: var(--color-critique-icon); }
.ui-timeline__item[data-tone="info"] { --tone: var(--color-info-icon); }
.ui-timeline__item[data-tone="or"] { --tone: var(--color-accent-line); }

/* Losange gravé */
.ui-timeline__marker {
  inline-size: 0.75rem;
  block-size: 0.75rem;
  margin: 0.4375rem auto 0;
  border: 1.5px solid var(--tone);
  background: var(--color-bg);
  transform: rotate(45deg);
}

.ui-timeline__item[data-current="true"] .ui-timeline__marker {
  background: var(--tone);
}

.ui-timeline__content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  min-width: 0;
}

.ui-timeline__title {
  font-weight: var(--weight-semibold);
}

.ui-timeline__meta {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ==========================================================================
   24. Avatar à initiales
   ========================================================================== */

.ui-avatar {
  --avatar-size: 2.25rem;
  --avatar-bg: var(--avatar-1);
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: var(--avatar-size);
  block-size: var(--avatar-size);
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--ink-900);
  font-size: calc(var(--avatar-size) * 0.4);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}

.ui-avatar--sm { --avatar-size: 1.75rem; }
.ui-avatar--lg { --avatar-size: 3rem; }
.ui-avatar--xl { --avatar-size: 4.5rem; }
.ui-avatar[data-tone="2"] { --avatar-bg: var(--avatar-2); }
.ui-avatar[data-tone="3"] { --avatar-bg: var(--avatar-3); }
.ui-avatar[data-tone="4"] { --avatar-bg: var(--avatar-4); }
.ui-avatar[data-tone="5"] { --avatar-bg: var(--avatar-5); }

/* Personne connectée : anneau or */
.ui-avatar--current {
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 3.5px var(--color-accent-line);
}

/* ==========================================================================
   25. Étapes (import, préparation de la salle)
   ========================================================================== */

.ui-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-steps__item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.ui-steps__index {
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border: 1px solid var(--color-control-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-nav);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.ui-steps__item[aria-current="step"] {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.ui-steps__item[aria-current="step"] .ui-steps__index {
  border-color: var(--color-accent-line);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.ui-steps__item[data-state="done"] {
  color: var(--color-text-nav);
}

.ui-steps__item[data-state="done"] .ui-steps__index {
  border-color: var(--color-ink-fill);
  background: var(--color-ink-fill);
  color: transparent;
  font-size: 0;
}

.ui-steps__item[data-state="done"] .ui-steps__index::before {
  content: "";
  inline-size: 1rem;
  block-size: 1rem;
  background-color: var(--color-text-inverse);
  -webkit-mask: var(--glyph-check) center / contain no-repeat;
  mask: var(--glyph-check) center / contain no-repeat;
}

/* ==========================================================================
   26. Section repliable (<details class="ui-disclosure">)
   ========================================================================== */

.ui-disclosure {
  border-top: 1px solid var(--color-line);
}

.ui-disclosure > summary {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--control-height);
  font-weight: var(--weight-semibold);
  list-style: none;
}

.ui-disclosure > summary::-webkit-details-marker {
  display: none;
}

.ui-disclosure > summary::before {
  content: "";
  flex: none;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  background-color: var(--color-text-muted);
  -webkit-mask: var(--glyph-chevron-right) center / contain no-repeat;
  mask: var(--glyph-chevron-right) center / contain no-repeat;
  transition: transform var(--duration-base) var(--ease-out);
}

.ui-disclosure[open] > summary::before {
  transform: rotate(90deg);
}

.ui-disclosure > summary:focus-visible {
  outline-offset: 0;
  border-radius: var(--radius-xs);
}

.ui-disclosure__body {
  padding-bottom: var(--space-md);
}

/* ==========================================================================
   27. Menu d'actions (popover) : <div class="ui-menu" popover>
   Ancré au bouton là où le navigateur sait le faire ; feuille d'actions sur téléphone.
   ========================================================================== */

.ui-menu {
  min-inline-size: 12rem;
  margin: auto;
  padding: var(--space-2xs);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}

@supports (position-area: block-end) {
  .ui-menu {
    margin: var(--space-2xs) 0;
    position-area: block-end span-inline-start;
    position-try-fallbacks: flip-block, flip-inline;
  }
}

.ui-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  inline-size: 100%;
  min-height: var(--control-height-sm);
  padding: 0 var(--space-sm);
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: start;
  text-decoration: none;
  white-space: nowrap;
}

@media (hover: hover) {
  .ui-menu__item:hover {
    background: var(--color-surface-hover);
  }
}

.ui-menu__item:focus-visible {
  outline-offset: -2px;
}

.ui-menu__item .ui-glyph {
  --glyph-size: 1.125rem;
  color: var(--color-text-muted);
}

.ui-menu__item--danger,
.ui-menu__item--danger .ui-glyph {
  color: var(--color-critique-text);
}

@media (hover: hover) {
  .ui-menu__item--danger:hover {
    background: var(--color-critique-tint);
  }
}

.ui-menu__separator {
  margin: var(--space-2xs) 0;
  border: 0;
  border-top: 1px solid var(--color-line);
}

@media (max-width: 39.999rem) {
  .ui-menu {
    inset: auto 0 0 0;
    inline-size: 100%;
    max-inline-size: none;
    margin: 0;
    padding: var(--space-xs) var(--space-xs) max(var(--space-xs), env(safe-area-inset-bottom));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position-area: none;
  }

  .ui-menu__item {
    min-height: 3rem;
    font-size: var(--text-base);
  }
}

/* ==========================================================================
   28. Barre de progression (<progress class="ui-progress">)
   ========================================================================== */

.ui-progress {
  display: block;
  inline-size: 100%;
  block-size: 0.5rem;
  border: 1px solid var(--color-control-border); /* piste lisible à 3:1, comme la jauge */
  border-radius: var(--radius-full);
  background: var(--color-surface-pressed);
  color: var(--color-ink-fill);
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

.ui-progress::-webkit-progress-bar {
  border-radius: var(--radius-full);
  background: var(--color-surface-pressed);
}

.ui-progress::-webkit-progress-value {
  border-radius: var(--radius-full);
  background: var(--color-ink-fill);
}

.ui-progress::-moz-progress-bar {
  border-radius: var(--radius-full);
  background: var(--color-ink-fill);
}

/* ==========================================================================
   29. Portée « nuit » : scène vidéo de la salle, et toasts.
   Les composants posés dedans s'inversent d'eux-mêmes : ils n'utilisent que des
   jetons sémantiques, tous redéfinis ici (contrastes vérifiés, DESIGN_SYSTEM.md 4.3).
   ========================================================================== */

.ui-night,
.ui-toast {
  --color-bg: var(--ink-950);
  --color-bg-sunken: var(--ink-950);
  --color-surface: var(--ink-900);
  --color-surface-hover: var(--ink-800);
  --color-surface-pressed: var(--ink-700);
  --color-surface-selected: var(--ink-800);
  --color-line: var(--ink-800);
  --color-line-strong: var(--ink-700);
  --color-control-border: var(--ink-500);
  --color-control-border-hover: var(--ink-300);
  --color-switch-thumb: var(--ink-300);
  --select-chevron: var(--select-chevron-night);
  --color-text: var(--paper-1);
  --color-text-muted: var(--ink-300);
  --color-text-nav: var(--ink-200);
  --color-text-disabled: var(--ink-400);
  --color-text-inverse: var(--ink-900);
  --color-ink-fill: var(--paper-1);
  --color-ink-fill-hover: var(--paper-3);
  --color-accent-line: var(--gold-400);
  --color-accent-text: var(--gold-300);
  --color-accent-tint: var(--ink-800);
  --color-accent-soft: var(--gold-300);
  --color-accent-border: var(--gold-400);
  --color-accent-text-strong: var(--gold-300);
  --color-focus: var(--gold-300);
  --color-info-icon: var(--info-night);
  --color-info-text: var(--info-night);
  --color-info-tint: var(--ink-800);
  --color-info-line: var(--ink-700);
  --color-succes-icon: var(--succes-night);
  --color-succes-text: var(--succes-night);
  --color-succes-tint: var(--ink-800);
  --color-succes-line: var(--ink-700);
  --color-attention-icon: var(--attention-night);
  --color-attention-text: var(--attention-night);
  --color-attention-tint: var(--ink-800);
  --color-attention-line: var(--ink-700);
  --color-critique-icon: var(--critique-night);
  --color-critique-text: var(--critique-night);
  --color-critique-tint: var(--ink-800);
  --color-critique-line: var(--ink-700);
  color-scheme: dark;
  color: var(--color-text);
}

.ui-night {
  background: var(--color-bg);
}

.ui-night .ui-badge--direct {
  --badge-line: var(--gold-400);
}

.ui-night ::selection {
  background: var(--gold-300);
  color: var(--ink-950);
}

/* ==========================================================================
   30. Animations
   ========================================================================== */

@keyframes ui-spin { to { transform: rotate(1turn); } }
@keyframes ui-pulse { 50% { opacity: 0.45; } }
@keyframes ui-breathe { 50% { opacity: 0.35; } }
@keyframes ui-fade-in { from { opacity: 0; } }
@keyframes ui-fade-out { to { opacity: 0; } }
@keyframes ui-panel-in { from { transform: translateX(100%); } }
@keyframes ui-panel-out { to { transform: translateX(100%); } }
@keyframes ui-sheet-in { from { transform: translateY(100%); } }
@keyframes ui-sheet-out { to { transform: translateY(100%); } }
@keyframes ui-dialog-in { from { opacity: 0; transform: translateY(0.5rem) scale(0.98); } }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(0.75rem); } }
@keyframes ui-toast-out { to { opacity: 0; transform: translateY(0.5rem); } }

/* Mouvement réduit : plus de déplacement ; les indicateurs de chargement ralentissent sans s'arrêter */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 1ms;
    --duration-fast: 1ms;
    --duration-base: 1ms;
    --duration-slow: 1ms;
    --duration-slower: 1ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }

  .ui-spinner,
  .ui-button[aria-busy="true"]::before {
    animation-duration: 2.4s !important;
    animation-iteration-count: infinite !important;
  }

  .ui-skeleton,
  .ui-badge--direct::before {
    animation: none !important;
  }
}

/* Contraste forcé (Windows) : le système impose ses couleurs (fonds, bords, ombres
   supprimées). Tout ce qui porte un état par la couleur ou l'ombre est redessiné ici
   en couleurs système. Les !important sont voulus : ces règles doivent l'emporter sur
   les variantes (ton, état), quelle que soit leur spécificité. */
@media (forced-colors: active) {
  /* Pictogrammes et marques dessinés par masque : couleur du texte du système */
  .ui-glyph,
  .ui-ornament,
  .ui-link--arrow::after,
  .ui-breadcrumb li + li::before,
  .ui-field__error::before,
  .ui-chip::before,
  .ui-sort::after,
  .ui-banner::before,
  .ui-toast__icon,
  .ui-health__state::before,
  .ui-dropzone__icon,
  .ui-file::before,
  .ui-disclosure > summary::before,
  .ui-check > input::before,
  .ui-steps__index::before,
  .ui-empty::before,
  .ui-dialog__title::before {
    forced-color-adjust: none;
    background-color: CanvasText !important;
  }

  /* Bouton radio choisi : un disque plein (l'anneau intérieur était une ombre) */
  .ui-check > input[type="radio"]:checked::before {
    content: "";
    inline-size: 0.625rem;
    block-size: 0.625rem;
    border-radius: 50%;
  }

  /* Interrupteur : pouce visible ; allumé, piste et pouce en couleurs de sélection */
  .ui-switch > input::before {
    forced-color-adjust: none;
    background-color: CanvasText !important;
  }

  .ui-switch > input:checked {
    forced-color-adjust: none;
    border-color: Highlight;
    background-color: Highlight;
  }

  .ui-switch > input:checked::before {
    background-color: HighlightText !important;
  }

  /* Étape en cours, page courante, bouton bascule enfoncé : couleurs de sélection */
  .ui-steps__item[aria-current="step"] .ui-steps__index,
  .ui-pagination__link[aria-current="page"],
  .ui-button[aria-pressed="true"] {
    forced-color-adjust: none;
    border-color: Highlight;
    background-color: Highlight;
    color: HighlightText;
  }

  .ui-button[aria-pressed="true"] .ui-glyph {
    background-color: HighlightText !important;
  }

  /* Rubrique, onglet, segment, puce choisis : un cadre de sélection */
  .ui-nav__item[aria-current]:not([aria-current="false"]),
  .ui-tabbar__item[aria-current]:not([aria-current="false"]),
  .ui-tab[aria-selected="true"],
  .ui-segmented input:checked + span,
  .ui-chip:has(> input:checked) {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }

  /* Jauge et barre de progression : piste encadrée, remplissage en couleur de sélection */
  .ui-meter,
  .ui-progress {
    forced-color-adjust: none;
    border-color: CanvasText;
    background-color: Canvas;
  }

  .ui-meter::before {
    background-color: Highlight;
  }

  .ui-meter__threshold {
    background-color: CanvasText;
  }

  .ui-progress::-webkit-progress-bar {
    background-color: Canvas;
  }

  .ui-progress::-webkit-progress-value {
    background-color: Highlight;
  }

  .ui-progress::-moz-progress-bar {
    background-color: Highlight;
  }

  /* Points et pastilles : forme visible (le fond serait effacé) */
  .ui-dot {
    forced-color-adjust: none;
    background-color: CanvasText;
  }

  .ui-dot--muted {
    background-color: Canvas;
    box-shadow: inset 0 0 0 1.5px CanvasText;
  }

  .ui-count {
    outline: 1px solid CanvasText;
  }

  /* Indicateurs qui tournent : l'arc ouvert reste ouvert */
  .ui-spinner,
  .ui-button[aria-busy="true"]::before {
    forced-color-adjust: none;
    border-color: currentColor;
    border-top-color: transparent;
  }

  /* Liste déroulante : la flèche du système (l'image du chevron a une couleur fixe) */
  .ui-select:not([multiple]) {
    background-image: none;
    -webkit-appearance: menulist;
    appearance: auto;
  }

  .ui-input[list] {
    background-image: none;
  }

  .ui-input[list]::-webkit-calendar-picker-indicator {
    opacity: 1;
  }
}

/* Impression : le contenu seul */
@media print {
  .ui-sidebar,
  .ui-topbar,
  .ui-tabbar,
  .ui-scrim,
  .ui-toaster,
  .ui-skip-link {
    display: none !important;
  }

  .ui-shell {
    display: block;
  }

  :where(body) {
    background: none;
  }

  .ui-table thead th {
    position: static;
  }
}
