:root {
    /* ================================================
       COULEURS DE BASE
       ================================================ */
    
    /* Fond principal (du plus sombre au plus clair) */
    --bg-darkest: #1a1918;
    --bg-darker: #1c1b19;
    --bg-dark: #1e1d1b;
    --bg-medium-dark: #201f1d;
    --bg-medium: #222120;
    --bg-medium-light: #242321;
    --bg-light: #252422;
    --bg-lighter: #2a2928;
    --bg-lightest: #323130;
    
    /* Fond avec transparence */
    --bg-overlay-dark: rgba(20, 19, 17, 0.95);
    
    /* ================================================
       BORDURES
       ================================================ */
    
    --border-darkest: rgba(50, 48, 42, 0.7);
    --border-dark: var(--border-window, rgba(70, 68, 62, 0.6));
    --border-medium: rgba(90, 88, 80, 0.4);
    --border-light: var(--border-window, rgba(120, 115, 105, 0.35));
    --border-lighter: rgba(150, 145, 135, 0.3);
    
    /* Bordures focus */

    /* ------------------------------------------------------------------
       CADRE DES FENÊTRES PRINCIPALES — source unique
       = STRICTEMENT la couleur --border-window (via --border-dark), SANS
       teinte d'accent : sinon un accent opaque empêcherait le bord de
       disparaître quand on pousse la transparence à fond.
       → transparence max = aucun bord ; couleur = même teinte partout,
         identique aux séparateurs internes (qui utilisent --border-dark).
       Le caractère propre à chaque thème vient de SA couleur de bord par
       défaut, pas d'une surcouche.
       ------------------------------------------------------------------ */
    --frame-border: var(--border-dark);

    /* ================================================
       COULEURS D'ACCENT
       ================================================ */
    
    /* Interactive States - PRIMARY (action positive, validation) */
    --interactive-primary-darkest: #7a8a55;
    --interactive-primary-dark: #9aaa75;
    --interactive-primary: #c5d4a0;
    --interactive-primary-light: #d5e4b0;
    --interactive-primary-bright: #e5f4c0;
    --interactive-primary-border: rgba(160, 180, 125, 0.7);
    --interactive-primary-glow: rgba(160, 190, 120, 0.5);

    /* Interactive States - SECONDARY (titre, highlight, important) */
    --interactive-secondary-dark: #a9901c;
    --interactive-secondary: #c9a227;
    --interactive-secondary-light: #e0c580;
    --interactive-secondary-border: rgba(215, 175, 105, 0.7);
    --interactive-secondary-border-hover: rgba(235, 195, 125, 0.8);
    --interactive-secondary-glow: rgba(215, 175, 105, 0.35);

    /* Interactive States - TERTIARY (accent, support, complément, warnings) */
    /* Nuances dérivées AUTOMATIQUEMENT de --interactive-tertiary : le curseur du
       personnaliseur ET le thème actif pilotent toute la gamme via color-mix.
       Chaque thème n'a qu'à redéfinir la base. (cf. danger) */
    --interactive-tertiary: #d4b0a0;
    --interactive-tertiary-border:       color-mix(in srgb, var(--interactive-tertiary) 65%, transparent);
    --interactive-tertiary-border-hover: color-mix(in srgb, var(--interactive-tertiary) 78%, transparent);

    /* Interactive States - DANGER (destructif, alerte, erreur) */
    /* Nuances sombres dérivées AUTOMATIQUEMENT de --interactive-danger :
       elles suivent la base (thème + personnalisation), aucune valeur à
       maintenir par thème. color-mix résout --interactive-danger avec la
       valeur en vigueur sur l'élément (donc le danger du thème actif). */
    --interactive-danger-dark:    color-mix(in srgb, var(--interactive-danger) 72%, #000);
    --interactive-danger: #e07050;
    --interactive-danger-light: #f08060;
    --interactive-danger-border: rgba(200, 80, 60, 0.7);
    --interactive-danger-glow: rgba(200, 80, 60, 0.5);

    /* Interactive States - INFO (infos, liens, détails) */
    /* Nuances dérivées AUTOMATIQUEMENT de --interactive-info : curseur + thème
       pilotent toute la gamme via color-mix. Chaque thème ne redéfinit que la base. */
    --interactive-info: #7a9aba;
    --interactive-info-light:   color-mix(in srgb, var(--interactive-info) 74%, #fff);
    --interactive-info-border:       color-mix(in srgb, var(--interactive-info) 70%, transparent);
    --interactive-info-glow:         color-mix(in srgb, var(--interactive-info) 40%, transparent);

    /* Additional utility aliases */
    --cyber-black: var(--bg-darkest);
    --rust-orange: #c9632e;
    --rust-orange-bright: #e07050;
    
    /* ================================================
       TEXTE
       ================================================ */
    
    --text-bright: #ffffff;
    --text-primary: #f0ebe0;
    --text-secondary: #d5d0c5;
    --text-muted: #a0a095;
    --text-faded: var(--text-muted);
    --text-disabled: #6a6860;
    --text-placeholder: #555550;

    /* Legacy aliases for backward compatibility */
    --text-main: var(--text-primary);
    
    /* Texte sur accents */
    
    /* ================================================
       OVERLAYS (Couleurs translucides - CSS seulement)
       ================================================ */

    /* Overlays noirs pour assombrissement (très commun) */
    --overlay-black-lightest: rgba(0, 0, 0, 0.15);  /* À peine visible */
    --overlay-black-light: rgba(0, 0, 0, 0.25);     /* Léger assombrissement */
    --overlay-black-medium: rgba(0, 0, 0, 0.35);    /* Assombrissement moyen */
    --overlay-black-strong: rgba(0, 0, 0, 0.5);     /* Assombrissement fort */
    --overlay-black-darker: rgba(0, 0, 0, 0.6);     /* Très assombri */
    --overlay-black-very-dark: rgba(0, 0, 0, 0.85); /* Quasi opaque */
    --overlay-black-almost-opaque: rgba(0, 0, 0, 0.9); /* Presque complètement opaque */

    /* ================================================
       BOUTON MENU (métal patiné - header)
       ================================================ */
    
    --btn-menu-bg: linear-gradient(180deg, rgba(85, 85, 85, 0.85) 0%, rgba(60, 60, 60, 0.9) 50%, rgba(40, 40, 40, 0.95) 100%);
    --btn-menu-bg-hover: linear-gradient(180deg, rgba(100, 100, 100, 0.9) 0%, rgba(80, 80, 80, 0.92) 50%, rgba(60, 60, 60, 0.96) 100%);
    --btn-menu-bg-active: linear-gradient(180deg, rgba(60, 60, 60, 0.9) 0%, rgba(40, 40, 40, 0.95) 50%, rgba(30, 30, 30, 0.98) 100%);
    
    --btn-menu-text: var(--text-secondary);
    --btn-menu-text-hover: #ffffff;
    --btn-menu-text-active: var(--interactive-primary);
    
    --btn-menu-border: rgba(100, 100, 100, 0.5);
    --btn-menu-border-hover: rgba(140, 140, 140, 0.65);
    --btn-menu-border-active: rgba(140, 170, 100, 0.6);
    
    --btn-menu-shadow: inset 0 1px 0 rgba(150, 150, 150, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.3);
    --btn-menu-shadow-hover: inset 0 1px 0 rgba(180, 180, 180, 0.2), 0 0 12px rgba(150, 150, 150, 0.2), 0 3px 6px rgba(0, 0, 0, 0.4);
    --btn-menu-shadow-active: inset 0 2px 4px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2);
    
    /* ================================================
       BOUTON SUBMENU (variante plus subtile)
       ================================================ */
    
    --btn-submenu-bg: linear-gradient(180deg, rgba(80, 80, 80, 0.6) 0%, rgba(50, 50, 50, 0.75) 100%);
    --btn-submenu-bg-hover: linear-gradient(180deg, rgba(100, 100, 100, 0.75) 0%, rgba(70, 70, 70, 0.88) 100%);
    --btn-submenu-bg-active: linear-gradient(180deg, rgba(60, 60, 60, 0.8) 0%, rgba(40, 40, 40, 0.9) 100%);
    
    --btn-submenu-text: var(--text-secondary);
    --btn-submenu-text-hover: #ffffff;
    --btn-submenu-text-active: var(--interactive-primary);
    
    --btn-submenu-border: rgba(100, 100, 100, 0.35);
    --btn-submenu-border-hover: rgba(140, 140, 140, 0.45);
    
    --btn-submenu-shadow: inset 0 1px 0 rgba(150, 150, 150, 0.1), 0 1px 3px rgba(0, 0, 0, 0.25);
    --btn-submenu-shadow-hover: 0 0 8px rgba(150, 150, 150, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3);
    --btn-submenu-shadow-active: inset 0 1px 3px rgba(0, 0, 0, 0.3);

    /* ================================================
       BOUTON DANGER (utilisé dans UI spécifiques)
       ================================================ */

    --btn-danger-bg: linear-gradient(180deg, #6a3530 0%, #4a2520 100%);
    --btn-danger-bg-hover: linear-gradient(180deg, #7a4540 0%, #5a3530 100%);

    /* ================================================
       INPUTS (tous les états)
       ================================================ */
    
    --input-bg: linear-gradient(180deg, rgba(25, 23, 20, 0.85) 0%, rgba(18, 16, 14, 0.9) 100%);
    --input-bg-hover: linear-gradient(180deg, rgba(30, 28, 25, 0.88) 0%, rgba(22, 20, 18, 0.92) 100%);
    --input-bg-focus: linear-gradient(180deg, rgba(28, 26, 22, 0.9) 0%, rgba(20, 18, 15, 0.95) 100%);
    
    --input-border: rgba(120, 115, 100, 0.4);
    --input-border-hover: rgba(140, 135, 120, 0.5);
    --input-border-focus: rgba(160, 180, 120, 0.5);
    
    --input-text: #d0ccc0;
    --input-text-focus: #f0ece0;
    
    --input-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
    --input-shadow-focus: inset 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 8px var(--interactive-primary-glow);
    
    /* ================================================
       CHECKBOX & RADIO (tous les états)
       ================================================ */
    
    --checkbox-bg: var(--bg-dark);
    --checkbox-bg-hover: var(--bg-medium);
    --checkbox-bg-checked: linear-gradient(180deg, #4a5835 0%, #3a4525 100%);
    
    --checkbox-border: var(--border-medium);
    --checkbox-border-hover: var(--border-light);
    --checkbox-border-checked: var(--interactive-primary-border);
    
    --checkbox-check-color: var(--interactive-primary);
    
    --checkbox-shadow-focus: 0 0 0 2px var(--interactive-primary-glow);
    
    /* ================================================
       SELECT / DROPDOWN (tous les états)
       ================================================ */
    
    --select-bg: var(--input-bg);
    
    --select-border: var(--input-border);
    --select-border-hover: var(--input-border-hover);
    --select-border-focus: var(--input-border-focus);
    
    --select-text: var(--input-text);
    
    /* ================================================
       SHADOWS
       ================================================ */
    
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.5);
    --shadow-strong: 0 10px 40px rgba(0, 0, 0, 0.6);
    --shadow-panel: 0 10px 50px rgba(0, 0, 0, 0.7);
    /* Fenêtres du HUD : liseré sombre + ombre serrée + ombre large, pour rester détachées d'un fond clair (image de jour) */
    --shadow-fenetre: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 0 10px 1px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.65), 0 12px 30px rgba(0, 0, 0, 0.6);
    
    /* Glow shadows */
    --shadow-glow-red: 0 0 20px var(--interactive-danger-glow);
    
    /* ================================================
       TRANSITIONS
       ================================================ */
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    
    /* Specific transitions */
    
    /* ================================================
       BORDER RADIUS
       ================================================ */
    
    --radius-xs: 2px;
    --radius-small: 4px;
    --radius-medium: 6px;
    --radius-large: 8px;
    --radius-xl: 12px;
    
    /* ================================================
       TYPOGRAPHY
       ================================================ */
    
    --font-family-base: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-family-display: 'Georgia', 'Times New Roman', serif;
    
    /* Tailles brutes */
    --font-size-xs:   9px;
    --font-size-sm:   10px;
    --font-size-base: 11px;
    --font-size-md:   12px;
    --font-size-lg:   14px;

    /* ── Variables sémantiques d'interface ──────────────────────
       Modifier ici pour changer globalement une catégorie de texte.
       Respecter la contrainte : minimum 0.75em / 9px.
    */
    --t-font-label:    var(--font-size-base); /* labels sous icônes, statusbar  → 11px */
    --t-font-terminal: var(--font-size-md);   /* terminal deck, output           → 12px */
    --t-font-topbar:   var(--font-size-md);   /* liens de la topbar              → 12px */

    --font-weight-medium: 500;
    
    --letter-spacing-wide: 0.025em;
    
}

body.theme-light {
    --bg-darkest: #e8e6e2;
    --bg-darker: #eceae6;
    --bg-dark: #f0eee8;
    --bg-medium: #f5f3ef;
    --bg-light: #faf8f5;
    --bg-lighter: #fdfcfa;
    --bg-lightest: #ffffff;
    
    --text-primary: #2a2825;
    --text-secondary: #4a4845;
    --text-muted: #8a8885;
    --text-disabled: #aaa8a5;
    
    --border-dark: var(--border-window, rgba(100, 95, 85, 0.3));
    --border-medium: rgba(120, 115, 105, 0.25);
    --border-light: var(--border-window, rgba(140, 135, 125, 0.2));
    
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.15);
    --shadow-strong: 0 10px 40px rgba(0, 0, 0, 0.2);
    --shadow-fenetre: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 12px 1px rgba(0, 0, 0, 0.35), 0 6px 14px rgba(0, 0, 0, 0.45), 0 16px 40px rgba(0, 0, 0, 0.5);
}

body.theme-neon {
    --interactive-primary-bright: #3affda;
    --interactive-primary-glow: rgba(20, 232, 200, 0.5);
    
    --interactive-secondary-light: #ffdd55;
    --interactive-secondary-glow: rgba(255, 204, 0, 0.4);
    
    --interactive-danger-glow: rgba(255, 51, 102, 0.5);
    
}

body.high-contrast {
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #c0c0c0;
    --border-light: var(--border-window, rgba(180, 175, 165, 0.5));
}

/* Thème daltonien (deutéranopie) */
body.colorblind-deuteranopia {
    --interactive-primary-border: rgba(160, 160, 255, 0.7);
    --interactive-secondary-border: rgba(255, 160, 160, 0.7);
    --interactive-tertiary: #a0ffa0;
    --interactive-tertiary-border: rgba(160, 255, 160, 0.7);
}

/* Thème daltonien (protanopie) */
body.colorblind-protanopia {
    --interactive-primary-border: rgba(128, 192, 255, 0.7);
    --interactive-secondary-border: rgba(255, 255, 128, 0.7);
    --interactive-danger-border: rgba(128, 128, 255, 0.7);
}

/* Réduction des mouvements */
@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0s;
        --transition-normal: 0s;
    }
}

/* Mode sombre système */
@media (prefers-color-scheme: dark) {
    :root:not(.theme-light) {
        /* Déjà en mode sombre par défaut */
    }
}

/* Mode clair système */
@media (prefers-color-scheme: light) {
    :root.theme-auto {
        --bg-darkest: #e8e6e2;
        --bg-dark: #f0eee8;
        --text-primary: #2a2825;
        --text-secondary: #4a4845;
    }
}

/* Taille de police augmentée */
body.large-text {
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 13px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
}

/* Taille de police réduite */
body.small-text {
    --font-size-xs: 8px;
    --font-size-sm: 9px;
    --font-size-base: 10px;
    --font-size-md: 11px;
    --font-size-lg: 12px;
}

:root {
    /* Arrière-plans */
    --t-bg0:       var(--bg-darkest);
    --t-bg1:       var(--bg-darker);
    --t-bg2:       var(--bg-medium);
    --t-bg3:       var(--bg-lightest);
    /* Bordures */
    --t-border:    var(--border-dark);
    --t-border-s:  var(--border-light);
    /* Accents (backward-compat aliases) */
    --t-accent1:   var(--interactive-primary);
    --t-accent1d:  var(--interactive-primary-dark);
    --t-accent2:   var(--interactive-secondary);
    --t-danger:    var(--interactive-danger);
    /* Texte */
    --t-text1:     var(--text-primary);
    --t-text2:     var(--text-secondary);
    --t-text3:     var(--text-muted);
    /* Écran terminal / LED */
    --t-screen:    var(--bg-darkest);
    --t-led:       var(--interactive-primary);
    /* Ombres / glow */
    --t-shadow:    0 4px 20px rgba(0,0,0,0.8);
    --t-glow:      var(--interactive-primary-glow);
    /* Éléments UI */
    --t-tabbg:     rgba(30,29,27,0.6);
    --t-btnbg:     rgba(40,38,35,0.5);
    --t-btnhov:    rgba(140,160,100,0.15);
    --t-grid:      rgba(100,120,80,0.12);
    /* HUD (widget personnage) */
    --t-hud-base:  #829b5a;
    --t-hud:       color-mix(in srgb, var(--t-hud-base) 65%, transparent);
    --t-hud-dim:   color-mix(in srgb, var(--t-hud-base) 35%, transparent);
    /* Joueur (pseudo, stats) */
    --t-player:    var(--interactive-primary);
    --t-player-bg: rgba(150,180,100,0.12);
    /* Widget personnage - customisable */
    --widget-player-health: var(--interactive-primary);    /* Barre santé */
    --widget-player-energy: var(--interactive-primary);    /* Barre forme */
    --widget-player-souffle: var(--t-accent1);             /* Jauge de souffle (bord haut de la carte) */
    /* Tchat / log couleurs de fond */
    --t-tchat-c:   rgba(120,145,80,0.55);
    --t-log-c:     rgba(197,212,160,0.08);
    /* Dégradés coins HUD (designcarte / designperso) */
    --t-hud-c68:   color-mix(in srgb, var(--t-hud-base) 68%, transparent);
    --t-hud-c60:   color-mix(in srgb, var(--t-hud-base) 60%, transparent);
    --t-hud-c58:   color-mix(in srgb, var(--t-hud-base) 58%, transparent);
    --t-hud-c50:   color-mix(in srgb, var(--t-hud-base) 50%, transparent);
}

/* Les thèmes du jeu ([data-theme="…"]) ne sont plus écrits ici : ils sont en base (table `theme`,
   migration 467), réglés dans Communication › Thèmes et posés par ingame.php juste après cette feuille
   (core/gameplay/theme_catalogue_lib.php, theme_feuille()). */
