/* BTS CG — styles propres au site, par-dessus /style.css (couleurs et base communes de lilas3.com).

   Thème : automatique (suit l'appareil) par défaut ; le bouton de la barre du haut peut forcer
   <html data-theme="dark"> ou <html data-theme="light"> (choix gardé dans le navigateur, voir assets/bts.js).
   Toutes les couleurs passent par les variables ci-dessous : ne jamais écrire une couleur en dur. */

:root {
    --g1: #7b4fc9;      /* couleurs des graphiques (assets/bts.js) */
    --g2: #1a9e8f;
    --g3: #d9822b;
    --g4: #c2417a;
    --g5: #3f6fd1;
    --g6: #8a8496;
    --code-bg: #f3eefb;
    --ok: #18703a;
    --ok-bg: #dcf5e4;
    --warn: #a24c00;
    --warn-bg: #fff3e0;
    --on-accent: #fff;  /* texte posé sur la couleur d'accent (boutons pleins) */
}

/* Sombre automatique (appareil en mode sombre, sauf si « clair » est forcé) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --g1: #b395f0;
        --g2: #4fd1c0;
        --g3: #f2a65a;
        --g4: #f07aaf;
        --g5: #7fa6ff;
        --g6: #a49cb3;
        --code-bg: #261f33;
        --ok: #7ee0a2;
        --ok-bg: #143a24;
        --warn: #ffb866;
        --warn-bg: #3d2a12;
        --on-accent: #14111a;
        /* Pied de page uni (pas de dégradé ni de flou en mode sombre) */
        --pied-fond: var(--surface);
        --pied-haut: 0px;
        --pied-haut-mobile: 0px;
        --pied-bord: 1px solid var(--border);
        --pied-flou: none;
        --pied-reserve: 62px;
        --footer-mid: var(--bg);
        --footer-end: var(--bg);
    }
}

/* Sombre forcé : couleurs de /style.css (mode sombre) + celles du site */
:root[data-theme="dark"] {
    --bg: #14111a;
    --bg-accent: #1d1727;
    --surface: #1e1a26;
    --text: #ece8f3;
    --muted: #a49cb3;
    --border: #2f2840;
    --accent: #b395f0;
    --accent-soft: #2a2240;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 18px 40px -16px rgba(0, 0, 0, .7);
    --footer-mid: #2f2840;
    --footer-end: #0b0910;
    --footer-text: #b9b1c8;
    --scroll-thumb: #4a3d66;
    --g1: #b395f0;
    --g2: #4fd1c0;
    --g3: #f2a65a;
    --g4: #f07aaf;
    --g5: #7fa6ff;
    --g6: #a49cb3;
    --code-bg: #261f33;
    --ok: #7ee0a2;
    --ok-bg: #143a24;
    --warn: #ffb866;
    --warn-bg: #3d2a12;
    --on-accent: #14111a;
    --pied-fond: var(--surface);
    --pied-haut: 0px;
    --pied-haut-mobile: 0px;
    --pied-bord: 1px solid var(--border);
    --pied-flou: none;
    --pied-reserve: 62px;
    --footer-mid: var(--bg);
    --footer-end: var(--bg);
    color-scheme: dark;
}

/* Barres de défilement des zones internes (sommaire, liste de recherche, tableaux…) : piste transparente,
   curseur fin et arrondi. /style.css donne à toutes les barres le dégradé du pied de page, prévu pour la page entière. */
body.bts *::-webkit-scrollbar { width: 10px; height: 10px; }
body.bts *::-webkit-scrollbar-track { background: transparent; }
body.bts *::-webkit-scrollbar-corner { background: transparent; }
body.bts *::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: color-mix(in srgb, var(--scroll-thumb) 70%, transparent) padding-box;
}
body.bts *::-webkit-scrollbar-thumb:hover { background: var(--accent) padding-box; }

@supports not selector(::-webkit-scrollbar) {
    body.bts * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
}

/* Pied de page : dégradé de lilas3.com en mode clair, mais plus bas et moins flou pour ne pas gêner la lecture ;
   barre unie en mode sombre. --pied-reserve = hauteur qu'il occupe en bas de l'écran (le sommaire s'arrête au-dessus). */
body.bts .site-footer {
    padding-top: var(--pied-haut, 30px);
    border-top: var(--pied-bord, 0);
    background: var(--pied-fond, linear-gradient(180deg, transparent 0%, var(--footer-mid) 45%, var(--footer-end) 100%));
}

body.bts .site-footer::before {
    display: var(--pied-flou, block);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

@media (max-width: 560px) {
    body.bts .site-footer { padding-top: var(--pied-haut-mobile, 24px); }
}

/* Clair forcé (même si l'appareil est en mode sombre) : couleurs claires de /style.css */
:root[data-theme="light"] {
    --bg: #f6f3fb;
    --bg-accent: #ece4f7;
    --surface: #ffffff;
    --text: #231d2e;
    --muted: #6b6378;
    --border: #e2daee;
    --accent: #7b4fc9;
    --accent-soft: #efe7fb;
    --shadow: 0 1px 2px rgba(35, 29, 46, .05), 0 8px 24px -12px rgba(76, 44, 140, .18);
    --shadow-hover: 0 2px 4px rgba(35, 29, 46, .06), 0 18px 40px -16px rgba(76, 44, 140, .35);
    --footer-mid: #e2daee;
    --footer-end: #c9b8e0;
    --footer-text: #4a4259;
    --scroll-thumb: #c4b0e6;
    color-scheme: light;
}

/* Bouton de thème (barre du haut) */
.bts-bar-droite { display: flex; align-items: center; gap: 14px; }

.bts-theme {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.bts-theme:hover { border-color: var(--accent); color: var(--accent); }
.bts-theme:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bts-theme svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bts-theme [data-icone] { display: none; }
.bts-theme[data-mode="auto"] [data-icone="auto"],
.bts-theme[data-mode="dark"] [data-icone="dark"],
.bts-theme[data-mode="light"] [data-icone="light"] { display: block; }

@media (max-width: 480px) {
    .bts-theme-libelle { display: none; }
}

/* ---------- Barre du haut ---------- */

.bts-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.bts-bar .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
}

.bts-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 750;
    font-size: 17px;
    text-decoration: none;
}

.bts-logo img { border-radius: 7px; }

.bts-logo span {
    color: var(--muted);
    font-weight: 500;
    font-size: 14px;
}

.bts-bar-link {
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
}

.bts-bar-link:hover { color: var(--accent); }

@media (max-width: 420px) {
    .bts-logo span { display: none; }
}

/* ---------- Onglets de l'accueil (P1…P7 + maison) ---------- */

/* Bloc « barre + titre » : le titre de l'onglet choisi est accroché sous la barre */
.bts-onglets-bloc {
    margin: 8px 0 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.bts-onglets {
    display: grid;
    grid-template-columns: 64px repeat(var(--parties, 7), minmax(0, 1fr));   /* --parties : nombre d'onglets de la matière */
    border-bottom: 1px solid var(--border);
}

.bts-onglet-titre {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px clamp(16px, 3vw, 24px) 12px;
    background: var(--surface);
}

/* Bouton « Réviser » (à droite du titre de l'onglet) */
.bts-reviser {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 13.5px;
    font-weight: 650;
    text-decoration: none;
    transition: filter .15s ease;
}

.bts-reviser[hidden] { display: none; }
.bts-reviser:hover { filter: brightness(1.08); }

.bts-reviser svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linejoin: round;
}


@media (max-width: 480px) {
    .bts-onglet-titre { flex-wrap: wrap; }
}

.bts-onglet-titre h2 {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
}

.bts-onglet-titre p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13.5px;
}

.bts-onglet {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 8px 4px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.bts-onglet + .bts-onglet { border-left: 1px solid var(--border); }

.bts-onglet strong {
    color: var(--accent);
    font-size: 15px;
    line-height: 1.2;
}

button.bts-onglet:hover { background: var(--accent-soft); }
button.bts-onglet:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

.bts-onglet[aria-selected="true"] {
    border-bottom-color: var(--accent);
    background: var(--accent-soft);
}

/* Processus sans fiche : grisé, non cliquable */
.bts-onglet.is-vide { cursor: default; opacity: .45; filter: grayscale(1); }
.bts-onglet.is-vide strong { color: var(--muted); }

.bts-onglet-maison svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Écran étroit : les 8 onglets tiennent sur une ligne */
@media (max-width: 480px) {
    .bts-onglets { grid-template-columns: repeat(calc(var(--parties, 7) + 1), minmax(0, 1fr)); }
    .bts-onglet { padding: 8px 2px; }
    .bts-onglet strong { font-size: 14px; }
    .bts-onglet-maison svg { width: 18px; height: 18px; }
}

/* Page de l'onglet choisi : bloc séparé de la barre */
.bts-panneau {
    margin: 20px 0 24px;
    padding: clamp(18px, 4vw, 36px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.bts-panneau[hidden] { display: none; }
.bts-panneau > .projects:first-child { margin-top: 0; }
.bts-panneau > .bts-panneau-sous-titre:first-child { margin-top: 0; }

.bts-panneau-sous-titre {
    margin: 30px 0 14px;
    padding-left: 12px;
    border-left: 4px solid var(--accent);
    font-size: 19px;
}


/* Rubriques d'un onglet : Scénarios, Cas, Présentation */
.bts-rubrique {
    margin: 30px 0 14px;
    padding-left: 12px;
    border-left: 4px solid var(--accent);
    font-size: 19px;
}

.bts-panneau > .bts-rubrique:first-child,
.bts-panneau > markdown + noscript + .bts-rubrique { margin-top: 0; }
.bts-panneau > markdown + .bts-rubrique,
.bts-panneau > markdown + noscript + .bts-rubrique { margin-top: 34px; }

.bts-rubrique-vide { margin: 0; color: var(--muted); font-size: 15px; }

/* Cartes d'éléments */
.bts-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bts-carte {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.bts-carte:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); }
.bts-carte[hidden] { display: none; }

/* Corps : gros titre, étiquette « Chapitre 1 », description.
   Toute la carte mène au Cours : le lien du titre est étendu à la carte (::after),
   les cases du pied passent au-dessus pour garder leur propre lien. */
.bts-carte { position: relative; }

.bts-carte-corps {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px 14px;
}

.bts-carte h3 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }

.bts-carte-global { color: inherit; text-decoration: none; }
.bts-carte-global::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.bts-carte-global:focus-visible { outline: none; }
.bts-carte:has(.bts-carte-global:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.bts-carte:has(.bts-carte-global:hover) h3 { color: var(--accent); }
.bts-carte-pages { position: relative; z-index: 1; background: var(--surface); }

.bts-carte-etiquette {
    margin: 2px 0 0;
    color: var(--accent);
    font-size: 13px;
    font-weight: 650;
}

.bts-carte-desc { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Pied : cases Cours | Fiche | Test sur toute la largeur */
.bts-carte-pages {
    display: grid;
    grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
    border-top: 1px solid var(--border);
}

.bts-carte-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 6px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    transition: background .15s ease;
}

.bts-carte-page + .bts-carte-page { border-left: 1px solid var(--border); }
a.bts-carte-page:hover { background: var(--accent-soft); }
a.bts-carte-page:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.bts-carte-page.is-vide { color: var(--muted); opacity: .45; cursor: default; }

/* Bouton Cours / Fiche / Test (cartes et en-tête d'une page) */
.bts-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent);
    font-size: 13.5px;
    font-weight: 650;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease;
}

a.bts-page:hover { border-color: var(--accent); background: var(--accent-soft); }
.bts-page.is-actif { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.bts-page.is-vide { color: var(--muted); opacity: .5; cursor: default; }

/* Onglet d'un processus : deux blocs séparés (Scénarios/Chapitres + Cas, puis Présentation).
   Le panneau n'est alors plus qu'un conteneur ; chaque bloc a son propre cadre. */
.bts-panneau:has(> .bts-bloc) {
    display: grid;
    gap: 20px;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

.bts-panneau:has(> .bts-bloc)[hidden] { display: none; }

.bts-bloc {
    min-width: 0;
    padding: clamp(18px, 4vw, 32px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.bts-bloc > .bts-rubrique:first-child { margin-top: 0; }

/* Présentation d'un processus, intégrée dans son bloc */
.bts-presentation markdown h2 { margin-top: 26px; font-size: 18px; }
.bts-presentation markdown .osm-md-section:first-child > h2 { margin-top: 0; }
.bts-presentation markdown h3 { font-size: 16px; }


/* ---------- Boutons, cases ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 22px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    transition: filter .15s ease, opacity .15s ease;
}

.btn:hover { filter: brightness(1.08); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-ghost {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--accent);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.check:hover { border-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.check input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ---------- Fenêtre d'accord ---------- */

body.bts-verrou { overflow: hidden; }

.gate {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    overflow-y: auto;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.gate-box {
    width: 100%;
    max-width: 520px;
    display: grid;
    gap: 14px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow-hover);
}

.gate-icon { border-radius: 14px; }

.gate-box h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -.01em;
}

.gate-box p { margin: 0 0 8px; color: var(--muted); }
.gate-box #gate-but p:last-child { margin-bottom: 0; }
.gate-box strong { color: var(--text); }
.gate-box .btn { margin-top: 4px; }

.gate-note {
    font-size: 13px;
    text-align: center;
}

.gate-erreur {
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--warn-bg);
    color: var(--warn) !important;
    font-weight: 600;
}

@media (max-width: 480px) {
    .gate-box { padding: 20px; }
}

/* ---------- Accueil général : cartes des matières ---------- */

.bts-matieres { margin-bottom: 24px; }

.bts-matiere-tete { display: flex; align-items: center; gap: 12px; }

.bts-matiere-icone {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent-soft);
}

.bts-matiere-icone svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bts-carte-matiere .bts-carte-etiquette { margin-top: 6px; }
.bts-carte-matiere.is-bientot .bts-matiere-icone { filter: grayscale(1); opacity: .6; }
.bts-carte-matiere.is-bientot h3 { color: var(--muted); }

/* Matière sans cours : bloc « bientôt » */
.bts-bientot { text-align: center; }
.bts-bientot .bts-matiere-icone { width: 56px; height: 56px; margin: 0 auto 10px; }
.bts-bientot h2 { margin: 0 0 8px; font-size: 21px; }
.bts-bientot p { max-width: 560px; margin: 0 auto 12px; color: var(--muted); }

/* Lien « Toutes les matières » au-dessus du titre d'une matière */
.bts-retour { margin: 0 auto 6px !important; font-size: 14px !important; }
.bts-retour a { color: var(--muted); font-weight: 600; text-decoration: none; }
.bts-retour a::before { content: "← "; }
.bts-retour a:hover { color: var(--accent); }

/* ---------- Accueil d'une matière ---------- */

/* Recherche : barre + liste déroulante juste dessous (par-dessus la page) */
.bts-recherche {
    position: relative;
    z-index: 25;
    max-width: 620px;
    margin: 0 auto 28px;
}

.bts-recherche-ligne { display: flex; align-items: center; gap: 10px; }
.bts-recherche-champ { position: relative; flex: 1; min-width: 0; }

/* « Annuler » : seulement en plein écran sur téléphone */
.bts-recherche-annuler {
    display: none;
    flex: none;
    padding: 8px 4px;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

/* Téléphone : recherche en plein écran au-dessus du clavier.
   --bts-vue = hauteur réellement visible (clavier déduit), fournie par assets/bts.js. */
@media (max-width: 700px) {
    body.bts-recherche-ouverte { overflow: hidden; }

    body.bts-recherche-ouverte .bts-recherche-boite {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 70;
        display: flex;
        flex-direction: column;
        height: var(--bts-vue, 100vh);
        padding: 10px 12px 10px;
        background: var(--bg);
    }

    body.bts-recherche-ouverte .bts-recherche-annuler { display: inline-flex; }

    body.bts-recherche-ouverte .bts-recherche-liste {
        position: static;
        flex: 0 1 auto;
        min-height: 0;
        max-height: none;
        margin-top: -1px;
    }

    body.bts-recherche-ouverte .bts-recherche-liste[hidden] { display: none; }
}

.bts-recherche-champ svg {
    position: absolute;
    top: 50%;
    left: 15px;
    width: 19px;
    height: 19px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}

.bts-recherche input {
    width: 100%;
    min-height: 48px;
    padding: 10px 16px 10px 44px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    box-shadow: var(--shadow);
}

.bts-recherche input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.bts-recherche input[aria-expanded="true"] { border-radius: 14px 14px 0 0; border-color: var(--accent); }

.bts-recherche-liste {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: min(62vh, 520px);
    overflow-y: auto;
    border: 1px solid var(--accent);
    border-top: 0;
    border-radius: 0 0 14px 14px;
    background: var(--surface);
    box-shadow: var(--shadow-hover);
    overscroll-behavior: contain;
}

.bts-recherche-liste[hidden] { display: none; }

.bts-res-tete {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
}

.bts-res {
    display: grid;
    gap: 2px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
}

.bts-res + .bts-res { border-top: 1px solid var(--border); }
.bts-res[aria-selected="true"], .bts-res:hover { background: var(--accent-soft); }

.bts-res-ou {
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.bts-res-titre { font-size: 15px; font-weight: 650; line-height: 1.3; }

.bts-res-extrait {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bts-res-extrait mark {
    padding: 0 2px;
    border-radius: 3px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}

.bts-res[aria-selected="true"] .bts-res-extrait mark,
.bts-res:hover .bts-res-extrait mark { background: var(--surface); }

.bts-cat { margin: 0 0 34px; scroll-margin-top: 72px; }

.bts-cat h2 {
    margin: 0;
    padding-left: 12px;
    border-left: 4px solid var(--accent);
    font-size: 21px;
}

.bts-cat-desc { margin: 4px 0 14px; padding-left: 16px; color: var(--muted); font-size: 15px; }

.bts-cat .projects { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.bts-cat .card { gap: 10px; padding: 18px 20px; }

.bts-cat .card h3 {
    margin: 0;
    font-size: 17.5px;
    line-height: 1.3;
}

.bts-avert,
.bts-alerte {
    max-width: 760px;
    margin: 10px auto 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--warn-bg);
    color: var(--warn);
    font-size: 14px;
    text-align: center;
}

.bts-alerte { margin-bottom: 20px; font-weight: 600; }

.bts-ok {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--ok-bg);
    color: var(--ok);
    font-weight: 600;
}

.bts-retirer {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

.bts-retirer p { margin-top: 0; }

/* ---------- Page d'un article ----------
   En-tête (gros titre + fil d'Ariane | cases Cours / Fiche / Test empilées),
   puis sommaire à gauche, article à droite avec Précédent / Suivant dessous. */

.bts-entete {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    margin: 22px 0 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.bts-entete.avec-pages { grid-template-columns: minmax(0, 1fr) 132px; }

.bts-entete-texte {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 18px clamp(18px, 3vw, 28px);
}

.bts-entete h1 {
    margin: 0;
    font-size: clamp(23px, 4vw, 31px);
    line-height: 1.15;
    letter-spacing: -.02em;
}

.bts-fil ol {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 0;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--muted);
    font-size: 13.5px;
}

.bts-fil li + li::before { content: "›"; margin: 0 8px; color: var(--muted); opacity: .7; }
.bts-fil a { color: var(--muted); text-decoration: none; }
.bts-fil a:hover { color: var(--accent); text-decoration: underline; }
.bts-fil [aria-current] { color: var(--text); font-weight: 600; }

/* Cases Cours / Fiche / Test : colonne à droite, séparées par des traits */
.bts-entete-pages {
    display: grid;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    border-left: 1px solid var(--border);
}

.bts-entete-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 6px 10px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    transition: background .15s ease;
}

.bts-entete-page + .bts-entete-page { border-top: 1px solid var(--border); }
a.bts-entete-page:hover { background: var(--accent-soft); }
a.bts-entete-page:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.bts-entete-page.is-actif { background: var(--accent); color: var(--on-accent); }
.bts-entete-page.is-vide { color: var(--muted); opacity: .45; cursor: default; }

/* Écran étroit : les cases passent sous le titre, côte à côte */
@media (max-width: 600px) {
    .bts-entete.avec-pages { grid-template-columns: minmax(0, 1fr); }
    .bts-entete-pages { grid-template-rows: none; grid-template-columns: repeat(3, minmax(0, 1fr)); border-left: 0; border-top: 1px solid var(--border); }
    .bts-entete-page + .bts-entete-page { border-top: 0; border-left: 1px solid var(--border); }
}

/* Le titre # de l'article est remplacé par le gros titre de l'en-tête */
.bts-article markdown h1 { display: none; }
.bts-article markdown .osm-md-niveau-1 > h1 + * { margin-top: 0; }

/* Largeur des pages : /style.css limite le contenu à 1080 px, trop étroit sur un grand écran.
   Ici, jusqu'à 1480 px (barre du haut, pages et pied de page restent alignés), avec des marges qui grandissent avec l'écran. */
.wrap { max-width: 1480px; padding-left: clamp(16px, 2.5vw, 36px); padding-right: clamp(16px, 2.5vw, 36px); }

.bts-colonne { display: grid; gap: 18px; min-width: 0; }

/* Cases d'auto-évaluation : listes « - [ ] … » d'Osmium Markdown 1.4.0 (état gardé par assets/bts.js) */
markdown li.osm-md-tache { margin: 6px 0; list-style: none; }
markdown ul:has(> li.osm-md-tache) { padding-left: 4px; }
markdown .osm-md-tache input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    accent-color: var(--accent);
    vertical-align: -3px;
}
markdown .osm-md-tache input[type="checkbox"]:not(:disabled) { cursor: pointer; }
markdown .osm-md-tache input[type="checkbox"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bts-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

/* Sommaire collé pendant la lecture : sous la barre du haut (76 px) et au-dessus du pied de page */
.bts-aside {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 76px - var(--pied-reserve, 92px) - 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.bts-article {
    min-width: 0;
    padding: clamp(18px, 4vw, 40px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

@media (min-width: 1400px) {
    .bts-layout { grid-template-columns: 270px minmax(0, 1fr); gap: 32px; }
}

@media (max-width: 860px) {
    .bts-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .bts-aside { position: static; max-height: none; }
}

/* Sommaire (Osmium Markdown, sans style par défaut) */
markdown-sommaire { display: block; font-size: 14.5px; }

markdown-sommaire .osm-md-sommaire-titre {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

markdown-sommaire ol { margin: 0; padding: 0; list-style: none; }
markdown-sommaire ol ol { padding-left: 14px; }
markdown-sommaire li { margin: 2px 0; }

markdown-sommaire a {
    display: block;
    padding: 4px 10px;
    border-left: 2px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    line-height: 1.35;
}

markdown-sommaire a:hover { color: var(--accent); }

markdown-sommaire a[aria-current="true"] {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 860px) {
    markdown-sommaire:not(:empty) {
        padding: 14px 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface);
    }
}

/* Texte de la fiche (Osmium Markdown, sans style par défaut) */
markdown { display: block; overflow-wrap: break-word; }

markdown .osm-md-section { scroll-margin-top: 76px; }

markdown h1 {
    margin: 0 0 18px;
    font-size: clamp(26px, 5vw, 34px);
    line-height: 1.15;
    letter-spacing: -.02em;
}

markdown h2 {
    margin: 34px 0 12px;
    padding-left: 12px;
    border-left: 4px solid var(--accent);
    font-size: 22px;
    line-height: 1.25;
}

markdown h3 { margin: 24px 0 8px; font-size: 18px; }
markdown h4 { margin: 18px 0 6px; font-size: 16px; }

markdown .osm-md-ancre {
    margin-left: .4em;
    color: var(--muted);
    font-weight: 400;
    text-decoration: none;
    opacity: 0;
    transition: opacity .15s;
}

markdown h1:hover .osm-md-ancre,
markdown h2:hover .osm-md-ancre,
markdown h3:hover .osm-md-ancre,
markdown .osm-md-ancre:focus { opacity: 1; }

markdown p, markdown ul, markdown ol { margin: 0 0 14px; }
markdown li { margin: 4px 0; }
markdown li > ul, markdown li > ol { margin: 4px 0 0; }

markdown blockquote {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-left: 4px solid var(--accent);
    border-radius: 0 12px 12px 0;
    background: var(--accent-soft);
}

markdown hr { margin: 28px 0; border: 0; border-top: 1px solid var(--border); }

markdown code {
    padding: .12em .4em;
    border-radius: 6px;
    background: var(--code-bg);
    font: .92em Consolas, "Courier New", monospace;
}

markdown pre {
    position: relative;
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--code-bg);
    overflow: hidden;
}

markdown pre code { display: block; padding: 0; overflow-x: auto; background: none; line-height: 1.55; }

markdown .osm-md-lang {
    position: absolute;
    top: 6px;
    right: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

markdown .osm-md-tableau { margin: 0 0 16px; overflow-x: auto; }

markdown table {
    min-width: 60%;
    border-collapse: collapse;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

markdown th, markdown td {
    padding: 7px 12px;
    border: 1px solid var(--border);
    vertical-align: top;
}

markdown th { background: var(--accent-soft); text-align: center; }
markdown td.osm-md-left { text-align: left; }
markdown td.osm-md-center { text-align: center; }
markdown td.osm-md-right { text-align: right; white-space: nowrap; }

markdown img { max-width: 100%; height: auto; border-radius: 10px; }

/* Graphiques (blocs ```graphique, voir assets/bts.js) */
.bts-graph {
    margin: 0 0 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
}

.bts-graph figcaption {
    margin: 0 0 10px;
    font-weight: 650;
}

.bts-graph-zone { position: relative; width: 100%; }

.bts-graph details { margin-top: 10px; font-size: 14px; }
.bts-graph summary { color: var(--muted); cursor: pointer; }
.bts-graph details table { margin-top: 8px; }

.bts-graph-erreur {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--warn-bg);
    color: var(--warn);
    font-size: 14px;
}

/* Schémas Mermaid (blocs ```mermaid) */
.bts-schema {
    margin: 0 0 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    overflow-x: auto;
}

.bts-schema-zone { min-height: 40px; text-align: center; }
.bts-schema-zone svg { max-width: 100%; height: auto; }

/* Blocs repliés (« :::details … ::: ») : réponses, corrigés */
.bts-repli {
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

.bts-repli > summary {
    padding: 12px 16px;
    color: var(--accent);
    font-weight: 650;
    cursor: pointer;
    list-style-position: inside;
}

.bts-repli > summary:hover { background: var(--accent-soft); border-radius: 12px; }
.bts-repli[open] > summary { border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.bts-repli > div { padding: 14px 16px 2px; }

.bts-article-pied {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px 20px;
    margin-top: 28px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13.5px;
}

.bts-suite {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 0;
}

.bts-suite a {
    display: grid;
    gap: 2px;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    transition: border-color .15s ease;
}

.bts-suite a:hover { border-color: var(--accent); }
.bts-suite small { color: var(--muted); font-weight: 500; }
.bts-suite .suiv { grid-column: 2; text-align: right; }

@media (max-width: 560px) {
    .bts-suite { grid-template-columns: 1fr; }
    .bts-suite .suiv { grid-column: 1; }
}

/* Bouton PDF (en-tête d'un article) */
.bts-entete-ligne { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.bts-entete-actions { flex: none; display: flex; gap: 8px; }
.bts-partager.is-copie { border-color: var(--accent); background: var(--accent-soft); }

.bts-pdf {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    padding: 6px 12px 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.bts-pdf:hover { border-color: var(--accent); background: var(--accent-soft); }
.bts-pdf:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.bts-pdf[aria-busy="true"] { opacity: .6; cursor: progress; }

.bts-pdf svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 480px) {
    .bts-pdf span { display: none; }
    .bts-pdf { padding: 7px; }
}

/* Ligne d'information : seulement dans le PDF */
.bts-entete-info { display: none; }

/* ---------- PDF / impression : mise en page dédiée ----------
   A4, toujours en couleurs claires (même en mode sombre), seul l'article est gardé :
   en-tête du document, réponses dépliées (assets/bts.js), pas de coupure dans un tableau,
   un schéma ou un graphique, numéros de page en bas. */

@page {
    size: A4;
    margin: 16mm 15mm 18mm;

    @bottom-left {
        content: "BTS CG · Fiches de révision · lilas3.com";
        color: #6b6378;
        font: 8pt system-ui, sans-serif;
    }

    @bottom-right {
        content: "Page " counter(page) " / " counter(pages);
        color: #6b6378;
        font: 8pt system-ui, sans-serif;
    }
}

@media print {
    /* Couleurs claires imposées, quel que soit le thème choisi */
    :root, :root[data-theme="dark"], :root[data-theme="light"] {
        --bg: #f6f3fb;
        --surface: #ffffff;
        --text: #231d2e;
        --muted: #6b6378;
        --border: #ddd3ec;
        --accent: #6a3fbb;
        --accent-soft: #f1eafc;
        --code-bg: #f5f1fb;
        --warn: #8a4000;
        --warn-bg: #fff3e0;
        --on-accent: #fff;
        color-scheme: light;
    }

    html, body { background: #fff !important; }
    body { display: block; min-height: 0; font-size: 10.5pt; line-height: 1.5; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none !important; }

    /* Seul l'article est gardé */
    .bts-bar, .bts-aside, .bts-entete-pages, .bts-suite, .site-footer, .bts-pdf,
    .bts-article-pied, .osm-md-ancre, .bts-graph details, noscript { display: none !important; }

    .wrap { max-width: none; padding: 0; }
    .bts-layout, .bts-colonne { display: block; }
    .bts-article { padding: 0; border: 0; background: none; }

    /* En-tête du document : titre, informations, fil d'Ariane, filet violet */
    .bts-entete {
        display: block;
        margin: 0 0 8mm;
        padding: 0 0 4mm;
        border: 0;
        border-bottom: 2.5pt solid var(--accent);
        border-radius: 0;
        background: none;
    }

    .bts-entete-texte { padding: 0; gap: 2mm; }
    .bts-entete h1 { font-size: 22pt; color: var(--text); }
    .bts-entete-info { display: block; margin: 0; color: var(--accent); font-size: 9pt; font-weight: 650; }
    .bts-fil ol { font-size: 8.5pt; }
    .bts-fil a { color: var(--muted); text-decoration: none; }

    /* Texte */
    markdown h2 { font-size: 14pt; margin: 7mm 0 3mm; break-after: avoid; page-break-after: avoid; }
    markdown h3 { font-size: 12pt; margin: 5mm 0 2mm; break-after: avoid; page-break-after: avoid; }
    markdown h4 { break-after: avoid; }
    markdown p, markdown li { orphans: 3; widows: 3; }
    markdown a { color: var(--accent); text-decoration: none; }
    markdown table { font-size: 9pt; }
    markdown th, markdown td { padding: 4px 8px; }

    /* Blocs à ne jamais couper */
    markdown .osm-md-tableau, markdown table, markdown tr, markdown blockquote, markdown pre,
    .bts-graph, .bts-schema, .bts-repli, figure { break-inside: avoid; page-break-inside: avoid; }
    markdown .osm-md-tableau { overflow: visible; }

    .bts-graph, .bts-schema { padding: 3mm; background: #fff; }
    .bts-schema-zone svg { max-height: 120mm; }

    /* Réponses : dépliées (assets/bts.js) et présentées comme un encadré « Réponses » */
    .bts-repli { border-color: var(--border); background: var(--bg); }
    .bts-repli > summary { padding: 2mm 3mm; list-style: none; color: var(--accent); font-size: 9.5pt; }
    .bts-repli > summary::-webkit-details-marker { display: none; }
    .bts-repli > div { padding: 2mm 3mm 0; }
}
