/* =====================================================================
   Pythonerie — styles (palette reprise de TamedAgents)
   ===================================================================== */
* { box-sizing: border-box; }

:root {
    --bg-primary: #f5f0e8;
    --bg-sidebar: #ebe5da;
    --bg-surface: #faf8f5;
    --bg-elevated: #ffffff;
    --bg-hover: #e8e2d9;
    --text-primary: #1a1a1a;
    --text-secondary: #5c5c5c;
    --text-muted: #8c8c8c;
    --border-color: #d9d2c7;
    --accent: #b35c2a;
    --accent-hover: #9a4e23;
    --accent-subtle: rgba(179, 92, 42, 0.12);
    --on-accent: #ffffff;
    --success: #16a34a;
    --danger: #dc2626;
    --console-bg: #1e1e2e;
    --console-fg: #e5e7eb;
    --console-erreur: #f87171;
    --console-info: #9ca3af;
    --console-commande: #fbbf24;
    --overlay-bg: rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.18);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

body.dark-mode {
    --bg-primary: #0a0a0a;
    --bg-sidebar: #111111;
    --bg-surface: #171717;
    --bg-elevated: #1e1e1e;
    --bg-hover: #2c2c2c;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #2d2d2d;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-subtle: rgba(139, 92, 246, 0.18);
    --console-bg: #0d0d12;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.redimensionne { cursor: col-resize; user-select: none; }

/* Pas de ligatures : un débutant doit voir >= et != tels qu'il les tape */
code, pre, .CodeMirror, .console {
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
}

code {
    font-family: var(--font-mono);
    font-size: 0.92em;
    background: var(--accent-subtle);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ---------------- Boutons ---------------- */
.btn {
    padding: 6px 14px;
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
a.btn { text-decoration: none; display: inline-block; }
.lien-guide { background: var(--accent-subtle); border-radius: var(--radius-md); padding: 8px 12px; }
.lien-guide a { color: var(--accent); font-weight: 600; }
.btn-secondaire {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-color: var(--border-color);
    font-weight: 500;
}
.btn-secondaire:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondaire.actif { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }
.btn-secondaire.danger { color: var(--danger); }
.btn-secondaire.danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-petit { font-size: 12px; padding: 4px 10px; }

/* ---------------- En-tête ---------------- */
.en-tête {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.marque { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* le logo est un disque sur fond blanc : le cercle retire les coins blancs */
.logo { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: block; }
.titre { font-weight: 700; font-size: 17px; }
.sous-titre { color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version { color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); white-space: nowrap; }
.actions-en-tête { display: flex; align-items: center; gap: 8px; }
.état-lispe { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.état-lispe.ok { color: var(--success); }
.état-lispe.erreur { color: var(--danger); }

/* ---------------- Espace de travail : 3 zones ---------------- */
.espace {
    --largeur-canevas: clamp(360px, 40vw, 900px);
    --largeur-programmes: 230px;
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: var(--largeur-programmes) 6px minmax(320px, 1fr) 6px var(--largeur-canevas);
}

.étiquette {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.note { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }
.note-dim { text-transform: none; font-weight: 400; margin-left: 4px; }

/* le nom du projet, en tête de la colonne des programmes */
/* il prend la place libre de la ligne (elle suit la largeur de la colonne), et se coupe
   avec « … » seulement s'il ne tient pas */
.nom-projet {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    padding: 1px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.nom-projet:hover { border-color: var(--border-color); background: var(--bg-hover); }
.nom-projet.sans-nom { color: var(--text-muted); font-style: italic; font-weight: 500; }
.section-tête {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 8px;
}

/* 1. Programmes */
.programmes {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.liste { list-style: none; margin: 6px 0 8px; padding: 0; }
.liste li {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}
.liste li:hover { background: var(--bg-hover); color: var(--text-primary); }
.liste li.actif { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
/* Arbre des programmes (comme dans TamedAgents) : répertoires, programmes,
   actions (renommer, exporter, supprimer) visibles au survol */
.barre-programmes { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.btn-large { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.btn-icône { padding: 3px 6px; display: flex; align-items: center; }
#listeProgrammes { min-height: 40px; border-radius: var(--radius-sm); }
#listeProgrammes.cible, #titreProgrammes.cible { outline: 1px dashed var(--accent); outline-offset: 2px; }
.liste li.arbre-ligne {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px 4px 3px 4px;
    border-radius: var(--radius-sm);
}
.liste li.arbre-ligne.sélection { background: var(--bg-hover); color: var(--text-primary); }
/* Programmes choisis pour une suppression groupée */
.liste li.arbre-ligne.choisi { background: var(--accent-subtle); box-shadow: inset 3px 0 0 var(--accent); }
.bandeau-sélection {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 6px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.bandeau-sélection[hidden] { display: none; }
.bandeau-collage span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bandeau-sélection span { flex: 1; min-width: 100px; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover:not(:disabled) { filter: brightness(0.92); background: var(--danger); border-color: var(--danger); }
.liste li.arbre-ligne.cible { outline: 1px solid var(--accent); outline-offset: -1px; background: var(--accent-subtle); }
.liste li.arbre-ligne.glisse { opacity: 0.4; }
.arbre-guide { width: 14px; align-self: stretch; position: relative; flex-shrink: 0; }
.arbre-guide::before {
    content: '';
    position: absolute;
    left: 7px; top: -3px; bottom: -3px;
    width: 1px;
    background: var(--border-color);
}
.arbre-chevron {
    width: 14px; height: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.arbre-chevron svg { width: 14px; height: 14px; transition: transform 0.1s; }
.arbre-chevron.ouvert svg { transform: rotate(90deg); }
.arbre-icône { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; margin-right: 4px; color: var(--text-muted); }
.arbre-icône svg { width: 16px; height: 16px; }
.liste li.actif .arbre-icône { color: var(--accent); }
.titre-dossier { color: var(--text-muted); font-weight: 500; }
.programme-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.programme-actions {
    display: inline-flex;
    gap: 1px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.1s;
}
.liste li.arbre-ligne:hover .programme-actions,
.liste li.arbre-ligne:focus-within .programme-actions { opacity: 1; }
.programme-actions button {
    background: none;
    border: none;
    padding: 0;
    width: 22px;
    height: 20px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.programme-actions button:hover { background: var(--bg-elevated); color: var(--text-primary); }
.programme-actions button:last-child:hover { color: var(--danger); }
/* Menu ☰ des programmes (repris de la barre latérale de TamedAgents) */
.menu-ancre { position: relative; display: inline-flex; }
/* position: fixed, placé par installeMenu sous le bouton : la barre latérale ne le rogne pas */
.menu {
    position: fixed;
    min-width: 220px;
    padding: 6px 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 70;
}
.menu[hidden] { display: none; }
.menu-section {
    padding: 4px 14px 2px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.menu-item {
    display: block;
    width: 100%;
    padding: 7px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-hover); color: var(--text-primary); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item:disabled { opacity: 0.45; cursor: default; background: none; }
/* Le nom de l'élève, en haut à droite */
.btn.élève { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.btn.élève.inconnu #nomÉlève { font-style: italic; color: var(--text-muted); }
/* Mode utilisateur unique : le nom reste lisible, mais le bouton ne réagit pas */
.btn.élève:disabled { opacity: 0.7; }
/* Le mode administrateur (port administrateur de serveur.py) : un bouton bien visible, et son formulaire */
.btn.admin { border-color: var(--accent); color: var(--accent); font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.btn.admin[hidden] { display: none; }
.formulaire-admin { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; white-space: normal; }
.formulaire-admin label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.formulaire-admin input { font: inherit; padding: 7px 9px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-primary); }
.menu-séparateur { height: 1px; margin: 6px 10px; background: var(--border-color); }
/* Listes déroulantes : Mes projets, Matériels, Exemples */
.menu.déroulante { max-width: min(380px, calc(100vw - 16px)); overflow-y: auto; }
.ligne-déroulante { display: flex; align-items: stretch; }
.ligne-déroulante .menu-item { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 4px; white-space: normal; }
.menu-texte { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.menu-détail { font-size: 11px; font-weight: 400; color: var(--text-muted); line-height: 1.3; margin-top: 2px; }
.menu-item.courant { color: var(--accent); font-weight: 700; }
/* dans Mes projets, la place de la coche est gardée sur chaque ligne : les noms restent alignés */
.menu-item.projet::before { content: ''; flex-shrink: 0; width: 1em; }
.menu-item.projet.courant::before { content: '✓'; }
.menu-item.sans-nom { font-style: italic; }
.menu-supprime { flex-shrink: 0; padding: 0 12px; border: none; background: none; font-size: 13px; cursor: pointer; opacity: 0.4; }
.menu-supprime:hover, .menu-supprime:focus-visible { opacity: 1; background: var(--bg-hover); outline: none; }
/* Mes projets : les projets au-delà des dix derniers ouverts, dans une zone qui défile */
.menu-groupe-titre { color: var(--text-muted); }
.menu-groupe { max-height: 240px; overflow-y: auto; margin: 0 8px 4px; border-left: 2px solid var(--border-color); }
.menu-groupe[hidden] { display: none; }
.répertoires-site { display: flex; flex-direction: column; gap: 6px; }
.bouton-déroulant { width: 100%; text-align: left; }
.bouton-déroulant[hidden] { display: none; }
/* seulement sur un écran étroit (téléphone, tablette en hauteur) */
.seulement-étroit { display: none; }

/* Écrans tactiles : pas de survol, les actions restent visibles */
@media (hover: none) { .programme-actions { opacity: 1; } }

.liste li.liste-vide { cursor: default; color: var(--text-muted); font-style: italic; }
.liste li.liste-vide.arbre-ligne { font-size: 11px; white-space: normal; line-height: 1.3; }
/* l'aperçu d'un fichier du projet (une image, ou le début des données) */
.aperçu-image { display: block; max-width: 100%; max-height: 60vh; margin: 12px auto 0; object-fit: contain; background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 16px 16px; }
.aperçu-données { max-height: 50vh; overflow: auto; margin: 12px 0 0; padding: 8px 10px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); font-family: var(--font-mono); font-size: 12px; white-space: pre; }
.liste li.liste-vide:hover { background: none; }
.nombre-exemples { font-size: 11px; color: var(--text-muted); background: var(--bg-hover); border-radius: 8px; padding: 0 6px; margin-left: 4px; }

/* 2. Édition */
.zone-édition {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 10px 12px 12px;
    gap: 8px;
}
.barre {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 30px;
}
.barre-gauche, .barre-droite { display: flex; align-items: center; gap: 6px; min-width: 0; }
.nom-programme { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.état-sauvegarde { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.état-sauvegarde.ok { color: var(--success); }
.état-sauvegarde.erreur { color: var(--danger); }

.conteneur-éditeur {
    position: relative;
    flex: 3 1 0;
    min-height: 140px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
}
/* la signature de la fonction sélectionnée, en bas de l'éditeur */
.signature {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
    padding: 4px 12px; font-family: var(--font-mono); font-size: 12px;
    background: var(--bg-surface); color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.conteneur-éditeur .CodeMirror {
    height: 100%;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.55;
}
.CodeMirror-gutters { border-right: 1px solid var(--border-color); background: var(--bg-surface); }
body:not(.dark-mode) .cm-s-default .cm-keyword { color: #a3410f; font-weight: 600; }
body:not(.dark-mode) .cm-s-default .cm-builtin { color: #1d6fa5; }
body:not(.dark-mode) .cm-s-default .cm-def { color: #6a3fb5; font-weight: 600; }
body:not(.dark-mode) .cm-s-default .cm-atom { color: #a0287d; }
body:not(.dark-mode) .cm-s-default .cm-string { color: #2e7d32; }
body:not(.dark-mode) .cm-s-default .cm-comment { color: #8c8c8c; font-style: italic; }
body:not(.dark-mode) .CodeMirror-activeline-background { background: rgba(179, 92, 42, 0.06); }
.CodeMirror-hints { font-family: var(--font-mono); font-size: 12px; z-index: 95; }

.panneau-lispe { display: none; flex: 1 1 0; min-height: 80px; flex-direction: column; }

/* Les données du programme : onglets Don0, Don1... */
.panneau-données { flex: 3 1 0; min-height: 140px; display: flex; flex-direction: column; gap: 6px; }
.panneau-données[hidden], .conteneur-éditeur[hidden] { display: none; }
/* Projet sans programme : un message par-dessus l'éditeur verrouillé */
.éditeur-vide { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 24px; text-align: center; color: var(--text-secondary); font-size: 15px; }
.éditeur-vide[hidden] { display: none; }
.éditeur-vide p { margin: 0; }
.éditeur-vide .btn { padding: 9px 18px; font-size: 14px; }
.éditeur-vide-note { font-size: 13px; color: var(--text-muted); max-width: 340px; }
/* le grand logo, au-dessus ; plus petit si l'éditeur est bas */
.éditeur-vide-logo { width: min(200px, 32vh); height: auto; border-radius: 50%; }
.barre-onglets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.espace-barre { flex: 1; }
.onglets { display: flex; gap: 2px; flex-wrap: wrap; }
.onglet {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
}
.onglet:hover { background: var(--bg-hover); color: var(--text-primary); }
.onglet.vide { font-style: italic; color: var(--text-muted); }
.onglet.actif { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); font-weight: 600; font-style: normal; }
.texte-données {
    flex: 1;
    min-height: 100px;
    resize: none;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}
.texte-données:focus { outline: 2px solid var(--accent-subtle); border-color: var(--accent); }
.note-données { font-size: 12px; color: var(--text-muted); min-height: 16px; }
.note-données code { font-family: var(--font-mono); color: var(--accent); }
.panneau-lispe.visible { display: flex; }
.panneau-lispe pre {
    flex: 1;
    margin: 0;
    overflow: auto;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Les numéros de ligne du code LispE (voir afficheLispE) */
.panneau-lispe pre.numéroté { counter-reset: ligne-lispe; }
.ligne-lispe::before {
    counter-increment: ligne-lispe;
    content: counter(ligne-lispe);
    display: inline-block;
    min-width: 3ch;
    margin-right: 1.2ch;
    padding-right: 0.8ch;
    border-right: 1px solid var(--border-color);
    text-align: right;
    color: var(--text-muted);
    user-select: none;
}

.zone-console { flex: 1.3 1 0; min-height: 90px; display: flex; flex-direction: column; }
/* la console est sous le canevas : elle prend la hauteur qui reste */
.zone-canevas > .zone-console { flex: 1 1 auto; min-height: 160px; }
/* Plein écran du code ou de la console : la zone occupe toute la fenêtre, au-dessus du
   reste (les propositions de l'éditeur et les fenêtres de dialogue passent devant) ;
   la taille de la police ne change pas */
body.plein-code .zone-édition,
body.plein-console .zone-console { position: fixed; inset: 0; z-index: 90; min-height: 0; background: var(--bg-primary); padding: 12px 16px 16px; }
body.plein-code .zone-console { display: none; }
#btnExécutionConsole { display: none; }
body.plein-console #btnExécutionConsole { display: inline-block; }
body.plein-code .conteneur-éditeur, body.plein-code .panneau-données { flex: 1 1 0; }
.console {
    flex: 1;
    overflow: auto;
    padding: 10px 12px;
    background: var(--console-bg);
    color: var(--console-fg);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}
.console-ligne { white-space: pre-wrap; word-break: break-word; }
.console-ligne.commande { color: var(--console-commande); }
/* demande() : la question du programme, puis la réponse de l'élève */
.console-ligne.question { color: var(--console-fg); }
.console-ligne .réponse-élève { color: var(--console-commande); }
.saisie-console.en-question .invite { font-weight: 700; }
.console { border-radius: var(--radius-md) var(--radius-md) 0 0; }
/* Ligne de commande sous la console */
.saisie-console {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 12px 8px;
    background: var(--console-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-family: var(--font-mono);
    font-size: 13px;
}
.saisie-console .invite { color: var(--console-commande); line-height: 1.5; padding-top: 1px; user-select: none; }
.saisie-console textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--console-fg);
    font: inherit;
    line-height: 1.5;
    padding: 1px 0;
    height: 1.5em;
    max-height: 9em;
    overflow-y: auto;
    font-variant-ligatures: none;
}
.saisie-console textarea::placeholder { color: var(--console-info); }
.saisie-console:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.console-ligne.erreur { color: var(--console-erreur); }
.console-ligne.info { color: var(--console-info); font-style: italic; }
.console-vide { color: var(--console-info); font-style: italic; }

/* Séparateur déplaçable */
.séparateur { cursor: col-resize; background: transparent; position: relative; touch-action: none; }
.séparateur::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 2px;
    width: 2px;
    background: var(--border-color);
    border-radius: 2px;
}
.séparateur:hover::after, body.redimensionne .séparateur::after { background: var(--accent); }

/* 3. Canevas */
.zone-canevas {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    min-width: 0;
    overflow: auto;
}
.cadre-canevas {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    background: #ffffff;
}
.cadre-canevas canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
/* touch-action : sur une tablette, glisser le doigt dessine au lieu de faire défiler la page */
#coucheTortue { cursor: crosshair; touch-action: none; }
/* saisie(clef, x, y, fonction) : le champ est placé en coordonnées du canevas ;
   container-type permet de dimensionner ses lettres en cqw (largeur du cadre) */
.cadre-canevas { container-type: inline-size; }
.saisie-canevas {
    position: absolute;
    z-index: 2;
    box-sizing: border-box;
    padding: 0.25em 0.45em;
    border: 1px solid #8a8a8a;
    border-radius: 4px;
    background: #ffffff;
    color: #1a1a1a;
    line-height: 1.2;
}
.saisie-canevas:focus { outline: 2px solid var(--accent); outline-offset: 0; }
/* les autres objets du canevas : bouton, case à cocher, bouton radio, glissière, zone d'édition */
.objet-canevas { position: absolute; z-index: 2; box-sizing: border-box; margin: 0; }
.édition-canevas { resize: none; }
.bouton-canevas {
    padding: 0.3em 0.8em;
    border: 1px solid #8a8a8a;
    border-radius: 6px;
    background: #f4f4f4;
    color: #1a1a1a;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}
.bouton-canevas:hover { background: #e6e6e6; }
.bouton-canevas:active { background: #d6d6d6; }
/* bouton_image : le bouton a la forme de son image ; sans second aspect, il s'enfonce un peu */
.bouton-image-canevas { padding: 0; border: none; background: transparent; cursor: pointer; line-height: 0; }
.bouton-image-canevas img { display: block; width: 100%; height: auto; pointer-events: none; user-select: none; }
.bouton-image-canevas:hover img { filter: brightness(1.08); }
.bouton-image-canevas.enfoncé img { filter: brightness(0.85); transform: translateY(1px); }
.bouton-image-canevas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* demande() et lit_fichier() : la petite fenêtre posée sur le canevas (voir cadreSurCanevas) */
.question-canevas {
    position: absolute; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(80%, 420px); padding: 16px 18px; border-radius: 10px;
    background: #ffffff; color: #1a1a1a; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    font-family: 'Inter', sans-serif; font-size: 15px; display: flex; flex-direction: column; gap: 10px;
}
.question-canevas input { font: inherit; padding: 6px 8px; border: 1px solid #8a8a8a; border-radius: 6px; }
.question-canevas input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.question-canevas-aide { font-size: 12px; color: #6b6b6b; }
.question-canevas-bouton { font: inherit; padding: 7px 12px; border: 1px solid #8a8a8a; border-radius: 6px; background: #f2f2f2; cursor: pointer; }
.question-canevas-bouton:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.coche-canevas { display: flex; align-items: center; gap: 0.35em; white-space: nowrap; line-height: 1.2; cursor: pointer; user-select: none; }
.coche-canevas input { width: 1em; height: 1em; margin: 0; accent-color: var(--accent); cursor: pointer; }
.glissière-canevas { height: 1.4em; accent-color: var(--accent); cursor: pointer; }
.déroulante-canevas { padding: 0.2em 0.3em; border: 1px solid #8a8a8a; border-radius: 4px; background: #ffffff; color: #1a1a1a; cursor: pointer; }
.arbre-canevas {
    overflow: auto;
    padding: 0.2em 0;
    border: 1px solid #8a8a8a;
    border-radius: 4px;
    background: #ffffff;
    color: #1a1a1a;
    line-height: 1.45;
    user-select: none;
}
.arbre-canevas details > summary { list-style: none; }
.arbre-canevas details > summary::-webkit-details-marker { display: none; }
.arbre-élément { padding: 0 0.5em; cursor: pointer; white-space: nowrap; }
.arbre-élément:hover { background: #eeeeee; }
.arbre-élément.choisi { background: var(--accent); color: #ffffff; }
.arbre-branche::before { content: '▸'; display: inline-block; width: 1em; }
details[open] > .arbre-branche::before { content: '▾'; }
.arbre-canevas > .arbre-élément:not(.arbre-branche), .arbre-enfants > .arbre-élément:not(.arbre-branche) { padding-left: 1.5em; }
.arbre-enfants { padding-left: 1em; }

/* Plein écran : la scène (barre + canevas) occupe tout l'écran ; le canevas garde ses
   proportions (--ratio, posé par canevas.js) et prend la plus grande taille possible */
.barre-plein-écran { display: none; }
.scène-canevas.plein {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: #101010;
    box-sizing: border-box;
}
.scène-canevas.plein.secours { position: fixed; inset: 0; z-index: 1000; }
/* sur une tablette : glisser le doigt dans la scène ne fait ni défiler, ni rafraîchir, ni quitter
   le plein écran (voir retientGlissés dans canevas.js) ; la console, elle, défile toujours */
.scène-canevas.plein { touch-action: none; overscroll-behavior: none; }
:root:has(.scène-canevas.plein), body:has(.scène-canevas.plein) { overscroll-behavior: none; }
.scène-canevas.plein .barre-plein-écran { display: flex; gap: 8px; align-self: flex-end; }
/* ▤ Console (ou affiche_console()) : en plein écran, la console vient sous le canevas */
.scène-canevas.plein.avec-console .cadre-canevas { width: min(100%, calc((100vh - 70px - 32vh) * var(--ratio, 1.3333))); }
.scène-canevas.plein > .zone-console { flex: none; height: 30vh; min-height: 0; width: min(100%, 1100px); }
.scène-canevas.plein > .zone-console #btnPleinConsole { display: none; }
#btnConsolePlein[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.scène-canevas.plein .cadre-canevas {
    flex: none;
    width: min(100%, calc((100vh - 70px) * var(--ratio, 1.3333)));
    border-color: #333;
}
.coordonnées { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); min-height: 18px; }

/* ---------------- Aide ---------------- */
.fond-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.fond-modal.visible { display: flex; }
.modal.petit { width: min(520px, 100%); }
#dialogueTexte { white-space: pre-line; line-height: 1.55; }
.case-dialogue { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; cursor: pointer; }
.collage-projet { display: block; width: 100%; height: 240px; margin-top: 10px; padding: 8px; box-sizing: border-box; resize: vertical;
    font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-elevated); color: var(--text-primary); }
.dialogue-boutons { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.dialogue-boutons .btn { padding: 9px 14px; font-size: 14px; text-align: center; }
.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: min(1000px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-tête {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-tête h2 { margin: 0; font-size: 18px; }
.modal-corps { padding: 6px 20px 20px; overflow-y: auto; line-height: 1.55; }
.modal-corps h3 { font-size: 15px; margin: 20px 0 8px; color: var(--accent); }
.grille-aide { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px; }
pre.exemple {
    margin: 0;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
}
.table-aide { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-aide td { padding: 5px 8px; border-bottom: 1px solid var(--border-color); vertical-align: top; }
.table-aide td:nth-child(odd) { white-space: nowrap; }
.table-aide td:nth-child(even) { color: var(--text-secondary); }
/* L'aide : un aide-mémoire, avec le logo, un sommaire et des parties repliables */
.aide-marque { display: flex; align-items: center; gap: 12px; }
.aide-logo { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.aide-sous-titre { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
.aide-sommaire { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.aide-sommaire a { padding: 3px 10px; border: 1px solid var(--border-color); border-radius: 999px; background: var(--bg-surface); color: var(--text-primary); font-size: 12px; text-decoration: none; }
.aide-sommaire a:hover { border-color: var(--accent); color: var(--accent); }
.modal-corps h3 { scroll-margin-top: 8px; }
.aide-règle { background: var(--accent-subtle); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; }
.aide-liste { margin: 6px 0; padding-left: 20px; font-size: 13px; }
.aide-liste li { margin: 3px 0; }
.aide-détails { margin-top: 8px; }
.aide-détails summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 13px; }
/* dans l'aide, la colonne du code peut passer à la ligne entre deux fonctions (jamais au milieu d'une) */
#aide .table-aide td:nth-child(odd) { white-space: normal; width: 25%; }
#aide .table-aide code { white-space: nowrap; }
.raccourcis kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-color); border-bottom-width: 2px; border-radius: 4px; background: var(--bg-surface); }
.aide-français { margin-top: 16px; }
.aide-français summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 15px; }
.aide-français h4 { font-size: 13px; margin: 14px 0 4px; color: var(--text-secondary); }
.table-aide td.lispe { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---------------- Écrans étroits ---------------- */
@media (max-width: 1100px) {
    body { overflow: auto; }
    .espace {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(520px, auto) auto;
    }
    .séparateur { display: none; }
    /* la liste des programmes au-dessus de l'éditeur : à sa taille, sans dépasser la moitié de l'écran */
    .programmes { border-right: none; border-bottom: 1px solid var(--border-color); height: max-content; max-height: 50vh; }
    .seulement-étroit { display: inline-block; }
    .programmes.replié > .section:not(:first-child),
    .programmes.replié > .section:first-child > :not(.section-tête) { display: none; }
    .programmes.replié .section-tête { margin-bottom: 0; }
    .zone-canevas { overflow: visible; }
    .sous-titre { display: none; }
}
@media (max-width: 700px) {
    .table-aide td:nth-child(odd) { white-space: normal; }
    .barre { flex-wrap: wrap; }
    /* l'en-tête tient sur la largeur d'un téléphone */
    .en-tête { flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
    .version, .sous-titre, .libellé { display: none; }
    .actions-en-tête { flex-wrap: wrap; gap: 6px; margin-left: auto; }
    .actions-en-tête .btn { padding: 5px 10px; }
    .btn.élève { max-width: 140px; }
    .zone-édition { padding: 8px; }
    .programmes { padding: 10px; }
}
.aide-français .table-aide { table-layout: fixed; }
.aide-français .table-aide td:nth-child(1) { width: 40%; white-space: normal; }
.aide-français .table-aide td:nth-child(3) { width: 24%; }

/* Créer une application Web : le choix du programme principal, dans le dialogue */
.choix-programme { width: 100%; padding: 6px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-primary); font: inherit; }

/* Une erreur dont on sait dans quelle fonction elle s'est produite : un clic y mène */
.console-ligne.erreur-cliquable { cursor: pointer; }
.console-ligne.erreur-cliquable:hover { text-decoration: underline dotted; }

/* La couche 3D (voir js/scene3d.js) : sous le canevas 2D, qui devient transparent */
.cadre-canevas canvas.couche-3d { pointer-events: none; }
