/* Corps de page centré verticalement et horizontalement */
body {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;         /* centre horizontalement */
    justify-content: flex-start; /* commence depuis le haut */
    min-height: 100vh;
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f9f9f9;
}

/* Titres */
h1, h2, h3 {
    text-align: center;
    color: #333;
}

input[type="text"] {
    padding: 5px;
    margin: 3px;
    font-size: 16px;
    border-radius: 6px;
    border: 1px solid #999;
    text-align: center;
}
#phrase-container p {
    font-size: 20px;
    margin: 15px;
}
#result {
    font-size: 22px;
    margin-top: 10px;
    text-align: center;
}
#bp_valider,#check {
    font-size: 22px;
    margin: 10px auto;   /* centrer horizontalement */
    display: block;      /* nécessaire pour que margin auto fonctionne */
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
}

#bp_valider:hover {
    background-color: #45a049;
}
#next {
    display: none;
    margin-top: 20px;
    padding: 10px 20px;
    border-radius: 10px;
    background-color: lightblue;
    border: 1px solid #777;
    cursor: pointer;
}

/* Scoreboard et section thème */
#scoreboard, #theme, #replay, #retour_cours {
    text-align: center;
    margin-top: 15px;
}

/* Container pour les colonnes de boutons du jeu de paires */
#container {
    display: flex;
    gap: 50px;
    margin-top: 20px;
    justify-content: center;  /* centre les colonnes horizontalement */
}

/* Colonnes pour les boutons */
.column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;      /* centre les boutons dans chaque colonne */
}

/* Boutons du jeu de paires */
.btn {
    padding: 10px;
    margin: 5px;
    width: 150px;
    background-color: lightgray;
    border-radius: 12px;
    border: 1px solid black;
    cursor: pointer;
    transition: 0.3s;
    font-size: 16px;
}

.btn:hover {
    transform: scale(1.05);
}

/* États des boutons */
.selected { background-color: lightblue !important; }
.correct { background-color: lightgreen !important; }
.wrong { background-color: lightcoral !important; }

/* Bouton rejouer */
#replay, #retour_cours {
    margin-top: 20px;
    padding: 12px 25px;
    border-radius: 10px;
    border: none;
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: 0.3s;
}

#replay:hover, #retour_cours:hover {
    background-color: #45a049;
}

/* Boutons (anciens thèmes, page Mes cours) */
#theme-buttons, #themes-paires, #themes-trous, #themes-blocs, #themes-qcm, #themes-code {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
	margin-bottom: 50px;
}

/* Boutons de thèmes */
.theme-btn {
    padding: 15px 25px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 12px;
    border: 1px solid #999;
    background-color: #f0f0f0;
    transition: 0.3s;
}

.theme-btn:hover {
    background-color: #d0ebff;
    transform: scale(1.05);
}

/* Conteneurs des mots et de la zone de composition */
#words, #target {
    width: 80%;              /* même largeur pour les deux */
    min-height: 100px;       /* même hauteur minimale */
    border: 2px dashed #ccc;
    padding: 10px;
    margin: 10px auto;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #fafafa;
    border-radius: 10px;
    justify-content: center; /* centre les mots horizontalement */
    align-items: center;     /* centre verticalement les mots */
    box-sizing: border-box;
}
/* Jetons de mots */
.word {
    display: inline-block;
    background-color: #d0ebff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: grab;
    user-select: none;
    font-weight: bold;
    transition: 0.2s;
}

.word:active {
    cursor: grabbing;
    background-color: #a4d1ff;
}

/* Phrase à traduire */
#sentence {
    width: 80%;
    text-align: center;
    background-color: #fff3cd;  /* jaune pâle */
    border: 2px solid #ffeeba;
    border-radius: 10px;
    padding: 15px;
    font-size: 1.4em;
    font-weight: bold;
    color: #444;
    margin-top: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
/* Texte sur plusieurs lignes (\n dans le JSON, ex : code Python) */
.multiligne {
    display: inline-block;
    white-space: pre-wrap;      /* respecte les \n et l'indentation */
    text-align: left;
    font-family: Consolas, "Courier New", monospace;
}
/* Phrases à trous : chaque paragraphe reste sur sa propre ligne */
#phrase-container p.multiligne {
    display: block;
    width: fit-content;
    margin: 15px auto;
}
/* Un bouton avec du code s'élargit au lieu de couper les lignes */
.btn:has(.multiligne) {
    width: auto;
    min-width: 150px;
}
/* Réponses du jeu à choix multiple */
#choices {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* Blocs en mode lignes de code */
#words.lines, #target.lines {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}
.line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: Consolas, "Courier New", monospace;
    font-weight: normal;
    text-align: left;
}
.line .code {
    flex: 1;
    white-space: pre;   /* garde les espaces d'indentation */
}
.indent-btn {
    border: 1px solid #888;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    padding: 2px 8px;
}
#words .indent-btn {
    display: none;  /* l'indentation se règle dans la zone de réponse */
}

/* Blocs de mots sur plusieurs lignes : boutons ↵ / ⇥ et réponse affichée comme du code */
#outils {
    display: none;
    width: 80%;
    margin: 0 auto;
    text-align: left;
}
#target.code-mots {
    display: block;          /* flux de texte : un ↵ passe vraiment à la ligne */
    text-align: left;
    line-height: 2.8;
}
#target.code-mots .word {
    margin: 0 4px;
    line-height: normal;
}
.word.special {
    background-color: #ffe8a3;
    color: #8a6d00;
}
.word.tab {
    min-width: 2.5em;
    text-align: center;
}
.word.retour {
    display: inline;         /* inline pour que le saut de ligne s'applique au texte qui suit */
    padding: 4px 10px;
}
.word.retour::after {
    content: "\A";
    white-space: pre;
}

/* Jeu « écrire du code » */
#zone-code {
    width: 80%;
}
#editeur {
    width: 100%;
    min-height: 220px;
    box-sizing: border-box;
    padding: 10px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
    tab-size: 4;
    border: 2px solid #ccc;
    border-radius: 10px;
    resize: vertical;
}
/* Coloration syntaxique (coloration.py) : la zone de texte, transparente, est posée sur un calque coloré */
.editeur-colore {
    position: relative;
}
.calque-coloration {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 10px;
    border: 2px solid transparent;   /* même place que la bordure de la zone de texte */
    border-radius: 10px;
    box-sizing: border-box;
    background: #fff;
    color: #1f2328;
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
    line-height: 1.4;
    tab-size: 4;
    white-space: pre;
    overflow: hidden;
    pointer-events: none;
    text-align: left;
}
.calque-contenu {
    min-width: max-content;
}
#editeur.editeur-transparent {
    display: block;
    position: relative;
    background: transparent;
    color: transparent;
    caret-color: #1f2328;
    line-height: 1.4;
    white-space: pre;            /* pas de retour à la ligne automatique : comme le calque */
    overflow-wrap: normal;
    overflow: auto;
}
#editeur.editeur-transparent::selection {
    background: rgba(0, 120, 215, 0.25);
}
/* Numéros de ligne de l'éditeur (coloration.py), affichés avec le bouton 🔢 (execution.outils_editeur) */
.gouttiere-numeros {
    display: none;
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: 3em;
    margin: 0;
    padding: 10px 6px 10px 0;
    box-sizing: border-box;
    overflow: hidden;
    background: #f3f4f6;
    border-right: 1px solid #ddd;
    border-radius: 8px 0 0 8px;
    color: #8a8f98;
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
    line-height: 1.4;
    text-align: right;
    pointer-events: none;
    z-index: 1;
}
.avec-numeros .gouttiere-numeros {
    display: block;
}
.avec-numeros .calque-coloration,
.avec-numeros #editeur.editeur-transparent {
    padding-left: calc(3em + 10px);
}
/* Barre au-dessus de l'éditeur : numéros de ligne, copier */
.outils-editeur {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 4px;
}
.outils-editeur button {
    padding: 2px 10px;
    font-size: 14px;
}
.outil-numeros[aria-pressed="true"] {
    background: #dbeafe;
    border-color: #3b82f6;
}
.copie-cachee {
    position: fixed;
    top: 0;
    left: -9999px;
    opacity: 0;
}
/* Touches ⇥ / ⇤ sous l'éditeur (execution.touches_tactiles) : seulement sur écran tactile */
.touches-tactiles {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}
.touches-tactiles button {
    min-width: 40px;
    min-height: 40px;
    padding: 4px 8px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 18px;
    touch-action: manipulation;   /* pas de zoom au double appui */
}
@media (pointer: coarse) {
    .touches-tactiles {
        display: flex;
    }
}
/* Auto-complétion (completion.py) */
.mesure-caractere {
    position: absolute;
    visibility: hidden;
    white-space: pre;
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
}
.completion {
    position: absolute;
    z-index: 10;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    min-width: 180px;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    font-family: Consolas, "Courier New", monospace;
    font-size: 15px;
    text-align: left;
}
.bulle-appel {
    position: absolute;
    z-index: 11;
    max-width: 100%;
    box-sizing: border-box;
    padding: 2px 8px;
    background: #fff8d6;
    color: #333;
    border: 1px solid #d9c86a;
    border-radius: 5px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    text-align: left;
    overflow-wrap: anywhere;
    pointer-events: none;
}
.completion li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 3px 10px;
    cursor: pointer;
}
.completion .py-methode { color: #795e26; }
.completion li.choisi {
    background: #d0ebff;
}
.completion small {
    color: #888;
    font-family: Arial, sans-serif;
    font-size: 12px;
}
.py-mot-cle { color: #af00db; }
.py-constante { color: #0000ff; }
.py-fonction { color: #795e26; }
.py-definition { color: #0070c1; }
.py-chaine { color: #a31515; }
.py-nombre { color: #098658; }
.py-commentaire { color: #6a737d; font-style: italic; }
.py-operateur { color: #d73a49; }
/* Sur le fond sombre des exemples */
.exemple .py-mot-cle { color: #c586c0; }
.exemple .py-constante { color: #569cd6; }
.exemple .py-fonction { color: #dcdcaa; }
.exemple .py-definition { color: #4fc1ff; }
.exemple .py-chaine { color: #ce9178; }
.exemple .py-nombre { color: #b5cea8; }
.exemple .py-commentaire { color: #6a9955; }
.exemple .py-operateur { color: #d4d4d4; }
#boutons-code {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}
#run, #reset {
    font-size: 18px;
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}
#run {
    background-color: #4CAF50;
    color: white;
}
#run:hover {
    background-color: #45a049;
}
#aide {
    text-align: center;
    color: #888;
    font-size: 13px;
}
#sorties {
    display: flex;
    gap: 20px;
}
#sorties > div {
    flex: 1;
    min-width: 0;
}
#sortie, #attendue {
    min-height: 60px;
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: #222;
    color: #eee;
    font-family: Consolas, "Courier New", monospace;
    white-space: pre-wrap;
}
#attendue {
    background: #e8f5e9;
    color: #333;
}
#sortie.erreur {
    color: #ff8a80;
}

/* Bandeau des pages ouvertes par « Prévisualiser » dans l'admin */
.bandeau-apercu {
    align-self: stretch;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 12px;
    padding: 6px 12px;
    background: #fff3cd;
    color: #7a5b00;
    border-bottom: 1px solid #ffe08a;
    text-align: center;
    font-size: 14px;
}
.bandeau-apercu button {
    margin: 0;
    padding: 3px 10px;
    font-size: 14px;
}
.bandeau-apercu.reussi {
    background: #e6f6ea;
    color: #1e6b34;
    border-bottom-color: #b7e4c4;
}

/* Bac à sable : cours à gauche, éditeur et console à droite */
#bac {
    width: min(1200px, 100%);
    box-sizing: border-box;
    padding: 0 16px 30px;
}
#bac-entete {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 10px 0;
}
#bac-entete h2 {
    margin: 0;
}
#navigation {
    display: flex;
    gap: 6px;
    align-items: center;
    max-width: 100%;
}
#navigation select {
    flex: 1;
    min-width: 0;          /* le sommaire rétrécit sur petit écran au lieu de déborder */
    max-width: 260px;
    padding: 4px;
}
#bac-colonnes {
    display: grid;
    grid-template-columns: minmax(0, var(--part-gauche, 1fr)) 20px minmax(0, var(--part-droite, 1fr));
    align-items: start;
}
@media (max-width: 800px) {
    #bac-colonnes {
        grid-template-columns: 1fr;   /* sur petit écran : le cours puis l'atelier */
        row-gap: 20px;
    }
    #poignee-colonnes {
        display: none;
    }
}
/* Poignée entre les colonnes (colonnes.py) */
#poignee-colonnes {
    align-self: stretch;
    min-height: 100px;
    cursor: col-resize;
    touch-action: none;   /* sur écran tactile, le doigt glisse la poignée au lieu de faire défiler */
    border-radius: 6px;
}
#poignee-colonnes::after {
    content: "";
    display: block;
    position: sticky;     /* à côté d'un long cours, la barre reste au milieu de l'écran */
    top: calc(50vh - 24px);
    width: 4px;
    height: 48px;
    margin: 60px 0 0 8px;
    border-radius: 2px;
    background: #bbb;
}
#poignee-colonnes:hover::after, #poignee-colonnes:focus-visible::after {
    background: #4CAF50;
}
#poignee-colonnes:hover {
    background: #eaf6eb;
}
#poignee-colonnes:focus-visible {
    outline: 2px solid #4CAF50;
}
body.glisse-colonnes {
    cursor: col-resize;
    user-select: none;
}
@media (min-width: 801px) {
    /* Sur grand écran, l'éditeur reste visible quand on fait défiler une longue leçon */
    #atelier {
        position: sticky;
        top: 10px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        box-sizing: border-box;
    }
}
#cours, #atelier {
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 0;
}
#cours h3 {
    text-align: left;
    margin: 0;
}
#lecon-entete {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
#lecon-actions {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
}
#imprimer-lecon, #modifier-lecon {
    flex-shrink: 0;
    margin: 0;
    padding: 4px 10px;
    font-size: 14px;
}
#modifier-lecon[hidden] {
    display: none;   /* sinon .bouton (display: inline-block) l'emporte sur l'attribut hidden */
}
.texte-cours, .consigne-cours {
    line-height: 1.5;
    text-align: left;
}
/* Markdown des cours (markdown_cours.py) */
.texte-cours p, .consigne-cours p {
    margin: 0 0 10px;
}
.texte-cours .titre-cours, .consigne-cours .titre-cours {
    text-align: left;
    margin: 16px 0 6px;
    color: #1a5276;
}
.texte-cours ul, .texte-cours ol, .consigne-cours ul, .consigne-cours ol {
    margin: 0 0 10px;
    padding-left: 24px;
}
.texte-cours li, .consigne-cours li {
    margin: 2px 0;
}
.md-liste ul, .md-liste ol {
    margin-bottom: 0;
}
.a-retenir {
    margin: 10px 0;
    padding: 8px 14px;
    border-left: 5px solid #4caf50;
    background: #eef8ee;
    border-radius: 0 8px 8px 0;
}
.a-retenir p:last-child {
    margin-bottom: 0;
}
.tableau-defilant {
    overflow-x: auto;
    margin: 0 0 10px;
}
.tableau-cours {
    border-collapse: collapse;
}
.tableau-cours th, .tableau-cours td {
    border: 1px solid #ccc;
    padding: 4px 10px;
}
.tableau-cours th {
    background: #eef1f5;
}
.texte-cours hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 14px 0;
}
.image-ligne {
    max-height: 1.6em;
    vertical-align: middle;
}
.image-cours {
    margin: 12px 0;
    text-align: center;
    white-space: normal;
}
.image-cours img {
    max-width: 100%;         /* jamais plus large que la colonne du cours */
    height: auto;
    border-radius: 6px;
}
.image-cours figcaption {
    font-size: 14px;
    color: #666;
    font-style: italic;
}
.image-cours .erreur {
    color: #c0392b;
}
#admin .barre-markdown {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 4px 0;
}
#admin .barre-markdown button {
    min-width: 32px;
    padding: 3px 7px;
    font-size: 13px;
    cursor: pointer;
}
#admin .aide-markdown {
    font-size: 13px;
    margin-left: 6px;
}
#admin .aide-markdown summary {
    cursor: pointer;
    color: #1a5276;
}
#admin .aide-markdown[open] {
    flex-basis: 100%;
    margin-left: 0;
}
#admin .aide-markdown pre {
    margin: 4px 0;
    padding: 8px;
    background: #f4f6f8;
    border-radius: 6px;
    white-space: pre-wrap;
}
.texte-cours code, .consigne-cours code {
    background: #eef1f5;
    padding: 1px 5px;
    border-radius: 4px;
    font-family: Consolas, "Courier New", monospace;
}
.exemple {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ccc;
}
.exemple pre {
    margin: 0;
    padding: 10px;
    background: #222;
    color: #eee;
    font-family: Consolas, "Courier New", monospace;
    white-space: pre;
    overflow-x: auto;
}
.exemple .essayer {
    display: block;
    width: 100%;
    border: none;
    padding: 6px;
    background: #d0ebff;
    cursor: pointer;
}
.exemple .essayer:hover {
    background: #a4d1ff;
}
#defi {
    margin-top: 20px;
    padding: 10px 15px;
    border-radius: 8px;
    background: #fff8e1;
    border: 1px solid #ffe082;
}
#defi h4, #defi h5, #entrainement h4 {
    margin: 6px 0;
}
#verifier {
    margin-top: 10px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: #ff9800;
    color: white;
    cursor: pointer;
}
#verifier:disabled {
    background: #ccc;
}
#defi-resultat {
    font-weight: bold;
}
#liens-jeux {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.lien-jeu {
    padding: 6px 12px;
    border-radius: 8px;
    background: #e8f5e9;
    color: #2e7d32;
    text-decoration: none;
}
.lien-jeu:hover {
    background: #c8e6c9;
}
.lien-jeu.introuvable {
    background: #eee;
    color: #888;
}
#retablir {
    font-size: 18px;
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}
/* Bac à sable de l'enseignant */
#atelier-outils {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
#atelier-outils select {
    min-width: 0;
    max-width: 220px;
    padding: 4px;
}
#atelier-etat {
    min-height: 1.3em;
    margin: 0 0 8px;
    color: #1e6b34;
}
#atelier-etat.erreur {
    color: #b3261e;
}
#atelier-nom {
    margin-top: 0;
    overflow-wrap: anywhere;
}
#sortie-atelier {
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 0;
}
#console-entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#console {
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: #222;
    color: #eee;
    font-family: Consolas, "Courier New", monospace;
    white-space: pre-wrap;
}
#console .erreur {
    color: #ff8a80;
}
#console .separateur {
    color: #777;
}

/* Page admin : création des thèmes */
#admin {
    width: min(900px, 95%);
    padding-bottom: 40px;
}
.carte {
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.carte h3 {
    text-align: left;
    margin-top: 0;
}
.rangee {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.champ {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.champ > span {
    font-weight: bold;
    color: #444;
}
.champ.case {
    flex-direction: row;
    align-items: center;
}
.champ small, .aide {
    color: #888;
    font-size: 13px;
}
#admin input[type="text"], #admin input[type="number"], #admin select, #admin textarea {
    font-size: 15px;
    padding: 6px 8px;
    margin: 0;
    border: 1px solid #999;
    border-radius: 6px;
    text-align: left;
    box-sizing: border-box;
}
#admin textarea {
    width: 100%;
    font-family: Consolas, "Courier New", monospace;
    resize: vertical;
    field-sizing: content;   /* la zone grandit avec son contenu */
    min-height: 2.5em;
}
#admin button {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #888;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 15px;
}
#admin button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
#enregistrer:not(:disabled), #telecharger:not(:disabled) {
    background: #4CAF50 !important;
    color: white;
    border: none !important;
}
.ligne-admin {
    border-left: 4px solid #4CAF50;
    background: #fafafa;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 15px;
    scroll-margin-top: 12px;
    transition: box-shadow 0.4s;
}
/* Élément ouvert par le bouton « Modifier » d'une leçon (admin.montrer_element) */
.ligne-admin.ligne-ciblee {
    box-shadow: 0 0 0 3px #3b82f6;
}
.entete-ligne {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.numero {
    font-weight: bold;
    color: #4CAF50;
}
#admin .supprimer {
    background: white;
    color: #c0392b;
    border-color: #e6b0aa;
    font-size: 13px;
}
.boutons-ligne {
    display: flex;
    gap: 6px;
}
#admin .apercu-ligne {
    background: white;
    color: #1a4f80;
    border-color: #a4c8ec;
    font-size: 13px;
}
#admin .inserer {
    background: white;
    color: #2e7d32;
    border-color: #a5d6a7;
    font-size: 13px;
}
#messages {
    list-style: none;
    padding: 0;
}
#messages li {
    margin: 4px 0;
}
#messages .erreur { color: #c0392b; }
#messages .avertissement { color: #b9770e; }
#messages .ok { color: #2e7d32; font-weight: bold; }
#apercu {
    background: #222;
    color: #eee;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    max-height: 400px;
}
/* Admin : exemple de tirage d'une question aléatoire */
#admin .tester {
    font-size: 13px;
}
.resultat-test {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: baseline;
}
.resultat-test:empty {
    display: none;
}
.resultat-test > .multiligne {
    flex-basis: 100%;
    font-weight: bold;
}
.resultat-test .bonne { color: #2e7d32; }
.resultat-test .mauvaise { color: #888; }
.resultat-test .erreur { color: #c0392b; }
.resultat-test .info {
    flex-basis: 100%;
    color: #444;
}
/* Jeu de code : limite du nombre de lignes */
#limite {
    margin: 4px 0 0;
    font-size: 14px;
    color: #555;
}
#limite.depasse {
    color: #c0392b;
    font-weight: bold;
}
.retour-cours {
    display: inline-block;
    margin: 8px 0;
    color: #2e7d32;
    text-decoration: none;
}
.retour-cours:hover {
    text-decoration: underline;
}

/* Admin : sommaire fixe à gauche (liens vers chaque partie et chaque élément) */
body.avec-sommaire {
    padding-left: 230px;
    box-sizing: border-box;
}
#sommaire-admin {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 15px 8px;
    background: white;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#sommaire-admin .titre-sommaire {
    font-weight: bold;
    color: #444;
    margin: 0 6px 8px;
}
#sommaire-admin .lien-sommaire {
    text-align: left;
    background: none;
    border: none;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
#sommaire-admin .element-sommaire {
    font-weight: normal;
    padding-left: 18px;
    color: #555;
}
#sommaire-admin .ajouter-sommaire {
    color: #2e7d32;
}
#sommaire-admin .lien-sommaire:hover {
    background: #eef6ee;
}
#sommaire-admin .lien-sommaire.actif {
    background: #e3f2e3;
    color: #2e7d32;
    box-shadow: inset 3px 0 0 #4CAF50;
}
.ligne-admin, #admin .carte {
    scroll-margin-top: 10px;
}
@media (max-width: 800px) {
    body.avec-sommaire { padding-left: 0; }
    #sommaire-admin { display: none; }
}

/* Page « Mes cours » : une carte par matière */
#matieres {
    width: min(800px, 95%);
}
.matiere h2 {
    margin: 0;
}
.entete-matiere {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.liste-cours {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.place-cours:empty {
    display: none;
}
.lien-cours {
    display: inline-block;
    color: #333;
    text-decoration: none;
}
.lien-cours small {
    display: block;
    margin-top: 4px;
    color: #777;
    font-size: 13px;
}
.lien-cours.ouvert {
    background-color: #d0ebff;
    border-color: #4c9be8;
}
.menu-lecons {
    margin: 14px 0 0;
    padding: 12px 12px 12px 40px;
    background: #f7fbff;
    border: 1px solid #d0ebff;
    border-radius: 8px;
}
.menu-lecons:empty {
    display: none;
}
.menu-lecons li {
    padding: 4px 0;
}
.menu-lecons a {
    color: #1a4f80;
    text-decoration: none;
}
.menu-lecons a:hover {
    text-decoration: underline;
}
/* Flèche du bouton d'un cours : ▾ menu fermé, ▴ menu ouvert */
.lien-cours {
    position: relative;
    padding-right: 42px;
}
.lien-cours::after {
    content: "▾";
    font-size: 24px;
    line-height: 1;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}
.lien-cours.ouvert::after {
    content: "▴";
}

/* Barre du compte, en haut de chaque page */
.barre-compte {
    box-sizing: border-box;
    align-self: stretch;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding: 8px 16px;
    background: white;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
}
.barre-compte a {
    color: #333;
    text-decoration: none;
}
.barre-compte a:hover {
    text-decoration: underline;
}
.barre-compte .espace {
    flex: 1;
}
.barre-compte form {
    margin: 0;
}
.barre-compte button {
    margin: 0;
    padding: 4px 10px;
    font-size: 14px;
}

/* Pages produites par le serveur */
.page-compte {
    box-sizing: border-box;
    width: min(1000px, 100%);
    padding: 16px;
}
.formulaire-etroit {
    box-sizing: border-box;
    width: min(400px, 100%);
    margin-left: auto;
    margin-right: auto;
}
.page-compte input[type="text"],
.page-compte input[type="email"],
.page-compte input[type="password"],
.page-compte textarea {
    box-sizing: border-box;
    padding: 7px;
    font: inherit;
    border: 1px solid #999;
    border-radius: 6px;
    text-align: left;
}
.page-compte .champ input,
.page-compte .champ textarea {
    width: 100%;
    margin: 0;
}
.message-erreur, .message-succes, .message-attention {
    padding: 10px 14px;
    border-radius: 6px;
    text-align: center;
}
.message-erreur { background: #fde8e8; color: #9b1c1c; }
.message-succes { background: #e6f6ea; color: #1e6b34; }
.message-attention { background: #fff4d6; color: #7a5300; }
.defilement {
    overflow-x: auto;
}
.tableau {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 14px;
}
.tableau th, .tableau td {
    padding: 8px 10px;
    border-bottom: 1px solid #e3e3e3;
    text-align: left;
    vertical-align: middle;
}
.tableau th {
    background: #f2f2f2;
    color: #444;
}
.bouton {
    display: inline-block;
    box-sizing: border-box;
    margin: 0 4px 0 0;
    padding: 4px 8px;
    color: #000;
    background: #efefef;
    border: 1px solid #767676;
    border-radius: 3px;
    font-size: 13px;
    text-decoration: none;
}
.bouton:hover {
    background: #e2e2e2;
}
.tableau .actions {
    white-space: nowrap;
}
.tableau .actions form {
    display: inline-block;
    margin: 0 4px 0 0;
}
.tableau .actions button {
    margin: 0;
    padding: 4px 8px;
    font-size: 13px;
}
button.danger {
    color: #9b1c1c;
}
.liste-classes {
    padding-left: 20px;
}
.liste-classes li {
    margin-bottom: 6px;
}
.fiches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.fiche {
    padding: 12px;
    background: white;
    border: 1px dashed #888;
    border-radius: 6px;
    break-inside: avoid;
}
.fiche code {
    font-size: 15px;
}

.coche-visible {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.coche-visible input {
    width: 18px;
    height: 18px;
    margin: 0;
}
.cours-masque td:first-child {
    color: #888;
    font-style: italic;
}
.carte h4 {
    margin: 18px 0 8px;
    color: #444;
}
.choix-import {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
@media print {
    .barre-compte, .sans-impression { display: none; }

    /* Impression d'une leçon : le cours seul, en A4 */
    @page {
        size: A4 portrait;
        margin: 15mm;
    }
    body {
        display: block;
        min-height: 0;
        background: white;
    }
    #bac {
        width: 100%;
        padding: 0;
    }
    #bac-entete > a, #navigation, #atelier, #entrainement, #imprimer-lecon, #modifier-lecon,
    #verifier, #defi-resultat, .essayer, .bandeau-apercu, #poignee-colonnes {
        display: none !important;
    }
    #bac-entete {
        justify-content: center;
    }
    #bac-colonnes {
        display: block;
    }
    #cours {
        padding: 0;
        border: none;
    }
    /* Le code sur fond blanc : lisible et sans encre, quelle que soit l'option « Graphiques d'arrière-plan » */
    #cours pre {
        color: #000;
        background: white;
        border: 1px solid #999;
    }
    .exemple .py-mot-cle { color: #7a0f9e; }
    .exemple .py-constante { color: #0033b3; }
    .exemple .py-fonction { color: #795e26; }
    .exemple .py-definition { color: #00708a; }
    .exemple .py-chaine { color: #a31515; }
    .exemple .py-nombre { color: #098658; }
    .exemple .py-commentaire { color: #3f7f3f; }
    .exemple .py-operateur { color: #000; }
    .exemple, .a-retenir, .image-cours, .tableau-cours, #defi {
        break-inside: avoid;
    }
    /* Sur papier rien ne défile : les lignes longues passent à la ligne au lieu d'être coupées */
    #cours pre {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }
    .tableau-defilant {
        overflow: visible;
    }
    #cours img {
        max-width: 100%;
    }
    h3, h4, h5, .titre-cours {
        break-after: avoid;
    }
}

/* Page « Jeux et cours » (jeux.html) : un tableau filtrable plutôt que des boutons */
#page-jeux {
    width: min(900px, 95%);
    margin: 0 auto 40px;
    text-align: left;
}
#page-jeux h1 {
    text-align: center;
}
.barre-jeux {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: flex-end;
}
.barre-jeux .champ {
    margin-bottom: 8px;
}
.barre-jeux select, .barre-jeux input {
    font-size: 16px;
    padding: 6px 8px;
}
.champ-recherche {
    flex: 1 1 240px;
}
.filtres-type {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.filtre-type {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 5px 12px;
    font-size: 14px;
    border: 1px solid #bbb;
    border-radius: 999px;
    background: #f5f5f5;
    color: #333;
    cursor: pointer;
}
.filtre-type:hover {
    background: #e6f2ff;
}
.filtre-type[aria-pressed="true"] {
    background: #1f6fbf;
    border-color: #1f6fbf;
    color: white;
}
.filtre-type .nombre {
    min-width: 1.6em;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 12px;
    text-align: center;
}
.filtre-type[aria-pressed="true"] .nombre {
    background: rgba(255, 255, 255, 0.25);
}
#jeux-etat {
    margin: 0 0 6px;
    color: #666;
    font-size: 14px;
}
.liste-jeux {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
}
.liste-jeux th {
    position: sticky;
    top: 0;
    background: #f3f6f9;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
}
.liste-jeux td {
    padding: 7px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}
.liste-jeux tbody tr:last-child td {
    border-bottom: none;
}
.liste-jeux tbody tr:hover {
    background: #f7fbff;
}
.titre-jeu a {
    color: #1a4f8a;
    font-weight: 600;
    text-decoration: none;
}
.titre-jeu a:hover, .titre-jeu a:focus-visible {
    text-decoration: underline;
}
.titre-jeu small {
    display: block;
    color: #888;
    font-size: 12px;
    font-family: monospace;
}
.badge-type {
    display: inline-block;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 13px;
    background: #eee;
    color: #333;
}
.type-cours { background: #e3f0ff; color: #164a80; }
.type-qcm { background: #fff1d6; color: #7a4b00; }
.type-trous { background: #f1e6ff; color: #4f2a85; }
.type-blocs { background: #ffe5e0; color: #8a2a17; }
.type-code { background: #e0f5e9; color: #1d5e37; }
.type-paires { background: #e5f6f8; color: #135a63; }
.type-trace { background: #fdf3e1; color: #6b4a12; }
.actions-jeu {
    text-align: right;
    white-space: nowrap;
}
.bouton-lien {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    background: #4CAF50;
    color: white;
    text-decoration: none;
    font-size: 14px;
}
.bouton-lien:hover {
    background: #45a049;
}
.bouton-lien.discret {
    margin-left: 6px;
    background: transparent;
    color: #333;
    border: 1px solid #ccc;
}
.bouton-lien.discret:hover {
    background: #f0f0f0;
}
#page-jeux .liens-bas {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 24px;
}
@media (max-width: 600px) {
    .liste-jeux th:nth-child(2), .liste-jeux td:nth-child(2) {
        display: none;
    }
    .liste-jeux td {
        padding: 7px 8px;
    }
}

/* Jeu « Suivre un programme » (jeu_trace.py) : le code à gauche, le tableau de suivi à droite */
#trace-jeu {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 20px;
    width: 95%;
    max-width: 1300px;
    align-items: start;
}
#trace-jeu h4 {
    margin: 10px 0 6px;
}
#trace-code {
    padding: 8px 0;
    border: 2px solid #ccc;
    border-radius: 10px;
    background: #fff;
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: auto;
}
.trace-ligne-code {
    display: flex;
    padding: 0 10px 0 0;
    cursor: pointer;
    border-left: 4px solid transparent;
}
.trace-ligne-code:hover {
    background: #f1f5f9;
}
.trace-numero {
    flex: none;
    width: 2.5em;
    padding-right: 10px;
    text-align: right;
    color: #999;
    user-select: none;
}
.trace-texte {
    white-space: pre;
    tab-size: 4;
}
.trace-ligne-code.ligne-executee {
    background: #e7f6ea;
    border-left-color: #4caf50;
}
.trace-ligne-code.ligne-visee {
    background: #fff4c2;
    border-left-color: #e0a800;
}
.trace-astuce {
    color: #777;
    font-size: 13px;
}
#trace-defilement {
    max-height: 60vh;
    overflow: auto;
    border: 2px solid #ccc;
    border-radius: 10px;
    background: #fff;
}
#trace-tableau {
    border-collapse: collapse;
    width: 100%;
    font-size: 15px;
}
#trace-tableau th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 8px;
    background: #eef2f7;
    border-bottom: 2px solid #ccc;
    white-space: nowrap;
}
#trace-tableau th.trace-variable {
    font-family: Consolas, "Courier New", monospace;
}
#trace-tableau th small {
    color: #777;
    font-weight: normal;
}
#trace-tableau td {
    position: relative;
    padding: 3px;
    border-bottom: 1px solid #e5e5e5;
    text-align: center;
}
#trace-tableau td.trace-etape {
    color: #999;
    width: 3em;
}
#trace-tableau tr.actif td {
    background: #fffbea;
}
#trace-tableau input.trace-case {
    width: 100%;
    min-width: 4em;
    box-sizing: border-box;
    margin: 0;
    padding: 4px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 15px;
}
#trace-tableau input.trace-case-ligne {
    min-width: 3em;
}
#trace-tableau input.trace-case-affichage {
    min-width: 8em;
}
#trace-tableau input.trace-case-condition {
    min-width: 14ch;
}
#trace-tableau input.trace-case:disabled {
    background: #f3f3f3;
    color: #333;
    border-color: #ddd;
}
#trace-tableau td.juste input.trace-case {
    background: #e7f6ea;
    border-color: #4caf50;
}
#trace-tableau td.faux input.trace-case {
    background: #fdecea;
    border-color: #e53935;
}
#trace-tableau td.devoile input.trace-case {
    background: #eef4ff;
    border-color: #7aa7e0;
}
.trace-correction {
    display: block;
    color: #c62828;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}
#trace-boutons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
#trace-boutons button {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #999;
    background: #fff;
    cursor: pointer;
    font-size: 15px;
}
#trace-verifier {
    background: #4caf50 !important;
    border-color: #3d8b40 !important;
    color: #fff;
}
#trace-verifier:hover {
    background: #45a049 !important;
}
@media (max-width: 800px) {
    #trace-jeu {
        grid-template-columns: minmax(0, 1fr);
    }
}
