/* =============================================================================
   PrivaBox : système visuel (phase 0 : socle)
   Référence : page de démonstration « Système visuel PrivaBox ».

   Ce fichier est chargé sur toutes les pages par config/bootstrap.php, après
   tailwind.css. En phase 0, il ne contient AUCUN sélecteur d'élément (body, h1,
   button…) ni de classe Tailwind : uniquement
     1. des variables (--pb-*) ;
     2. des composants à activer explicitement (.pb-card, .pb-btn, .pb-input…).
   Tant qu'une page n'utilise pas ces classes, son apparence ne change pas.

   Thème : sombre par défaut (comme le site). Le thème clair s'applique quand
   <html data-pb-theme="light"> est posé ; ce sera fait en phase 1 par un script
   placé dans <head>, à partir des préférences déjà enregistrées par les membres
   (privabox_global_theme_mode / privabox_doc_theme_preference).
   ========================================================================== */

/* ---------- 1. Variables : thème sombre (défaut) ---------- */
:root {
  /* Surfaces */
  --pb-bg: #0a101c;            /* fond de page */
  --pb-surface: #111a2b;       /* cartes */
  --pb-surface-2: #172236;     /* champs, survols */
  --pb-surface-3: #1f2c44;     /* pistes de jauge, séparations marquées */
  --pb-raised: #24324c;        /* élément sélectionné dans un groupe */
  --pb-border: #223049;
  --pb-border-strong: #304060;

  /* Texte */
  --pb-text: #e7ecf3;
  --pb-muted: #a0abbd;
  --pb-faint: #7d8a9e;

  /* Accent unique */
  --pb-accent: #2f63d6;        /* fond des boutons principaux */
  --pb-accent-hover: #3a70e6;
  --pb-accent-text: #8eb0ff;   /* liens, icônes et textes d'accent */
  --pb-accent-soft: rgba(96, 142, 255, .15);
  --pb-on-accent: #ffffff;

  /* États (jamais utilisés comme décoration) */
  --pb-success: #56cba0;
  --pb-success-soft: rgba(86, 203, 160, .13);
  --pb-warning: #f1b862;
  --pb-warning-soft: rgba(241, 184, 98, .13);
  --pb-danger: #f38b95;
  --pb-danger-soft: rgba(243, 139, 149, .13);
  --pb-danger-solid: #c23946;

  /* Relief */
  --pb-shadow-pop: 0 18px 40px -14px rgba(0, 0, 0, .65), 0 2px 6px rgba(0, 0, 0, .3);
  --pb-shadow-seg: 0 1px 2px rgba(0, 0, 0, .4);
  --pb-backdrop: rgba(2, 6, 14, .7);
  --pb-focus: #8eb0ff;

  /* Teintes discrètes par module (icônes uniquement) */
  --pb-tint-box: #d0852d;
  --pb-tint-passwords: #5a82ea;
  --pb-tint-albums: #b4649f;
  --pb-tint-memos: #8b6fdc;
  --pb-tint-budget: #2f9d78;
  --pb-tint-agenda: #d06459;
  --pb-tint-contacts: #3999b6;
  --pb-tint-consos: #c49a2e;

  /* Typographie : Inter (déclarée dans privabox-ui.css) */
  --pb-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --pb-fs-12: .75rem;    /* minimum absolu */
  --pb-fs-13: .8125rem;  /* libellés, navigation */
  --pb-fs-14: .875rem;   /* texte de l'espace membre */
  --pb-fs-16: 1rem;      /* texte des pages publiques */
  --pb-fs-20: 1.25rem;   /* titre de carte, fenêtre */
  --pb-fs-24: 1.5rem;    /* titre de section */
  --pb-fs-32: 2rem;      /* titre de page */
  --pb-fs-40: 2.5rem;    /* titre d'accueil */

  /* Formes */
  --pb-r-control: 10px;
  --pb-r-card: 14px;
  --pb-r-dialog: 20px;

  /* Hauteurs de contrôle */
  --pb-h-control: 40px;
  --pb-h-control-sm: 32px;
}

/* ---------- 1 bis. Variables : thème clair ---------- */
html[data-pb-theme="light"] {
  --pb-bg: #f4f6f9;
  --pb-surface: #ffffff;
  --pb-surface-2: #eef1f5;
  --pb-surface-3: #e3e8ee;
  --pb-raised: #ffffff;
  --pb-border: #dde2e9;
  --pb-border-strong: #c6ced9;

  --pb-text: #0f1828;
  --pb-muted: #4f5d70;
  --pb-faint: #687487;

  --pb-accent: #2457d4;
  --pb-accent-hover: #1d48b3;
  --pb-accent-text: #2152cc;
  --pb-accent-soft: #e8eefd;
  --pb-on-accent: #ffffff;

  --pb-success: #137a57;
  --pb-success-soft: #e3f3ec;
  --pb-warning: #975a06;
  --pb-warning-soft: #fbf0de;
  --pb-danger: #bb2d3b;
  --pb-danger-soft: #fbe8ea;
  --pb-danger-solid: #bb2d3b;

  --pb-shadow-pop: 0 14px 34px -14px rgba(15, 24, 40, .25), 0 2px 6px rgba(15, 24, 40, .06);
  --pb-shadow-seg: 0 1px 2px rgba(15, 24, 40, .12);
  --pb-backdrop: rgba(15, 24, 40, .45);
  --pb-focus: #2457d4;
}

/* =============================================================================
   2. Composants (à activer explicitement par leur classe)
   ========================================================================== */

/* ---------- Carte ---------- */
.pb-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  padding: 20px;
  background: var(--pb-surface);
  color: var(--pb-text);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-r-card);
}

/* ---------- Boutons ---------- */
.pb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--pb-h-control);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--pb-r-control);
  font: 500 var(--pb-fs-14)/1 var(--pb-font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.pb-btn:focus-visible { outline: 2px solid var(--pb-focus); outline-offset: 2px; }
.pb-btn:disabled, .pb-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.pb-btn-primary { background: var(--pb-accent); color: var(--pb-on-accent); }
.pb-btn-primary:hover { background: var(--pb-accent-hover); }
.pb-btn-secondary { background: var(--pb-surface); color: var(--pb-text); border-color: var(--pb-border-strong); }
.pb-btn-secondary:hover { background: var(--pb-surface-2); }
.pb-btn-ghost { background: transparent; color: var(--pb-muted); }
.pb-btn-ghost:hover { background: var(--pb-surface-2); color: var(--pb-text); }
.pb-btn-danger { background: var(--pb-danger-solid); color: #ffffff; }
.pb-btn-danger:hover { filter: brightness(1.08); }
.pb-btn-sm { height: var(--pb-h-control-sm); padding: 0 12px; font-size: var(--pb-fs-13); }
.pb-btn-icon { width: var(--pb-h-control); padding: 0; }
.pb-btn-icon.pb-btn-sm { width: var(--pb-h-control-sm); }
.pb-btn-block { width: 100%; }

/* ---------- Champs ---------- */
.pb-field { display: grid; gap: 6px; align-content: start; }
.pb-label { font: 500 var(--pb-fs-13)/1.4 var(--pb-font); color: var(--pb-text); }
.pb-hint { font-size: var(--pb-fs-12); color: var(--pb-muted); }
.pb-hint.is-error { color: var(--pb-danger); }
.pb-input {
  width: 100%;
  height: var(--pb-h-control);
  padding: 0 12px;
  background: var(--pb-surface);
  color: var(--pb-text);
  border: 1px solid var(--pb-border-strong);
  border-radius: var(--pb-r-control);
  font: 400 var(--pb-fs-14) var(--pb-font);
  transition: border-color .15s, box-shadow .15s;
}
textarea.pb-input { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; }
.pb-input::placeholder { color: var(--pb-faint); }
.pb-input:focus { outline: none; border-color: var(--pb-accent); box-shadow: 0 0 0 3px var(--pb-accent-soft); }
.pb-input.is-error { border-color: var(--pb-danger); }

/* ---------- Groupe de choix (ex. visibilité) ---------- */
.pb-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--pb-surface-2);
  border: 1px solid var(--pb-border);
  border-radius: 12px;
}
.pb-seg > button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--pb-muted);
  font: 500 var(--pb-fs-13) var(--pb-font);
  cursor: pointer;
}
.pb-seg > button:hover { color: var(--pb-text); }
.pb-seg > button[aria-pressed="true"] { background: var(--pb-raised); color: var(--pb-text); box-shadow: var(--pb-shadow-seg); }

/* ---------- Badges ---------- */
.pb-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--pb-border);
  background: var(--pb-surface-2);
  color: var(--pb-muted);
  font: 500 var(--pb-fs-12)/1 var(--pb-font);
  white-space: nowrap;
}
.pb-badge-accent { background: var(--pb-accent-soft); color: var(--pb-accent-text); border-color: transparent; }
.pb-badge-success { background: var(--pb-success-soft); color: var(--pb-success); border-color: transparent; }
.pb-badge-warning { background: var(--pb-warning-soft); color: var(--pb-warning); border-color: transparent; }
.pb-badge-danger { background: var(--pb-danger-soft); color: var(--pb-danger); border-color: transparent; }

/* ---------- Messages ---------- */
.pb-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--pb-border);
  border-radius: 12px;
  background: var(--pb-surface);
  color: var(--pb-text);
  font-size: var(--pb-fs-14);
}
.pb-alert-info > :first-child { color: var(--pb-accent-text); }
.pb-alert-success { background: var(--pb-success-soft); border-color: transparent; }
.pb-alert-success > :first-child { color: var(--pb-success); }
.pb-alert-warning { background: var(--pb-warning-soft); border-color: transparent; }
.pb-alert-warning > :first-child { color: var(--pb-warning); }
.pb-alert-danger { background: var(--pb-danger-soft); border-color: transparent; }
.pb-alert-danger > :first-child { color: var(--pb-danger); }

/* ---------- Jauge ---------- */
.pb-meter { height: 8px; border-radius: 999px; background: var(--pb-surface-3); overflow: hidden; }
.pb-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--pb-accent); }

/* ---------- Pastille d'icône de module ---------- */
.pb-mod-ico {
  --pb-tint: var(--pb-accent-text);
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: color-mix(in srgb, var(--pb-tint) 78%, var(--pb-text));
  background: color-mix(in srgb, var(--pb-tint) 13%, transparent);
}
.pb-mod-ico[data-module="box"]       { --pb-tint: var(--pb-tint-box); }
.pb-mod-ico[data-module="passwords"] { --pb-tint: var(--pb-tint-passwords); }
.pb-mod-ico[data-module="albums"]    { --pb-tint: var(--pb-tint-albums); }
.pb-mod-ico[data-module="memos"]     { --pb-tint: var(--pb-tint-memos); }
.pb-mod-ico[data-module="budget"]    { --pb-tint: var(--pb-tint-budget); }
.pb-mod-ico[data-module="agenda"]    { --pb-tint: var(--pb-tint-agenda); }
.pb-mod-ico[data-module="contacts"]  { --pb-tint: var(--pb-tint-contacts); }
.pb-mod-ico[data-module="consos"]    { --pb-tint: var(--pb-tint-consos); }

/* ---------- Utilitaires ---------- */
.pb-num { font-variant-numeric: tabular-nums; }
.pb-sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Sélecteur de langue (config/i18n.php : pb_lang_switcher) ---------- */
/* Menu déroulant compact « FR ▾ » de la barre de navigation */
.pb-lang-menu { position: relative; display: inline-flex; flex-shrink: 0; }
.pb-lang-toggle { gap: 5px; }
.pb-lang-toggle span { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.pb-lang-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 176px;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 6px;
  background: var(--pb-surface);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-r-card);
  box-shadow: var(--pb-shadow-pop);
}
.pb-lang-list[hidden] { display: none; }
.pb-lang-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--pb-text);
  font: 500 var(--pb-fs-13) var(--pb-font);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.pb-lang-option:hover { background: var(--pb-surface-2); }
.pb-lang-option[aria-current="true"] { background: var(--pb-accent-soft); color: var(--pb-accent-text); font-weight: 600; }
.pb-lang-option:focus-visible, .pb-lang-toggle:focus-visible { outline: 2px solid var(--pb-focus); outline-offset: 2px; }

/* Rangée FR · EN · DE · ES du menu mobile */
.pb-lang-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: 4px;
  margin: 0;
  padding: 4px;
  background: var(--pb-surface-2);
  border: 1px solid var(--pb-border);
  border-radius: 12px;
}
.pb-lang-inline .pb-lang-option { justify-content: center; min-height: 40px; font-weight: 600; }
.pb-lang-inline .pb-lang-option[aria-current="true"] { background: var(--pb-raised); color: var(--pb-text); box-shadow: var(--pb-shadow-seg); }

@media (max-width: 640px) {
  .pb-lang-option { min-height: 44px; }
  .pb-lang-list { right: -48px; }
}

/* ---------- Mobile : cibles tactiles et champs sans zoom ---------- */
@media (max-width: 640px) {
  .pb-btn { height: 44px; }
  .pb-btn-sm { height: 36px; }
  .pb-btn-icon { width: 44px; }
  .pb-btn-icon.pb-btn-sm { width: 36px; }
  .pb-input { height: 44px; font-size: 16px; }
  .pb-seg > button { height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .pb-btn, .pb-input { transition: none; }
}

/* =============================================================================
   3. Phase 1 : thème clair natif (sans conversion par script)

   Portée :
     - les pages migrées, marquées <html data-pb-native> par le script de <head>
       (liste dans config/bootstrap.php ; pour l'instant : tableau de bord) ;
     - la barre de navigation (#pbMainTopNavbar), sur toutes les pages.
   Les autres pages restent sur l'ancien système (navbar.php) jusqu'à leur migration.
   Le thème sombre n'est pas modifié : tout ce bloc ne s'applique qu'en clair.

   Les classes Tailwind sombres sont reliées aux variables. Le motif
   [class^="X"],[class*=" X"] couvre X et ses variantes d'opacité (X/80)
   sans toucher aux variantes de survol (hover:X).
   ========================================================================== */

/* Contrôles natifs (barres de défilement, listes) en clair sur les pages migrées */
html[data-pb-theme="light"][data-pb-native] { color-scheme: light; }

/* Îlots volontairement sombres en mode clair (présentation des modules, visionneuse photo) :
   les variables y reprennent les valeurs sombres, donc tout reste lisible.
   Les --pbl-* (couleurs des modules) sont remises à « initial » : leur valeur de repli,
   c'est-à-dire la couleur sombre d'origine, s'applique alors. */
html[data-pb-theme="light"] :is(#module-preview-modal, #viewer-modal) {
  --pbl-bd-base: initial; --pbl-bd-strong: initial;
  --pbl-bg-k0: initial; --pbl-bg-k1: initial; --pbl-bg-k2: initial; --pbl-bg-k3: initial;
  --pbl-bg-k4: initial; --pbl-bg-k5: initial; --pbl-bg-overlay: initial; --pbl-shadow: initial;
  --pbl-tx-text: initial; --pbl-tx-muted: initial; --pbl-tx-faint: initial;
  --pbl-tx-2dd4bf: initial; --pbl-tx-34d399: initial; --pbl-tx-38bdf8: initial; --pbl-tx-5eead4: initial;
  --pbl-tx-60a5fa: initial; --pbl-tx-67e8f9: initial; --pbl-tx-6ee7b7: initial; --pbl-tx-818cf8: initial;
  --pbl-tx-93c5fd: initial; --pbl-tx-a5b4fc: initial; --pbl-tx-a5f3fc: initial; --pbl-tx-a78bfa: initial;
  --pbl-tx-a7f3d0: initial; --pbl-tx-bae6fd: initial; --pbl-tx-c084fc: initial; --pbl-tx-c4b5fd: initial;
  --pbl-tx-c7d2fe: initial; --pbl-tx-ddd6fe: initial; --pbl-tx-e9d5ff: initial; --pbl-tx-f472b6: initial;
  --pbl-tx-f87171: initial; --pbl-tx-fb7185: initial; --pbl-tx-fb923c: initial; --pbl-tx-fbbf24: initial;
  --pbl-tx-fcd34d: initial; --pbl-tx-fda4af: initial; --pbl-tx-fdba74: initial; --pbl-tx-fde047: initial;
  --pbl-tx-fde68a: initial; --pbl-tx-fecdd3: initial;
}
html[data-pb-theme="light"] :is(#module-preview-modal, #viewer-modal) {
  color-scheme: dark;
  --pb-bg: #0a101c; --pb-surface: #111a2b; --pb-surface-2: #172236; --pb-surface-3: #1f2c44; --pb-raised: #24324c;
  --pb-border: #223049; --pb-border-strong: #304060;
  --pb-text: #e7ecf3; --pb-muted: #a0abbd; --pb-faint: #7d8a9e;
  --pb-accent-text: #8eb0ff; --pb-accent-soft: rgba(96, 142, 255, .15);
  --pb-success: #56cba0; --pb-success-soft: rgba(86, 203, 160, .13);
  --pb-warning: #f1b862; --pb-warning-soft: rgba(241, 184, 98, .13);
  --pb-danger: #f38b95; --pb-danger-soft: rgba(243, 139, 149, .13);
  --pb-backdrop: rgba(2, 6, 14, .7);
}

/* ---------- Couleurs écrites en dur dans les modules ----------
   Les blocs <style> des modules utilisent var(--pbl-…, couleur d'origine).
   Ces variables ne sont définies qu'ici, en clair et sur les pages migrées :
   partout ailleurs, la couleur d'origine (repli) s'applique, à l'identique. */
html[data-pb-theme="light"][data-pb-native] {
  /* Fonds sombres neutres, du plus foncé (k0) au plus clair (k5) */
  --pbl-bg-k0: var(--pb-surface-2);
  --pbl-bg-k1: var(--pb-surface);
  --pbl-bg-k2: var(--pb-surface-2);
  --pbl-bg-k3: var(--pb-surface-3);
  --pbl-bg-k4: var(--pb-surface-3);
  --pbl-bg-k5: var(--pb-border-strong);
  --pbl-bg-overlay: var(--pb-backdrop);
  /* Bordures */
  --pbl-bd-base: var(--pb-border);
  --pbl-bd-strong: var(--pb-border-strong);
  /* Textes neutres clairs */
  --pbl-tx-text: var(--pb-text);
  --pbl-tx-muted: var(--pb-muted);
  --pbl-tx-faint: var(--pb-faint);
  /* Ombres sombres -> ombre légère */
  --pbl-shadow: 0 1px 3px rgba(15, 24, 40, .08);
  /* Textes colorés pastel (prévus pour fond sombre) -> foncés pour rester lisibles sur clair */
  --pbl-tx-2dd4bf: color-mix(in srgb, #2dd4bf 45%, #0f1828);
  --pbl-tx-34d399: color-mix(in srgb, #34d399 45%, #0f1828);
  --pbl-tx-38bdf8: color-mix(in srgb, #38bdf8 45%, #0f1828);
  --pbl-tx-5eead4: color-mix(in srgb, #5eead4 45%, #0f1828);
  --pbl-tx-60a5fa: color-mix(in srgb, #60a5fa 45%, #0f1828);
  --pbl-tx-67e8f9: color-mix(in srgb, #67e8f9 45%, #0f1828);
  --pbl-tx-6ee7b7: color-mix(in srgb, #6ee7b7 45%, #0f1828);
  --pbl-tx-818cf8: color-mix(in srgb, #818cf8 45%, #0f1828);
  --pbl-tx-93c5fd: color-mix(in srgb, #93c5fd 45%, #0f1828);
  --pbl-tx-a5b4fc: color-mix(in srgb, #a5b4fc 45%, #0f1828);
  --pbl-tx-a5f3fc: color-mix(in srgb, #a5f3fc 45%, #0f1828);
  --pbl-tx-a78bfa: color-mix(in srgb, #a78bfa 45%, #0f1828);
  --pbl-tx-a7f3d0: color-mix(in srgb, #a7f3d0 45%, #0f1828);
  --pbl-tx-bae6fd: color-mix(in srgb, #bae6fd 45%, #0f1828);
  --pbl-tx-c084fc: color-mix(in srgb, #c084fc 45%, #0f1828);
  --pbl-tx-c4b5fd: color-mix(in srgb, #c4b5fd 45%, #0f1828);
  --pbl-tx-c7d2fe: color-mix(in srgb, #c7d2fe 45%, #0f1828);
  --pbl-tx-ddd6fe: color-mix(in srgb, #ddd6fe 45%, #0f1828);
  --pbl-tx-e9d5ff: color-mix(in srgb, #e9d5ff 45%, #0f1828);
  --pbl-tx-f472b6: color-mix(in srgb, #f472b6 45%, #0f1828);
  --pbl-tx-f87171: color-mix(in srgb, #f87171 45%, #0f1828);
  --pbl-tx-fb7185: color-mix(in srgb, #fb7185 45%, #0f1828);
  --pbl-tx-fb923c: color-mix(in srgb, #fb923c 45%, #0f1828);
  --pbl-tx-fbbf24: color-mix(in srgb, #fbbf24 45%, #0f1828);
  --pbl-tx-fcd34d: color-mix(in srgb, #fcd34d 45%, #0f1828);
  --pbl-tx-fda4af: color-mix(in srgb, #fda4af 45%, #0f1828);
  --pbl-tx-fdba74: color-mix(in srgb, #fdba74 45%, #0f1828);
  --pbl-tx-fde047: color-mix(in srgb, #fde047 45%, #0f1828);
  --pbl-tx-fde68a: color-mix(in srgb, #fde68a 45%, #0f1828);
  --pbl-tx-fecdd3: color-mix(in srgb, #fecdd3 45%, #0f1828);
}

/* La visionneuse photo garde son fond presque opaque. */
html[data-pb-theme="light"] #viewer-modal { background-color: rgba(0, 0, 0, .95) !important; }

/* ---------- Tableur (Box) : en-têtes de lignes et de colonnes ----------
   Leurs couleurs sombres sont écrites dans le HTML du tableur ; on les remplace
   ici à l'affichage, sans modifier le contenu enregistré. */
html[data-pb-theme="light"][data-pb-native] #datos-spreadsheet :is(.sheet-row-num, thead th) {
  background-color: var(--pb-surface-2) !important;
  color: var(--pb-muted) !important;
  border-color: var(--pb-border) !important;
}

/* ---------- Graphiques SVG : traits et textes prévus pour fond sombre ---------- */
html[data-pb-theme="light"][data-pb-native] svg :is(line, circle, path, rect, polyline):is([stroke="#1e293b"], [stroke="#0f172a"], [stroke="#020617"], [stroke="#334155"]) {
  stroke: var(--pb-surface-3);
}
html[data-pb-theme="light"][data-pb-native] svg :is(line, path):is([stroke="#475569"], [stroke="#64748b"]) {
  stroke: var(--pb-border-strong);
}
html[data-pb-theme="light"][data-pb-native] svg text:is([fill="#94a3b8"], [fill="#cbd5e1"], [fill="#64748b"]) { fill: var(--pb-muted); }
html[data-pb-theme="light"][data-pb-native] svg text:is([fill="#ffffff"], [fill="#fff"], [fill="#f8fafc"], [fill="#e2e8f0"], [fill="white"]) { fill: var(--pb-text); }

/* ---------- Fond de page ----------
   Le corps de page et les bandes pleine largeur (section/header/main en bg-slate-950)
   prennent le fond de page, pas la couleur de surface des cartes. */
html[data-pb-theme="light"][data-pb-native] body {
  background-color: var(--pb-bg) !important;
  color: var(--pb-text);
}
/* !important : les correspondances ci-dessous ont le poids d'un identifiant (#pbMainTopNavbar dans leur :is). */
html[data-pb-theme="light"][data-pb-native] body :is(section, header, main):is([class^="bg-slate-950"], [class*=" bg-slate-950"]) {
  background-color: var(--pb-bg) !important;
}

/* ---------- Fonds neutres ---------- */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-slate-950"], [class*=" bg-slate-950"], [class^="bg-gray-950"], [class*=" bg-gray-950"]) { background-color: var(--pb-surface-2); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-slate-900"], [class*=" bg-slate-900"], [class^="bg-gray-900"], [class*=" bg-gray-900"]) { background-color: var(--pb-surface); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-slate-800"], [class*=" bg-slate-800"], [class^="bg-gray-800"], [class*=" bg-gray-800"]) { background-color: var(--pb-surface-2); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-slate-700"], [class*=" bg-slate-700"], [class^="bg-slate-600"], [class*=" bg-slate-600"]) { background-color: var(--pb-surface-3); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:bg-slate-950, .hover\:bg-slate-900):hover { background-color: var(--pb-surface-2); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:bg-slate-800, .hover\:bg-slate-700, .hover\:bg-slate-600):hover { background-color: var(--pb-surface-3); }

/* Voiles de fenêtres */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-black/"], [class*=" bg-black/"]) { background-color: var(--pb-backdrop); }

/* ---------- Fonds teintés sombres -> versions douces ---------- */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-blue-950"], [class*=" bg-blue-950"], [class^="bg-blue-900"], [class*=" bg-blue-900"],
      [class^="bg-indigo-950"], [class*=" bg-indigo-950"], [class^="bg-indigo-900"], [class*=" bg-indigo-900"],
      [class^="bg-sky-950"], [class*=" bg-sky-950"]) { background-color: var(--pb-accent-soft); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-emerald-950"], [class*=" bg-emerald-950"], [class^="bg-emerald-900"], [class*=" bg-emerald-900"],
      [class^="bg-green-950"], [class*=" bg-green-950"], [class^="bg-teal-950"], [class*=" bg-teal-950"]) { background-color: var(--pb-success-soft); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-rose-950"], [class*=" bg-rose-950"], [class^="bg-rose-900"], [class*=" bg-rose-900"],
      [class^="bg-red-950"], [class*=" bg-red-950"]) { background-color: var(--pb-danger-soft); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="bg-amber-950"], [class*=" bg-amber-950"], [class^="bg-amber-900"], [class*=" bg-amber-900"],
      [class^="bg-yellow-950"], [class*=" bg-yellow-950"], [class^="bg-orange-950"], [class*=" bg-orange-950"]) { background-color: var(--pb-warning-soft); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:bg-rose-950, .hover\:bg-rose-900, .hover\:bg-red-950):hover { background-color: var(--pb-danger-soft); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:bg-blue-950, .hover\:bg-blue-900):hover { background-color: var(--pb-accent-soft); }

/* Dégradés sombres (from-slate-…) -> surface unie */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class*="from-slate-9"], [class*="from-slate-8"], [class*="from-gray-9"]) { background-image: none; background-color: var(--pb-surface); }

/* ---------- Bordures ---------- */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="border-slate-950"], [class*=" border-slate-950"], [class^="border-slate-900"], [class*=" border-slate-900"],
      [class^="border-slate-800"], [class*=" border-slate-800"], [class^="border-gray-800"], [class*=" border-gray-800"]) { border-color: var(--pb-border); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="border-slate-700"], [class*=" border-slate-700"], [class^="border-slate-600"], [class*=" border-slate-600"],
      [class^="border-gray-700"], [class*=" border-gray-700"]) { border-color: var(--pb-border-strong); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:border-slate-700, .hover\:border-slate-600, .hover\:border-slate-500):hover { border-color: var(--pb-border-strong); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.divide-slate-800, .divide-slate-700) > :not([hidden]) ~ :not([hidden]) { border-color: var(--pb-border); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="border-blue-950"], [class*=" border-blue-950"], [class^="border-blue-900"], [class*=" border-blue-900"],
      [class^="border-blue-800"], [class*=" border-blue-800"], [class^="border-indigo-800"], [class*=" border-indigo-800"]) { border-color: color-mix(in srgb, var(--pb-accent) 28%, transparent); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="border-emerald-900"], [class*=" border-emerald-900"], [class^="border-emerald-800"], [class*=" border-emerald-800"],
      [class^="border-emerald-700"], [class*=" border-emerald-700"]) { border-color: color-mix(in srgb, var(--pb-success) 30%, transparent); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="border-rose-900"], [class*=" border-rose-900"], [class^="border-rose-800"], [class*=" border-rose-800"],
      [class^="border-rose-700"], [class*=" border-rose-700"], [class^="border-red-800"], [class*=" border-red-800"]) { border-color: color-mix(in srgb, var(--pb-danger) 30%, transparent); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="border-amber-900"], [class*=" border-amber-900"], [class^="border-amber-800"], [class*=" border-amber-800"],
      [class^="border-amber-700"], [class*=" border-amber-700"]) { border-color: color-mix(in srgb, var(--pb-warning) 32%, transparent); }

/* ---------- Textes neutres ---------- */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-white"], [class*=" text-white"], .text-slate-50, [class^="text-slate-100"], [class*=" text-slate-100"],
      [class^="text-slate-200"], [class*=" text-slate-200"], [class^="text-gray-100"], [class*=" text-gray-100"],
      [class^="text-gray-200"], [class*=" text-gray-200"]) { color: var(--pb-text); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-slate-300"], [class*=" text-slate-300"], [class^="text-slate-400"], [class*=" text-slate-400"],
      [class^="text-gray-300"], [class*=" text-gray-300"], [class^="text-gray-400"], [class*=" text-gray-400"]) { color: var(--pb-muted); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-slate-500"], [class*=" text-slate-500"], [class^="text-slate-600"], [class*=" text-slate-600"],
      [class^="text-gray-500"], [class*=" text-gray-500"]) { color: var(--pb-faint); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:text-white, .hover\:text-slate-100, .hover\:text-slate-200):hover { color: var(--pb-text); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:text-slate-300, .hover\:text-slate-400):hover { color: var(--pb-muted); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.placeholder-slate-500, .placeholder-slate-600, .placeholder-slate-400)::placeholder { color: var(--pb-faint); }

/* ---------- Textes colorés clairs (prévus pour le sombre) -> versions lisibles sur clair ---------- */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-blue-100"], [class*=" text-blue-100"], [class^="text-blue-200"], [class*=" text-blue-200"],
      [class^="text-blue-300"], [class*=" text-blue-300"], [class^="text-blue-400"], [class*=" text-blue-400"],
      [class^="text-indigo-200"], [class*=" text-indigo-200"], [class^="text-indigo-300"], [class*=" text-indigo-300"],
      [class^="text-indigo-400"], [class*=" text-indigo-400"]) { color: var(--pb-accent-text); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.hover\:text-blue-300, .hover\:text-blue-400):hover,
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  .group:hover :is(.group-hover\:text-blue-400, .group-hover\:text-blue-300) { color: var(--pb-accent-hover); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-emerald-100"], [class*=" text-emerald-100"], [class^="text-emerald-200"], [class*=" text-emerald-200"],
      [class^="text-emerald-300"], [class*=" text-emerald-300"], [class^="text-emerald-400"], [class*=" text-emerald-400"],
      [class^="text-green-300"], [class*=" text-green-300"], [class^="text-green-400"], [class*=" text-green-400"],
      [class^="text-teal-300"], [class*=" text-teal-300"], [class^="text-teal-400"], [class*=" text-teal-400"]) { color: var(--pb-success); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-rose-100"], [class*=" text-rose-100"], [class^="text-rose-200"], [class*=" text-rose-200"],
      [class^="text-rose-300"], [class*=" text-rose-300"], [class^="text-rose-400"], [class*=" text-rose-400"],
      [class^="text-red-300"], [class*=" text-red-300"], [class^="text-red-400"], [class*=" text-red-400"]) { color: var(--pb-danger); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-amber-100"], [class*=" text-amber-100"], [class^="text-amber-200"], [class*=" text-amber-200"],
      [class^="text-amber-300"], [class*=" text-amber-300"], [class^="text-amber-400"], [class*=" text-amber-400"],
      [class^="text-yellow-300"], [class*=" text-yellow-300"], [class^="text-yellow-400"], [class*=" text-yellow-400"],
      [class^="text-orange-300"], [class*=" text-orange-300"], [class^="text-orange-400"], [class*=" text-orange-400"]) { color: var(--pb-warning); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-violet-300"], [class*=" text-violet-300"], [class^="text-violet-400"], [class*=" text-violet-400"],
      [class^="text-purple-300"], [class*=" text-purple-300"], [class^="text-purple-400"], [class*=" text-purple-400"]) { color: #6d28d9; }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-sky-300"], [class*=" text-sky-300"], [class^="text-sky-400"], [class*=" text-sky-400"],
      [class^="text-cyan-300"], [class*=" text-cyan-300"], [class^="text-cyan-400"], [class*=" text-cyan-400"]) { color: #0369a1; }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is([class^="text-pink-300"], [class*=" text-pink-300"], [class^="text-pink-400"], [class*=" text-pink-400"],
      [class^="text-fuchsia-300"], [class*=" text-fuchsia-300"], [class^="text-fuchsia-400"], [class*=" text-fuchsia-400"]) { color: #be185d; }

/* ---------- Ombres adoucies en clair ---------- */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.shadow-2xl, .shadow-xl) { box-shadow: var(--pb-shadow-pop); }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.shadow-lg, .shadow-md, .shadow) { box-shadow: 0 1px 3px rgba(15, 24, 40, .08); }

/* ---------- Exceptions : texte blanc sur fonds colorés pleins (boutons, bandeaux) ----------
   Placées en dernier pour l'emporter sur les correspondances ci-dessus. */
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.bg-blue-500, .bg-blue-600, .bg-blue-700, .bg-indigo-500, .bg-indigo-600, .bg-violet-500, .bg-violet-600,
      .bg-purple-500, .bg-purple-600, .bg-emerald-500, .bg-emerald-600, .bg-teal-600, .bg-rose-500, .bg-rose-600,
      .bg-red-500, .bg-red-600, .bg-amber-500, .bg-amber-600, .bg-cyan-600, .bg-pink-600,
      [class*="from-blue-5"], [class*="from-blue-6"], [class*="from-indigo-5"], [class*="from-indigo-6"],
      [class*="from-violet-6"], [class*="from-emerald-5"], [class*="from-emerald-6"], [class*="from-rose-5"], [class*="from-rose-6"]),
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.bg-blue-500, .bg-blue-600, .bg-blue-700, .bg-indigo-500, .bg-indigo-600, .bg-violet-500, .bg-violet-600,
      .bg-purple-500, .bg-purple-600, .bg-emerald-500, .bg-emerald-600, .bg-teal-600, .bg-rose-500, .bg-rose-600,
      .bg-red-500, .bg-red-600, .bg-amber-500, .bg-amber-600, .bg-cyan-600, .bg-pink-600,
      [class*="from-blue-5"], [class*="from-blue-6"], [class*="from-indigo-5"], [class*="from-indigo-6"],
      [class*="from-violet-6"], [class*="from-emerald-5"], [class*="from-emerald-6"], [class*="from-rose-5"], [class*="from-rose-6"]) * { color: #ffffff; }
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.bg-blue-500, .bg-blue-600, .bg-blue-700, .bg-indigo-600, .bg-emerald-600, .bg-rose-600, .bg-red-600,
      [class*="from-blue-6"], [class*="from-indigo-6"]):hover,
:is(html[data-pb-theme="light"][data-pb-native], html[data-pb-theme="light"] #pbMainTopNavbar)
  :is(.bg-blue-500, .bg-blue-600, .bg-blue-700, .bg-indigo-600, .bg-emerald-600, .bg-rose-600, .bg-red-600,
      [class*="from-blue-6"], [class*="from-indigo-6"]) :hover { color: #ffffff; }
