/* Thème commun à toutes les apps (clair / sombre / auto).
   Les apps utilisent les mêmes variables (--ink, --white, --soft, --line, --muted, --brand-tint, --brand-dark, --shadow).
   Chargé après style.css, avant le CSS de chaque app.
   theme.js pose toujours data-theme="light" ou "dark" sur <html> (même en mode « auto »),
   donc ces règles priment sur les @media (prefers-color-scheme) de style.css. */

/* Couleur de marque : violet, identique sur tout le site (clair et sombre).
   C'est la SEULE définition : les apps et la palette lisent --brand / --accent. */
:root {
    --brand: #5b4bdb;
    --brand-dark: #4a3cc0;
    --brand-tint: #eeebfc;
    --on-brand: #fff;                 /* texte posé sur un fond --brand */
    --accent: var(--brand);
    --on-accent: var(--on-brand);
}

/* Clair : on réaffirme les valeurs de base pour qu'un appareil en mode sombre
   ne les écrase pas quand la personne a choisi « Clair » (voir @media dans style.css). */
html[data-theme="light"],
html[data-theme="light"] body {
    color-scheme: light;
    --ink: #1F1B2E;
    --muted: #6A6580;
    --line: #DDD9E8;
}

/* Sombre */
html[data-theme="dark"],
html[data-theme="dark"] body {
    color-scheme: dark;
    --ink: #e8ecf4;
    --white: #171c28;
    --soft: #1f2535;
    --line: #2e3547;
    --muted: #9aa5ba;
    --brand: #9a8cff;
    --brand-tint: #2b2547;
    --brand-dark: #b3a8ff;
    --on-brand: #17141f;
    --shadow: 0 8px 30px rgba(0, 0, 0, .45);
    /* États (boutons, badges, messages) et fenêtres : variantes sombres des variables de style.css */
    --danger: #ff8a80;
    --danger-dark: #ff6f61;
    --danger-soft: rgba(255, 138, 128, .14);
    --danger-line: rgba(255, 138, 128, .4);
    --on-danger: #17141f;
    --ok-soft: rgba(14, 159, 110, .2);
    --ok-ink: #6ee7b7;
    --warn-soft: rgba(255, 200, 87, .15);
    --warn-ink: #ffd27a;
    --backdrop: rgba(0, 0, 0, .65);
    --modal-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7);
}
html[data-theme="dark"] dialog::backdrop { background: rgba(0, 0, 0, .65); }
html[data-theme="dark"] body { background: #0f131c; color: var(--ink); }

/* Sélecteur de thème réutilisable (Auto / Clair / Sombre) — voir HostTheme.bind() dans theme.js
   Usage : <div class="theme-switch" role="group"> <button data-theme-choice="auto|light|dark">…</button> … </div> */
.theme-switch { display: inline-flex; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.theme-switch button { display: inline-flex; align-items: center; gap: 6px; padding: .5rem .9rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 600 .88rem/1 var(--font-body, inherit); cursor: pointer; transition: background .15s, color .15s; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 27, 51, .14); }
.theme-switch button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.theme-switch svg { width: 16px; height: 16px; flex: none; }
