/**
 * Mode sombre — chargé après vise20.css / additions.
 * Palette : bleu nuit profond, cartes graphite, or tamisé, lisibilité WCAG-friendly.
 */
html[data-theme='dark'] {
  color-scheme: dark;

  --bg-main: #0c0f14;
  --card-bg: #161c26;
  --text-main: #e8ecf4;
  --text-muted: #94a0b8;
  --border-soft: #2a3344;
  --primary: #7eb0ff;
  --primary-dark: #5a8fd9;
  --gold-accent: #d4b87a;
  --success: #5cbf7a;

  --surface-page: #0c0f14;
  --surface-card: #161c26;
  --surface-tint-sat: #121a28;
  --surface-tint-med: #101c16;
  --surface-tint-warm: #18140e;
  --surface-scrim: rgba(10, 12, 18, 0.94);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 18px 40px rgba(0, 0, 0, 0.35);
  --shadow-cta: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 2px 12px rgba(90, 143, 217, 0.35);
  --shadow-cta-med: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 2px 10px rgba(60, 140, 90, 0.28);

  --noir: var(--text-main);
  --blanc: #1e2633;
  --or: var(--gold-accent);
  --or-clair: #e8d4a8;
  --or-dark: #b89a5e;
  --gris: var(--text-muted);
  --gris-clair: #2f3a4d;
  --creme: var(--bg-main);
  --rouge: #f08080;
  --vert: var(--success);
  --orange: #e8a060;
  --vert-bg: #14261c;
  --orange-bg: #2a1f14;
  --rouge-bg: #2a1518;
  --vert-border: #2d5a3d;
  --orange-border: #5a4530;
  --rouge-border: #5a3030;
  --card-border: var(--border-soft);

  --sat-blue: #8ab4ff;
  --sat-blue-light: #1a2438;
  --med-green: #7ecf9a;
  --med-green-light: #142018;
  --vise20-shadow-card: var(--shadow-sm);
  --vise20-shadow-hover: var(--shadow-md);
}

html[data-theme='dark'] body {
  background-color: var(--surface-page);
  background-image: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(100, 150, 255, 0.12), transparent 55%);
  color: var(--text-main);
}

html[data-theme='dark'] .wm-cell {
  color: rgba(232, 236, 244, 0.04);
}

html[data-theme='dark'] #screen-app.portal-premium {
  background-image: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(100, 150, 255, 0.1), transparent 55%);
}

html[data-theme='dark'] #screen-app.portal-premium .h-logo {
  color: var(--primary);
}

html[data-theme='dark'] #screen-app.portal-premium .simulator-sat {
  border-color: rgba(126, 176, 255, 0.22);
  background: linear-gradient(180deg, var(--surface-tint-sat) 0%, var(--card-bg) 48%);
}

html[data-theme='dark'] #screen-app.portal-premium .simulator-med {
  border-color: rgba(92, 191, 122, 0.2);
  background: linear-gradient(180deg, var(--surface-tint-med) 0%, var(--card-bg) 48%);
}

html[data-theme='dark'] #screen-app.portal-premium .simulator-qudurat {
  border-color: rgba(212, 184, 122, 0.28);
  background: linear-gradient(180deg, var(--surface-tint-warm) 0%, var(--card-bg) 48%);
}

/* QCM — blocs encore en couleurs « papier » */
html[data-theme='dark'] #page-qcm #qcm-body {
  color: var(--text-main);
}

html[data-theme='dark'] #page-qcm .qcm-q-text pre.blocks {
  background: #121820;
  color: #e4dfd6;
  border-color: rgba(212, 184, 122, 0.2);
}

html[data-theme='dark'] .qcm-hint-btn {
  background: rgba(30, 38, 50, 0.95);
  color: var(--text-main);
  border-color: rgba(212, 184, 122, 0.35);
}

html[data-theme='dark'] .desmos-float-panel {
  background: var(--card-bg);
  border-color: var(--border-soft);
}

html[data-theme='dark'] .btn-back:hover {
  border-color: rgba(126, 176, 255, 0.35);
  color: var(--primary);
  background: rgba(126, 176, 255, 0.08);
}

html[data-theme='dark'] .restrict-overlay {
  background: rgba(8, 10, 14, 0.88);
}
html[data-theme='dark'] .card-level.sim-locked .restrict-overlay {
  background: rgba(10, 12, 18, 0.92) !important;
}

html[data-theme='dark'] .card-ch.card-ch--trial-locked::after {
  background: rgba(20, 26, 36, 0.75);
  color: rgba(250, 248, 244, 0.92);
}

/* Premium badge header */
html[data-theme='dark'] #screen-app.portal-premium .h-session .vise20-header-premium-badge {
  border-color: rgba(92, 191, 122, 0.45);
  background: linear-gradient(135deg, rgba(30, 55, 38, 0.95), rgba(18, 32, 24, 0.98));
  color: rgba(220, 245, 228, 0.96);
}

html[data-theme='dark'] #screen-app.portal-premium .h-session .btn-premium-checkout {
  border-color: rgba(212, 184, 122, 0.45);
  background: linear-gradient(135deg, #c9a96e, #9a7b42);
  color: #0c0f14;
}

/* Toasts */
html[data-theme='dark'] .vise20-toast--ok {
  background: rgba(22, 42, 30, 0.97);
  color: #dff5e6;
  border-color: rgba(92, 191, 122, 0.4);
}

html[data-theme='dark'] .vise20-toast--error {
  background: rgba(42, 22, 22, 0.97);
  color: #fce4e4;
  border-color: rgba(240, 128, 128, 0.45);
}

/* Scratchblocks — léger assombrissement sans casser les couleurs pédagogiques */
html[data-theme='dark'] .scratchblocks-inline,
html[data-theme='dark'] pre.blocks {
  filter: brightness(0.96);
}

/* Hub chapitre — onglets / cartes claires */
html[data-theme='dark'] .chapter-modes-tab:hover {
  color: var(--primary);
  background: rgba(126, 176, 255, 0.08);
}

html[data-theme='dark'] .chapter-modes-tab.is-active {
  background: rgba(30, 38, 52, 0.98);
  color: var(--primary);
  border-color: rgba(126, 176, 255, 0.25);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

html[data-theme='dark'] .chapter-train-subcard-drill:hover {
  background: rgba(126, 176, 255, 0.06);
}

/* Médailles / lux blocks — fonds clairs */
html[data-theme='dark'] #quiz-config-overlay .qc-difficulty-block--lux,
html[data-theme='dark'] .qc-medal-card--lux {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme='dark'] .qc-row--wrap .qc-opt {
  border-color: var(--border-soft);
  background: rgba(22, 28, 38, 0.65);
}

/* PDF fiche révision */
html[data-theme='dark'] .fiche-revision-inner {
  background: var(--card-bg);
  color: var(--text-main);
}

/* Interrupteur thème (détails sombres) */
html[data-theme='dark'] .vise20-theme-toggle {
  border-color: rgba(126, 176, 255, 0.22);
  background: linear-gradient(180deg, rgba(126, 176, 255, 0.12), rgba(126, 176, 255, 0.04));
  color: rgba(232, 236, 244, 0.85);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
html[data-theme='dark'] .vise20-theme-toggle:hover {
  border-color: rgba(126, 176, 255, 0.45);
  color: var(--primary);
}
html[data-theme='dark'] .vise20-theme-toggle__icon {
  background: #1a2230;
  border-color: rgba(126, 176, 255, 0.22);
}
html[data-theme='dark'] .vise20-theme-toggle--fab {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

html[data-theme='dark'] .login-oubli-lead {
  color: rgba(232, 236, 244, 0.88);
}

html[data-theme='dark'] .signup-success-text {
  color: rgba(232, 236, 244, 0.88) !important;
}

html[data-theme='dark'] .sim-launch-overlay {
  background: rgba(10, 12, 18, 0.94);
}

html[data-theme='dark'] .wm-cell.wm-cell--exam {
  color: rgba(232, 236, 244, 0.04);
}

html[data-theme='dark'] .btn-preflight-start {
  color: #0c0f14;
}

html[data-theme='dark'] .pwd-note-strict {
  color: #ff8a8a;
}

html[data-theme='dark'] .cp-note,
html[data-theme='dark'] .cp-niveau-row label {
  color: rgba(232, 236, 244, 0.88);
}

/* ═══ Portail : variables artefact + halos (moins de « lait » sur fond nuit) ═══ */
html[data-theme='dark'] #screen-app.portal-premium {
  --art-orange: #f2b870;
  --art-orange-dim: rgba(240, 200, 130, 0.95);
  --art-glow: rgba(126, 176, 255, 0.14);
}
html[data-theme='dark'] #screen-app.portal-premium::before,
html[data-theme='dark'] #screen-app.portal-premium::after {
  opacity: 0.16;
}
html[data-theme='dark'] #screen-app.portal-premium > .vise20-drift-orb-host .vise20-drift-orb {
  opacity: 0.22;
}

/* Dashboard — blocs niveaux (titres Spé Maths …) */
html[data-theme='dark'] .france-theme-wrap {
  background: rgba(22, 28, 38, 0.92);
  border-color: rgba(212, 184, 122, 0.28);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
html[data-theme='dark'] .france-theme-label {
  color: rgba(240, 210, 150, 0.95) !important;
}
html[data-theme='dark'] .france-sector-label {
  color: rgba(232, 236, 244, 0.82) !important;
}
html[data-theme='dark'] .restrict-card-name {
  color: #f0ebe3 !important;
}

/* Protocole d’entrée (texte gris sur gris → corrigé) */
html[data-theme='dark'] .protocol-prose {
  color: rgba(232, 236, 244, 0.88) !important;
}
html[data-theme='dark'] .protocol-prose strong {
  color: #fff !important;
}
html[data-theme='dark'] .protocol-prose--kicker {
  color: rgba(240, 210, 150, 0.92) !important;
}
html[data-theme='dark'] .protocol-rule {
  background: rgba(26, 34, 48, 0.95) !important;
  border-left-color: rgba(212, 184, 122, 0.65) !important;
  color: rgba(232, 236, 244, 0.9);
}
html[data-theme='dark'] .protocol-rule strong {
  color: #fff;
}
html[data-theme='dark'] .protocol-num {
  color: rgba(240, 190, 120, 0.95) !important;
}
html[data-theme='dark'] .proto-commit-heading {
  color: #f5f2eb !important;
  border-bottom-color: rgba(212, 184, 122, 0.45) !important;
}
html[data-theme='dark'] .proto-signature-label {
  background: rgba(22, 30, 42, 0.98) !important;
  border-color: rgba(212, 184, 122, 0.4) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
html[data-theme='dark'] .proto-signature-text {
  color: rgba(232, 236, 244, 0.95) !important;
}

/* Hub chapitre — titres tuiles (bleu trop sombre sur fond teinté) */
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--qcm .chapter-mode-tile-title,
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--open .chapter-mode-tile-title {
  color: #f0f4ff !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--qcm .chapter-mode-tile-tag,
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--open .chapter-mode-tile-tag {
  color: rgba(200, 210, 230, 0.92) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--defis .chapter-mode-tile-title {
  color: #f2faf4 !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--defis .chapter-mode-tile-tag {
  color: rgba(200, 230, 210, 0.9) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--fiche .chapter-mode-tile-title {
  color: #fff8ec !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile::before {
  opacity: 0.28;
  background: radial-gradient(ellipse 95% 75% at 100% 0%, rgba(126, 176, 255, 0.14), transparent 58%);
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--defis::before,
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--qcm::before,
html[data-theme='dark'] #screen-app.portal-premium .chapter-mode-tile--open::before {
  background: radial-gradient(ellipse 90% 70% at 100% 0%, rgba(255, 255, 255, 0.08), transparent 55%);
  opacity: 0.4;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-modes-frame--revision .chapter-modes-frame-title {
  color: rgba(240, 210, 150, 0.95) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-modes-frame--activities .chapter-modes-frame-title,
html[data-theme='dark'] #screen-app.portal-premium .chapter-modes-frame--train .chapter-modes-frame-title {
  color: #c8dcff !important;
}
html[data-theme='dark'] #screen-app.portal-premium .chapter-modes-train-slogan {
  color: rgba(200, 210, 230, 0.88) !important;
}
html[data-theme='dark'] .chapter-modes-bilan-h2,
html[data-theme='dark'] .chapter-modes-plan-h2 {
  color: #f5f2eb !important;
}
html[data-theme='dark'] .chapter-modes-bilan-lead,
html[data-theme='dark'] .chapter-modes-bilan-list,
html[data-theme='dark'] .chapter-modes-plan-lead {
  color: rgba(232, 236, 244, 0.9) !important;
}
html[data-theme='dark'] .chapter-modes-plan-note {
  color: rgba(180, 195, 220, 0.9) !important;
}

/* Titres pages (performance, etc.) */
html[data-theme='dark'] #screen-app.portal-premium .section-label {
  color: rgba(240, 210, 150, 0.95) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .page-h1 {
  color: #f5f7fc !important;
}

/* Performance */
html[data-theme='dark'] .perf-section-label {
  color: rgba(220, 200, 160, 0.88) !important;
}
html[data-theme='dark'] .perf-section-label--sub {
  color: rgba(190, 200, 220, 0.75) !important;
}
html[data-theme='dark'] .perf-heatmap-intro {
  color: rgba(210, 218, 235, 0.88) !important;
}
html[data-theme='dark'] .perf-table th,
html[data-theme='dark'] .perf-table td {
  color: rgba(232, 236, 244, 0.92) !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}
html[data-theme='dark'] .perf-select {
  background: linear-gradient(180deg, #1e2633, #161c26) !important;
  color: var(--text-main) !important;
  border-color: rgba(212, 184, 122, 0.35) !important;
}
html[data-theme='dark'] .btn-perf-track {
  background: linear-gradient(180deg, #242e3d, #1a222e) !important;
  color: rgba(240, 210, 150, 0.95) !important;
  border-color: rgba(212, 184, 122, 0.4) !important;
}
html[data-theme='dark'] .btn-perf-track:hover {
  color: #fff8ec !important;
  border-color: rgba(240, 210, 150, 0.55) !important;
}
html[data-theme='dark'] .mk-trophy-block {
  background: linear-gradient(155deg, #1c2433 0%, #1a1f2a 50%, #161c26 100%) !important;
  border-color: rgba(212, 184, 122, 0.35) !important;
}
html[data-theme='dark'] .mk-trophy-title {
  color: #f5f2eb !important;
}
html[data-theme='dark'] .mk-trophy-sub {
  color: rgba(200, 210, 230, 0.88) !important;
}
html[data-theme='dark'] .mk-hint {
  color: rgba(160, 175, 200, 0.75) !important;
}

/* Défis / progression */
html[data-theme='dark'] .defi-row {
  background: rgba(22, 28, 38, 0.92) !important;
  border-color: rgba(212, 184, 122, 0.22) !important;
}
html[data-theme='dark'] .defis-progress-wrap {
  background: linear-gradient(180deg, #1a2230, #141a24) !important;
  border-color: rgba(212, 184, 122, 0.22) !important;
}
html[data-theme='dark'] .defis-progress-meta {
  color: rgba(210, 218, 235, 0.85) !important;
}
html[data-theme='dark'] .defis-legend {
  color: rgba(180, 195, 215, 0.85) !important;
}

/* CM matières — cartes claires */
html[data-theme='dark'] .cm-subject-card {
  background: linear-gradient(160deg, rgba(28, 36, 50, 0.98), rgba(20, 26, 36, 0.96)) !important;
  border-color: rgba(212, 184, 122, 0.3) !important;
  color: var(--text-main);
}
html[data-theme='dark'] .cm-subject-name {
  color: #f5f2eb !important;
}
html[data-theme='dark'] .cm-subject-card--featured {
  background: linear-gradient(155deg, rgba(34, 42, 58, 0.99), rgba(22, 28, 40, 0.97)) !important;
}

/* Bandeau session (SESSION ACTIVE …) : fond clair du thème artefact + texte clair = illisible ; reprendre un bloc sombre + texte très clair */
html[data-theme='dark'] #screen-app.portal-premium .h-session {
  color: #f2f6ff !important;
  background: linear-gradient(180deg, rgba(40, 48, 64, 0.98), rgba(26, 32, 44, 0.96)) !important;
  border-color: rgba(210, 175, 115, 0.42) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55) !important;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .breadcrumb span {
  color: rgba(190, 200, 220, 0.88) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .breadcrumb span:hover {
  color: var(--primary) !important;
}
html[data-theme='dark'] #screen-app.portal-premium .breadcrumb .cur {
  color: #fff !important;
}
