/* =============================================================================
   Charte commune des applications Facilimed — UN SEUL fichier pour toutes les applis.
   Servie à https://hub.facilimed.org/commun/charte.css par hub-facilimed (copie exacte
   dans son app/commun/, voir commun/README.md). Chaque page la charge AVANT sa propre
   feuille : <link rel="stylesheet" href="https://hub.facilimed.org/commun/charte.css">
   Une appli ne redéfinit pas ces jetons ni ces composants : elle n'ajoute que ses styles
   propres (app/static/style.css). Toute évolution se fait ici, rétrocompatible.
   Charte : CLAUDE.md, « Charte d'interface (Material Design 3 + Apple HIG) ».
   Règles : aucune couleur, taille ou rayon en dur dans un composant — uniquement
   les jetons ci-dessous ; le bloc « Responsive » reste EN FIN DE FICHIER.
   ============================================================================= */

/* --- 1. Jetons ------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Couleur — rôles Material 3, primaire Facilimed (bleu 0b5394) */
  --primary: #0b5394;
  --on-primary: #ffffff;
  --primary-container: #d4e3ff;
  --on-primary-container: #001c3a;
  --secondary-container: #dae2f9;
  --on-secondary-container: #131c2b;
  --surface: #fbfcff;
  --surface-container-low: #f3f4f9;
  --surface-container: #edeef3;
  --surface-container-high: #e7e8ed;
  --on-surface: #1a1c20;
  --on-surface-variant: #43474e;
  --outline: #73777f;
  --outline-variant: #c3c6cf;
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #410002;
  --success: #1b6c3a;
  --success-container: #c8f0d2;
  --warning: #7a4f00;
  --warning-container: #ffddb3;
  --scrim: rgb(0 0 0 / 0.32);
  --inverse-surface: #2f3036;
  --inverse-on-surface: #f1f0f7;
  --inverse-primary: #a6c8ff;
  --app-bar: var(--primary);
  --on-app-bar: var(--on-primary);
  /* Ancien nom conservé pour les applis qui l'utilisent déjà */
  --bad: var(--error);

  /* Typographie — police système, échelle Material 3 réduite (taille/interligne) */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: 400 2.25rem/2.75rem var(--font);      /* 36/44 */
  --headline: 400 1.5rem/2rem var(--font);         /* 24/32 */
  --title-l: 400 1.375rem/1.75rem var(--font);     /* 22/28 */
  --title-m: 500 1rem/1.5rem var(--font);          /* 16/24 */
  --body-l: 400 1rem/1.5rem var(--font);           /* 16/24 */
  --body-m: 400 0.875rem/1.25rem var(--font);      /* 14/20 */
  --label-l: 500 0.875rem/1.25rem var(--font);     /* 14/20 */
  --label-m: 500 0.75rem/1rem var(--font);         /* 12/16 */

  /* Espacement — grille de 4 px */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --gutter: var(--s5);
  --content-max: 1200px;

  /* Forme */
  --radius-xs: 4px; --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;
  --radius-xl: 28px; --radius-full: 9999px;

  /* Élévation — trois niveaux seulement */
  --elev-1: 0 1px 2px rgb(0 0 0 / 0.30), 0 1px 3px 1px rgb(0 0 0 / 0.15);
  --elev-2: 0 1px 2px rgb(0 0 0 / 0.30), 0 2px 6px 2px rgb(0 0 0 / 0.15);
  --elev-3: 0 4px 8px 3px rgb(0 0 0 / 0.15), 0 1px 3px rgb(0 0 0 / 0.30);

  /* États (voiles appliqués par-dessus le conteneur) */
  --state-hover: 0.08; --state-focus: 0.12; --state-pressed: 0.12; --state-disabled: 0.38;

  /* Mouvement */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur-short: 150ms; --dur-medium: 250ms;

  /* Cibles */
  --target: 40px;            /* souris ; 44 px au toucher (bloc Responsive) */
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #a6c8ff;
    --on-primary: #00315f;
    --primary-container: #004786;
    --on-primary-container: #d4e3ff;
    --secondary-container: #3e4759;
    --on-secondary-container: #dae2f9;
    --surface: #111318;
    --surface-container-low: #1a1c20;
    --surface-container: #1e2024;
    --surface-container-high: #282a2f;
    --on-surface: #e2e2e9;
    --on-surface-variant: #c3c6cf;
    --outline: #8d9199;
    --outline-variant: #43474e;
    --error: #ffb4ab;
    --on-error: #690005;
    --error-container: #93000a;
    --on-error-container: #ffdad6;
    --success: #8ad7a0;
    --success-container: #00522a;
    --warning: #ffb95c;
    --warning-container: #5c3b00;
    --inverse-surface: #e2e2e9;
    --inverse-on-surface: #2f3036;
    --inverse-primary: #0b5394;
    /* En sombre, la barre d'en-tête est une surface (Material 3), pas un aplat de couleur vive */
    --app-bar: var(--surface-container);
    --on-app-bar: var(--on-surface);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* --- 2. Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
img, svg, video { max-width: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* L'attribut hidden masque toujours, même un élément auquel la charte donne un display
   (label en grid, .actions en flex…) : sans cette règle, label { display: grid } l'emportait
   et un champ masqué par l'appli restait visible (constat du 2026-10-16, contacts). */
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100dvh;
  font: var(--body-l); color: var(--on-surface); background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
h1 { font: var(--headline); margin: 0; }
h2 { font: var(--title-l); margin: 0 0 var(--s4); }
h3 { font: var(--title-m); margin: 0 0 var(--s3); }
p { margin: 0 0 var(--s4); max-width: 70ch; }
a { color: var(--primary); text-underline-offset: 2px; }
small, .label { font: var(--label-m); color: var(--on-surface-variant); }
.num, td.num, table { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-xs); }

/* --- 3. Structure : barre d'en-tête et contenu ------------------------------ */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--s4);
  min-height: 64px;
  padding: var(--s2) var(--gutter);
  padding-top: max(var(--s2), env(safe-area-inset-top));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  background: var(--app-bar); color: var(--on-app-bar);
}
.app-bar h1 { font: var(--title-l); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar h1 a { color: inherit; text-decoration: none; }
/* Icône de l'appli (envoyée dans l'IAM, posée par ui.js : iconeAppli), à gauche du titre et dans
   son lien vers l'accueil. Liseré clair : plusieurs icônes ont la couleur de la barre. */
.app-bar h1 .app-icone { width: 32px; height: 32px; margin-right: var(--s3); vertical-align: middle;
  border-radius: 23%; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--on-app-bar) 35%, transparent); }
.app-bar h1 .app-icone-lien { display: inline-block; }
/* Structure standard de l'en-tête (CLAUDE.md « En-tête ») :
     <header class="app-bar"><h1>Titre</h1>
       <nav class="app-nav" aria-label="Navigation principale">onglets…</nav>
       <div class="app-actions">roue (btn-icone) + <div data-menu-utilisateur …></div></div></header>
   Bureau : une ligne (titre | onglets | actions). Mobile : une ligne (☰ | titre · page en cours),
   onglets, actions et compte dans le tiroir du ☰ (ui.js : tiroirNavigation). Sans onglets :
   titre et actions sur une ligne. */
/* Onglets trop nombreux pour la largeur : ils défilent dans leur rangée, la page ne déborde
   jamais ; le titre garde une largeur minimale au lieu de disparaître. */
.app-bar .app-nav { display: flex; align-items: center; gap: var(--s1); min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.app-bar .app-nav::-webkit-scrollbar { display: none; }
.app-bar h1 { min-width: min(10ch, 30%); }
.app-bar .app-nav a { flex: none; display: inline-flex; align-items: center; min-height: var(--target); padding: 0 var(--s3);
  border-radius: var(--radius-full); color: var(--on-app-bar); text-decoration: none; font: var(--label-l); white-space: nowrap; }
.app-bar .app-nav a:hover { background: color-mix(in srgb, var(--on-app-bar) 10%, transparent); }
.app-bar .app-nav a[aria-current="page"], .app-bar .app-nav a.active { background: color-mix(in srgb, var(--on-app-bar) 18%, transparent); }
.app-bar .app-actions { display: flex; align-items: center; gap: var(--s1); flex: none; margin-left: auto; }
.app-bar nav { display: flex; align-items: center; gap: var(--s1); }
.app-bar nav a, .app-bar nav .btn-text { color: var(--on-app-bar); }
.app-bar nav a[aria-current="page"] { background: color-mix(in srgb, var(--on-app-bar) 16%, transparent); }
/* Menu ☰ du téléphone (ui.js : tiroirNavigation) : bouton et page en cours masqués au bureau */
.app-bar .btn-tiroir, .app-bar .page-courante { display: none; }
dialog.tiroir {
  position: fixed; inset: 0 auto 0 0; margin: 0; width: min(320px, 86vw); max-width: none;
  height: 100dvh; max-height: 100dvh; padding: 0 0 max(var(--s4), env(safe-area-inset-bottom));
  border: 0; border-radius: 0 var(--radius-lg) var(--radius-lg) 0; overflow-y: auto;
  background: var(--surface-container-low); color: var(--on-surface); }
dialog.tiroir::backdrop { background: color-mix(in srgb, var(--scrim) 40%, transparent); }
.tiroir .tiroir-entete { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: max(var(--s3), env(safe-area-inset-top)) var(--s2) var(--s2) var(--s5); font: var(--title-m); }
.tiroir nav { display: flex; flex-direction: column; }
.tiroir a { display: flex; align-items: center; gap: var(--s3); min-height: 48px; margin: 0 var(--s3); padding: 0 var(--s4);
  border-radius: var(--radius-full); color: var(--on-surface); text-decoration: none; font: var(--label-l); font-size: 16px; }
.tiroir a:hover, .tiroir a:focus-visible { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.tiroir a[aria-current="page"] { background: var(--secondary-container); color: var(--on-secondary-container); font-weight: 600; }
.tiroir a .icone-svg { width: 20px; height: 20px; color: var(--on-surface-variant); flex: none; }
.tiroir hr { border: 0; border-top: 1px solid var(--outline-variant); margin: var(--s3) var(--s5); }
.tiroir .qui { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s5) var(--s3); }
.tiroir .qui .nom { font: var(--label-l); color: var(--on-surface); overflow-wrap: anywhere; }
.tiroir .qui .email { font: var(--body-m); color: var(--on-surface-variant); overflow-wrap: anywhere; }

/* Sous-onglets (2e niveau, à l'intérieur d'une destination de l'en-tête) : seuls onglets admis
   sous l'en-tête, la navigation principale est dans .app-nav (CLAUDE.md « En-tête »).
     <nav class="sous-onglets" aria-label="…"><a href="…" aria-current="page">…</a>…</nav>
   (<button aria-selected="true"> pour des panneaux de la même page). Une rangée qui défile
   horizontalement : les libellés ne rétrécissent jamais, au téléphone non plus. */
.sous-onglets { display: flex; gap: var(--s1); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--outline-variant); margin-bottom: var(--s5); }
.sous-onglets::-webkit-scrollbar { display: none; }
.sous-onglets > a, .sous-onglets > button {
  flex: none; display: inline-flex; align-items: center; min-height: var(--target); padding: 0 var(--s4);
  font: var(--label-l); white-space: nowrap; text-decoration: none; cursor: pointer;
  color: var(--on-surface-variant); background: none; border: none; border-radius: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px; box-shadow: none; }
.sous-onglets > a:hover, .sous-onglets > button:hover { color: var(--on-surface); box-shadow: none; }
.sous-onglets > [aria-current="page"], .sous-onglets > [aria-selected="true"], .sous-onglets > .active {
  color: var(--primary); border-bottom-color: var(--primary); }

main {
  max-width: var(--content-max); margin: 0 auto;
  padding: var(--s5) var(--gutter) var(--s7);
  padding-bottom: max(var(--s7), env(safe-area-inset-bottom));
}
section { margin-bottom: var(--s6); }

/* --- 4. Cartes ------------------------------------------------------------- */
.card {
  background: var(--surface-container-low); color: var(--on-surface);
  border: 1px solid var(--outline-variant); border-radius: var(--radius-md);
  padding: var(--s4);
  transition: box-shadow var(--dur-short) var(--ease);
}
.card > :last-child { margin-bottom: 0; }
a.card, .card.cliquable { display: block; text-decoration: none; cursor: pointer; }
.grille { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* --- 5. Boutons : plein > tonal > contour > texte ; danger pour l'irréversible */
.btn, .btn-tonal, .btn-outlined, .btn-text, .btn-danger, button {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--target); min-width: var(--target);
  padding: 0 var(--s5);
  font: var(--label-l); letter-spacing: 0.01em;
  border: 1px solid transparent; border-radius: var(--radius-full);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow var(--dur-short) var(--ease);
}
.btn, button { background: var(--primary); color: var(--on-primary); }
.btn-tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn-outlined { background: transparent; color: var(--primary); border-color: var(--outline); }
.btn-text { background: transparent; color: var(--primary); padding: 0 var(--s3); }
.btn-danger { background: var(--error); color: var(--on-error); }
/* Voile d'état : même mécanique pour toutes les variantes */
.btn::after, .btn-tonal::after, .btn-outlined::after, .btn-text::after, .btn-danger::after, button::after,
.card.cliquable::after, a.card::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: currentColor; opacity: 0; transition: opacity var(--dur-short) var(--ease);
  pointer-events: none;
}
a.card, .card.cliquable { position: relative; isolation: isolate; overflow: hidden; }
@media (hover: hover) {
  .btn:hover::after, .btn-tonal:hover::after, .btn-outlined:hover::after, .btn-text:hover::after,
  .btn-danger:hover::after, button:hover::after, a.card:hover::after, .card.cliquable:hover::after { opacity: var(--state-hover); }
  .btn:hover, button:hover, .btn-danger:hover { box-shadow: var(--elev-1); }
  a.card:hover, .card.cliquable:hover { box-shadow: var(--elev-1); }
}
:is(.btn, .btn-tonal, .btn-outlined, .btn-text, .btn-danger, button):focus-visible::after { opacity: var(--state-focus); }
:is(.btn, .btn-tonal, .btn-outlined, .btn-text, .btn-danger, button):active::after { opacity: var(--state-pressed); }
:is(.btn, .btn-tonal, .btn-outlined, .btn-text, .btn-danger, button):disabled,
:is(.btn, .btn-tonal, .btn-outlined, .btn-text, .btn-danger, button)[aria-disabled="true"] {
  background: color-mix(in srgb, var(--on-surface) 12%, transparent);
  color: color-mix(in srgb, var(--on-surface) 38%, transparent);
  border-color: transparent; box-shadow: none; cursor: not-allowed;
}
:is(.btn-text, .btn-outlined):disabled { background: transparent; }
.btn-icone { padding: 0; width: var(--target); }
.btn-icone svg, .btn svg, .btn-tonal svg, .btn-outlined svg, .btn-text svg, .btn-danger svg, button svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
/* Pictogrammes communs (ui.js : data-icone / icone()) : trait 2 px, couleur du texte.
   Bouton à icône seule : rond, voile d'état au survol, aria-label obligatoire. */
.icone { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; line-height: 0; }
.icone-svg, .icone svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button .icone-svg, .btn .icone-svg, .btn-tonal .icone-svg, .btn-outlined .icone-svg,
.btn-text .icone-svg, .btn-danger .icone-svg { width: 20px; height: 20px; fill: none; }
/* Bouton à icône seule (Material « standard icon button ») : ni bordure ni ombre, un disque
   teinté au survol (voile d'état), un anneau au focus clavier. Même rendu en <button> et en
   <a>. Sélecteurs a./button. pour primer sur les règles locales des applis. */
a.btn-icone, button.btn-icone, .btn-icone {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--target); height: var(--target); min-width: var(--target); min-height: var(--target); padding: 0;
  border: 0; border-radius: var(--radius-full); box-shadow: none;
  background: transparent; color: var(--on-surface-variant); text-decoration: none; cursor: pointer;
}
a.btn-icone::after, button.btn-icone::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: currentColor; opacity: 0; transition: opacity var(--dur-short) var(--ease); pointer-events: none;
}
a.btn-icone:hover, button.btn-icone:hover, a.btn-icone:focus-visible, button.btn-icone:focus-visible,
a.btn-icone:active, button.btn-icone:active { border: 0; box-shadow: none; }
@media (hover: hover) { a.btn-icone:hover::after, button.btn-icone:hover::after { opacity: var(--state-hover); } }
a.btn-icone:focus-visible::after, button.btn-icone:focus-visible::after { opacity: var(--state-focus); }
a.btn-icone:active::after, button.btn-icone:active::after { opacity: var(--state-pressed); }
a.btn-icone:hover, button.btn-icone:hover { color: var(--on-surface); }
.btn-icone.danger, .btn-icone[data-danger], .btn-icone.danger:hover, .btn-icone[data-danger]:hover { color: var(--error); }
.btn-icone:disabled, .btn-icone[aria-disabled="true"] { opacity: var(--state-disabled); cursor: default; }
.app-bar .btn-icone { color: var(--on-app-bar); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* --- 6. Formulaires : libellé au-dessus, aide/erreur en texte sous le champ -- */
.form { display: grid; gap: var(--s4); }
label { display: grid; gap: var(--s1); font: var(--label-l); color: var(--on-surface); }
label.check { display: flex; align-items: center; gap: var(--s3); min-height: var(--target); font: var(--body-l); cursor: pointer; }
/* Groupe de cases (saisir(), type "cases") : un titre, une case par valeur, sans cadre */
fieldset.cases { display: grid; gap: 0; margin: 0; padding: 0; border: 0; }
fieldset.cases legend { padding: 0; margin-bottom: var(--s1); font: var(--label-l); color: var(--on-surface); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px;
  padding: var(--s3) var(--s4);
  font: var(--body-l); color: var(--on-surface);
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius-xs);
  transition: border-color var(--dur-short) var(--ease);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--on-surface-variant); opacity: 1; }
@media (hover: hover) { input:hover, select:hover, textarea:hover { border-color: var(--on-surface); } }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.aide, .erreur-champ { font: var(--body-m); color: var(--on-surface-variant); }
.erreur-champ { color: var(--error); }
.erreur-champ::before { content: "⚠ "; }   /* l'erreur n'est jamais portée par la seule couleur */
.form-ligne { display: flex; gap: var(--s3); align-items: end; }
.form-ligne > label { flex: 1; }
/* Champs obligatoires (CLAUDE.md « Champs obligatoires ») : repère posé par marquerObligatoires()
   de ui.js, qui tient la classe « requis » du libellé d'après l'attribut required de son champ et
   data-repere d'après le mode du formulaire. Astérisque masqué aux lecteurs d'écran, qui annoncent
   déjà « obligatoire » grâce à required. */
label.requis[data-repere="asterisque"] > .libelle::after { content: " *"; content: " *" / ""; color: var(--error); }
label:not(.requis)[data-repere="facultatif"] > .libelle::after { content: " (facultatif)"; font: var(--body-m); color: var(--on-surface-variant); }
.note-obligatoire { display: none; margin: 0; font: var(--body-m); color: var(--on-surface-variant); }
:is(form, dialog):has(label.requis[data-repere="asterisque"]) > .note-obligatoire { display: block; }
.note-obligatoire .asterisque { color: var(--error); }

/* --- 7. Listes et tableaux ------------------------------------------------- */
.liste { list-style: none; margin: 0; padding: 0; border: 1px solid var(--outline-variant); border-radius: var(--radius-md); overflow: hidden; }
.liste > li { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s4); background: var(--surface); }
.liste > li + li { border-top: 1px solid var(--outline-variant); }
.liste .titre { flex: 1; min-width: 0; }
.liste .secondaire { display: block; font: var(--body-m); color: var(--on-surface-variant); }
.table-wrap { overflow-x: auto; border: 1px solid var(--outline-variant); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font: var(--body-m); }
th { font: var(--label-l); text-align: left; color: var(--on-surface-variant); background: var(--surface-container-low); }
th, td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--outline-variant); }
tr:last-child td { border-bottom: 0; }
/* Ligne qui s'ouvre (data-href ou data-ouvrir, comportement de ui.js) : un simple clic,
   pointeur, voile de survol et anneau de focus clavier (CLAUDE.md « Lignes de liste »). */
tr[data-href], tr[data-ouvrir] { cursor: pointer; }
@media (hover: hover) {
  tr[data-href]:hover, tr[data-ouvrir]:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
}
tr[data-href]:focus-visible, tr[data-ouvrir]:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Statuts : couleur + texte, jamais la couleur seule */
.statut { display: inline-flex; align-items: center; gap: var(--s1); min-height: 24px; padding: 0 var(--s2); border-radius: var(--radius-sm); font: var(--label-m); background: var(--surface-container-high); color: var(--on-surface-variant); }
.statut.ok { background: var(--success-container); color: var(--success); }
.statut.alerte { background: var(--warning-container); color: var(--warning); }
.statut.erreur { background: var(--error-container); color: var(--on-error-container); }

/* État vide : ce qui manque et l'action qui le remplit */
.vide { padding: var(--s6) var(--s4); text-align: center; color: var(--on-surface-variant); border: 1px dashed var(--outline-variant); border-radius: var(--radius-md); }
.vide p { margin: 0 auto var(--s4); }

/* --- 8. Chargement --------------------------------------------------------- */
.squelette { min-height: 56px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-container) 0%, var(--surface-container-high) 50%, var(--surface-container) 100%); background-size: 200% 100%; animation: squelette 1.2s linear infinite; }
.squelette + .squelette { margin-top: var(--s2); }
@keyframes squelette { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.chargement { display: inline-block; width: 20px; height: 20px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* --- 9. Dialogues (saisir / confirmer) ------------------------------------- */
dialog {
  width: min(560px, calc(100vw - 2 * var(--s4)));
  max-height: calc(100dvh - 2 * var(--s5));
  padding: var(--s5); border: 0; border-radius: var(--radius-xl);
  background: var(--surface-container-high); color: var(--on-surface);
  box-shadow: var(--elev-3);
}
/* Fenêtre large : section Configuration, fenêtre de travail avec formulaire ou tableau (CLAUDE.md,
   « Configuration en fenêtre et listes paginées »). Plein écran sous 700 px comme toute fenêtre. */
dialog.fenetre-large { width: min(960px, calc(100vw - 2 * var(--s4))); }
/* Barre de pagination sous une liste (« Listes paginées ») : « ‹ 1 2 3 › » + Page X sur Y */
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s3) 0 var(--s4); }
.pagination button { min-width: 44px; min-height: 44px; }
.pagination .aide { margin: 0; }
dialog::backdrop { background: var(--scrim); }
dialog[open] { animation: apparait var(--dur-medium) var(--ease); }
@keyframes apparait { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog h3 { font: var(--headline); margin: 0 0 var(--s4); }
dialog p { color: var(--on-surface-variant); }
dialog menu { display: flex; justify-content: flex-end; gap: var(--s2); margin: var(--s5) 0 0; padding: 0; }
/* En-tête fixe d'une fenêtre riche (fiche, détail) : premier enfant du <dialog>, il couvre toute la
   largeur et la marge haute du dialogue, opaque, pour que le contenu qui défile passe dessous sans
   rester visible au-dessus ni sur les côtés. Titre (h2/h3) à gauche, actions et fermeture à droite. */
.fenetre-entete {
  position: sticky; top: calc(-1 * var(--s5)); z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  margin: calc(-1 * var(--s5)) calc(-1 * var(--s5)) var(--s4);
  padding: var(--s4) var(--s5);
  background: var(--surface-container-high);
  border-bottom: 1px solid var(--outline-variant);
}
.fenetre-entete > h2, .fenetre-entete > h3 { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Clic sur le fond grisé avec une saisie en cours : la fenêtre reste ouverte et tremble
   (ui.js, « Fenêtres : clic à côté »). Sans animation si le mouvement est réduit. */
dialog.tremble { animation: tremble 320ms var(--ease); }
@keyframes tremble {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Menu de l'utilisateur (ui.js : data-menu-utilisateur) : pastille à droite de l'en-tête, menu
   aux couleurs de SURFACE — jamais celles de la barre (texte blanc sur fond clair sinon). */
.menu-utilisateur { position: relative; display: inline-flex; }
.menu-utilisateur .btn-pastille { padding: 2px; }
.menu-utilisateur .btn-pastille .pastille { width: 36px; height: 36px; }
.menu-utilisateur .menu { right: 0; top: calc(100% + var(--s2)); min-width: 240px; max-width: min(320px, calc(100vw - 24px)); }
.menu-utilisateur .menu[hidden] { display: none; }
.menu-utilisateur .menu .qui { padding: var(--s2) var(--s4) var(--s3); margin-bottom: var(--s1); border-bottom: 1px solid var(--outline-variant); color: var(--on-surface); }
.menu-utilisateur .menu .qui .nom { font: var(--title-m); color: var(--on-surface); overflow-wrap: anywhere; }
.menu-utilisateur .menu .qui .email { font: var(--body-m); color: var(--on-surface-variant); overflow-wrap: anywhere; }
.menu-utilisateur .menu a { gap: var(--s3); color: var(--on-surface); background: transparent; }
.menu-utilisateur .menu a:hover, .menu-utilisateur .menu a:focus-visible { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.menu-utilisateur .menu .icone-svg { width: 20px; height: 20px; color: var(--on-surface-variant); }
/* Nouveautés (ui.js : data-nouveautes) : point sur la pastille et sur l'entrée tant qu'elles ne
   sont pas ouvertes ; date de mise à jour en pied de menu (et du tiroir du téléphone). */
.menu-utilisateur .point-pastille { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--error); box-shadow: 0 0 0 2px var(--app-bar); pointer-events: none; }
.menu-utilisateur .point-pastille[hidden] { display: none; }
.point-nouveau { display: inline-block; width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--error); }
.point-nouveau[hidden] { display: none; }
.menu-utilisateur .menu .maj, .tiroir .maj { padding: var(--s2) var(--s4) var(--s1); margin-top: var(--s1); border-top: 1px solid var(--outline-variant); font: var(--body-m); color: var(--on-surface-variant); }
.tiroir .maj { margin: var(--s2) var(--s5) 0; padding: var(--s2) 0 0; }
.nouveautes .nouveautes-jour { font: var(--title-m); margin: var(--s4) 0 var(--s2); color: var(--on-surface); }
.nouveautes .nouveautes-jour:first-child { margin-top: 0; }
.nouveautes .nouveaute { padding: var(--s3) 0; border-top: 1px solid var(--outline-variant); }
.nouveautes .nouveaute-titre { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.nouveautes .nouveaute p { margin: var(--s1) 0 0; overflow-wrap: anywhere; }
.nouveautes .nouveaute a { display: inline-block; margin-top: var(--s1); }

/* --- 10. Bandeau transitoire (notifier) ------------------------------------ */
.snackbar {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  bottom: max(var(--s4), env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--s3);
  min-height: 48px; max-width: min(560px, calc(100vw - 2 * var(--s4)));
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  font: var(--body-m); color: var(--inverse-on-surface); background: var(--inverse-surface);
  border-radius: var(--radius-xs); box-shadow: var(--elev-3);
  animation: apparait var(--dur-medium) var(--ease);
}
.snackbar .btn-text { color: var(--inverse-primary); }

/* --- 11. Menu déroulant de l'en-tête --------------------------------------- */
.menu { position: absolute; z-index: 20; min-width: 220px; padding: var(--s2) 0; background: var(--surface-container); color: var(--on-surface); border-radius: var(--radius-sm); box-shadow: var(--elev-2); }
.menu a, .menu button { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 0 var(--s4); border-radius: 0; background: transparent; color: var(--on-surface); font: var(--body-l); text-decoration: none; justify-content: flex-start; }

/* --- 11bis. Liste déroulante à sélection multiple (ui.js, multiSelect()) --- */
.multiselect { position: relative; display: inline-block; width: 100%; }
.multiselect-source { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.multiselect-bouton {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); width: 100%; min-width: 0;
  min-height: var(--target); padding: 0 var(--s3); background: var(--surface); color: var(--on-surface-variant);
  border: 1px solid var(--outline); border-radius: var(--radius-xs); font: var(--body-l); text-align: left;
}
.multiselect-bouton-texte { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-bouton.actif { color: var(--on-surface); border-color: var(--primary); }
.multiselect-bouton::after { content: ""; flex: none; width: 8px; height: 8px; margin-top: -3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.multiselect-menu { top: calc(100% + var(--s1)); left: 0; min-width: max(100%, 180px); width: max-content; max-width: min(320px, calc(100vw - 24px)); max-height: 280px; overflow-y: auto; overflow-x: hidden; }
.multiselect-menu label.check { padding: 0 var(--s4); min-height: 44px; white-space: nowrap; }
@media (hover: hover) { .multiselect-menu label.check:hover { background: var(--surface-container-high); } }

/* Texte réservé aux lecteurs d'écran (libellé d'une icône de statut, d'une case de planning) */
.visuellement-masque { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Barre latérale d'applications (hub) : condensée 72 px (icônes, nom en infobulle et en
   aria-label), dépliée 260 px (icône + nom). Le comportement (mode, organisation, badges) est
   celui de la page qui la porte ; la charte ne fixe que l'aspect. */
.rail { position: sticky; top: 0; align-self: flex-start; display: flex; flex-direction: column; gap: var(--s1);
  width: 260px; height: 100dvh; overflow-y: auto; padding: var(--s2); background: var(--surface-container-low);
  border-right: 1px solid var(--outline-variant); transition: width var(--dur-medium) var(--ease); }
.rail.condensee { width: 72px; }
/* Contenu plus haut que la barre : il défile, aucun élément ne rétrécit (en-tête écrasé sinon) */
.rail > * { flex-shrink: 0; }
.rail-section { font: var(--label-m); color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: .04em; padding: var(--s3) var(--s3) var(--s1); }
.rail.condensee .rail-section { height: 1px; padding: 0; margin: var(--s2); background: var(--outline-variant); overflow: hidden; color: transparent; }
.rail-entree { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 var(--s3);
  border-radius: var(--radius-full); color: var(--on-surface); text-decoration: none; font: var(--label-l); }
@media (hover: hover) { .rail-entree:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); } }
.rail-entree:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Entrée de la barre en <button> (Organiser…) : même aspect qu'un lien, pas celui d'un bouton */
button.rail-entree { width: 100%; justify-content: flex-start; background: transparent; border: 0; box-shadow: none;
  color: var(--on-surface); font: var(--label-l); cursor: pointer; text-align: left; }
button.rail-entree[aria-pressed="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.rail-icone { flex: none; width: 24px; height: 24px; border-radius: var(--radius-xs); object-fit: contain; }
.rail-monogramme { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-xs);
  background: var(--primary-container); color: var(--on-primary-container); font: var(--label-m); }
.rail-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail.condensee .rail-entree, .rail.condensee button.rail-entree { justify-content: center; padding: 0; }
.rail.condensee .rail-nom, .rail.condensee .rail-outils { display: none; }
.rail-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); font: var(--label-m);
  display: inline-grid; place-items: center; background: var(--surface-container-high); color: var(--on-surface-variant); }
.rail-badge.statut-warning { background: var(--warning-container); color: var(--warning); }
.rail-badge.statut-error { background: var(--error-container); color: var(--on-error-container); }
.rail.condensee .rail-badge { position: absolute; top: 4px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
.rail-outils { display: flex; gap: var(--s1); margin-left: auto; }
.rail-pied { margin-top: auto; }

/* Carte de widget (ui.js : carteWidget) — formes kpi, list, status, calendar */
.widget-grille { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.widget-carte { grid-column: span 4; display: flex; flex-direction: column; gap: var(--s2); min-width: 0;
  padding: var(--s4); background: var(--surface); border: 1px solid var(--outline-variant); border-radius: var(--radius-md); }
.widget-carte.taille-s { grid-column: span 3; }
.widget-carte.taille-l { grid-column: span 8; }
.widget-entete { display: flex; align-items: center; gap: var(--s2); min-height: 32px; }
.widget-entete h3 { margin: 0; flex: 1; min-width: 0; font: var(--title-m); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-appli { font: var(--label-m); color: var(--on-surface-variant); }
.widget-appli a { color: inherit; text-decoration: none; }
@media (hover: hover) { .widget-appli a:hover { text-decoration: underline; } }
.widget-contenu { min-width: 0; }
.widget-contenu a { color: var(--primary); text-decoration: none; }
@media (hover: hover) { .widget-contenu a:hover { text-decoration: underline; } }
.widget-vide { margin: 0; color: var(--on-surface-variant); font: var(--body-m); }
.widget-kpi { display: flex; flex-direction: column; gap: var(--s1); }
.widget-kpi-valeur { font: var(--display); font-variant-numeric: tabular-nums; color: var(--on-surface); }
.widget-carte.taille-s .widget-kpi-valeur { font: var(--headline); font-variant-numeric: tabular-nums; }
.widget-kpi-libelle { display: inline-flex; align-items: center; gap: var(--s1); font: var(--body-m); color: var(--on-surface-variant); }
.widget-liste, .widget-etats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.widget-liste li, .widget-etats li { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) 0; border-top: 1px solid var(--outline-variant); }
.widget-liste li:first-child, .widget-etats li:first-child { border-top: 0; }
.widget-ligne { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.widget-titre { font: var(--body-m); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-sous-titre { font: var(--label-m); color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-date { flex: none; font: var(--label-m); color: var(--on-surface-variant); font-variant-numeric: tabular-nums; }
.widget-plus { margin: var(--s2) 0 0; font: var(--label-l); }
.widget-statut { flex: none; display: inline-flex; width: 20px; height: 20px; }
.widget-statut .icone { width: 18px; height: 18px; }
.statut-ok { color: var(--success); }
.statut-warning { color: var(--warning); }
.statut-error { color: var(--error); }
.statut-info { color: var(--primary); }
.widget-cal-defile { overflow-x: auto; }
.widget-cal { width: 100%; border-collapse: collapse; font: var(--label-m); }
.widget-cal th, .widget-cal td { padding: var(--s1); text-align: center; border-bottom: 1px solid var(--outline-variant); white-space: nowrap; }
.widget-cal tbody th { text-align: left; font: var(--body-m); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.widget-cal .jour-off { background: var(--surface-container); color: var(--on-surface-variant); }
.widget-cal-case { display: inline-block; width: 18px; height: 18px; border-radius: var(--radius-xs); background: currentColor; vertical-align: middle; }
.widget-cal-case.demi-am { clip-path: polygon(0 0, 100% 0, 0 100%); }
.widget-cal-case.demi-pm { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.widget-cal-mobile { display: none; }
.widget-cal-mobile h4 { font: var(--label-l); margin: var(--s2) 0 0; }
.widget-legende { display: flex; flex-wrap: wrap; gap: var(--s3); margin: var(--s2) 0 0; font: var(--label-m); color: var(--on-surface-variant); }
.widget-legende > span { display: inline-flex; align-items: center; gap: var(--s1); }
.widget-legende .widget-cal-case { width: 12px; height: 12px; }
/* Vue « mois » du calendrier (layout: "month") : sept colonnes, lundi → dimanche */
.widget-mois { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.widget-mois-entete { font: var(--label-m); color: var(--on-surface-variant); text-align: center; padding: var(--s1) 0; }
.widget-mois-jour { min-height: 72px; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: var(--s1);
  border-radius: var(--radius-xs); background: var(--surface-container-low); overflow: hidden; }
.widget-mois-jour.jour-off { background: var(--surface-container); }
.widget-mois-jour.hors-mois { background: transparent; }
.widget-mois-jour.hors-mois .widget-mois-num { color: var(--outline); }
.widget-mois-jour.aujourdhui { box-shadow: inset 0 0 0 2px var(--primary); }
.widget-mois-num { font: var(--label-m); color: var(--on-surface-variant); font-variant-numeric: tabular-nums; }
.widget-mois-jour.aujourdhui .widget-mois-num { color: var(--primary); font-weight: 700; }
.widget-mois-ferie { font: var(--label-m); color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-mois-absent { display: block; font: var(--label-m); padding: 1px var(--s1); border-radius: var(--radius-xs);
  border-left: 3px solid currentColor; background: var(--surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-mois-absent.demi-am, .widget-mois-absent.demi-pm { border-left-style: dashed; }
.widget-mois-plus { font: var(--label-m); color: var(--on-surface-variant); }
/* Navigation de période d'un widget (‹ libellé › Aujourd'hui) */
.widget-nav { display: flex; align-items: center; gap: var(--s1); margin-bottom: var(--s2); flex-wrap: wrap; }
.widget-nav-libelle { font: var(--label-l); color: var(--on-surface); min-width: 0; }
.widget-nav .btn-text { margin-left: auto; }
.widget-carte.squelette .widget-contenu { min-height: 96px; border-radius: var(--radius-sm); background: var(--surface-container); }
.widget-carte.en-erreur .widget-contenu { color: var(--error); }

/* =============================================================================
   Responsive — point de rupture unique 700 px, EN FIN DE FEUILLE (voir CLAUDE.md,
   « Interface responsive »). Rien ne doit suivre ce bloc.
   ============================================================================= */
@media (hover: none) {
  /* Rien n'est accessible qu'au survol : afficher ce que montrerait une infobulle */
  [data-infobulle]::after { content: attr(data-infobulle); display: block; font: var(--body-m); color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (pointer: coarse) {
  :root { --target: 44px; }
}
/* Messages de notice.facilimed.org (ui.js, messagesFacilimed) : bandeaux, écran d'accueil, cloche.
   Couleurs par gravité : info = primary, success, warning, critical = error (jetons, clair et sombre). */
.msg-bandeaux { display: grid; gap: 1px; }
.msg-bandeaux.msg-bas { position: sticky; bottom: 0; z-index: 5; padding-bottom: env(safe-area-inset-bottom); }
.msg-bandeau { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4);
  background: var(--primary-container); color: var(--on-primary-container); font: var(--body-m); }
.msg-bandeau.gravite-success { background: var(--success-container); color: var(--on-surface); }
.msg-bandeau.gravite-warning { background: var(--warning-container); color: var(--on-surface); }
.msg-bandeau.gravite-critical { background: var(--error-container); color: var(--on-error-container); }
.msg-bandeau-icone { flex: none; display: inline-flex; padding-top: 2px; }
.msg-bandeau-icone .icone-svg { width: 20px; height: 20px; }
.msg-bandeau-texte { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.msg-bandeau-texte > div > :first-child { margin-top: var(--s1); }
.msg-bandeau-texte > div > :last-child { margin-bottom: 0; }
.msg-bandeau-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.msg-bandeau .btn-text, .msg-bandeau .btn-icone { color: inherit; }
.msg-plus { justify-self: start; margin: var(--s1) var(--s4); }
dialog.msg-splash { width: min(640px, calc(100vw - 2 * var(--s4))); border-top: 6px solid var(--primary); }
dialog.msg-splash.gravite-success { border-top-color: var(--success); }
dialog.msg-splash.gravite-warning { border-top-color: var(--warning); }
dialog.msg-splash.gravite-critical { border-top-color: var(--error); }
dialog.msg-splash h2 { font: var(--headline); margin: 0; }
.msg-splash-corps { color: var(--on-surface); overflow-wrap: anywhere; }
.msg-splash-corps img, .msg-bandeau img, .msg-item img { max-width: 100%; height: auto; }
.msg-cloche { position: relative; display: inline-flex; }
.msg-cloche[hidden] { display: none; }
.msg-compteur { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-full);
  background: var(--error); color: var(--on-error); font: var(--label-m); font-size: 10px; line-height: 16px; text-align: center; pointer-events: none; }
.msg-compteur[hidden] { display: none; }
.msg-panneau { right: 0; top: calc(100% + var(--s2)); width: min(380px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow-y: auto;
  padding: 0; color: var(--on-surface); }
.msg-panneau[hidden] { display: none; }
.msg-panneau-entete { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s2) var(--s4); border-bottom: 1px solid var(--outline-variant); }
.msg-item { border-bottom: 1px solid var(--outline-variant); border-left: 4px solid var(--primary); }
.msg-item.gravite-success { border-left-color: var(--success); }
.msg-item.gravite-warning { border-left-color: var(--warning); }
.msg-item.gravite-critical { border-left-color: var(--error); }
.msg-item.non-lue { background: var(--surface-container-low); }
.msg-item-titre { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: var(--s3) var(--s4); border: 0;
  background: transparent; color: var(--on-surface); font: var(--title-m); text-align: left; cursor: pointer; }
.msg-item-titre .point-nouveau { margin-left: 0; flex: none; }
.msg-item-corps { padding: 0 var(--s4) var(--s3); font: var(--body-m); overflow-wrap: anywhere; }
.msg-item-corps .actions { flex-wrap: wrap; }
.msg-panneau-pied { display: block; padding: var(--s3) var(--s4); text-align: center; }
@media (hover: hover) { .msg-item-titre:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); } }

@media (max-width: 700px) {
  :root { --gutter: var(--s4); --target: 44px; }
  .rail { display: none; }
  .widget-grille { grid-template-columns: minmax(0, 1fr); }
  .widget-carte, .widget-carte.taille-s, .widget-carte.taille-l { grid-column: auto; }
  .widget-cal-defile { display: none; }
  .widget-mois { display: none; }
  .widget-cal-mobile { display: block; }
  .app-bar { min-height: 56px; flex-wrap: wrap; row-gap: 0; column-gap: var(--s2); padding-bottom: 0; }
  .app-bar h1 { font: var(--title-m); font-size: 1.125rem; flex: 1 1 0; order: 1; padding: var(--s2) 0; }
  .app-bar h1 .app-icone { width: 28px; height: 28px; margin-right: var(--s2); }
  .app-bar .app-actions { order: 2; }
  .app-bar .app-nav { order: 3; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) var(--s1); }
  .app-bar .app-nav::-webkit-scrollbar { display: none; }
  .app-bar .app-nav a { flex: none; padding: 0 var(--s3); font-size: 15px; }
  /* En-tête à onglets : une seule ligne, ☰ | nom de l'appli · page en cours ; onglets, actions
     et compte passent dans le tiroir (ui.js : tiroirNavigation) */
  .app-bar.avec-tiroir { flex-wrap: nowrap; padding-bottom: var(--s2); column-gap: var(--s1); }
  .app-bar.avec-tiroir .btn-tiroir { display: inline-flex; order: 0; margin-left: calc(-1 * var(--s2)); }
  .app-bar.avec-tiroir h1 { order: 1; }
  .app-bar.avec-tiroir .app-nav, .app-bar.avec-tiroir .app-actions { display: none; }
  .app-bar.avec-tiroir .page-courante { display: inline; font: var(--body-l, var(--body-m)); opacity: .85; }
  .app-bar.avec-tiroir .page-courante:not(:empty)::before { content: " · "; }
  .sous-onglets { margin: 0 calc(-1 * var(--gutter)) var(--s4); padding: 0 var(--gutter); }
  .sous-onglets > a, .sous-onglets > button { padding: 0 var(--s3); font-size: 15px; }
  main { padding-top: var(--s4); }
  h2 { font: var(--title-m); font-size: 1.125rem; }
  /* Champs à 16 px minimum : sinon iOS zoome */
  input, select, textarea { font-size: 16px !important; }
  /* Formulaires empilés, boutons pleine largeur */
  .form-ligne { flex-direction: column; align-items: stretch; }
  .form-ligne > .btn, .form-ligne > button { width: 100%; }
  /* Modales plein écran */
  dialog, dialog.fenetre-large { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
           padding: max(var(--s5), env(safe-area-inset-top)) var(--s4) max(var(--s5), env(safe-area-inset-bottom)); }
  .fenetre-entete { top: calc(-1 * max(var(--s5), env(safe-area-inset-top))); padding: var(--s3) var(--s4);
                    margin: calc(-1 * max(var(--s5), env(safe-area-inset-top))) calc(-1 * var(--s4)) var(--s4); }
  dialog > .form { min-height: 100%; display: flex; flex-direction: column; }
  dialog > .form > * { flex: none; }
  dialog menu { margin-top: auto; padding-top: var(--s4); }
  dialog menu > * { flex: 1; }
  .app-bar nav .btn-text { padding: 0 var(--s2); }
  /* Menu de l'en-tête : panneau pleine largeur */
  .menu { position: fixed; left: 12px; right: 12px; top: 64px; min-width: 0; }
  .menu-utilisateur .menu { position: fixed; left: 12px; right: 12px; top: 64px; min-width: 0; max-width: none; }
  .menu a, .menu button { font-size: 16px; }
  .grille { grid-template-columns: 1fr; }
  /* Tableaux .table en cartes : libellé de colonne posé par etiqueterTables() (app.js) */
  .table-wrap:has(> .table) { border: 0; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--surface-container-low); border: 1px solid var(--outline-variant); border-radius: var(--radius-md); margin-bottom: var(--s2); padding: var(--s2) var(--s4); }
  .table td { border: 0; padding: var(--s1) 0; white-space: normal; overflow-wrap: anywhere; text-align: left; }
  .table td[data-label]:not(:empty)::before { content: attr(data-label) " : "; font: var(--label-m); color: var(--on-surface-variant); }
  .masque-mobile { display: none !important; }
}

/* --- 11ter. Éditeur WYSIWYG des champs HTML (ui.js, editeurHtml()) ---------- */
fieldset { min-width: 0; } /* sinon un contenu large (menu, aperçu) élargit la page ou la fenêtre */
.editeur-html { display: flex; flex-direction: column; border: 1px solid var(--outline); border-radius: 4px; background: var(--surface); min-width: 0; }
.editeur-html:focus-within { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.editeur-barre { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px; border-bottom: 1px solid var(--outline-variant); background: var(--surface-container-low); border-radius: 4px 4px 0 0; position: sticky; top: 0; z-index: 1; }
.editeur-barre .btn-text { min-width: var(--target); padding: 0 8px; }
.editeur-barre .btn-text[aria-pressed="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.editeur-barre select { width: auto; max-width: 100%; min-width: 0; min-height: var(--target); }
.editeur-couleur { display: inline-flex; align-items: center; gap: 4px; min-height: var(--target); padding: 0 8px; margin: 0; cursor: pointer; font-weight: 700; }
.editeur-html .editeur-couleur input[type=color] { width: 28px; height: 28px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 4px; background: none; box-shadow: none; }
.editeur-invite { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border-bottom: 1px solid var(--outline-variant); }
.editeur-invite[hidden] { display: none; }
.editeur-invite input { flex: 1 1 200px; min-width: 0; }
.editeur-zone { min-height: 160px; max-height: 60vh; overflow: auto; padding: 12px; outline: none; overflow-wrap: anywhere; font: var(--body-l); }
.editeur-zone img { max-width: 100%; height: auto; }
.editeur-zone:empty::before { content: attr(data-placeholder); color: var(--on-surface-variant); }
.editeur-html.en-source .editeur-zone { font-family: ui-monospace, Consolas, monospace; font-size: 0.875rem; white-space: pre-wrap; }
/* --- Aperçu PDF dessiné page par page (afficherPdf de ui.js, navigateurs sans lecteur PDF) --- */
.apercu-pdf { display: grid; gap: var(--s3); justify-items: stretch; }
.apercu-pdf canvas { display: block; width: 100%; height: auto; background: var(--surface);
  border: 1px solid var(--outline-variant); border-radius: var(--radius-xs); box-shadow: var(--elev-1); }
.apercu-pdf .actions { justify-content: center; }

@media (max-width: 700px) {
  .editeur-zone { max-height: none; }
  .msg-bandeau { flex-wrap: wrap; }
  .msg-bandeau-actions { width: 100%; justify-content: flex-end; }
}
