@font-face {
    font-family: "Goelang Quicksand";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src:
        url("../fonts/quicksand/Quicksand-Medium.a227ded7064f.woff2") format("woff2"),
        url("../fonts/quicksand/Quicksand-Medium.f897a9a3b250.ttf") format("truetype");
}

:root {
    --violet-900: #1f1432;
    --violet-800: #31233f;
    --violet-700: #522e6b;
    --violet-600: #6a3d8b;
    --violet-200: #d8c5ff;
    --violet-100: #f6f1ff;
    --white: #ffffff;
    --vert: #a2d5c6;
    --brand-logo-violet: #d8c5ff;
    --brand-logo-green: #a2d5c6;

    /* Surface tokens — clair (défaut) */
    --surface-page: var(--violet-100);
    --surface-card: var(--white);
    --surface-card-muted: rgba(31, 20, 50, 0.04);
    --surface-overlay: rgba(31, 20, 50, 0.5);
    --surface-header: var(--violet-800);
    --surface-topbar: var(--vert);
    --surface-mainbar: var(--white);

    /* Texte */
    --text-primary: var(--violet-900);
    --text-secondary: rgba(31, 20, 50, 0.75);
    --text-on-dark: var(--white);
    --text-muted: rgba(31, 20, 50, 0.6);

    /* Bordures et focus */
    --border-soft: rgba(31, 20, 50, 0.12);
    --border-strong: rgba(31, 20, 50, 0.25);
    --focus-ring: rgba(106, 61, 139, 0.45);

    /* Sémantique */
    --color-success: #2f9e6b;
    --color-warning: #d99100;
    --color-danger: #dc3545;
    --color-info: #35a7ff;
}

[data-theme="dark"] {
    --violet-900: #f6f1ff;
    --violet-800: #e0d4f5;
    --violet-700: #c8b4ea;
    --violet-600: #b59be0;
    --violet-200: #6a3d8b;
    --violet-100: #1a1228;
    --white: #2a1f3d;
    --vert: #6e9e91;

    --surface-page: #14101e;
    --surface-card: #221833;
    --surface-card-muted: rgba(255, 255, 255, 0.05);
    --surface-overlay: rgba(0, 0, 0, 0.7);
    --surface-header: #0f0a18;
    --surface-topbar: #1f1832;
    --surface-mainbar: #1a1228;

    --text-primary: #f0e7ff;
    --text-secondary: rgba(240, 231, 255, 0.78);
    --text-on-dark: #f0e7ff;
    --text-muted: rgba(240, 231, 255, 0.55);

    --border-soft: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.22);
    --focus-ring: rgba(216, 197, 255, 0.55);

    --color-success: #4cd391;
    --color-warning: #ffc53a;
    --color-danger: #ff6b7a;
    --color-info: #5ab8ff;

    color-scheme: dark;
}

html,
body {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--violet-100);
}

.global-header {
    background: var(--violet-800);
    color: var(--white);
    box-shadow: 0 8px 22px rgba(10, 8, 20, 0.35);
    position: relative;
    z-index: 1030;
    flex-shrink: 0;
}

.nav-topbar {
    background: var(--vert);
    color: var(--violet-800);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 45px;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-topbar .container-fluid,
.nav-mainbar .container-fluid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    margin-left: 0;
}

.nav-topbar .container-fluid {
    min-height: 45px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-left: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 0;
}

.topbar-right .nav-item.dropdown {
    margin-right: 0;
}

.lab-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lab-badge {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-weight: 600;
    margin-right: 0.75rem;
    letter-spacing: 0.1em;
}

.lab-copy {
    font-weight: 500;
    opacity: 0.9;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.topbar-link {
    color: var(--violet-800);
    opacity: 0.75;
    font-weight: 600;
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.topbar-link:hover {
    opacity: 1;
}

.topbar-center {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--violet-800);
}

.topbar-primary-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.topbar-section-link {
    font-weight: 600;
    color: rgba(31, 20, 50, 0.6);
    text-decoration: none;
    position: relative;
    padding-bottom: 0.2rem;
}

.topbar-section-link i {
    margin-right: 0.35rem;
}

.topbar-section-link--management {
    margin-left: 1.5rem;
}

.btn-topbar i {
    margin-right: 0.35rem;
}

.topbar-section-link.is-active {
    color: var(--violet-900);
}

.topbar-section-link.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: var(--violet-800);
}

.mt-3 > small.text-muted {
    margin-left: 10px;
}

.btn-topbar {
    background: transparent;
    color: var(--violet-800);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    padding: 0.25rem 1rem;
    margin-right: 1em;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav-mainbar {
    background: var(--violet-700);
    min-height: 54px;
    padding: 0;
    position: relative;
    z-index: 1040;
}

.nav-mainbar .container-fluid {
    min-height: 54px;
    flex-wrap: nowrap;
}

#menu-toggle {
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--white);
    background: transparent;
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--white);
    text-transform: none;
    letter-spacing: 0;
}

.navbar-brand .brand-title {
    display: inline-flex;
    align-items: baseline;
    font-family: "Goelang Quicksand", "Quicksand", "Trebuchet MS", system-ui, sans-serif;
    font-size: 1.45rem;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0;
    text-transform: lowercase;
}

.navbar-brand .brand-letter {
    color: var(--brand-logo-violet);
    transition: color 0.16s ease;
}

.navbar-brand .brand-letter--accent {
    color: var(--brand-logo-green);
}

.navbar-brand:hover .brand-letter,
.navbar-brand:focus .brand-letter {
    color: var(--brand-logo-green);
}

.navbar-brand:hover .brand-letter--accent,
.navbar-brand:focus .brand-letter--accent {
    color: var(--brand-logo-green);
}

.navbar-brand .brand-mark {
    height: 32px;
    margin-left: 0.5em;
}

.programme-banner-catalog-card {
    height: 150px !important;
    min-height: 150px !important;
}

.nav-primary {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1 1 auto;
    justify-content: center;
    margin-left: 0;
}

.nav-primary-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    position: relative;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-primary-link:hover,
.nav-primary-link.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
}

.nav-primary-link-shell {
    position: relative;
    display: inline-flex;
}

.nav-primary-link-shell--jellyfin:not(.is-jellyfin-available)::after {
    content: "";
    position: absolute;
    left: -0.9rem;
    right: -0.9rem;
    top: 100%;
    height: 1rem;
    z-index: 1049;
}

.nav-primary-link.is-disabled {
    color: rgba(255, 255, 255, 0.52);
    background: rgba(255, 255, 255, 0.04);
    cursor: help;
}

.nav-primary-link.is-disabled:hover,
.nav-primary-link.is-disabled:focus {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.72);
}

.nav-jellyfin-status-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
    display: inline-block;
}

.nav-primary-link[data-validation-ok="1"] .nav-jellyfin-status-dot {
    background: #7fd9b9;
}

.nav-primary-link.is-manual-service {
    color: #FFE45E;
}

.nav-primary-link.is-manual-service .nav-jellyfin-status-dot {
    background: #FFE45E;
}

.nav-primary-link.is-checking .nav-jellyfin-status-dot {
    background: #f6d36f;
    animation: jellyfinStatusPulse 1s ease-in-out infinite;
}

@keyframes jellyfinStatusPulse {
    0%, 100% { opacity: 0.45; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.nav-primary-tooltip {
    display: none;
    position: absolute;
    left: 50%;
    top: calc(100% + 0.55rem);
    transform: translateX(-50%);
    z-index: 1050;
    width: min(320px, calc(100vw - 2rem));
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    background: #241934;
    color: #fff;
    box-shadow: 0 12px 30px rgba(9, 5, 20, 0.28);
    font-size: 0.82rem;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: 0;
    text-align: left;
}

.nav-primary-tooltip::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    border: 0.45rem solid transparent;
    border-bottom-color: #241934;
}

.nav-primary-link-shell:hover .nav-primary-tooltip,
.nav-primary-link-shell:focus-within .nav-primary-tooltip,
.nav-primary-link-shell.is-tooltip-open .nav-primary-tooltip {
    display: block;
}

.nav-tooltip-link {
    display: inline-block;
    margin-top: 0.35rem;
    margin-right: 0.65rem;
    color: #d8c5ff;
    text-decoration: underline;
}

.nav-tooltip-link:hover {
    color: #ffffff;
}

.nav-utilities {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-utilities .nav-item.dropdown {
    margin-right: 0;
}

/* Bootstrap 4 n'a pas de classes gap-* : on les fournit (utilisé sur pages IA). */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

@supports not (gap: 0.5rem) {
    .gap-1 > * { margin-right: 0.25rem; margin-bottom: 0.25rem; }
    .gap-2 > * { margin-right: 0.5rem; margin-bottom: 0.5rem; }
    .gap-3 > * { margin-right: 1rem; margin-bottom: 1rem; }
}

.nav-utilities .nav-link,
.nav-utilities .utility-link {
    color: var(--text-on-dark);
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: opacity 0.2s ease;
}

/* Menu utilitaires (barre violette): alignement icônes homogène (img + font). */
.nav-utilities .nav-tools {
    display: flex;
    align-items: center;
}

.nav-utilities .nav-tools .utility-link {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    line-height: 1;
}

.nav-utilities .nav-tools .utility-link i {
    display: block;
    line-height: 1;
}

#nav-theme-icon {
    margin-left: 4px;
    margin-right: -6px;
}

#navLangDropdown .fa-globe {
    margin-left: 4px;
    margin-right: -4px;
}

.nav-utilities .nav-link:hover,
.nav-utilities .utility-link:hover {
    opacity: 1;
}

.utility-link img {
    width: 22px;
    height: 22px;
    display: block;
    margin-top: 8px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* Modal dictionnaire (/search/) */
.goelang-dictionary-frame {
    width: 100%;
    height: 75vh;
    border: 0;
    display: block;
}

/* Coach IA: TOC (sommaire) dans les blocs de question */
.coach-ia-toc {
    margin-left: auto;
    text-align: right;
}

/* Coach IA: layout série (liste persistante + zone exercice) */
.coach-ia-series-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    max-width: 100%;
}

.coach-ia-series-toc {
    width: 320px;
    max-width: 100%;
    position: sticky;
    top: 1rem;
    padding: 0.75rem;
    border-radius: 12px;
    background: rgba(31, 20, 50, 0.04);
}

.coach-ia-toc-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    line-height: 1;
}

.coach-ia-series-layout.is-toc-hidden .coach-ia-toc-list {
    display: none;
}

.coach-ia-series-layout.is-toc-hidden .coach-ia-series-toc-body {
    display: none;
}

.coach-ia-series-layout.is-toc-hidden .coach-ia-series-toc {
    width: auto;
}

/* Coach IA: préférences audio compactes dans la sidebar */
.coach-ia-series-toc .coach-ia-tts-prefs {
    width: 100%;
}

.coach-ia-series-toc .coach-ia-tts-prefs-voice {
    flex: 1 1 160px;
    min-width: 0;
}

.coach-ia-series-toc .coach-ia-tts-prefs-rate {
    flex: 0 1 110px;
    min-width: 0;
}

.coach-ia-series-toc .coach-ia-tts-prefs-autoplay {
    flex: 1 1 100%;
    min-width: 0;
}

.coach-ia-series-toc #coach-ia-tts-voice,
.coach-ia-series-toc #coach-ia-tts-rate {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Réduit les risques de débordement (support variable selon navigateur) */
.coach-ia-series-toc #coach-ia-tts-voice {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coach-ia-series-main {
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

/* Coach IA: modale d'invitation au plein écran (1×/session) */
.coach-ia-immersion-prompt {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.coach-ia-immersion-prompt[hidden] {
    display: none;
}

.coach-ia-immersion-prompt__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 8, 20, 0.55);
    backdrop-filter: blur(2px);
}

.coach-ia-immersion-prompt__dialog {
    position: relative;
    width: 100%;
    max-width: 28rem;
    background: linear-gradient(180deg, #ffffff 0%, #f7f4ff 100%);
    color: var(--violet-900, #3a2560);
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 18px 48px rgba(10, 8, 20, 0.28);
    border: 1px solid rgba(92, 60, 146, 0.12);
}

.coach-ia-immersion-prompt__title {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    color: #5C3C92;
}

.coach-ia-immersion-prompt__text {
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

.coach-ia-immersion-prompt__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.coach-ia-immersion-prompt__accept {
    background-color: #5C3C92;
    border-color: #5C3C92;
}

html[data-theme="dark"] .coach-ia-immersion-prompt__dialog {
    background: linear-gradient(180deg, rgba(21, 27, 38, 0.99) 0%, rgba(12, 16, 24, 0.99) 100%);
    color: #eef3fb;
    border-color: rgba(162, 213, 198, 0.18);
}

html[data-theme="dark"] .coach-ia-immersion-prompt__title {
    color: #A2D5C6;
}

/* Coach IA: mode immersion (fullscreen) */
#coach-ia-immersion-root.is-immersion {
    /* Typo responsive: min lisible mobile, max plus grand sur grands écrans */
    font-size: calc(clamp(1.1rem, 1.1vw + 0.9rem, 2.05rem) * var(--coach-ia-immersion-scale, 1));
    line-height: 1.5;
    width: 100%;
    max-width: min(72ch, 78vw);
    margin-left: auto;
    margin-right: auto;
    background:
        radial-gradient(1200px 460px at 12% 0%, rgba(162, 213, 198, 0.28) 0%, rgba(162, 213, 198, 0) 58%),
        radial-gradient(900px 360px at 88% 12%, rgba(92, 60, 146, 0.12) 0%, rgba(92, 60, 146, 0) 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 244, 255, 0.94) 100%);
    color: var(--violet-900);
    border-radius: 12px;
    padding: 1rem;
    box-sizing: border-box;
    position: relative;
    /* Réserve un espace vertical constant sous la topbar (progress + nav) */
    padding-top: 6rem;
    /* Réserve de l'espace pour la barre de références en bas (si affichée). */
    padding-bottom: 4.25rem;
    display: flex;
    flex-direction: column;
    /* Centrage vertical sûr : ne masque pas le haut quand le contenu déborde */
    justify-content: safe center;
    gap: clamp(0.75rem, 1.8vh, 1.35rem);
    overflow-y: auto;
    box-shadow:
        inset 0 0 0 1px rgba(82, 46, 107, 0.06),
        0 18px 48px rgba(10, 8, 20, 0.08);
}

html[data-theme="dark"] #coach-ia-immersion-root.is-immersion {
    background:
        radial-gradient(1000px 400px at 14% 0%, rgba(162, 213, 198, 0.14) 0%, rgba(162, 213, 198, 0) 58%),
        radial-gradient(900px 340px at 86% 14%, rgba(92, 60, 146, 0.24) 0%, rgba(92, 60, 146, 0) 60%),
        linear-gradient(180deg, rgba(21, 27, 38, 0.98) 0%, rgba(12, 16, 24, 0.99) 100%);
    color: #eef3fb;
    box-shadow:
        inset 0 0 0 1px rgba(162, 213, 198, 0.12),
        0 18px 48px rgba(0, 0, 0, 0.26);
}

/* Immersion: barre de références (pinnée en bas) */
.coach-ia-immersion-refs {
    display: none;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-refs {
    display: block;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 12px;
    width: min(72ch, 78vw);
    max-width: min(72ch, 78vw);
    z-index: 2050;
    background: var(--white);
    color: var(--violet-900);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* En sommaire: on masque la barre de refs (évite de couvrir la grille). */
#coach-ia-immersion-root.is-immersion.is-sommaire .coach-ia-immersion-refs {
    display: none !important;
}

.coach-ia-immersion-refs-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    font-size: 0.85em;
    line-height: 1.25;
}

.coach-ia-immersion-refs-kind {
    font-weight: 700;
}

.coach-ia-immersion-refs-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted rgba(0, 0, 0, 0.25);
}

.coach-ia-immersion-refs-link:hover {
    text-decoration: underline;
}

.coach-ia-immersion-refs-sep {
    opacity: 0.65;
}

/* Coach IA step=2 (Chapitres): fullscreen */
.coach-ia-chapters-root {
    position: relative;
}

.coach-ia-step2-chapters-fs {
    display: none;
}

.coach-ia-chapters-root.is-immersion {
    font-size: clamp(1.05rem, 1.0vw + 0.9rem, 1.85rem);
    line-height: 1.4;
    width: 100%;
    height: 100%;
    background: var(--white);
    color: var(--violet-900);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coach-ia-chapters-root.is-immersion .coach-ia-step2-chapters-fs {
    display: block;
    width: 100%;
}

.coach-ia-chapters-root.is-immersion .coach-ia-chapters-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
}

.coach-ia-chapters-root.is-immersion .coach-ia-step2-normal,
.coach-ia-chapters-root.is-immersion .coach-ia-step2-actions,
.coach-ia-chapters-root.is-immersion .coach-ia-step2-management,
.coach-ia-chapters-root.is-immersion .coach-ia-step2-title,
.coach-ia-chapters-root.is-immersion .coach-ia-step2-help {
    display: none !important;
}

.coach-ia-step2-back-btn {
    display: none;
}

.coach-ia-chapters-root.is-immersion .coach-ia-step2-back-btn {
    display: inline-flex;
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 2100;
    align-items: center;
    justify-content: center;
    width: 2.4em;
    height: 2.4em;
    padding: 0;
    line-height: 1;
}

.coach-ia-chapters-root.is-immersion .coach-ia-chapter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 4.2rem;
    font-size: 1em;
}

.coach-ia-chapters-root.is-immersion .coach-ia-chapter-emoji {
    font-size: 1.4em;
    line-height: 1;
}

.coach-ia-chapters-root.is-immersion .coach-ia-chapter-label {
    font-size: 0.95em;
}

.coach-ia-chapters-root.is-immersion .coach-ia-chapter-btn.is-selected {
    border-width: 2px;
    border-color: var(--violet-900);
}

/* Bouton Retour (fullscreen) : bas-gauche, graphique */
.coach-ia-immersion-back-btn {
    display: none;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-back-btn {
    display: inline-flex;
    z-index: 2100;
    position: fixed;
    left: 12px;
    bottom: 12px;
    top: auto;
    right: auto;
    align-items: center;
    justify-content: center;
    width: 2.4em;
    height: 2.4em;
    padding: 0;
    line-height: 1;
}

/* Lecture (Ressource/Micro-leçon): en fullscreen on masque le fil d'ariane / id (page_title). */
#coach-ia-immersion-root.is-immersion .coach-ia-page-title {
    display: none;
}

/* En immersion, on masque le lien Retour textuel (remplacé par le bouton graphique). */
#coach-ia-immersion-root.is-immersion .coach-ia-back-link {
    display: none;
}

/* Sommaire interne (immersion fullscreen) */
#coach-ia-immersion-root .coach-ia-sommaire {
    display: none;
}

#coach-ia-immersion-root.is-immersion .coach-ia-sommaire {
    display: none;
    flex: 1 1 auto;
    width: 100%;
    align-items: center;
    justify-content: center;
}

#coach-ia-immersion-root.is-immersion.is-sommaire .coach-ia-sommaire {
    display: flex;
}

#coach-ia-immersion-root.is-immersion.is-sommaire .coach-ia-exercise-screen {
    display: none;
}

/* En sommaire: on masque actions / formulaires de l'exercice */
#coach-ia-immersion-root.is-immersion.is-sommaire .coach-ia-actions,
#coach-ia-immersion-root.is-immersion.is-sommaire form,
#coach-ia-immersion-root.is-immersion.is-sommaire .coach-ia-immersion-exit {
    display: none !important;
}

/* Exception: les outils du sommaire (Chapitres/Interrompre + réglages TTS) doivent rester visibles. */
#coach-ia-immersion-root.is-immersion.is-sommaire #coach-ia-sommaire-tools {
    width: 100%;
    margin-bottom: 0.9rem;
}

#coach-ia-immersion-root.is-immersion.is-sommaire #coach-ia-sommaire-tools form {
    display: block !important;
}

#coach-ia-immersion-root.is-immersion .coach-ia-sommaire-inner {
    width: 100%;
    max-width: min(1200px, 94vw);
    max-height: 78vh;
    display: flex;
    flex-direction: column;
}

#coach-ia-immersion-root.is-immersion .coach-ia-sommaire-title {
    margin-bottom: 0.75rem;
}

#coach-ia-immersion-root.is-immersion .coach-ia-sommaire-list {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(var(--coach-ia-sommaire-cols, 1), minmax(0, 1fr));
    /* Beaucoup d'items: cases de hauteur stable; on scroll dans la liste. */
    grid-auto-rows: clamp(3.1rem, 7.2vh, 5.4rem);
    gap: clamp(0.5rem, 1.2vh, 1rem);
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    align-content: start;
}

#coach-ia-immersion-root.is-immersion .coach-ia-sommaire-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    white-space: normal;
    /* Taille de base (peut être réduite par JS si nécessaire). */
    font-size: clamp(0.85rem, 2.0vh, 1.05rem);
    line-height: 1.15;
    padding: 0.45em 0.6em;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    overflow: hidden;
}

#coach-ia-immersion-root.is-immersion .coach-ia-sommaire-link.is-selected {
    border-width: 2px;
    border-color: var(--violet-900);
}

/* Immersion: répartition verticale (toc au-dessus, contenu en dessous) */
.coach-ia-page.is-immersion .coach-ia-series-layout {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    min-height: 100vh;
}

.coach-ia-page.is-immersion .coach-ia-series-toc {
    width: 100%;
    position: static;
}

.coach-ia-page.is-immersion .coach-ia-series-main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: safe center;
    padding: 2.5vh 0;
    overflow-y: auto;
}

/* Immersion: contrôler la taille des boutons/champs (Bootstrap reste en rem sinon) */
#coach-ia-immersion-root.is-immersion .btn,
#coach-ia-immersion-root.is-immersion .form-control,
#coach-ia-immersion-root.is-immersion .form-select {
    font-size: 1em;
}

#coach-ia-immersion-root.is-immersion .btn {
    padding: 0.55em 0.95em;
}

#coach-ia-immersion-root.is-immersion .coach-ia-tts-btn {
    width: 1.75em;
    height: 1.75em;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Progress bars: plus épaisses en fullscreen */
#coach-ia-immersion-root.is-immersion .coach-ia-progress .progress.coach-ia-progress-track {
    height: 14px !important;
}

/* Progress bar incluse dans le fullscreen (affichée uniquement en immersion) */
.coach-ia-progress--immersion {
    display: none;
    margin-bottom: 0.75rem;
}

.coach-ia-page.is-immersion .coach-ia-progress--immersion {
    display: block;
}

/* En fullscreen, l'élément fullscreen = #coach-ia-immersion-root: on force l'affichage et on le fixe en haut. */
#coach-ia-immersion-root.is-immersion .coach-ia-progress--immersion {
    display: block;
    margin: 0;
    width: min(520px, 60vw);
}

/* Immersion: topbar (progress + actions à droite) */
#coach-ia-immersion-root.is-immersion .coach-ia-immersion-topbar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    z-index: 2000;
}

/* Mode normal: afficher une topbar compacte (pas en position absolue) */
#coach-ia-immersion-root:not(.is-immersion) .coach-ia-immersion-topbar {
    position: static;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

#coach-ia-immersion-root:not(.is-immersion) .coach-ia-immersion-top-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

#coach-ia-immersion-root:not(.is-immersion) .coach-ia-immersion-top-actions-left {
    flex: 0 0 auto;
}

#coach-ia-immersion-root:not(.is-immersion) .coach-ia-immersion-top-actions-center {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
}

#coach-ia-immersion-root:not(.is-immersion) .coach-ia-immersion-top-actions-right {
    flex: 0 0 auto;
}

/* Navigation R/L/E en immersion: icônes + onglet actif en inversion vidéo */
#coach-ia-immersion-root.is-immersion .coach-ia-mkdocs-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#coach-ia-immersion-root.is-immersion .coach-ia-mkdocs-nav-btn {
    min-width: 2.25em;
    text-align: center;
}

#coach-ia-immersion-root.is-immersion .coach-ia-mkdocs-nav-btn.is-active {
    color: var(--white) !important;
    background: var(--violet-800) !important;
    border-color: var(--violet-800) !important;
}

#coach-ia-immersion-root.is-immersion .coach-ia-mkdocs-nav-btn.is-active:hover,
#coach-ia-immersion-root.is-immersion .coach-ia-mkdocs-nav-btn.is-active:focus {
    color: var(--white) !important;
    background: var(--violet-800) !important;
    border-color: var(--violet-800) !important;
}

/* Quand la progressbar est dans la topbar, elle ne doit plus être absolument positionnée. */
#coach-ia-immersion-root.is-immersion .coach-ia-immersion-topbar .coach-ia-progress--immersion {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    margin: 0;
    flex: 0 0 auto;
}

/* Fullscreen: pas de libellé 'Exercice X/Y' dans la topbar. */
#coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-center > .fw-semibold {
    display: none;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions > * {
    min-width: 0;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-left {
    flex: 0 0 auto;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-center {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
}

#coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-right {
    flex: 0 0 auto;
}

/* Production: en immersion on masque métadonnées (badges/longueur attendue) */
.coach-ia-page.is-immersion .coach-ia-production-expected,
.coach-ia-page.is-immersion .coach-ia-production-constraints {
    display: none;
}

/* Immersion: améliorer la lisibilité du texte "muted" (contraste) */
#coach-ia-immersion-root.is-immersion .text-muted {
    color: rgba(31, 20, 50, 0.75) !important;
}

#coach-ia-immersion-root.is-immersion .coach-ia-ex-type {
    display: none;
}

/* Masque les titres de section (Consigne, Contexte, etc.) */
#coach-ia-immersion-root.is-immersion > .mt-3 > small.text-muted,
#coach-ia-immersion-root.is-immersion .mt-3 > small.text-muted {
    display: none;
}

/* Progress texte: masquer, garder la barre */
.coach-ia-page.is-immersion .coach-ia-progress small.text-muted {
    display: none;
}

/* Quitter: visible seulement en immersion (JS contrôle display) */
.coach-ia-immersion-exit {
    display: none;
    line-height: 1;
    min-width: 2.25em;
    justify-content: center;
    align-items: center;
}

#coach-ia-immersion-root.is-immersion ~ .coach-ia-immersion-exit,
.coach-ia-immersion-exit {
    /* la position est appliquée via une règle séparée ci-dessous */
}

/* Plus de superposition: le bouton Quitter vit dans la topbar. */

@media (max-width: 992px) {
    .coach-ia-series-layout {
        flex-direction: column;
    }
    .coach-ia-series-toc {
        width: 100%;
        position: static;
    }

    #coach-ia-immersion-root.is-immersion {
        max-width: 100%;
    }
}

.coach-ia-toc summary {
    cursor: pointer;
    font-weight: 600;
    color: rgba(31, 20, 50, 0.85);
}

.coach-ia-toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.coach-ia-toc-link {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(31, 20, 50, 0.06);
    color: rgba(31, 20, 50, 0.9);
    text-decoration: none;
    font-size: 0.9rem;
}

.coach-ia-toc-link:hover {
    background: rgba(31, 20, 50, 0.10);
    text-decoration: none;
}

.coach-ia-toc-link.is-current {
    background: rgba(31, 20, 50, 0.16);
    font-weight: 700;
}

/* Coach IA: TTS */
.coach-ia-tts-btn {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    font-size: 0.95rem;
}

.coach-ia-tts-btn.is-playing,
.coach-ia-tts-btn.is-paused {
    opacity: 1;
}

/* Compensation optique du triangle « play » : sa bounding-box est centrée,
   mais la masse visuelle du triangle (centroïde à 1/3 de la base) tire vers la
   gauche, si bien qu'il paraît décentré dans le bouton rond. On le repousse
   d'~1px vers la droite pour recaler le centroïde sur le centre. Le glyphe
   « pause » (fa-pause) est symétrique et ne doit PAS être décalé. */
.coach-ia-tts-icon.fa-play {
    transform: translateX(1px);
}

.coach-ia-dictaphone.is-recording {
    opacity: 1;
}

/* Coach IA: QCM/QCU (Selection) */
.coach-ia-selection-options {
    display: flex;
    justify-content: center;
    max-width: 100%;
}

.coach-ia-selection-list {
    width: min(760px, 100%);
    max-width: 100%;
    margin: 0;
    padding-left: 1.4rem;
}

.coach-ia-selection-list li::marker {
    font-weight: 900;
    color: var(--violet-800);
}

.coach-ia-selection-item {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    margin: 0.55rem 0;
    max-width: 100%;
    min-width: 0;
}

.coach-ia-selection-label {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-radius: 16px;
    border: 1px solid rgba(82, 46, 107, 0.22);
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
    min-width: 0;
    max-width: 100%;
}

.has-choice-colors .coach-ia-selection-label,
#coach-ia-immersion-root.has-choice-colors .coach-ia-selection-label {
    background: var(--coach-ia-choice-bg, rgba(255, 255, 255, 0.92));
    border-color: var(--coach-ia-choice-border, rgba(82, 46, 107, 0.22));
}

.has-choice-colors [data-coach-ia-colored-answer="1"],
#coach-ia-immersion-root.has-choice-colors [data-coach-ia-colored-answer="1"] {
    background-color: var(--coach-ia-choice-bg, rgba(255, 255, 255, 0.92));
    border-color: var(--coach-ia-choice-border, rgba(82, 46, 107, 0.22));
    /* §2.3 : le fond des réponses colorées est toujours un pastel clair (mélange avec du
       blanc, cf. coach_ia_exercises.html). Le texte saisi doit donc rester sombre y compris
       en thème sombre, où form-control hérite sinon d'un texte clair → illisible (ex.
       "select in text" : blanc sur jaune clair). */
    color: #1c1230;
    -webkit-text-fill-color: #1c1230;
}

.has-choice-colors [data-coach-ia-colored-answer="1"]::placeholder,
#coach-ia-immersion-root.has-choice-colors [data-coach-ia-colored-answer="1"]::placeholder {
    color: rgba(28, 18, 48, 0.55);
}

.coach-ia-selection-label:hover {
    border-color: rgba(82, 46, 107, 0.45);
    background: rgba(246, 241, 255, 0.85);
    transform: translateY(-1px);
}

.has-choice-colors .coach-ia-selection-label:hover,
#coach-ia-immersion-root.has-choice-colors .coach-ia-selection-label:hover {
    background: var(--coach-ia-choice-bg-hover, rgba(246, 241, 255, 0.85));
    border-color: var(--coach-ia-choice-border, rgba(82, 46, 107, 0.45));
}

.has-choice-colors [data-coach-ia-colored-answer="1"]:focus,
.has-choice-colors [data-coach-ia-colored-answer="1"]:focus-visible,
#coach-ia-immersion-root.has-choice-colors [data-coach-ia-colored-answer="1"]:focus,
#coach-ia-immersion-root.has-choice-colors [data-coach-ia-colored-answer="1"]:focus-visible {
    border-color: var(--coach-ia-choice-border, rgba(82, 46, 107, 0.45));
}

.coach-ia-selection-input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
}

.coach-ia-selection-text {
    color: rgba(31, 20, 50, 0.92);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Coach IA: mode audio seul (cache les textes, centre les boutons play) */
.is-audio-only .coach-ia-tts-row {
    justify-content: center;
}

.is-audio-only .coach-ia-tts-row .flex-grow-1 {
    display: none !important;
}

.is-audio-only .coach-ia-selection-text {
    display: none;
}

.is-audio-only .coach-ia-selection-label {
    justify-content: center;
}

.is-audio-only .coach-ia-ex-type {
    display: none;
}

/* Coach IA: Aide raccourcis (bouton bas-droite) */
.coach-ia-help {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

/* En fullscreen, position fixe (relative au fullscreen root) */
#coach-ia-immersion-root.is-immersion .coach-ia-help {
    position: fixed;
    right: 18px;
    bottom: 18px;
}

.coach-ia-help-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.coach-ia-help-panel {
    width: min(360px, calc(100vw - 36px));
    border-radius: 16px;
    border: 1px solid rgba(82, 46, 107, 0.16);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 40px rgba(10, 8, 20, 0.10);
    padding: 0.85rem 0.95rem;
}

/* Boîte de dialogue plus large en plein écran */
#coach-ia-immersion-root.is-immersion .coach-ia-help-panel {
    width: min(520px, calc(100vw - 36px));
}

/* Le layout series doit être positionné pour contenir le bouton aide */
.coach-ia-series-layout {
    position: relative;
}

/* Coach IA: type d'exercice (bloc + format) */
.coach-ia-ex-type {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.coach-ia-ex-block {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1.15rem;
    letter-spacing: 0.03em;
}

.coach-ia-ex-emoji {
    line-height: 1;
}

.coach-ia-ex-format {
    font-weight: 600;
}

/* Coach IA: tuiles de blocs (chapitres) */
.coach-ia-block-label {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}

.coach-ia-block-emoji {
    line-height: 1;
}

.list-group-item.active {
    background: var(--violet-700) !important;
}

.vc_list-text a {
    color: var(--violet-800) !important;
    font-weight: 400;
    text-decoration: none;
    transition: color 0.2s ease;
}

.list-group-item.active a{
  color: white !important;
}

.badge-primary {
    background: var(--vert);
    color: var(--violet-800);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.page-region {
    flex: 1 0 auto;
}

.page-shell {
    padding: 2rem;
    max-width: 1500px !important;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 767.98px) {
    .page-shell {
        padding: 0;
    }
}

.demo-showcase {
    margin-top: 2rem;
    margin-bottom: 2rem;
    background: var(--violet-100);
    border-radius: 18px;
    padding: 2rem;
}

.demo-intro .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--violet-600);
    margin-bottom: 0.5rem;
}

.demo-intro .lead {
    color: #4a4261;
    max-width: 720px;
}

.demo-card {
    background: var(--white);
    border-radius: 16px;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 12px 24px rgba(15, 12, 32, 0.08);
    border: 1px solid rgba(82, 46, 107, 0.08);
}

.demo-card .demo-eyebrow {
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--violet-600);
    margin-bottom: 0.25rem;
}

.demo-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--violet-900);
}

.demo-card p {
    flex: 1 1 auto;
    color: #4a4a5e;
}

.btn-demo {
    align-self: flex-start;
    background: var(--violet-700);
    color: var(--white);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.45rem 1.25rem;
}

.btn-demo i {
    margin-left: 0.35rem;
}

.col-sm-4 {
    background-color: var(--violet-100) !important;
}

.nav-bottom-bar {
    width: 100%;
    position: relative;
    background-color: #452b72 !important;
    background-image: linear-gradient(180deg, #5c3c92 0%, #452b72 100%);
    color: var(--text-on-dark);
    padding: 1rem 1rem 1.5rem;
    margin-top: auto;
    flex-shrink: 0;
    box-shadow: 0 -10px 24px rgba(10, 8, 20, 0.16);
}

html[data-theme="dark"] .nav-bottom-bar {
    background-color: #14101e !important;
    background-image: linear-gradient(180deg, #24163b 0%, #14101e 100%);
}

/* ✅ Le cœur de l’alignement horizontal */
.nav-bottom-bar #menu-footer {
    width: 100%;
    background: transparent;
}

.nav-bottom-bar .bottom-nav {
    display: flex;
    justify-content: center;   /* centre horizontalement */
    align-items: center;
    flex-wrap: wrap;           /* retour à la ligne si écran trop petit */
    gap: 1.5rem;               /* espacement élégant entre les liens */
    list-style: none;
    padding: 0;
    margin: 0;
    position: static;
    z-index: auto;
}

/* Liens */
.nav-bottom-bar li a {
    color: var(--text-on-dark);
    font-weight: 500;
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s ease;
    white-space: nowrap;       /* empêche les retours moches dans un lien */
}

.nav-bottom-bar li a:hover {
    opacity: 1;
}

/* === Coach IA ============================================================= */

.coach-ia-page {
    position: relative;
    isolation: isolate;
}

.coach-ia-page::before {
    content: '';
    position: absolute;
    inset: -18px -12px;
    border-radius: 26px;
    background:
        radial-gradient(900px 320px at 15% 0%, rgba(216, 197, 255, 0.55) 0%, rgba(216, 197, 255, 0) 60%),
        radial-gradient(700px 280px at 85% 10%, rgba(162, 213, 198, 0.40) 0%, rgba(162, 213, 198, 0) 62%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.80) 0%, rgba(246, 241, 255, 0.55) 100%);
    border: 1px solid rgba(82, 46, 107, 0.08);
    z-index: -1;
}

html[data-theme="dark"] .coach-ia-page::before {
    background:
        radial-gradient(1000px 360px at 16% 0%, rgba(92, 60, 146, 0.55) 0%, rgba(92, 60, 146, 0) 58%),
        radial-gradient(850px 300px at 86% 8%, rgba(162, 213, 198, 0.22) 0%, rgba(162, 213, 198, 0) 60%),
        linear-gradient(180deg, rgba(26, 22, 40, 0.96) 0%, rgba(11, 14, 22, 0.98) 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

.coach-ia-header {
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1em;
}

.coach-ia-page h2 {
    font-weight: 900;
    color: var(--violet-900);
    letter-spacing: -0.02em;
}

.coach-ia-page .alert {
    border-radius: 16px;
    border-color: rgba(82, 46, 107, 0.12);
}

.coach-ia-page .card {
    border-radius: 18px;
    border: 1px solid rgba(82, 46, 107, 0.14);
    box-shadow: 0 18px 40px rgba(10, 8, 20, 0.08);
}

.coach-ia-page .card-body {
    padding: 1.25rem;
    max-width: 100%;
    min-width: 0;
}

.coach-ia-page .card-title {
    font-weight: 800;
    color: var(--violet-900);
}

.coach-ia-page .form-control,
.coach-ia-page .form-select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border-radius: 14px;
    padding: 0.7rem 0.9rem;
    border-color: rgba(82, 46, 107, 0.22);
    overflow: hidden;
    text-overflow: ellipsis;
}

.coach-ia-page .form-select.d-inline-block,
.coach-ia-page .form-control.d-inline-block {
    width: auto;
    max-width: 100%;
    vertical-align: middle;
}

.coach-ia-page .form-control:focus,
.coach-ia-page .form-select:focus {
    border-color: rgba(82, 46, 107, 0.5);
    box-shadow: 0 0 0 0.2rem rgba(82, 46, 107, 0.15);
}

.coach-ia-page .btn {
    border-radius: 999px;
    font-weight: 700;
    padding: 0.55rem 0.95rem;
}

.coach-ia-page .btn.btn-sm {
    padding: 0.35rem 0.75rem;
}

.coach-ia-mode-picker {
    position: relative;
}

.coach-ia-mode-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.coach-ia-mode-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(82, 46, 107, 0.25);
    background: var(--white);
    color: var(--violet-800);
    font-weight: 700;
    cursor: pointer;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.coach-ia-mode-tile:hover {
    border-color: rgba(82, 46, 107, 0.45);
    transform: translateY(-1px);
}

#coach-ia-mode-media:checked ~ label[for="coach-ia-mode-media"],
#coach-ia-mode-import:checked ~ label[for="coach-ia-mode-import"],
#coach-ia-mode-examples:checked ~ label[for="coach-ia-mode-examples"],
#coach-ia-mode-programme:checked ~ label[for="coach-ia-mode-programme"] {
    background: var(--violet-700);
    border-color: rgba(216, 197, 255, 0.6);
    color: var(--white);
}

.coach-ia-mode-panel {
    display: none;
}

#coach-ia-mode-media:checked ~ .coach-ia-mode-panels .coach-ia-mode-panel-media {
    display: block;
}

#coach-ia-mode-import:checked ~ .coach-ia-mode-panels .coach-ia-mode-panel-import {
    display: block;
}

#coach-ia-mode-examples:checked ~ .coach-ia-mode-panels .coach-ia-mode-panel-examples {
    display: block;
}

#coach-ia-mode-programme:checked ~ .coach-ia-mode-panels .coach-ia-mode-panel-programme {
    display: block;
}

.coach-ia-progress .progress {
    background: var(--violet-200);
    border-radius: 999px;
    overflow: hidden;
}

.mt-3.coach-ia-progress {
    margin: 1em;
}

/* Double barre + overlay succès */
.coach-ia-progress .progress.coach-ia-progress-track {
    position: relative;
}

.coach-ia-progress-layer {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 999px;
    transition: width 240ms ease;
}

.coach-ia-progress-layer--position {
    background: var(--violet-700);
    z-index: 1;
    overflow: hidden;
}

.coach-ia-progress-layer--position::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.28) 50%, rgba(255,255,255,0) 100%);
    transform: translateX(-60%);
    animation: coach-ia-shine 1.6s ease-in-out infinite;
    pointer-events: none;
}

.coach-ia-progress-layer--success {
    background: var(--vert);
    z-index: 2;
}

.coach-ia-progress small {
    font-weight: 600;
}

.coach-ia-actions {
    flex-wrap: wrap;
    max-width: 100%;
}

.coach-ia-actions--center {
    justify-content: center;
}

.coach-ia-actions--springs {
    position: relative;
}

.coach-ia-actions--springs::before,
.coach-ia-actions--springs::after {
    content: '';
    flex: 1 1 auto;
    min-width: 0;
}

.coach-ia-actions--springs > * {
    flex: 0 0 auto;
    max-width: 100%;
}

.coach-ia-actions .btn {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

.coach-ia-page .row {
    min-width: 0;
}

.coach-ia-page .row > [class*="col-"] {
    min-width: 0;
    overflow-wrap: anywhere;
}

.coach-ia-page .coach-ia-tts-row {
    max-width: 100%;
    min-width: 0;
}

.coach-ia-page .coach-ia-tts-row > .flex-grow-1 {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.coach-ia-time-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
}

/* Bootstrap gap-* n'est pas toujours dispo: garantir l'espace radio -> texte. */
.coach-ia-time-choices input[type="radio"] {
    margin-right: 0.5rem;
}

.coach-ia-time-choices label {
    margin: 0;
}

.coach-ia-exercise-types-panel {
    max-width: 860px;
}

.coach-ia-exercise-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.65rem;
}

.coach-ia-exercise-type-option {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    min-width: 0;
    margin: 0;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(82, 46, 107, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
}

.coach-ia-exercise-type-option input {
    margin-top: 0.2rem;
    flex: 0 0 auto;
}

.coach-ia-exercise-type-option span {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.coach-ia-exercise-type-option strong,
.coach-ia-exercise-type-option small {
    overflow-wrap: anywhere;
}

html[data-theme="dark"] .coach-ia-exercise-type-option,
[data-bs-theme="dark"] .coach-ia-exercise-type-option {
    background: rgba(22, 18, 34, 0.88);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.92);
}

html[data-theme="dark"] .coach-ia-exercise-type-option .text-muted,
[data-bs-theme="dark"] .coach-ia-exercise-type-option .text-muted {
    color: rgba(255, 255, 255, 0.68) !important;
}

.coach-ia-toggle {
    display: inline-block;
    max-width: 100%;
}

.coach-ia-toggle summary {
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    list-style: none;
    box-sizing: border-box;
    width: fit-content;
    max-width: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    border: 1px solid rgba(82, 46, 107, 0.15);
    background: rgba(255, 255, 255, 0.75);
    line-height: 1.25;
    min-height: 46px;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
}

.coach-ia-toggle summary > span {
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
}

.coach-ia-toggle summary > small {
    white-space: nowrap;
}

/* Quand le panneau dépliable est ouvert, on passe en bloc pleine largeur
   pour que le contenu (textarea, table de répartition, texte du chunk) ne
   soit plus rétréci par le `inline-block` du résumé fermé. */
.coach-ia-toggle[open] {
    display: block;
    width: 100%;
}

html[data-theme="dark"] .coach-ia-toggle summary,
[data-bs-theme="dark"] .coach-ia-toggle summary {
    background: rgba(24, 20, 31, 0.85);
    border-color: rgba(162, 213, 198, 0.28);
    color: #e9e4f0;
}

html[data-theme="dark"] .coach-ia-toggle summary .text-muted,
[data-bs-theme="dark"] .coach-ia-toggle summary .text-muted {
    color: rgba(233, 228, 240, 0.7) !important;
}

/* Sélecteur volontairement spécifique (`.coach-ia-page textarea…`) : la règle
   générique `.coach-ia-page .form-control { overflow: hidden }` (destinée aux
   inputs/selects mono-ligne) écraserait sinon l'ascenseur de ce textarea. */
.coach-ia-page textarea.coach-ia-raw-edit {
    max-height: 280px;
    /* `scroll` (et non `auto`) force l'ascenseur vertical à rester visible,
       y compris sous Linux/GTK où les overlay-scrollbars se masquent au repos. */
    overflow-y: scroll;
    white-space: pre-wrap;
    width: 100%;
}

/* Ascenseur toujours visible et bien contrasté pour les zones défilables
   du Coach IA (texte brut étape 3, revue du chunk pendant les exercices). */
.coach-ia-raw-edit,
.coach-ia-chunk-review-text {
    scrollbar-width: thin;
    scrollbar-color: var(--violet-700, #5C3C92) rgba(82, 46, 107, 0.12);
}

.coach-ia-raw-edit::-webkit-scrollbar,
.coach-ia-chunk-review-text::-webkit-scrollbar {
    width: 12px;
}

.coach-ia-raw-edit::-webkit-scrollbar-track,
.coach-ia-chunk-review-text::-webkit-scrollbar-track {
    background: rgba(82, 46, 107, 0.12);
    border-radius: 8px;
}

.coach-ia-raw-edit::-webkit-scrollbar-thumb,
.coach-ia-chunk-review-text::-webkit-scrollbar-thumb {
    background: var(--violet-700, #5C3C92);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Zone de revue du chunk pendant les exercices : hauteur bornée + défilement. */
.coach-ia-chunk-review-text {
    max-height: 320px;
    overflow-y: scroll;
    white-space: pre-wrap;
}

.coach-ia-toggle summary::-webkit-details-marker {
    display: none;
}

.coach-ia-progress .progress-bar {
    background: var(--violet-700);
    transition: width 240ms ease;
    position: relative;
    overflow: hidden;
}

.coach-ia-progress .progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.28) 50%, rgba(255,255,255,0) 100%);
    transform: translateX(-60%);
    animation: coach-ia-shine 1.6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes coach-ia-shine {
    0% { transform: translateX(-60%); opacity: 0.4; }
    55% { transform: translateX(60%); opacity: 0.9; }
    100% { transform: translateX(60%); opacity: 0; }
}

.coach-ia-page .coach-ia-instruction {
    border-radius: 14px;
    border: 1px solid rgba(82, 46, 107, 0.12);
    background: rgba(255, 255, 255, 0.75);
}

html[data-theme="dark"] .coach-ia-page .coach-ia-instruction,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-instruction {
    background: linear-gradient(135deg, rgba(18, 24, 35, 0.98), rgba(24, 31, 44, 0.98));
    border-color: rgba(162, 213, 198, 0.22);
    color: #eef3fb;
}

html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly {
    background: linear-gradient(135deg, rgba(18, 24, 35, 0.98), rgba(24, 31, 44, 0.98));
    border-color: rgba(162, 213, 198, 0.22);
    color: #eef3fb;
}

html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly-rendered,
html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly-rendered p,
html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly-rendered li,
html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly-rendered span,
html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly-rendered strong,
html[data-theme="dark"] .coach-ia-page .coach-ia-grammarly-rendered em,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly-rendered,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly-rendered p,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly-rendered li,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly-rendered span,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly-rendered strong,
html[data-theme="dark"] #coach-ia-immersion-root.is-immersion .coach-ia-grammarly-rendered em {
    color: #eef3fb !important;
}

.coach-ia-media-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(82, 46, 107, 0.18);
    color: rgba(31, 20, 50, 0.75);
    font-weight: 600;
    font-size: 0.85rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Coach IA — rendu type Grammarly (Production) */
.coach-ia-grammarly {
    border: 1px solid rgba(82, 46, 107, 0.15);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.75);
    padding: 12px 12px 10px;
}

.coach-ia-grammarly-text {
    white-space: pre-wrap;
    line-height: 1.55;
}

.coach-ia-grammarly-hint {
    margin-top: 8px;
}

.coach-ia-issue {
    position: relative;
    display: inline;
    cursor: pointer;
    border-bottom: 2px solid var(--violet-700);
    background: var(--violet-200);
    border-radius: 6px;
    padding: 0 2px;
}

.coach-ia-issue:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.22);
}

.coach-ia-issue--warning {
    text-decoration: underline dotted currentColor 2px;
}

.coach-ia-issue--info {
    text-decoration: underline solid currentColor 1px;
}

.coach-ia-issue--error {
    text-decoration: underline wavy #ED474A 2px;
}

.coach-ia-issue--type-grammar {
    background: rgba(237, 71, 74, 0.18);
    border-bottom-color: #ED474A;
}

.coach-ia-issue--type-spelling {
    background: rgba(255, 197, 58, 0.28);
    border-bottom-color: #FFC53A;
}

.coach-ia-issue--type-style {
    background: rgba(53, 167, 255, 0.20);
    border-bottom-color: #35A7FF;
}

.coach-ia-issue--type-coherence {
    background: rgba(92, 60, 146, 0.20);
    border-bottom-color: #5C3C92;
}

.coach-ia-issue--type-suggestion {
    background: rgba(162, 213, 198, 0.35);
    border-bottom-color: #A2D5C6;
}

/* Types d'erreurs propres au dialogue (six types, charte Goélang).
   `grammar` réutilise la couleur existante ; les cinq autres s'y ajoutent. */
.coach-ia-issue--type-conjugation {
    background: rgba(255, 197, 58, 0.28);
    border-bottom-color: #FFC53A;
}

.coach-ia-issue--type-lexis {
    background: rgba(53, 167, 255, 0.20);
    border-bottom-color: #35A7FF;
}

.coach-ia-issue--type-syntax {
    background: rgba(92, 60, 146, 0.20);
    border-bottom-color: #5C3C92;
}

.coach-ia-issue--type-register {
    background: rgba(255, 99, 146, 0.22);
    border-bottom-color: #FF6392;
}

.coach-ia-issue--type-idiom {
    background: rgba(162, 213, 198, 0.35);
    border-bottom-color: #A2D5C6;
}

/* Fil du dialogue */
.coach-ia-dialogue__thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.coach-ia-dialogue__turn {
    border-radius: 0.5rem;
    padding: 0.6rem 0.9rem;
    max-width: 90%;
}

.coach-ia-dialogue__turn--partner {
    background: rgba(162, 213, 198, 0.25);
    align-self: flex-start;
    color: #1f2a36;
}

.coach-ia-dialogue__turn--learner {
    background: rgba(53, 167, 255, 0.14);
    align-self: flex-end;
    color: #1f2a36;
}

.coach-ia-dialogue__turn-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.coach-ia-dialogue__state {
    font-variant-numeric: tabular-nums;
}

/* Soulignements masqués tant que l'utilisateur n'a pas demandé à voir */
.coach-ia-dialogue:not(.show-errors) .coach-ia-issue {
    background: transparent;
    border-bottom-color: transparent;
}

.coach-ia-annotation-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
}

.coach-ia-annotation-legend .coach-ia-legend-swatch {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border-radius: 3px;
    margin-right: 0.35em;
    vertical-align: -0.1em;
    border-bottom: 2px solid transparent;
}

.coach-ia-tooltip {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    min-width: min(320px, 85vw);
    max-width: 520px;
    background: var(--white);
    border: 1px solid rgba(82, 46, 107, 0.18);
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(10, 8, 20, 0.18);
    padding: 10px 12px;
    color: rgba(31, 20, 50, 0.9);
    font-weight: 600;
    z-index: 9999;
    display: none;
}

html[data-theme="dark"] .coach-ia-tooltip,
[data-bs-theme="dark"] .coach-ia-tooltip {
    background: #2a2433;
    color: #e9e4f0;
    border-color: rgba(162, 213, 198, 0.3);
}

/* En fullscreen, les tooltips doivent rester visibles malgré overflow-y: auto */
#coach-ia-immersion-root.is-immersion .coach-ia-issue {
    position: relative;
    z-index: auto;
}

#coach-ia-immersion-root.is-immersion .coach-ia-tooltip {
    z-index: 9999;
}

/* Desktop: survol */
.coach-ia-issue:hover .coach-ia-tooltip {
    display: block;
}

/* Mobile/tap: toggle via JS */
.coach-ia-issue.is-open .coach-ia-tooltip {
    display: block;
}

.coach-ia-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 20, 50, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
}

.coach-ia-loading-overlay.is-visible {
    display: flex;
}

.coach-ia-loading-card {
    width: min(520px, 100%);
    background: var(--white);
    border-radius: 18px;
    border: 1px solid rgba(82, 46, 107, 0.18);
    box-shadow: 0 20px 60px rgba(10, 8, 20, 0.35);
    padding: 18px 18px 14px;
}

.coach-ia-loading-title {
    font-weight: 800;
    color: var(--violet-900);
    font-size: 1.05rem;
}

.coach-ia-loading-sub {
    margin-top: 6px;
    color: rgba(31, 20, 50, 0.7);
    font-weight: 600;
    font-size: 0.9rem;
}

.coach-ia-loading-percent {
    margin-top: 10px;
    font-weight: 800;
    color: var(--violet-700);
    text-align: right;
}

.coach-ia-loading-bar {
    margin-top: 14px;
    height: 10px;
    border-radius: 999px;
    background: var(--violet-200);
    overflow: hidden;
}

.coach-ia-loading-bar span {
    display: block;
    height: 100%;
    width: 5%;
    background: var(--violet-700);
    border-radius: 999px;
    transition: width .25s ease;
}

.coach-ia-loading-details summary {
    cursor: pointer;
    color: var(--violet-800);
    font-weight: 700;
    font-size: 0.86rem;
}

.coach-ia-loading-details pre {
    max-height: 160px;
    overflow: auto;
    white-space: pre-wrap;
    border: 1px solid rgba(82, 46, 107, 0.18);
    border-radius: 8px;
    padding: 10px;
    background: rgba(162, 213, 198, 0.12);
    color: var(--violet-900);
    font-size: 0.78rem;
}

.btn-coach-ok {
    background: var(--vert);
    border: 1px solid var(--vert);
    color: var(--violet-800);
    font-weight: 600;
}

.btn-coach-ok:hover,
.btn-coach-ok:focus {
    background: var(--vert);
    border-color: var(--vert);
    color: var(--violet-900);
}

.btn-coach-ko {
    background: transparent;
    border: 1px solid var(--violet-700);
    color: var(--violet-700);
    font-weight: 600;
}

.btn-coach-ko:hover,
.btn-coach-ko:focus {
    background: var(--violet-200);
    border-color: var(--violet-700);
    color: var(--violet-900);
}

.badge-coach-ok {
    background: var(--vert);
    color: var(--violet-900);
    font-weight: 700;
}

.badge-coach-ko {
    background: var(--violet-200);
    color: var(--violet-900);
    font-weight: 700;
}

.coach-ia-block-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.coach-ia-page details > summary {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(82, 46, 107, 0.18);
    background: rgba(255, 255, 255, 0.75);
}

.coach-ia-page details[open] > summary {
    background: rgba(216, 197, 255, 0.35);
}

@media (max-width: 575px) {
    .coach-ia-page::before {
        inset: -12px -10px;
        border-radius: 22px;
    }

    .coach-ia-page .card {
        border-radius: 16px;
        box-shadow: 0 14px 30px rgba(10, 8, 20, 0.08);
    }

    .coach-ia-page .card-body {
        padding: 1rem;
    }

    .coach-ia-mode-tile {
        width: 100%;
        justify-content: flex-start;
    }

    .coach-ia-progress small {
        display: block;
        margin-top: 6px;
        line-height: 1.35;
    }

    .coach-ia-actions .btn,
    .coach-ia-actions form {
        flex: 1 1 220px;
    }

    .coach-ia-actions form button {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .coach-ia-page-shell {
        padding-left: 0;
        padding-right: 0;
    }

    .coach-ia-actions--springs::before {
        content: none;
        display: none;
    }

    .coach-ia-page-shell > .container,
    .coach-ia-page-shell > .coach-ia-page {
        max-width: none;
        padding-left: 0;
        padding-right: 0;
    }

    .coach-ia-page::before {
        inset: -12px 0;
        border-radius: 22px;
    }

    #coach-ia-immersion-root.is-immersion {
        max-width: 100vw;
        padding-top: 1rem;
    }

    #coach-ia-immersion-root.is-immersion .coach-ia-immersion-topbar {
        position: static;
        top: auto;
        left: auto;
        right: auto;
        margin-bottom: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    #coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
    }

    #coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-left,
    #coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-right {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    #coach-ia-immersion-root.is-immersion .coach-ia-immersion-top-actions-center {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        justify-content: stretch;
    }

    #coach-ia-immersion-root.is-immersion .coach-ia-progress--immersion,
    #coach-ia-immersion-root.is-immersion .coach-ia-immersion-topbar .coach-ia-progress--immersion {
        width: 100%;
        max-width: none;
    }

    #coach-ia-immersion-root.is-immersion .coach-ia-mkdocs-nav {
        min-width: 0;
        max-width: 100%;
    }

    #coach-ia-immersion-root.is-immersion[data-coach-ia-page-kind="exercises"] .coach-ia-tts-row {
        display: block !important;
    }

    #coach-ia-immersion-root.is-immersion[data-coach-ia-page-kind="exercises"] .coach-ia-tts-row::after {
        content: '';
        display: block;
        clear: both;
    }

    #coach-ia-immersion-root.is-immersion[data-coach-ia-page-kind="exercises"] .coach-ia-tts-row > .coach-ia-tts-btn {
        float: left;
        position: relative;
        top: 5px;
        left: 10px;
        margin: 0.15rem 0.75rem 0.35rem 0;
    }

    #coach-ia-immersion-root.is-immersion[data-coach-ia-page-kind="exercises"] .coach-ia-tts-row > .flex-grow-1,
    #coach-ia-immersion-root.is-immersion[data-coach-ia-page-kind="exercises"] .coach-ia-tts-row > .coach-ia-selection-label {
        display: block;
        min-width: 0;
    }
}

@media (min-width: 768px) {
    .coach-ia-block-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .coach-ia-block-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.coach-ia-block-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.coach-ia-block-tile {
    position: relative;
    display: block;
    cursor: pointer;
    text-decoration: none;
}

.coach-ia-block-tile-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: var(--white);
    border: 1px solid rgba(82, 46, 107, 0.15);
    border-radius: 14px;
    padding: 18px 14px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(91, 33, 182, 0.08);
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.coach-ia-block-tile:hover .coach-ia-block-tile-inner {
    transform: translateY(-1px);
    border-color: rgba(82, 46, 107, 0.35);
}

.coach-ia-block-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--violet-900);
}

.coach-ia-block-meta {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(31, 20, 50, 0.6);
}

.coach-ia-block-radio:checked + .coach-ia-block-tile-inner {
    background: var(--violet-700);
    border-color: rgba(216, 197, 255, 0.6);
}

.coach-ia-block-radio:checked + .coach-ia-block-tile-inner .coach-ia-block-label {
    color: var(--white);
}

.coach-ia-block-radio:checked + .coach-ia-block-tile-inner .coach-ia-block-meta {
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 1199px) {
    .nav-primary {
        gap: 0.75rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 690px) {
    .topbar-primary-nav {
        letter-spacing: 0em;
        gap: 0em;
    }
}

@media (min-width: 351px) and (max-width: 690px) {
    .nav-primary,
    #primary-menu {
        gap: 0em;
        flex-wrap: wrap;
    }
}

@media (max-width: 990px) and (min-width: 711px) {
    .nav-topbar {
        min-height: 45px;
    }

    .nav-topbar .container-fluid {
        min-height: 45px;
        gap: 1rem;
    }

    .topbar-center {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
    }

    .topbar-primary-nav {
        justify-content: center;
        gap: 0.85rem;
        min-width: 0;
    }

    .topbar-section-link {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        line-height: 1.1;
        text-align: center;
        padding-bottom: 0.1rem;
    }

    .topbar-section-link i {
        margin-right: 0;
    }

    .topbar-section-link--management {
        margin-left: 0;
    }
}

@media (min-width: 351px) and (max-width: 1199.98px) {
    .nav-mainbar .container-fluid {
        flex-wrap: wrap;
        align-items: center;
        row-gap: 0.5rem;
    }

    .navbar-brand {
        order: 1;
    }

    .nav-utilities {
        order: 2;
        margin-left: auto;
        flex: 0 0 auto;
    }

    .nav-primary {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 0.75rem;
        padding-bottom: 0.25rem;
    }

    .nav-primary-link-shell {
        flex: 0 0 auto;
    }
}

@media (max-width: 350px) {
    .nav-mainbar {
        padding: 0.75rem 0;
    }

    .nav-mainbar .container-fluid {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .navbar-brand {
        order: 1;
        min-width: 0;
    }

    #menu-toggle {
        order: 3;
        margin-left: 0;
    }

    .nav-utilities {
        order: 2;
        width: auto;
        min-width: 0;
        margin-left: auto;
        justify-content: flex-end;
        gap: 0.5rem;
        flex: 0 1 auto;
    }

    .nav-tools {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        min-width: 0;
        flex-wrap: nowrap;
    }

    #navLangDropdown + .dropdown-menu {
        left: 0;
        right: auto;
        min-width: min(220px, calc(100vw - 30px));
        max-width: calc(100vw - 30px);
    }

    .nav-user {
        margin-left: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 0 0 auto;
    }

    .navbar-brand .brand-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 40vw;
    }

    .nav-primary {
        position: absolute;
        left: 0;
        top: 100%;
        width: 100%;
        background: var(--violet-700);
        padding: 0.75rem 1.5rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        box-shadow: 0 12px 24px rgba(9, 5, 20, 0.55);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    }

    .nav-primary.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

@media (max-width: 710px) {
    .nav-topbar .container-fluid,
    .nav-mainbar .container-fluid {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .nav-topbar {
        height: auto;
        padding: 0.5rem 0;
    }

    /* Mobile: barre verte compacte, sections visibles (wrap, aligné à gauche) */
    .nav-topbar .container-fluid {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .topbar-left {
        display: none;
    }

    /* §12.1 : le bouton « Télécharger » doit rester accessible en mobile
       (auparavant masqué avec .topbar-left). On l'affiche sur une ligne centrée. */
    .topbar-right {
        display: flex;
        width: 100%;
        order: 9;
        justify-content: center;
    }

    .topbar-center {
        width: 100%;
        min-width: 0;
        justify-content: center;
    }

    .nav-mainbar {
        padding: 0.75rem 0;
    }

    .topbar-primary-nav {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
        overflow: visible;
        white-space: normal;
        min-width: 0;
        width: 100%;
    }

    .topbar-section-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.2rem 0.65rem;
        border-radius: 999px;
        line-height: 1.2;
        text-align: center;
    }

    .topbar-section-link--management {
        margin-left: 0;
    }

    .topbar-section-link.is-active {
        color: var(--violet-900);
        background: rgba(255, 255, 255, 0.55);
        border: 1px solid rgba(31, 20, 50, 0.18);
    }

    .topbar-section-link.is-active::after {
        display: none;
    }

    /* Mobile: barre violette sans chevauchement (wrap si nécessaire) */
    .nav-mainbar .container-fluid {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .navbar-brand {
        order: 1;
        min-width: 0;
    }

    #menu-toggle {
        order: 3;
        margin-left: 0;
    }

    .nav-utilities {
        order: 2;
        width: auto;
        min-width: 0;
        margin-left: auto;
        justify-content: flex-end;
        gap: 0.5rem;
        flex: 0 1 auto;
    }

    .nav-tools {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        min-width: 0;
        flex-wrap: nowrap;
    }

    #navLangDropdown + .dropdown-menu {
        left: 0;
        right: auto;
        min-width: min(220px, calc(100vw - 30px));
        max-width: calc(100vw - 30px);
    }

    .nav-user {
        margin-left: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 0 0 auto;
    }

    .navbar-brand .brand-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 40vw;
    }

    .nav-primary {
        position: absolute;
        left: 0;
        top: 100%;
        width: 100%;
        background: var(--violet-700);
        padding: 0.75rem 1.5rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        box-shadow: 0 12px 24px rgba(9, 5, 20, 0.55);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    }

    .nav-primary.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .nav-primary-link {
        width: 100%;
        padding: 0.35rem 0.35rem;
        justify-content: center;
        text-align: center;
    }

    .nav-primary-link-shell {
        width: 100%;
        display: flex;
    }

    .nav-primary-link-shell--jellyfin:not(.is-jellyfin-available)::after {
        left: 0.75rem;
        right: 0.75rem;
        height: 0.8rem;
    }

    .nav-primary-tooltip {
        left: 1rem;
        right: 1rem;
        top: calc(100% + 0.35rem);
        transform: none;
        width: auto;
    }

    .nav-primary-tooltip::before {
        left: 50%;
    }
}

@media (min-width: 351px) {
    #menu-toggle {
        display: none;
    }
}

@media (min-width: 351px) and (max-width: 710px) {
    .nav-mainbar .container-fluid {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-utilities {
        order: 2;
        width: auto;
        min-width: 0;
        margin-left: auto;
        justify-content: flex-end;
        gap: 0.5rem;
        flex: 0 1 auto;
    }

    .nav-tools {
        flex-wrap: nowrap;
    }

    .nav-user {
        margin-left: 0;
        flex: 0 0 auto;
    }

    .nav-primary {
        position: static;
        left: auto;
        top: auto;
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        padding: 0 0 0.25rem;
        background: transparent;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .nav-primary-link {
        width: auto;
        justify-content: center;
        text-align: center;
    }

    .nav-primary-link-shell {
        width: auto;
        flex: 0 0 auto;
        display: flex;
    }
}

@media (max-width: 350px) {
    .topbar-primary-nav a[data-section],
    .topbar-primary-nav a[data-section]:visited,
    .topbar-primary-nav a[data-section]:hover,
    .topbar-primary-nav a[data-section]:focus,
    .topbar-primary-nav a[data-section]:active {
        font-weight: 600;
        color: rgba(31, 20, 50, 0.6);
        text-decoration: none;
        position: relative;
        padding-bottom: 0.2rem;
    }

    .topbar-primary-nav a[data-section] i {
        margin-right: 0.35rem;
    }

    .topbar-primary-nav a[data-section].topbar-section-link--management {
        margin-left: 1.5rem;
    }

    .topbar-primary-nav a[data-section].is-active,
    .topbar-primary-nav a[data-section].is-active:visited,
    .topbar-primary-nav a[data-section].is-active:hover,
    .topbar-primary-nav a[data-section].is-active:focus,
    .topbar-primary-nav a[data-section].is-active:active {
        color: var(--violet-900);
    }

    .topbar-primary-nav a[data-section].is-active::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: -2px;
        width: 100%;
        height: 2px;
        background: var(--violet-800);
    }

    .nav-mainbar .container-fluid {
        flex-wrap: wrap;
    }

    #menu-toggle {
        order: 2;
        margin-left: auto;
    }

    .nav-utilities {
        order: 3;
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .nav-tools {
        flex-wrap: wrap;
    }

    .nav-user {
        margin-left: auto;
    }
}

@media (max-width: 470px) {
    .navbar-brand .brand-title {
        display: none;
    }

    .topbar-section-link {
        width: auto;
        flex: 0 0 auto;
    }
}

@media (max-width: 399px) {
    .topbar-primary-nav {
        justify-content: center;
    }
}

.demo-showcase {
    display: none;
}


.list-group {
    max-width: none !important;
}

.coach-ia-toggle.mt-3 {
    width: 100% !important;
}

/* ── Icônes inline [[icon:goelang]] / [[icon:ext-xxx]] ── */
.inline-icon.goelang-logo {
    height: 1.2em;
    vertical-align: middle;
    display: inline-block;
    filter: brightness(0);  /* logo blanc → noir pour thème clair */
}

.inline-icon.ext-icon {
    height: 1em;
    width: 1em;
    vertical-align: -0.125em;
    display: inline-block;
}

.panel-inline-icon {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

.panel-inline-icon--panneau-connexion2 {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M8%204.8v14.4%22%2F%3E%3Ccircle%20cx%3D%2214.5%22%20cy%3D%2210%22%20r%3D%221.8%22%2F%3E%3Cpath%20d%3D%22M12.2%2015.2c.8-1.5%202.1-2.2%203.6-2.2%201.5%200%202.7.7%203.4%202%22%2F%3E%3C%2Fsvg%3E");
}

.panel-inline-icon--panneau-lateral {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M15.5%204.8v14.4%22%2F%3E%3Cpath%20d%3D%22M6.5%208h5.5%22%2F%3E%3Cpath%20d%3D%22M6.5%2011.5h5.5%22%2F%3E%3Cpath%20d%3D%22M6.5%2015h5.5%22%2F%3E%3Cpath%20d%3D%22M17.5%208h1%22%2F%3E%3Cpath%20d%3D%22M17.5%2011.5h1%22%2F%3E%3Cpath%20d%3D%22M17.5%2015h1%22%2F%3E%3C%2Fsvg%3E");
}

.panel-inline-icon--panneau-contexte {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M6.5%208.2h7%22%2F%3E%3Cpath%20d%3D%22M6.5%2011.5h4.5%22%2F%3E%3Cpath%20d%3D%22M13.5%2010l4%201v4.2l-4%20.8-2.2%202v-2.4l-1.8-.4v-4l4-1.2Z%22%2F%3E%3C%2Fsvg%3E");
}

svg.inline-icon.ext-icon.ext-icon-svg,
svg.inline-icon.ext-icon.ext-icon-svg * {
    fill: currentColor !important;
    stroke: currentColor !important;
}

/* ── Sélecteur de thème (clair / sombre / système) ── */
#nav-theme-dropdown {
    cursor: pointer;
}

#nav-theme-wrapper .dropdown-menu {
    min-width: 180px;
    padding: 0.25rem 0;
}

#nav-theme-wrapper .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.9rem;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
}

#nav-theme-wrapper .dropdown-item:hover,
#nav-theme-wrapper .dropdown-item:focus {
    background: var(--surface-card-muted);
    color: var(--text-primary);
    outline: none;
}

#nav-theme-wrapper .dropdown-item .nav-theme-active-mark {
    margin-left: auto;
    visibility: hidden;
    color: var(--violet-600);
}

#nav-theme-wrapper .dropdown-item.active,
#nav-theme-wrapper .dropdown-item[aria-checked="true"] {
    background: var(--surface-card-muted);
    color: var(--text-primary);
    font-weight: 600;
}

#nav-theme-wrapper .dropdown-item.active .nav-theme-active-mark,
#nav-theme-wrapper .dropdown-item[aria-checked="true"] .nav-theme-active-mark {
    visibility: visible;
}

/* ── Surfaces de base : utilisation des tokens sémantiques ── */
body {
    background: var(--surface-page);
    color: var(--text-primary);
}

/* ── Overrides ciblés mode sombre ── */
[data-theme="dark"] body {
    color: var(--text-primary);
}

[data-theme="dark"] .global-header {
    background: var(--surface-header);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .nav-topbar {
    background: var(--surface-topbar);
    color: var(--text-on-dark);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .nav-mainbar {
    background: var(--surface-mainbar);
    color: var(--text-primary);
}

[data-theme="dark"] .nav-mainbar .navbar-brand,
[data-theme="dark"] .nav-mainbar .nav-link,
[data-theme="dark"] .nav-mainbar .utility-link,
[data-theme="dark"] #menu-toggle {
    color: var(--text-primary);
}

[data-theme="dark"] .nav-mainbar .nav-link:hover,
[data-theme="dark"] .nav-mainbar .nav-link:focus,
[data-theme="dark"] .nav-mainbar .utility-link:hover,
[data-theme="dark"] .nav-mainbar .utility-link:focus {
    color: #ffffff;
}

[data-theme="dark"] .dropdown-menu {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-divider {
    border-top-color: var(--border-soft);
}

[data-theme="dark"] .modal-content {
    background: var(--surface-card);
    color: var(--text-primary);
    border: 1px solid var(--border-soft);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border-soft);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-control-sm,
[data-theme="dark"] select.form-control,
[data-theme="dark"] textarea.form-control {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea.form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-control:focus {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--violet-600);
    box-shadow: 0 0 0 0.2rem var(--focus-ring);
}

[data-theme="dark"] .table {
    color: var(--text-primary);
    background: transparent;
}

[data-theme="dark"] .table thead th {
    border-bottom-color: var(--border-soft);
}

[data-theme="dark"] .table tbody tr {
    border-color: var(--border-soft);
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .table-hover tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

[data-theme="dark"] .card {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

[data-theme="dark"] .alert {
    border-color: var(--border-soft);
}

[data-theme="dark"] pre,
[data-theme="dark"] code {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

[data-theme="dark"] hr {
    border-color: var(--border-soft);
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

/* Icônes utilitaires (SVG blancs filtrés sur navbar foncée) :
   en mode sombre, la mainbar reste foncée → on conserve le filtre blanc d'origine. */
[data-theme="dark"] .utility-link img {
    filter: brightness(0) invert(1);
    opacity: 0.92;
}

[data-theme="dark"] .nav-utilities .utility-link {
    color: var(--text-on-dark);
}

[data-theme="dark"] .nav-utilities .utility-link i,
[data-theme="dark"] .nav-utilities .utility-link .fas,
[data-theme="dark"] .nav-utilities .utility-link .far,
[data-theme="dark"] .nav-utilities .utility-link .fab {
    color: var(--text-on-dark);
}

/* Logo Goélang + icônes inline : forcer le blanc en thème sombre. */
[data-theme="dark"] img.inline-icon.goelang-logo,
[data-theme="dark"] img.inline-icon.ext-icon {
    filter: brightness(0) invert(1) !important;
    opacity: 1;
}

[data-theme="dark"] .panel-inline-icon--panneau-connexion2,
html[data-theme="dark"] .panel-inline-icon--panneau-connexion2 {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23ffffff%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M8%204.8v14.4%22%2F%3E%3Ccircle%20cx%3D%2214.5%22%20cy%3D%2210%22%20r%3D%221.8%22%2F%3E%3Cpath%20d%3D%22M12.2%2015.2c.8-1.5%202.1-2.2%203.6-2.2%201.5%200%202.7.7%203.4%202%22%2F%3E%3C%2Fsvg%3E");
}

[data-theme="dark"] .panel-inline-icon--panneau-lateral,
html[data-theme="dark"] .panel-inline-icon--panneau-lateral {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23ffffff%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M15.5%204.8v14.4%22%2F%3E%3Cpath%20d%3D%22M6.5%208h5.5%22%2F%3E%3Cpath%20d%3D%22M6.5%2011.5h5.5%22%2F%3E%3Cpath%20d%3D%22M6.5%2015h5.5%22%2F%3E%3Cpath%20d%3D%22M17.5%208h1%22%2F%3E%3Cpath%20d%3D%22M17.5%2011.5h1%22%2F%3E%3Cpath%20d%3D%22M17.5%2015h1%22%2F%3E%3C%2Fsvg%3E");
}

[data-theme="dark"] .panel-inline-icon--panneau-contexte,
html[data-theme="dark"] .panel-inline-icon--panneau-contexte {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23ffffff%22%20stroke-width%3D%221.8%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M6.5%208.2h7%22%2F%3E%3Cpath%20d%3D%22M6.5%2011.5h4.5%22%2F%3E%3Cpath%20d%3D%22M13.5%2010l4%201v4.2l-4%20.8-2.2%202v-2.4l-1.8-.4v-4l4-1.2Z%22%2F%3E%3C%2Fsvg%3E");
}

/* ──────────────────────────────────────────────────────────
   Sombre — corrections de contraste ciblées
   ────────────────────────────────────────────────────────── */

/* Topbar : items de section visibles en sombre (non-active) */
[data-theme="dark"] .nav-topbar {
    background: #2a213a;
    color: #ece4ff;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .nav-topbar,
[data-theme="dark"] .topbar-link,
[data-theme="dark"] .topbar-center,
[data-theme="dark"] .btn-topbar {
    color: #ece4ff;
}

[data-theme="dark"] .topbar-section-link {
    color: rgba(236, 228, 255, 0.7);
}

[data-theme="dark"] .topbar-section-link:hover {
    color: #ffffff;
}

[data-theme="dark"] .topbar-section-link.is-active {
    color: #ffffff;
}

[data-theme="dark"] .topbar-section-link.is-active::after {
    background: var(--vert);
}

[data-theme="dark"] .btn-topbar {
    border-color: rgba(255, 255, 255, 0.3);
    color: #ece4ff;
}

[data-theme="dark"] .btn-topbar:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* Mainbar : conserver fond foncé + texte clair (la palette violet inversée
   donnerait un mainbar pastel illisible avec son texte blanc) */
[data-theme="dark"] .global-header {
    background: #1a1228;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .nav-mainbar {
    background: #2d1f47;
    color: #ffffff;
}

[data-theme="dark"] .nav-mainbar .navbar-brand,
[data-theme="dark"] .nav-mainbar .brand-title {
    color: #ffffff;
}

[data-theme="dark"] .nav-primary-link {
    color: rgba(255, 255, 255, 0.78);
}

[data-theme="dark"] .nav-primary-link:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

[data-theme="dark"] .nav-primary-link.is-active {
    background: rgba(162, 213, 198, 0.18);
    color: #ffffff;
}

[data-theme="dark"] .nav-primary-link.is-disabled {
    color: rgba(255, 255, 255, 0.48);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .nav-primary-tooltip {
    background: #1c1428;
}

[data-theme="dark"] .nav-primary-tooltip::before {
    border-bottom-color: #1c1428;
}

/* Bootstrap utility — text-* classes en sombre */
[data-theme="dark"] .text-primary {
    color: #b39bf0 !important;
}

[data-theme="dark"] .text-secondary {
    color: rgba(240, 231, 255, 0.7) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-body {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-info {
    color: #5ab8ff !important;
}

[data-theme="dark"] .text-success {
    color: #4cd391 !important;
}

[data-theme="dark"] .text-warning {
    color: #ffc53a !important;
}

[data-theme="dark"] .text-danger {
    color: #ff6b7a !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--surface-card) !important;
    color: var(--text-primary);
}

[data-theme="dark"] .bg-white {
    background-color: var(--surface-card) !important;
    color: var(--text-primary);
}

/* Bootstrap : boutons outline lisibles en sombre */
[data-theme="dark"] .btn-outline-primary {
    color: #b39bf0;
    border-color: #b39bf0;
}
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-primary:focus {
    background-color: rgba(179, 155, 240, 0.15);
    color: #ffffff;
    border-color: #c8b4ea;
}

[data-theme="dark"] .btn-outline-secondary {
    color: #cfc4e8;
    border-color: rgba(255, 255, 255, 0.35);
}
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-secondary:focus {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.55);
}

[data-theme="dark"] .btn-outline-success {
    color: #4cd391;
    border-color: #4cd391;
}
[data-theme="dark"] .btn-outline-success:hover {
    background-color: rgba(76, 211, 145, 0.18);
    color: #ffffff;
}

[data-theme="dark"] .btn-outline-danger {
    color: #ff8d99;
    border-color: #ff6b7a;
}
[data-theme="dark"] .btn-outline-danger:hover {
    background-color: rgba(255, 107, 122, 0.18);
    color: #ffffff;
}

[data-theme="dark"] .btn-outline-warning {
    color: #ffc53a;
    border-color: #ffc53a;
}
[data-theme="dark"] .btn-outline-warning:hover {
    background-color: rgba(255, 197, 58, 0.18);
    color: #ffffff;
}

[data-theme="dark"] .btn-outline-info {
    color: #5ab8ff;
    border-color: #5ab8ff;
}
[data-theme="dark"] .btn-outline-info:hover {
    background-color: rgba(90, 184, 255, 0.18);
    color: #ffffff;
}

[data-theme="dark"] .btn-light {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

[data-theme="dark"] .btn-secondary {
    background-color: #4a3a6a;
    border-color: #4a3a6a;
    color: #ffffff;
}

[data-theme="dark"] .close,
[data-theme="dark"] button.close {
    color: var(--text-primary);
    text-shadow: none;
}

/* Cards par défaut Bootstrap */
[data-theme="dark"] .card {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: var(--border-soft);
    color: var(--text-primary);
}

[data-theme="dark"] .card-img-top,
[data-theme="dark"] .card-img,
[data-theme="dark"] .card-img-bottom {
    background-color: rgba(255, 255, 255, 0.92);
    border-radius: inherit;
}

/* Game launch portal : SVG sombres → fond clair derrière l'image */
[data-theme="dark"] .game-launch-card .card-img-top {
    background-color: #ece4ff;
    padding: 12px;
}

/* Test positionnement : cartes (front/back) avec hex clair en dur */
[data-theme="dark"] .tp-card-face,
[data-theme="dark"] .tp-card-front,
[data-theme="dark"] .tp-card-back {
    background-color: #2c2348 !important;
    color: var(--text-primary);
}

[data-theme="dark"] .tp-word {
    color: #f0e7ff;
}

/* Dictionary editor : barre de filtres (#f8f9fa en clair) */
[data-theme="dark"] .ude-filter-bar {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-soft);
    color: var(--text-primary);
}

[data-theme="dark"] .ude-dict-chip {
    background: var(--surface-card);
    border-color: var(--border-soft);
    color: var(--text-primary);
}

[data-theme="dark"] .ude-dict-chip:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Upload page : main, history, logs */
[data-theme="dark"] .upl-main {
    background: var(--surface-page);
    color: var(--text-primary);
}

[data-theme="dark"] #upload-history-card,
[data-theme="dark"] #upload-history-card.card,
[data-theme="dark"] .logs-card,
[data-theme="dark"] .card.logs-card {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border: 1px solid var(--border-soft);
}

[data-theme="dark"] .upl-history-type {
    color: var(--text-muted);
}

[data-theme="dark"] .upl-history-name,
[data-theme="dark"] button.upl-history-name {
    color: var(--text-primary);
}

[data-theme="dark"] .upl-history-name:hover::after {
    background: #1a1228;
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

/* Tables : entêtes lisibles en sombre */
[data-theme="dark"] .table thead th,
[data-theme="dark"] .vc-list-table thead th {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

[data-theme="dark"] .vc-list-table,
[data-theme="dark"] .vc-list-table td,
[data-theme="dark"] .vc-list-table th {
    color: var(--text-primary);
    border-color: var(--border-soft);
}

/* Pagination */
[data-theme="dark"] .page-link {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

[data-theme="dark"] .page-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: var(--violet-600);
    border-color: var(--violet-600);
    color: #ffffff;
}

[data-theme="dark"] .page-item.disabled .page-link {
    background-color: var(--surface-card);
    color: var(--text-muted);
    border-color: var(--border-soft);
}

/* Badges Bootstrap : laisser leurs couleurs explicites + texte foncé/clair adapté */
[data-theme="dark"] .badge.badge-light,
[data-theme="dark"] .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

/* Liens dans le contenu */
[data-theme="dark"] a {
    color: #b39bf0;
}

[data-theme="dark"] a:hover,
[data-theme="dark"] a:focus {
    color: #d8c5ff;
}

/* Page curricula/programme : surcharges des cartes/zones avec hex en dur */
[data-theme="dark"] .programme-overview,
[data-theme="dark"] .competence-card,
[data-theme="dark"] .palier-card,
[data-theme="dark"] .programme-action-bar {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

/* Inline `style="background:#fff*"` ou `#f8f9fa` dans curricula : surcharge progressive */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background-color:#fff"],
[data-theme="dark"] [style*="background-color: #fff"] {
    background-color: var(--surface-card) !important;
    color: var(--text-primary);
}

[data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background: #f8f9fa"],
[data-theme="dark"] [style*="background-color:#f8f9fa"],
[data-theme="dark"] [style*="background-color: #f8f9fa"],
[data-theme="dark"] [style*="background:#f8f7fc"],
[data-theme="dark"] [style*="background: #f8f7fc"],
[data-theme="dark"] [style*="background:#fffdf5"],
[data-theme="dark"] [style*="background: #fffdf5"],
[data-theme="dark"] [style*="background:#e9ecef"],
[data-theme="dark"] [style*="background: #e9ecef"],
[data-theme="dark"] [style*="background-color:#e9ecef"] {
    background-color: rgba(255, 255, 255, 0.04) !important;
    color: var(--text-primary);
}

/* Badge avec fond clair Bootstrap utility (#dee2e6 etc.) */
[data-theme="dark"] [style*="background:#dee2e6"],
[data-theme="dark"] [style*="background: #dee2e6"] {
    background-color: rgba(255, 255, 255, 0.10) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] [style*="background:#e9ecef"] {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] [style*="color:#333"],
[data-theme="dark"] [style*="color: #333"],
[data-theme="dark"] [style*="color:#495057"],
[data-theme="dark"] [style*="color: #495057"],
[data-theme="dark"] [style*="color:#6c757d"],
[data-theme="dark"] [style*="color: #6c757d"],
[data-theme="dark"] [style*="color:#adb5bd"],
[data-theme="dark"] [style*="color: #adb5bd"] {
    color: var(--text-primary) !important;
}

/* Bordures Bootstrap */
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-right,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-left {
    border-color: var(--border-soft) !important;
}

[data-theme="dark"] .list-group-item {
    background-color: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-soft);
}

/* Texte muted utilisateur */
[data-theme="dark"] small,
[data-theme="dark"] .small {
    color: inherit;
}

/* ──────────────────────────────────────────────────────────
   Sombre — round 3 : pages spécifiques signalées en QA
   ────────────────────────────────────────────────────────── */

/* Coach IA — neutralise le halo lumineux ::before */
[data-theme="dark"] .coach-ia-page::before {
    background:
        radial-gradient(900px 320px at 15% 0%, rgba(106, 61, 139, 0.35) 0%, rgba(106, 61, 139, 0) 60%),
        radial-gradient(700px 280px at 85% 10%, rgba(76, 211, 145, 0.18) 0%, rgba(76, 211, 145, 0) 62%),
        linear-gradient(180deg, rgba(34, 24, 51, 0.55) 0%, rgba(20, 16, 30, 0.20) 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .coach-ia-chapter-btn {
    color: #f0e7ff;
    border-color: rgba(255, 255, 255, 0.30);
    background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .coach-ia-chapter-btn:hover,
[data-theme="dark"] .coach-ia-chapter-btn:focus {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

[data-theme="dark"] .coach-ia-chapter-btn.is-selected {
    background: rgba(162, 213, 198, 0.18);
    color: #ffffff;
    border-color: rgba(162, 213, 198, 0.45);
}

/* Upload — dropzone et footer */
[data-theme="dark"] .upl-dropzone {
    background: #221833;
    border-color: rgba(255, 255, 255, 0.18);
    color: #f0e7ff;
}

[data-theme="dark"] .upl-dropzone.drag {
    background: #2c2348;
    border-color: var(--violet-600);
    color: #ffffff;
}

[data-theme="dark"] #browse,
[data-theme="dark"] #dropzone .btn,
[data-theme="dark"] .upl-dropzone .btn {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.22);
    color: #f0e7ff;
}

[data-theme="dark"] #browse:hover,
[data-theme="dark"] .upl-dropzone .btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

[data-theme="dark"] .upl-footer {
    background: transparent;
    color: var(--text-primary);
}

[data-theme="dark"] .upl-footer a,
[data-theme="dark"] .upl-footer .text-muted {
    color: rgba(240, 231, 255, 0.7);
}

/* Dictionary editor — barre de recherche */
[data-theme="dark"] .ude-search-bar {
    background: #221833;
    border-color: rgba(255, 255, 255, 0.10);
    color: #f0e7ff;
}

[data-theme="dark"] .ude-search-bar input,
[data-theme="dark"] .ude-search-bar__input,
[data-theme="dark"] .ude-search-bar .form-control {
    background: #1a1228;
    color: #f0e7ff;
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .ude-search-bar input::placeholder,
[data-theme="dark"] .ude-search-bar .form-control::placeholder {
    color: rgba(240, 231, 255, 0.45);
}

/* Curricula — bouton primary lisible (texte blanc sur fond violet) */
[data-theme="dark"] .btn-primary {
    background-color: #6a3d8b !important;
    border-color: #6a3d8b !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-primary:focus {
    background-color: #7d4ea3 !important;
    border-color: #7d4ea3 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-primary:disabled,
[data-theme="dark"] .btn-primary.disabled {
    background-color: #4a3a6a !important;
    border-color: #4a3a6a !important;
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Curricula programme — prochaine action highlight (background:#fffdf5 inline) */
[data-theme="dark"] .programme-next-action {
    background: rgba(255, 197, 58, 0.08) !important;
    border-left-color: #FFC53A !important;
    color: var(--text-primary);
}

/* Statistics — tous les fonds blancs */
[data-theme="dark"] .stats-wrapper {
    background: #1a1228;
    color: var(--text-primary);
}

[data-theme="dark"] .stats-header h3,
[data-theme="dark"] .chart-panel h4,
[data-theme="dark"] .feedback-list h4,
[data-theme="dark"] .group-results h4,
[data-theme="dark"] .insight-summary h5 {
    color: #b39bf0;
}

[data-theme="dark"] .stats-card,
[data-theme="dark"] .chart-panel,
[data-theme="dark"] .feedback-list,
[data-theme="dark"] .group-results,
[data-theme="dark"] .insight-card {
    background: #221833;
    border-color: rgba(255, 255, 255, 0.10);
    color: var(--text-primary);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .stats-card .label,
[data-theme="dark"] .stats-card .meta,
[data-theme="dark"] .activity-empty,
[data-theme="dark"] .chart-legend,
[data-theme="dark"] .feedback-list li,
[data-theme="dark"] .stats-filter label,
[data-theme="dark"] .stats-filter .activity-options label {
    color: rgba(240, 231, 255, 0.7);
}

[data-theme="dark"] .stats-card .value,
[data-theme="dark"] .stats-header strong {
    color: #f0e7ff;
}

[data-theme="dark"] .stats-filter select,
[data-theme="dark"] .stats-filter .activity-options {
    background: #1a1228;
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

[data-theme="dark"] .group-results th {
    color: rgba(240, 231, 255, 0.6);
}

[data-theme="dark"] .member-avatar {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Community — partage : shared-vocab-card */
[data-theme="dark"] .shared-vocab-card {
    background: #221833;
    border-color: rgba(255, 255, 255, 0.10);
    color: var(--text-primary);
}

[data-theme="dark"] .shared-vocab-card__title {
    color: #f0e7ff;
}

[data-theme="dark"] .shared-vocab-card__description {
    color: rgba(240, 231, 255, 0.72);
}

[data-theme="dark"] .shared-vocab-card__meta .badge {
    background: rgba(255, 255, 255, 0.10);
    color: var(--text-primary);
}

/* Bootstrap alerts (alert-info, success, warning, danger) — adaptation sombre */
[data-theme="dark"] .alert-info {
    background-color: rgba(90, 184, 255, 0.12);
    border-color: rgba(90, 184, 255, 0.35);
    color: #cfe7ff;
}

[data-theme="dark"] .alert-info a,
[data-theme="dark"] .alert-info .alert-link {
    color: #aed4ff;
}

[data-theme="dark"] .alert-success {
    background-color: rgba(76, 211, 145, 0.12);
    border-color: rgba(76, 211, 145, 0.35);
    color: #c8f5dd;
}

[data-theme="dark"] .alert-warning {
    background-color: rgba(255, 197, 58, 0.12);
    border-color: rgba(255, 197, 58, 0.35);
    color: #ffe9a8;
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(255, 107, 122, 0.12);
    border-color: rgba(255, 107, 122, 0.35);
    color: #ffc8ce;
}

[data-theme="dark"] .alert-primary {
    background-color: rgba(179, 155, 240, 0.12);
    border-color: rgba(179, 155, 240, 0.35);
    color: #d8c5ff;
}

[data-theme="dark"] .alert-secondary {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: #cfc4e8;
}

/* Page-help-card (gradient violet pâle clair → violet foncé en sombre) */
[data-theme="dark"] .page-help-card {
    background: linear-gradient(135deg, #2c2348 0%, #221833 100%);
    border-color: rgba(216, 197, 255, 0.18);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .page-help-text {
    color: #f0e7ff;
}

[data-theme="dark"] .page-help-title {
    color: #d8c5ff;
}

[data-theme="dark"] .page-help-lamp,
[data-theme="dark"] .page-help-close {
    color: #d8c5ff;
}

[data-theme="dark"] .page-help-toggle {
    background: #2c2348;
    border-color: rgba(216, 197, 255, 0.18);
    color: #d8c5ff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .page-help-toggle:hover {
    background: #3a2c5c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .page-help-tooltip {
    background: #1a1228;
    color: #f0e7ff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .page-help-tooltip strong {
    color: #d8c5ff;
}

/* ──────────────────────────────────────────────────────────
   Sombre — round 4 : QA ciblée
   ────────────────────────────────────────────────────────── */

/* Bootstrap nav-tabs / nav-pills (dictionary-editor onglets) */
[data-theme="dark"] .nav-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .nav-tabs .nav-link,
[data-theme="dark"] .nav-pills .nav-link {
    color: rgba(240, 231, 255, 0.7);
    background: transparent;
    border-color: transparent;
}

[data-theme="dark"] .nav-tabs .nav-link:hover,
[data-theme="dark"] .nav-pills .nav-link:hover {
    color: #f0e7ff;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .nav-tabs .nav-link.active,
[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    background: #221833;
    color: #f0e7ff;
    border-color: rgba(255, 255, 255, 0.12) rgba(255, 255, 255, 0.12) #221833;
}

[data-theme="dark"] .nav-pills .nav-link.active,
[data-theme="dark"] .nav-pills .show > .nav-link {
    background: #6a3d8b;
    color: #ffffff;
}

[data-theme="dark"] .nav-tabs .nav-link.disabled {
    color: rgba(240, 231, 255, 0.3);
}

/* Statistics — formulaire de filtres */
[data-theme="dark"] #stats-filter-form {
    background: #221833;
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

/* Curricula programme — bannière gamification (texte blanc à adoucir) */
[data-theme="dark"] #gamification-overlay > div:first-child {
    background: linear-gradient(135deg, #4a8276 0%, #3b2a5e 100%) !important;
    color: #f0e7ff !important;
}

[data-theme="dark"] #gamification-overlay [style*="color: #fff"],
[data-theme="dark"] #gamification-overlay [style*="color:#fff"] {
    color: #f0e7ff !important;
}

/* Community/groups/manage — boutons d'icônes de tuiles */
[data-theme="dark"] .page-tile-control-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.20);
    color: rgba(240, 231, 255, 0.78);
}

[data-theme="dark"] .page-tile-control-btn:hover,
[data-theme="dark"] .page-tile-control-btn:focus {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.40);
    color: #ffffff;
}

[data-theme="dark"] .page-tile-control-btn:disabled,
[data-theme="dark"] .page-tile-control-btn[disabled] {
    opacity: 0.4;
}

/* History (session_history.html) — sh-source dropdown trigger */
[data-theme="dark"] .sh-source-trigger {
    color: #b39bf0;
}

[data-theme="dark"] .sh-source-trigger:hover,
[data-theme="dark"] .sh-source-trigger:focus {
    color: #d8c5ff;
}

[data-theme="dark"] .sh-source,
[data-theme="dark"] .sh-source-meta,
[data-theme="dark"] .sh-source-detail {
    color: var(--text-primary);
}

[data-theme="dark"] .sh-source-menu {
    background: var(--surface-card);
    border-color: var(--border-soft);
}

[data-theme="dark"] .sh-source-menu .dropdown-item {
    color: var(--text-primary);
}

/* Réduire les transitions de couleur si l'utilisateur préfère */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-property: none !important;
    }
}

/* ============================================================
   Thème sombre — pages Gestion (IA, Reporting) & Rôles/Droits
   Règle charte : texte clair sur fond foncé, y compris tableaux
   et onglets. Les styles clairs vivent dans les <style> des
   templates (management/ia.html, management/reporting.html,
   management/page.html, community/roles_manage.html) ; les
   overrides sombres sont centralisés ici.
   ============================================================ */

/* Surfaces principales (cartes, sections, tableaux encadrés) */
html[data-theme="dark"] .management-card,
html[data-theme="dark"] .management-block,
html[data-theme="dark"] .management-table,
html[data-theme="dark"] .management-notice,
html[data-theme="dark"] .management-form-block,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .dash-section,
html[data-theme="dark"] .ia-prompt-kpi,
html[data-theme="dark"] .ia-scenario-card,
html[data-theme="dark"] .ia-scenario-metric,
html[data-theme="dark"] .fb-card,
html[data-theme="dark"] .fb-section,
html[data-theme="dark"] .role-card,
html[data-theme="dark"] .override-card,
[data-bs-theme="dark"] .management-card,
[data-bs-theme="dark"] .management-block,
[data-bs-theme="dark"] .management-table,
[data-bs-theme="dark"] .management-notice,
[data-bs-theme="dark"] .management-form-block,
[data-bs-theme="dark"] .kpi-card,
[data-bs-theme="dark"] .dash-section,
[data-bs-theme="dark"] .ia-prompt-kpi,
[data-bs-theme="dark"] .ia-scenario-card,
[data-bs-theme="dark"] .ia-scenario-metric,
[data-bs-theme="dark"] .fb-card,
[data-bs-theme="dark"] .fb-section,
[data-bs-theme="dark"] .role-card,
[data-bs-theme="dark"] .override-card {
    background: #241d2f;
    border-color: rgba(162, 213, 198, 0.16);
    color: #e9e4f0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Textes secondaires / libellés gris foncé → gris clair */
html[data-theme="dark"] .management-card-label,
html[data-theme="dark"] .management-card-helper,
html[data-theme="dark"] .management-checklist-item,
html[data-theme="dark"] .management-table thead th,
html[data-theme="dark"] .management-fieldset-help,
html[data-theme="dark"] .management-field-help,
html[data-theme="dark"] .kpi-card .kpi-label,
html[data-theme="dark"] .ia-filter-bar label,
html[data-theme="dark"] .ia-prompts-meta,
html[data-theme="dark"] .ia-prompt-kpi .label,
html[data-theme="dark"] .ia-scenario-metric .label,
html[data-theme="dark"] .fb-card-label,
html[data-theme="dark"] .fb-card-helper,
html[data-theme="dark"] .fb-table th,
html[data-theme="dark"] .dash-loading,
html[data-theme="dark"] .stuck-card .stuck-meta,
html[data-theme="dark"] .stuck-card .stuck-note,
html[data-theme="dark"] .stuck-card .stuck-info .stuck-uuid,
[data-bs-theme="dark"] .management-card-label,
[data-bs-theme="dark"] .management-card-helper,
[data-bs-theme="dark"] .management-checklist-item,
[data-bs-theme="dark"] .management-table thead th,
[data-bs-theme="dark"] .kpi-card .kpi-label,
[data-bs-theme="dark"] .fb-card-label,
[data-bs-theme="dark"] .fb-card-helper,
[data-bs-theme="dark"] .fb-table th {
    color: #b7aecb;
}

/* Valeurs fortes / titres */
html[data-theme="dark"] .management-card-value,
html[data-theme="dark"] .management-fieldset legend,
html[data-theme="dark"] .ia-prompt-kpi .value,
html[data-theme="dark"] .ia-scenario-metric .value,
html[data-theme="dark"] .fb-card-value,
html[data-theme="dark"] .stuck-card .stuck-debug summary,
[data-bs-theme="dark"] .management-card-value,
[data-bs-theme="dark"] .fb-card-value {
    color: #e9e4f0;
}

/* Onglets Gestion (IA / Reporting) et Rôles */
html[data-theme="dark"] .management-tab,
html[data-theme="dark"] .roles-tab,
[data-bs-theme="dark"] .management-tab,
[data-bs-theme="dark"] .roles-tab {
    color: #b7aecb;
}
html[data-theme="dark"] .management-tab:hover,
html[data-theme="dark"] .roles-tab:hover,
[data-bs-theme="dark"] .management-tab:hover,
[data-bs-theme="dark"] .roles-tab:hover {
    color: #e9e4f0;
}
html[data-theme="dark"] .management-tab.is-active,
html[data-theme="dark"] .roles-tab.is-active,
[data-bs-theme="dark"] .management-tab.is-active,
[data-bs-theme="dark"] .roles-tab.is-active {
    color: #A2D5C6;
    border-bottom-color: #A2D5C6;
}

/* Tableaux du dashboard IA */
html[data-theme="dark"] .dash-table th {
    background: #2a2433;
    color: #cfc7e0;
}
html[data-theme="dark"] .dash-table th,
html[data-theme="dark"] .dash-table td {
    border-bottom-color: rgba(162, 213, 198, 0.12);
}
html[data-theme="dark"] .dash-table tr:hover td {
    background: #2a2433;
}
html[data-theme="dark"] .dash-section h3 {
    border-bottom-color: rgba(162, 213, 198, 0.2);
}

/* Cartes « jobs bloqués », préformatés, boutons du dashboard IA */
html[data-theme="dark"] .stuck-card {
    background: #35222c;
    border-color: rgba(237, 71, 74, 0.4);
    color: #e9e4f0;
}
html[data-theme="dark"] .stuck-card .stuck-debug pre,
html[data-theme="dark"] .ia-prompts-pre {
    background: #1d1826;
    color: #e9e4f0;
    border-color: rgba(162, 213, 198, 0.2);
}
html[data-theme="dark"] .btn-sm-dash {
    background: #2a2433;
    color: #e9e4f0;
    border-color: rgba(162, 213, 198, 0.35);
}
html[data-theme="dark"] .btn-sm-dash:hover {
    background: #362e44;
}
html[data-theme="dark"] .ia-prompts-preview-row td {
    background: #241d2f;
}
html[data-theme="dark"] .ia-scenario-card {
    background: #241d2f;
}
html[data-theme="dark"] .ia-scenario-projection {
    background: rgba(162, 213, 198, 0.08);
}
html[data-theme="dark"] .management-fieldset {
    background: rgba(162, 213, 198, 0.06);
    border-color: rgba(162, 213, 198, 0.18);
}
html[data-theme="dark"] .ia-pager a,
html[data-theme="dark"] .ia-pager span {
    color: #cfc7e0;
    border-color: rgba(162, 213, 198, 0.25);
}
html[data-theme="dark"] .ia-pager a:hover {
    background: #2a2433;
}

/* Alertes du dashboard IA */
html[data-theme="dark"] .alert-warning-dash { background: #3a3220; border-color: #9a8420; color: #ffe9a8; }
html[data-theme="dark"] .alert-critical { background: #3a2226; border-color: #8f3a42; color: #f5b8bd; }
html[data-theme="dark"] .alert-ok { background: #20342a; border-color: #2e6b47; color: #b9e6c9; }

/* Badges feedback (reporting) */
html[data-theme="dark"] .fb-badge-green { background: rgba(26, 122, 76, 0.25); color: #8fdcb4; }
html[data-theme="dark"] .fb-badge-yellow { background: rgba(154, 103, 0, 0.25); color: #f2cd7e; }
html[data-theme="dark"] .fb-badge-red { background: rgba(194, 48, 48, 0.25); color: #f2a1a1; }
html[data-theme="dark"] .fb-table th,
html[data-theme="dark"] .fb-table td {
    border-bottom-color: rgba(162, 213, 198, 0.12);
}

/* Page Rôles & Droits (community/roles_manage.html) */
html[data-theme="dark"] .role-card-title,
[data-bs-theme="dark"] .role-card-title {
    color: #e9e4f0;
}
html[data-theme="dark"] .perm-matrix th {
    background: rgba(125, 95, 167, 0.22);
    color: #e9e4f0;
}
html[data-theme="dark"] .perm-matrix th,
html[data-theme="dark"] .perm-matrix td {
    border-color: rgba(162, 213, 198, 0.14);
}
html[data-theme="dark"] .perm-matrix .perm-cat-row td {
    background: rgba(125, 95, 167, 0.28);
    color: #cbb6ea;
}
html[data-theme="dark"] .perm-matrix .perm-denied { color: #5c5470; }
html[data-theme="dark"] .perm-key-hint { color: #8f86a3; }
html[data-theme="dark"] .delete-confirm-dialog {
    background: #241d2f;
    color: #e9e4f0;
}

/* ── Coach IA : page de correction & annotations — lisibilité thème sombre ──
   Retour utilisateur 2026-07-08 : titres de sections (Annotations,
   Suggestions, Points forts…) et légende gris foncé sur fond sombre. */
html[data-theme="dark"] .coach-ia-correction-page .text-muted,
html[data-theme="dark"] .coach-ia-annotation-list .text-muted,
[data-bs-theme="dark"] .coach-ia-correction-page .text-muted,
[data-bs-theme="dark"] .coach-ia-annotation-list .text-muted {
    color: #b7aecb !important;
}
html[data-theme="dark"] .coach-ia-annotation-list .border,
[data-bs-theme="dark"] .coach-ia-annotation-list .border {
    border-color: rgba(162, 213, 198, 0.22) !important;
}
html[data-theme="dark"] .coach-ia-annotation-legend,
html[data-theme="dark"] .coach-ia-annotation-legend small,
[data-bs-theme="dark"] .coach-ia-annotation-legend,
[data-bs-theme="dark"] .coach-ia-annotation-legend small {
    color: #cfc7e0 !important;
}
/* Les pastilles de la légende utilisent des fonds translucides pensés pour le
   thème clair : en sombre on ajoute un liseré clair pour qu'elles ressortent. */
html[data-theme="dark"] .coach-ia-legend-swatch,
[data-bs-theme="dark"] .coach-ia-legend-swatch {
    outline: 1px solid rgba(233, 228, 240, 0.45);
    outline-offset: 0;
}
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-grammar    { background: rgba(237, 71, 74, 0.55); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-spelling   { background: rgba(255, 197, 58, 0.6); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-style      { background: rgba(53, 167, 255, 0.55); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-coherence  { background: rgba(146, 108, 210, 0.6); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-suggestion { background: rgba(162, 213, 198, 0.6); }

/* ── Étape 1 Coach IA : boutons d'intention lisibles dans les deux thèmes,
   y compris à l'état désactivé (textarea vide au chargement). ── */
#coach-ia-paste-form .btn-primary {
    background-color: #5C3C92;
    border-color: #5C3C92;
    color: #ffffff;
}
#coach-ia-paste-form .btn-primary:hover,
#coach-ia-paste-form .btn-primary:focus {
    background-color: #6f4bae;
    border-color: #6f4bae;
    color: #ffffff;
}
#coach-ia-paste-form .btn-outline-primary {
    color: #5C3C92;
    border-color: #5C3C92;
}
#coach-ia-paste-form .btn-outline-primary:hover,
#coach-ia-paste-form .btn-outline-primary:focus {
    background-color: rgba(92, 60, 146, 0.12);
    color: #4a2f77;
    border-color: #4a2f77;
}
#coach-ia-paste-form .btn:disabled {
    opacity: 0.75;
}
html[data-theme="dark"] #coach-ia-paste-form .btn-primary,
[data-bs-theme="dark"] #coach-ia-paste-form .btn-primary {
    background-color: #7d4ea3 !important;
    border-color: #7d4ea3 !important;
    color: #ffffff !important;
}
html[data-theme="dark"] #coach-ia-paste-form .btn-outline-primary,
[data-bs-theme="dark"] #coach-ia-paste-form .btn-outline-primary {
    color: #cbb6ea;
    border-color: #cbb6ea;
}
html[data-theme="dark"] #coach-ia-paste-form .btn:disabled,
[data-bs-theme="dark"] #coach-ia-paste-form .btn:disabled {
    opacity: 0.7;
}

/* ── Cartes d'annotations de la correction : reprendre les couleurs de la
   légende (bordure gauche + liseré) selon le type d'erreur. ── */
.coach-ia-annotation-card { border-left-width: 4px !important; }
.coach-ia-annotation-card--grammar    { border-left-color: #ED474A !important; }
.coach-ia-annotation-card--spelling   { border-left-color: #FFC53A !important; }
.coach-ia-annotation-card--style      { border-left-color: #35A7FF !important; }
.coach-ia-annotation-card--coherence  { border-left-color: #5C3C92 !important; }
.coach-ia-annotation-card--suggestion { border-left-color: #A2D5C6 !important; }
html[data-theme="dark"] .coach-ia-annotation-card--coherence { border-left-color: #926cd2 !important; }

/* ── Statistiques — légendes des donuts (Répartition par type d'activité,
   formats/blocs Coach IA) : la classe `.activity-legend` porte un texte quasi
   noir (#111827) codé en dur dans statistics.html → illisible en sombre. ── */
html[data-theme="dark"] .activity-legend,
[data-bs-theme="dark"] .activity-legend {
    color: rgba(240, 231, 255, 0.88);
}

/* Thème sombre : texte clair sur fond foncé, y compris dans le fil du dialogue
   et les séries phonétiques (charte obligatoire). */
html[data-theme="dark"] .coach-ia-dialogue__turn--partner,
html[data-theme="dark"] .coach-ia-dialogue__turn--learner,
[data-bs-theme="dark"] .coach-ia-dialogue__turn--partner,
[data-bs-theme="dark"] .coach-ia-dialogue__turn--learner {
    color: #f2f5f8;
}

html[data-theme="dark"] .coach-ia-dialogue__turn--partner,
[data-bs-theme="dark"] .coach-ia-dialogue__turn--partner {
    background: rgba(162, 213, 198, 0.16);
}

html[data-theme="dark"] .coach-ia-dialogue__turn--learner,
[data-bs-theme="dark"] .coach-ia-dialogue__turn--learner {
    background: rgba(53, 167, 255, 0.18);
}

html[data-theme="dark"] .coach-ia-dialogue__state,
[data-bs-theme="dark"] .coach-ia-dialogue__state {
    color: #c9d3dd;
}

html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-conjugation { background: rgba(255, 197, 58, 0.6); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-lexis       { background: rgba(53, 167, 255, 0.55); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-syntax      { background: rgba(146, 108, 210, 0.6); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-register    { background: rgba(255, 99, 146, 0.55); }
html[data-theme="dark"] .coach-ia-legend-swatch.coach-ia-issue--type-idiom       { background: rgba(162, 213, 198, 0.6); }

/* Série phonétique : verdicts et carte */
.coach-ia-phonetic__verdict.is-target { color: #1d7a5f; }
.coach-ia-phonetic__verdict.is-distractor { color: #ED474A; }
.coach-ia-phonetic__verdict.is-other { color: #6c757d; }
.coach-ia-phonetic__ipa { font-family: inherit; }
.coach-ia-phonetic__slot { background: rgba(255, 228, 94, 0.55); padding: 0 0.15rem; }

html[data-theme="dark"] .coach-ia-phonetic__verdict.is-target,
[data-bs-theme="dark"] .coach-ia-phonetic__verdict.is-target { color: #7fd9b8; }
html[data-theme="dark"] .coach-ia-phonetic__verdict.is-distractor,
[data-bs-theme="dark"] .coach-ia-phonetic__verdict.is-distractor { color: #ff8b8d; }
html[data-theme="dark"] .coach-ia-phonetic__verdict.is-other,
[data-bs-theme="dark"] .coach-ia-phonetic__verdict.is-other { color: #c9d3dd; }
html[data-theme="dark"] .coach-ia-phonetic__slot,
[data-bs-theme="dark"] .coach-ia-phonetic__slot { background: rgba(255, 228, 94, 0.3); color: #f2f5f8; }
html[data-theme="dark"] .coach-ia-phonetic__ipa,
[data-bs-theme="dark"] .coach-ia-phonetic__ipa { color: #c9d3dd; }

/* Lecture à voix haute : puces de mots */
.coach-ia-word {
    border: 1px solid transparent;
    border-radius: 0.35rem;
    padding: 0.1rem 0.35rem;
    background: transparent;
    font: inherit;
    cursor: pointer;
}
.coach-ia-word--good { background: rgba(162, 213, 198, 0.45); color: #14503c; }
.coach-ia-word--needs-work { background: rgba(255, 99, 146, 0.28); color: #7a1230; }
.coach-ia-word--retried { background: rgba(255, 228, 94, 0.5); color: #5a4300; }

html[data-theme="dark"] .coach-ia-word--good,
[data-bs-theme="dark"] .coach-ia-word--good { background: rgba(162, 213, 198, 0.28); color: #b9ecd9; }
html[data-theme="dark"] .coach-ia-word--needs-work,
[data-bs-theme="dark"] .coach-ia-word--needs-work { background: rgba(255, 99, 146, 0.3); color: #ffc0d1; }
html[data-theme="dark"] .coach-ia-word--retried,
[data-bs-theme="dark"] .coach-ia-word--retried { background: rgba(255, 228, 94, 0.28); color: #ffeaa0; }

.coach-ia-read-aloud__tip {
    position: absolute;
    z-index: 30;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    max-width: 22rem;
}
.coach-ia-read-aloud { position: relative; }
.coach-ia-read-aloud__tip-close {
    position: absolute; top: 0.2rem; right: 0.4rem;
    border: 0; background: transparent; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.coach-ia-read-aloud__score { font-size: 1.4rem; font-weight: 600; }

html[data-theme="dark"] .coach-ia-read-aloud__tip,
[data-bs-theme="dark"] .coach-ia-read-aloud__tip {
    background: #1f2a36;
    color: #f2f5f8;
    border-color: rgba(255, 255, 255, 0.18);
}
html[data-theme="dark"] .coach-ia-read-aloud__tip-close,
[data-bs-theme="dark"] .coach-ia-read-aloud__tip-close { color: #f2f5f8; }
html[data-theme="dark"] .coach-ia-read-aloud__score,
[data-bs-theme="dark"] .coach-ia-read-aloud__score { color: #f2f5f8; }
html[data-theme="dark"] .coach-ia-read-aloud__text,
[data-bs-theme="dark"] .coach-ia-read-aloud__text { background: #1f2a36 !important; color: #f2f5f8; }
