/* =========================================================
   THOMATHS — SYSTÈME DE DESIGN
   Slate sombre, légèrement bleuté ; titres serif (maths/pro) ;
   accent bleu raffiné ; contrastes doux.

   Les couleurs/rayons/typo sont définis dans tokens.css (chargé
   avant ce fichier) — ne jamais coder de couleur en dur ici,
   toujours passer par var(--nom-du-token).
   ========================================================= */

/* ===== BASE ===== */
body {
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 650px at 100% 100%, rgba(109, 123, 255, 0.035), transparent 60%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.02 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 480px, var(--bg) 100%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); color: #fff; }

/* ===== MODE ADMIN / ÉLÈVE =====
   Ossature du toggle édition/vue. La classe mode-admin / mode-eleve
   est posée sur <body> côté serveur (context_processor admin_mode).
   Tagger tout contrôle d'édition avec .admin-only : il disparaît
   automatiquement en vue élève. (Cosmétique uniquement pour l'instant ;
   la vraie protection des endpoints viendra plus tard côté vues.) */

h1, h2, h3, .editable-title {
    font-family: var(--font-head);
    color: var(--text);
    letter-spacing: 0.01em;
}
h1 { font-weight: 600; font-size: 1.9rem; }
h2 { font-weight: 600; }

a { color: var(--accent); }

/* Scrollbars (feel « app ») — --text-faint plutôt que --surface-3 (constaté
   trop proche du fond au repos, --surface-3 #262f42 sur --surface #161d2d :
   contraste faible, thumb à peine visible tant qu'on ne survole pas). */
* { scrollbar-width: thin; scrollbar-color: var(--text-faint) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
    background: var(--text-faint);
    border-radius: 6px;
    border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* La navbar (header, logo, liens, menu mobile) vit dans nav.css. */

/* ===== PAGE ADMIN ===== */
.admin-panel { max-width: 720px; margin: 32px auto; padding: 0 16px; }
.admin-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 24px; color: var(--text); }
.admin-section h2 { font-size: 1rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.06em; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.admin-action-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    margin-bottom: 12px;
}
.admin-action-info { flex: 1; min-width: 0; }
.admin-action-info strong { display: block; margin-bottom: 4px; color: var(--text); }
.admin-action-info p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }
/* .admin-btn a été repliée sur .button + .button-lg (même fond accent, même
   taille standard) : les pages admin utilisent désormais le bouton
   générique. Seul le flex-shrink, propre à la mise en page de
   .admin-action-card, reste nécessaire ici. */
.admin-action-card .button { flex-shrink: 0; }
.admin-feedback {
    width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 0.88rem; font-weight: 500;
}
.admin-feedback-ok { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.admin-feedback-err { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.admin-feedback + .admin-feedback,
.admin-feedback { margin-bottom: var(--space-3); }

/* ---------- Conflits de synchronisation .tex (cours_conflicts.html) ----------
   Ces règles remplacent 16 attributs style= posés en dur dans le template.
   Aucune couleur en dur : la page était la seule à écrire var(--text-muted)
   directement dans du HTML. */
.admin-empty { color: var(--text-muted); }
.conflict-meta { color: var(--text-muted); margin: 2px 0; }
.conflict-uid { opacity: 0.6; }
/* Deux colonnes « disque » / « base » — sur mobile elles s'empilent, sinon
   deux cartes d'exercice côte à côte deviennent illisibles. */
.conflict-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-top: 10px;
}
.conflict-compare-sm {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-top: 6px;
    font-size: 0.9em;
}
@media (max-width: 1024px) {
    .conflict-compare,
    .conflict-compare-sm { grid-template-columns: 1fr; }
}
.conflict-compare-label { color: var(--text-muted); margin-bottom: 4px; }
.conflict-excerpt { white-space: pre-wrap; }

/* ---------- Prompts Gemini (ai_prompts.html) ----------
   Page de debug : les prompts sont longs, elle prend toute la largeur (même
   principe que main:has(#doc-chapters-root) dans doc.css, qui élargit Cours
   & TD). Remplace un <style> inline dans le template. */
main:has(#ai-prompts-root) { max-width: none; }
.ai-prompts-grid {
    display: flex;
    gap: var(--space-4);
    align-items: flex-start;
}
@media (max-width: 1024px) {
    .ai-prompts-grid { flex-direction: column; }
}
.ai-prompt-col { flex: 1; min-width: 0; }
.ai-prompt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}
.ai-prompt-raw {
    white-space: pre-wrap;
    background: var(--inset);
    color: var(--text);
    border: 1px solid var(--border-soft);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 0.95em;
    max-height: 80vh;
    overflow-y: auto;
}

/* ---------- Exercice seul (exercises/detail.html) ----------
   Page minimale, atteinte par lien direct : une carte centrée, sans socle
   DA. Remplace un style= en dur sur le conteneur. */
.exo-detail-page {
    max-width: 900px;
    margin: var(--space-5) auto;
    padding: 0 var(--space-4);
}

.admin-gap-stats { margin-top: 6px !important; font-size: 0.8rem !important; font-weight: 600; }
.admin-gap-ok { color: var(--accent); }
.admin-gap-warning { color: #c9962c; }
.admin-gap-urgent { color: var(--danger); }

/* ===== PANNEAU ADMIN — tableau de bord (cf. admin_panel.html) ===== */
.admin-panel-wide { max-width: 1410px; }
/* Le panneau admin est plus large que le socle DA (1180px, cf.
   main:has(.doc-page-scroll) dans doc.css). Le sélecteur passe par l'ID posé
   en doc_body_attrs et non par .admin-panel-wide : à spécificité égale c'est
   doc.css qui gagnerait, puisqu'il est chargé après theme.css. L'ID tranche
   quel que soit l'ordre de chargement. */
main:has(#admin-panel-root) { max-width: 1410px; }

/* Dans le socle, l'en-tête Σ fournit déjà le titre et l'espacement : la marge
   verticale de .admin-panel ferait un trou sous le bandeau. */
#admin-panel-root .admin-panel { margin-top: 0; padding-left: 0; padding-right: 0; }

.admin-group-title {
    font-size: 0.78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.08em; margin: 28px 0 12px;
}
.admin-group-title:first-of-type { margin-top: 8px; }

/* 5 tuiles sur la ligne de stats : volontairement plus étroites que les
   cartes d'action en dessous (4 par ligne), pas besoin qu'elles matchent. */
.admin-stats-row {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 12px; margin-bottom: 8px;
}
@media (max-width: 980px) { .admin-stats-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .admin-stats-row { grid-template-columns: repeat(2, 1fr); } }
.admin-stat-tile {
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
    padding: 18px 14px; display: flex; flex-direction: column; align-items: center;
    text-align: center; gap: 6px;
}
.admin-stat-icon {
    width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; margin-bottom: 4px; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.admin-stat-icon-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 15%, transparent); }
.admin-stat-icon-warning { color: #c9962c; background: color-mix(in srgb, #c9962c 15%, transparent); }
.admin-stat-value { font-size: 1.7rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.admin-stat-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.admin-stat-sub { font-size: 0.75rem; color: var(--text-muted); }

.admin-search { margin: 18px 0 4px; }
.admin-search input {
    width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft); background: var(--surface); color: var(--text);
    font-size: 0.9rem;
}
.admin-search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* 6 cartes par ligne sur desktop (même largeur que le tableau de bord
   au-dessus), dégrade en dessous (tablette/mobile). */
.admin-card-grid {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
}
@media (max-width: 1280px) { .admin-card-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .admin-card-grid { grid-template-columns: 1fr; } }

/* Tableau de bord fusionné avec "Gestion du contenu" : une seule ligne de
   6 cartes sur desktop large (cf. .admin-panel-wide élargi en conséquence).
   Contenu centré et cartes plus hautes (icône au-dessus du titre, comme les
   anciennes tuiles de stats) — un simple flex left-align rendait la ligne
   "plate" avec 6 cartes courtes côte à côte. */
.admin-card-grid-dashboard { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1280px) { .admin-card-grid-dashboard { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .admin-card-grid-dashboard { grid-template-columns: 1fr; } }

.admin-card-grid-dashboard .admin-card {
    align-items: center; text-align: center; justify-content: flex-start;
    min-height: 220px; padding: 28px 20px; gap: 10px;
}
.admin-card-grid-dashboard .admin-card-icon { width: 46px; height: 46px; margin-bottom: 4px; }
.admin-card-grid-dashboard .admin-card-icon svg { width: 20px; height: 20px; }
.admin-card-grid-dashboard .admin-card-title { font-size: 1rem; }
.admin-card-grid-dashboard .admin-card-value { font-size: 2.1rem; }
.admin-card-grid-dashboard .admin-card p { flex: none; }

.admin-card-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.1; }

/* Carte informative sans action (Sauvegardes) : pas de curseur pointeur ni
   de survol animé, contrairement aux autres cartes de ce tableau de bord. */
.admin-card-static { cursor: default; }
.admin-card-static:hover { border-color: var(--border-soft); transform: none; }

.admin-card {
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
    padding: 16px; display: flex; flex-direction: column; gap: 8px;
    cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.admin-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.admin-card:active { transform: translateY(0); }
.admin-card-title { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 10px; }
.admin-card p { margin: 0; font-size: 0.85rem; color: var(--text-muted); flex: 1; }
.admin-card-badge {
    background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 8px;
    font-size: 0.72rem; font-weight: 700;
}

/* Icône : petit rond coloré, comme les tuiles de stats. Couleur par famille
   (posée sur la grille de section) + surcharges individuelles (ex. la
   corbeille reste rouge même dans une famille d'une autre couleur). */
.admin-card-icon {
    width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.admin-card-icon svg { width: 15px; height: 15px; }

.admin-card-grid-content .admin-card-icon { color: #6d7bff; background: color-mix(in srgb, #6d7bff 16%, transparent); }
.admin-card-grid-maintenance .admin-card-icon { color: #2fb787; background: color-mix(in srgb, #2fb787 16%, transparent); }
.admin-card-grid-dev .admin-card-icon { color: #a76ef5; background: color-mix(in srgb, #a76ef5 16%, transparent); }
.admin-card-grid-danger .admin-card-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }

.admin-card-icon-red { color: var(--danger) !important; background: color-mix(in srgb, var(--danger) 16%, transparent) !important; }
.admin-card-icon-orange { color: #c9962c !important; background: color-mix(in srgb, #c9962c 16%, transparent) !important; }

/* Groupe "Actions à fort impact" : bordure teintée en permanence, pas
   seulement au survol, pour signaler que ce n'est pas une carte comme les
   autres (import/réexport écrasent des données). */
.admin-card-grid-danger .admin-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border-soft)); }
.admin-card-grid-danger .admin-card:hover { border-color: var(--danger); }

/* L'action (lien/bouton) reste dans le DOM — la carte entière la déclenche
   au clic (cf. JS) — mais n'a plus besoin d'être affichée séparément. */
.admin-card-action { display: none; }

.admin-card-status { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }

.admin-card-placeholder { cursor: default; opacity: 0.55; }
.admin-card-placeholder:hover { border-color: var(--border-soft); transform: none; }
.admin-card-placeholder .admin-card-icon { color: var(--text-muted); background: var(--surface-2, var(--surface)); }

/* Action désactivée temporairement (risque d'écrasement) : grisée comme un
   placeholder, mais garde l'action dans le DOM (bouton disabled) plutôt que
   de la retirer, pour rester réactivable d'un clic sur le badge une fois le
   risque vérifié — cf. admin-card-disabled-note ci-dessous. */
.admin-card-disabled { cursor: default; opacity: 0.55; }
.admin-card-disabled:hover { border-color: var(--border-soft); transform: none; }
.admin-card-disabled .admin-card-icon { color: var(--text-muted); background: var(--surface-2, var(--surface)); }
.admin-card-disabled .admin-card-action-btn { display: none; }
.admin-card-disabled-note {
    font-size: 0.78rem; font-weight: 600; color: #c9962c;
    background: color-mix(in srgb, #c9962c 12%, transparent);
    border-radius: 6px; padding: 6px 8px; margin: 0;
}

/* Sauvegardes : bloc à gauche (CTA) + liste à droite, cf. mockup. */
.admin-backup-layout { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.admin-backup-cta {
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
    padding: 24px 20px; flex: 0 0 220px; display: flex; flex-direction: column;
    align-items: center; text-align: center; gap: 8px;
}
.admin-backup-cta-icon { width: 44px; height: 44px; margin-bottom: 6px; }
.admin-backup-cta strong { color: var(--text); }
.admin-backup-cta p { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.admin-backup-cta .button { margin-top: 8px; }
.admin-backup-list {
    flex: 1; min-width: 280px; background: var(--surface); border: 1px solid var(--border-soft);
    border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center;
}
.admin-backup-list table { width: 100%; }
@media (max-width: 700px) { .admin-backup-cta { flex-basis: 100%; } }

.submenu {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    overflow: hidden;
}
.submenu li a { color: var(--text-muted); border-radius: var(--radius-sm); }
.submenu li a:hover { background: var(--accent); color: var(--on-accent); }

/* =========================================================
   ===== BOUTONS — LE JEU COMPLET =====
   =========================================================
   QUATRE VARIANTES, DEUX TAILLES, et rien d'autre. Ne PAS redessiner un
   style de bouton par page : c'est ce qui avait produit .admin-btn,
   .colles-btn, .planning-btn, .ghost-button et .btn-icon, tous repliés ici.

     .button           plein, fond --accent      → action principale
     .button-secondary neutre, fond --surface-3  → action secondaire
     .button-outline   contour --accent          → action tertiaire / barre
     .button-danger    contour --danger          → action destructrice

     (taille par défaut)  29px  → barres de contexte, cartes, panneaux
     + .button-lg         36px  → modales, formulaires, action principale
                                  d'une page

   UNE SEULE VARIANTE À LA FOIS. `class="button button-secondary"` était
   l'idiome d'avant pour obtenir la petite taille ; il n'a plus lieu d'être
   et applique deux fonds concurrents (seul l'ordre de déclaration ci-dessous
   décide du gagnant). Écrire `class="button-secondary"`, plus `.button-lg`
   si la grande taille est voulue.

   LA TAILLE S'ÉCRIT, ELLE NE SE DÉDUIT PAS. Avant (2026-08-18), aucune
   variante sauf .button ne portait de padding : .button-secondary employée
   seule héritait des 8px 16px du sélecteur `button` (form.css) et faisait
   35px, mais combinée en `class="button button-secondary"` elle tombait à
   29px. Même variante, deux tailles, selon la présence d'une classe voisine
   — rien dans le nom ne le disait. Ça avait produit trois modales à deux
   tailles sur la même page, et une action principale plus petite que son
   bouton secondaire. Les quatre variantes portent donc maintenant LEUR
   PROPRE forme, et .button-lg est le seul moyen d'obtenir la grande taille.

   Pour les boutons ICÔNE, ne rien créer non plus : .doc-header-icon-btn
   (32x32, avec cadre) ou .btn-icon-sm (28x28, sans cadre).
   ========================================================= */

/* ---------- Forme commune aux quatre variantes ----------
   box-sizing / line-height / display:inline-flex sont indispensables : sans
   eux un <a class="button"> est en content-box et hérite du line-height
   ~1.55 de la page, là où un <button> est en border-box avec un line-height
   "normal" — le MÊME bouton mesurait 34px en <a> contre 29px en <button>.
   min-width n'est PAS neutralisé ici : un <button> garde les 120px de
   form.css (cohérent avec les boutons de formulaire), un <a> reste à sa
   largeur de contenu. Seul .button-outline l'annule, cf. plus bas. */
.button,
.button-secondary,
.button-outline,
.button-danger {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.2;
    padding: 5px 10px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

/* ---------- Taille standard ----------
   Reprend les valeurs que le sélecteur `button` de form.css imposait
   auparavant, mais de façon explicite et pour n'importe quelle balise. */
.button-lg {
    padding: 8px 16px;
    font-size: 0.95rem;
}

/* ---------- Variante 1 : plein ---------- */
.button {
    background-color: var(--accent);
    color: var(--on-accent);
}
.button:hover { background-color: var(--accent-strong); }
.button:active { transform: translateY(1px); }

/* ---------- Variante 2 : neutre ----------
   `.btn-secondary` était un alias strictement identique, renommé partout.
   Les !important d'avant ne servaient qu'à battre editable.css, qui la
   redéfinissait en gris #3a3a3a ; cette règle-là a été supprimée. Ne pas
   réintroduire d'alias ni d'!important. */
.button-secondary {
    background-color: var(--surface-3);
    color: var(--text);
    border-color: var(--border);
}
.button-secondary:hover { background-color: var(--surface-4, var(--surface-3)); border-color: var(--accent); }

/* ---------- Variante 3 : contour ---------- */
.button-outline {
    /* min-width:0 — écrase `button { min-width: 120px }` (form.css) : ce
       bouton sert surtout en barre, où 120px de large seraient absurdes. */
    min-width: 0;
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.button-outline:hover { background: var(--accent-dim, rgba(109, 123, 255, 0.12)); }

/* ---------- Variante 4 : destructrice ----------
   `.btn-danger` (form.css) a été renommée ici pour s'accorder aux trois
   autres. Contour plutôt que fond plein : une action destructrice doit se
   voir sans hurler tant qu'elle n'est pas survolée. */
.button-danger {
    background-color: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.button-danger:hover { background-color: var(--danger); color: #fff; }

/* Générique : `disabled` posé en JS pendant une action longue (ex. génération
   IA) doit se voir — sans ça le bouton reste visuellement actif. */
.button:disabled,
.button-secondary:disabled,
.button-outline:disabled,
.button-danger:disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

/* ===== CARTES ===== */
#sheets-container { display: flex; flex-direction: column; gap: 20px; }
/* #exercises-container : grille 2 colonnes définie dans exercise_card.css */

/* .exercise-card seul (sans .editable-card) : cas des cartes non éditables
   (corbeille, in_trash=True) — même fond/bordure que les cartes normales,
   uniquement l'interactivité change, jamais l'apparence. */
.editable-card, .exercise-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
/* border-top/right/bottom seulement (pas le raccourci border-color) : le
   liseré gauche coloré des exercices (.exercise-card, ci-dessous) doit
   rester visible au survol, il ne doit jamais être écrasé par le hover.
   :not(.selected) : sinon ce hover (0,2,0) écrase 3 des 4 côtés du contour
   de sélection (.selected, 0,1,0, plus bas dans ce fichier) au survol,
   donnant l'impression que la bordure violette de sélection disparaît. */
.editable-card:hover:not(.selected) { border-top-color: var(--border); border-right-color: var(--border); border-bottom-color: var(--border); }
/* Liseré gauche coloré (exercise_card.css) : ce fichier étant chargé après,
   son border-left doit être redéclaré ici pour ne pas être écrasé par le
   border ci-dessus (même sélecteur/spécificité, celui chargé en dernier
   gagne). */

/* --- Autocomplete dropdown custom --- */
.autocomplete-drop {
    position: fixed;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    z-index: 9999;
}
.autocomplete-item {
    padding: 6px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.autocomplete-item:hover,
.autocomplete-item.active { background: var(--accent); color: var(--on-accent); }
.autocomplete-group-label {
    padding: 4px 10px 2px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}


/* --- Track badge --- */
.track-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    width: fit-content;
    max-width: 68px;
    line-height: 1.4;
    letter-spacing: 0.03em;
}
.track-badge:hover { border-color: var(--accent); color: var(--accent); }

.track-popover {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}
.track-pop-row { display: flex; align-items: center; gap: 5px; }
.track-pop-label { font-size: 0.68rem; color: var(--text-muted); width: 28px; flex-shrink: 0; }
.track-pop-btn {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    min-width: 0 !important;
}
.track-pop-btn:hover { border-color: var(--accent); color: var(--accent); }
.track-pop-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Needed so popover is positioned relative to actions div */
.editable-actions { position: relative; top: auto; right: auto; display: flex; align-items: center; gap: 6px; }

/* --- Icônes de droite (footer de carte) --- */
.exo-icons-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

.notes-inline { padding: 0 1rem 0.75rem; }
.notes-textarea {
    width: 100%;
    min-height: 60px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.82rem;
    padding: 6px 8px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
}

/* --- Footer (timestamps + source + notes) --- */
.exo-footer {
    border-top: 1px solid var(--border-soft);
    margin-top: 6px;
    padding-top: 4px;
    display: flex; flex-direction: column; gap: 2px;
}

/* --- Source row --- */
.exo-source-row .inline-edit { cursor: pointer; padding: 1px 4px; border-radius: 3px; border: 1px solid transparent; }
.exo-source-row .inline-edit:hover { background: var(--surface-2); border-color: var(--border); }
.exo-source-sep { color: var(--text-faint); }

.editable-actions span:hover { background: var(--accent); color: var(--on-accent); }

/* ===== FAMILLE DE VARIANTES ===== */
.family-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 0 16px;
}
.family-nav-item {
    padding: 4px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.family-nav-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--violet); }

/* ===== BARRE DE VARIANTES ===== */
.variant-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 8px 4px 4px;
    margin-top: 8px;
    border-top: 1px solid var(--border-soft);
}

/* Boutons de base de la barre */
.vbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 5px;
    background: var(--violet-dim);
    color: var(--violet);
    border: 1px solid rgba(157,125,232,0.25);
    border-radius: 5px;
    font-size: 0.82rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    user-select: none;
}
.vbar-btn:hover:not(:disabled) {
    background: var(--violet-soft);
    border-color: var(--violet);
}
.vbar-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Bouton-sélecteur (label + flèche) — légèrement plus large */
.vbar-select-wrap {
    position: relative;
}
.vbar-select-btn {
    padding: 0 7px;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.vbar-label {
    pointer-events: none;
}

/* Menu déroulant */
.vbar-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    min-width: 180px;
    max-height: 50vh;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow-x: hidden;
    overflow-y: auto;
}
.vbar-menu-item {
    display: block;
    width: 100%;
    padding: 7px 12px;
    text-align: left;
    background: none;
    border: none;
    /* Visible dans cette feuille par défaut : texte plein (var(--text),
       "blanc"), cf. .vbar-menu-item-hidden ci-dessous pour le cas grisé. */
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.1s, color 0.1s;
}
.vbar-menu-item:hover { background: var(--surface-3); color: var(--text); }
.vbar-menu-item.vbar-menu-current {
    color: var(--violet);
    font-weight: 600;
}
/* Variante masquée dans cette feuille — le menu liste maintenant TOUJOURS
   la famille complète (cf. variant_bar.js, showAll), ce statut est donc le
   seul repère de visibilité : grisée (même code couleur que
   .variant-panel-row-hidden, exercise_card.css) plutôt que blanche. */
.vbar-menu-item.vbar-menu-item-hidden {
    color: var(--text-faint);
    font-style: italic;
}
.variant-bar.variant-bar-current-hidden .vbar-label {
    opacity: 0.6;
    font-style: italic;
}
/* La variante AFFICHÉE est elle-même masquée dans cette feuille : griser le
   libellé seul (ci-dessus) passait inaperçu — toute la carte se grise pour
   que ce soit visible sans avoir à lire la barre de variantes. */
.exercise-card:has(.variant-bar.variant-bar-current-hidden) {
    opacity: 0.55;
}

/* Bouton ⧉ (voir toute la famille) */
.vbar-all {
    font-size: 0.9rem;
}

/* Bouton + (créer variante) */
.vbar-add {
    font-size: 1rem;
    font-weight: 700;
}

/* Surbrillance temporaire en mode famille lors du scroll vers une carte */
@keyframes vbar-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(157,125,232,0.45); }
    60%  { box-shadow: 0 0 0 8px rgba(157,125,232,0); }
    100% { box-shadow: none; }
}
.vbar-highlight {
    animation: vbar-pulse 1s ease-out;
}

/* ---------------------------------------------------------------------------
   BLOCS Énoncé / Indication / Correction — style sobre "pro"
   ---------------------------------------------------------------------------
   Fond uniforme intégré au design ; seul un mince liseré gauche coloré
   distingue les trois types. POUR REVENIR AUX CADRES COLORÉS D'ORIGINE :
   supprimer tout ce bloc (les couleurs d'origine restent dans editable.css).
   --------------------------------------------------------------------------- */
.editable-meta .editable-block summary { padding: 6px 10px; }
.editable-block summary::-webkit-details-marker { display: none; }
.editable-block summary::before { display: none; }
.editable-block summary::after {
    content: "›";
    font-size: 1.1rem;
    line-height: 1;
    color: var(--border);
    transform: rotate(90deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
    margin-left: 8px;
}
.editable-block:not([open]) summary::after { transform: rotate(0deg); }

.editable-block.statement            { background: var(--surface-2); border-color: var(--border-soft); border-left-color: var(--accent); }
.editable-block.statement summary::after { color: var(--accent); }

.editable-block.hints                { background: var(--surface-2); border-color: var(--border-soft); border-left-color: var(--content-hint-bd); }
.editable-block.hints summary::after { color: var(--content-hint-bd); }

.editable-block.solution             { background: var(--surface-2); border-color: var(--border-soft); border-left-color: var(--success); }
.editable-block.solution summary::after { color: var(--success); }
/* --------------------------------------------------------------------------- */

/* ===== ZONES D'INSERTION ===== */
/* Titre de sous-chapitre comme subsection */
.subchapter-section-heading {
    font-family: var(--font-head);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 5px;
    margin: 28px 0 6px;
    letter-spacing: 0.01em;
}
.subchapter-section-heading:first-child { margin-top: 4px; }
.subchapter-section-nosub {
    color: var(--text-muted);
    font-style: italic;
}

/* ===== FORMULAIRE : lignes chapitre/sous-chapitre ===== */
.chapter-link-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.chapter-link-row input {
    flex: 1;
    min-width: 0;
}
.chapter-link-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.chapter-link-remove:hover { color: var(--danger, #e05252); }
.chapter-link-add {
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 3px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    margin-top: 2px;
}
.chapter-link-add:hover { border-color: var(--accent); color: var(--accent); }

/* ===== BREADCRUMB =====
   .breadcrumb-trail/.crumb-* supprimées (2026-08-18) : c'était le 5e système
   de fil d'Ariane du site, dont orphans.html était le dernier utilisateur.
   Il n'en reste que deux, et c'est voulu : .ctx-breadcrumb (context_bar.css)
   partout, et .dp-breadcrumb (sheet_detail.css) sur la page feuille, qui est
   coloré par type de document et porte un menu déroulant. */

/* ===== MENU CONTEXTUEL EXERCICE ===== */
.exo-ctx-menu {
    position: fixed;
    z-index: 9000;
    min-width: 160px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    overflow: hidden;
}
.exo-ctx-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.exo-ctx-item:hover { background: var(--surface-3); color: var(--text); }
.exo-ctx-item svg { vertical-align: -3px; margin-right: 1px; }
.exo-ctx-item .tex-logo { font-size: 12px; vertical-align: -1px; }
.exo-ctx-danger { color: var(--danger-soft) !important; }
.exo-ctx-danger:hover { background: rgba(229,103,95,0.12) !important; color: var(--danger-soft) !important; }
.exo-ctx-sep { height: 1px; background: var(--border-soft); margin: 3px 0; }
.exo-ctx-item:disabled { opacity: 0.4; cursor: default; }
.exo-ctx-item:disabled:hover { background: transparent; color: var(--text-muted); }

/* ===== BASE MODALE GÉNÉRIQUE (backdrop/boîte/en-tête) — partagée par la
   modale "Ajouter un exercice → IA" (_ai_exercise_modal.html) et la modale
   d'import LaTeX (exercises/index.html) ===== */
.vlink-backdrop[hidden] { display: none !important; }
.vlink-backdrop {
    position: fixed; inset: 0; z-index: 9500;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
}
.vlink-modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 20px 24px; width: 420px; max-width: 95vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.vlink-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
/* min-width:0 nécessaire : le `button { min-width: 120px }` générique de
   form.css n'est pas surchargé par une règle de padding/taille plus
   spécifique, donc sans ça la croix devient un gros bouton rectangulaire. */
.vlink-close { background: none; border: none; color: var(--text-muted); font-size: 1rem; cursor: pointer; padding: 2px 6px; border-radius: 4px; min-width: 0; }
.vlink-close:hover { background: var(--surface-3); color: var(--text); }
.vlink-hint { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 10px; }

/* ===== MODALE "Ajouter un exercice → IA" ===== */
.ai-exo-modal { width: 520px; }
.ai-exo-dropzone {
    border: 2px dashed var(--border); border-radius: 8px; padding: 14px;
    min-height: 90px; display: flex; flex-direction: column; align-items: stretch;
    justify-content: center; gap: 10px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.ai-exo-dropzone:focus-visible, .ai-exo-dropzone.ai-exo-dropzone-active {
    border-color: var(--accent); background: var(--accent-soft);
}
.ai-exo-dropzone-empty {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    color: var(--text-muted); font-size: 0.85rem; text-align: center;
}
.ai-exo-browse-link { color: var(--accent); cursor: pointer; text-decoration: underline; }
/* Une image collée/déposée prend toute la largeur de la zone (pas une
   petite vignette) : c'est un scan d'exercice à relire, pas un avatar —
   empilées verticalement s'il y en a plusieurs (exercice coupé sur
   plusieurs pages/colonnes, cf. import multi-images existant). */
.ai-exo-previews { display: flex; flex-direction: column; gap: 8px; }
.ai-exo-preview { position: relative; width: 100%; }
.ai-exo-preview img { display: block; width: 100%; height: auto; max-height: 260px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); background: var(--inset); }
.ai-exo-preview-remove {
    /* min-width/padding:0 nécessaires : sans ça le `button { min-width:120px;
       padding:8px 16px }` générique de form.css l'emporte sur width/height
       (min-width prime sur width), et le bouton déborde très largement du
       coin de la miniature au lieu d'un petit rond dessus. */
    position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
    min-width: 0; padding: 0;
    border-radius: 50%; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.25);
    color: #fff; font-size: 0.7rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.ai-exo-preview-remove:hover { background: rgba(0,0,0,0.75); }
.ai-exo-text {
    width: 100%; box-sizing: border-box; margin-top: 10px;
    background: var(--inset); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); padding: 8px 10px; font-size: 0.85rem; outline: none;
    resize: vertical; min-height: 60px; font-family: inherit;
}
.ai-exo-text:focus { border-color: var(--accent); }
.ai-exo-error {
    margin-top: 8px; padding: 6px 10px; border-radius: 6px;
    background: var(--danger-soft, rgba(220,38,38,0.12)); color: var(--danger, #dc2626);
    font-size: 0.82rem;
}
.ai-exo-error[hidden] { display: none; }

/* ===== Modale "Variantes → Importer" ===== */
.vimport-error {
    margin-top: 8px; padding: 6px 10px; border-radius: 6px;
    background: var(--danger-soft, rgba(220,38,38,0.12)); color: var(--danger, #dc2626);
    font-size: 0.82rem;
}
.vimport-error[hidden] { display: none; }
.ai-exo-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 10px; }
.ai-exo-status { font-size: 0.8rem; color: var(--text-muted); }

/* ===== Modale Notions (cf. _notions_modal.html, notions_modal.js) ===== */
.notions-modal {
    width: min(820px, 94vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    /* padding géré par en-tête/toolbar/body séparément (cf. plus bas) : le
       body a besoin d'aller jusqu'aux bords pour que sa scrollbar interne
       (overflow-y) ne colle pas au padding du conteneur générique
       .vlink-modal (420px, pensé pour une modale simple sans zone
       scrollable, cf. règle de base plus haut). */
    padding: 0;
}
.notions-modal .vlink-header {
    margin: 0;
    padding: 18px 22px 14px 24px;
    border-bottom: 1px solid var(--border-soft, var(--border));
}
.notions-modal .vlink-header strong {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
}
.notions-modal .vlink-close {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    font-size: 0.9rem;
}
.notions-modal-toolbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-soft, var(--border));
}
.notions-modal-toolbar button { min-width: 0; }
.notions-modal-status { font-size: 0.82rem; color: var(--text-muted); }
.notions-modal-status.is-error { color: var(--danger, #dc2626); }
.notions-modal-body {
    flex: 1;
    /* min-height:0 indispensable : un enfant flex a par défaut un
       min-height "auto" (= taille du contenu), qui l'empêche de se
       tasser sous le max-height:88vh du parent — sans ça la modale
       grandit avec le contenu au lieu de faire défiler .notions-modal-body
       (bug flexbox classique, cf. scroll cassé signalé). */
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 22px 20px 24px;
}
.notions-add-notion {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: border-color 0.12s, background 0.12s;
}
.notions-add-notion:hover { border-color: var(--text-muted); }
.notions-add-notion:focus { color: var(--text); border-style: solid; border-color: var(--accent); outline: none; background: var(--accent-soft); }

.notions-section {
    border-radius: 10px;
    background: var(--surface-2, rgba(127, 127, 127, 0.06));
    border: 1px solid var(--border-soft, var(--border));
    border-left: 3px solid var(--accent);
    /* Ombre allégée : la précédente (0.15 alpha) tranchait trop fort sur le
       fond déjà translucide de .notions-modal-body, effet "sale" signalé. */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    /* flex-shrink:0 indispensable : .notions-section est un item flex
       colonne de .notions-modal-body (overflow-y:auto). `overflow: hidden`
       ci-dessus annule le min-height:auto implicite d'un flex item — sans
       ce flex-shrink:0, le navigateur réduisait chaque section SOUS la
       hauteur de son contenu réel pour tout faire tenir, au lieu de
       laisser le parent scroller : listes/notions tronquées en bas
       (section "Partie entière" à une seule notion réduite à ~1 ligne
       visible, ressemblant à une section vide), hover qui semblait
       "passer derrière" le bloc, espacements incohérents d'une section à
       l'autre selon l'ampleur du rognage. */
    flex-shrink: 0;
}
.notions-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px 10px 14px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--border-soft, var(--border));
    transition: background 0.12s;
}
.notions-section-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 1;
    cursor: text;
}
.notions-list { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.notions-notion-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    transition: background 0.12s;
}
.notions-notion-row:hover { background: var(--surface-3, rgba(127, 127, 127, 0.1)); }
.notions-notion-row::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    margin-top: 7px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.6;
}
.notions-notion-text { flex: 1; font-size: 0.9rem; line-height: 1.4; color: var(--text); cursor: text; }
.notions-section .notions-add-notion { margin: 0 8px 8px; width: calc(100% - 16px); }
/* Bouton ✕ rond et centré (même logique que .vlink-close/.ai-exo-preview-remove
   plus haut) — remplace l'ancien texte "✕" brut mal centré dans sa boîte. */
.notions-delete-btn {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    /* min-width/padding:0 nécessaires : sans ça le `button { min-width:120px;
       padding:8px 16px }` générique de form.css l'emporte sur width/height
       (min-width prime sur width), cf. même piège documenté sur
       .ai-exo-preview-remove plus haut. */
    min-width: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 0.72rem;
    line-height: 1;
    padding: 0;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.notions-section-head:hover .notions-delete-btn,
.notions-notion-row:hover .notions-delete-btn { opacity: 1; }
.notions-delete-btn:hover { color: #fff; background: var(--danger, #dc2626); }
.notions-questions { display: flex; flex-direction: column; gap: 2px; padding: 0 8px 6px 20px; }
.notions-question-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.12s;
}
.notions-question-row:hover { background: var(--surface-3, rgba(127, 127, 127, 0.1)); }
.notions-question-text { flex: 1; font-size: 0.82rem; line-height: 1.4; color: var(--text-muted); cursor: text; }
.notions-question-text.is-td { color: var(--text); }
/* min-width/padding:0 : même piège que .notions-delete-btn ci-dessus, le
   bouton générique de form.css impose min-width:120px sinon. */
.notions-question-td-btn {
    flex: none;
    min-width: 0;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-faint);
    font-size: 0.68rem;
    line-height: 1.4;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, border-color 0.12s, background 0.12s;
}
.notions-question-row:hover .notions-question-td-btn { opacity: 1; }
.notions-question-td-btn.is-active { opacity: 1; color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.notions-question-row .notions-delete-btn { width: 18px; height: 18px; }
.notions-add-question {
    box-sizing: border-box;
    width: 100%;
    margin-top: 2px;
    padding: 3px 6px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-faint);
    font-size: 0.8rem;
}
.notions-add-question:hover { border-color: var(--text-muted); }
.notions-add-question:focus { color: var(--text); border-style: solid; border-color: var(--accent); outline: none; background: var(--accent-soft); }
.notions-inline-input {
    width: 100%;
    box-sizing: border-box;
    padding: 2px 4px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

/* ===== Barre de recherche dans le contenu (Ctrl/Cmd+F) ===== */
.doc-find-bar[hidden] { display: none !important; }
.doc-find-bar {
    position: fixed; top: 14px; right: 24px; z-index: 9200;
    display: flex; flex-direction: column; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 6px 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
/* Rangée recherche / rangée remplacement (cf. doc-find-replace-row, Ctrl/Cmd+H)
   l'une sous l'autre plutôt que côte à côte : chacune garde son propre flex
   row pour l'alignement de ses champs/boutons. */
.doc-find-row { display: flex; align-items: center; gap: 6px; }
.doc-find-replace-row[hidden] { display: none !important; }
.doc-find-input {
    background: var(--inset); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); padding: 5px 8px; font-size: 0.85rem; outline: none;
    width: 220px;
}
.doc-find-input:focus { border-color: var(--accent); }
.doc-find-count { color: var(--text-muted); font-size: 0.8rem; min-width: 3.5em; text-align: center; }
/* Boutons ▲▼✕ : .btn-icon-sm (theme.css, cf. son commentaire) plutôt que du
   padding/width ad hoc — évite le min-width:120px de form.css sur <button>.
   Seule la taille est resserrée ici (22px : la barre est plus fine qu'une
   modale) sans redéfinir le reste de la classe. */
.doc-find-bar .btn-icon-sm { width: 22px; height: 22px; font-size: 0.8rem; }
.doc-find-case { font-weight: 700; font-size: 0.7rem !important; }
.doc-find-case[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
mark.doc-find-hit { background: var(--find-hit); color: inherit; border-radius: 2px; }
mark.doc-find-hit-active { background: var(--find-hit-active); color: var(--on-find-hit); }
::highlight(doc-find-hit) { background-color: var(--find-hit); }
::highlight(doc-find-hit-active) { background-color: var(--find-hit-active); color: var(--on-find-hit); }
/* Dans CodeMirror, le token de coloration syntaxique impose déjà une couleur
   de texte : on la neutralise (!important) sinon un \commande bleu sur fond
   jaune reste illisible. */
.cm-doc-find-hit { background: var(--find-hit); border-radius: 2px; }
.cm-doc-find-hit-active { background: var(--find-hit-active); color: var(--on-find-hit) !important; }

/* ===== EXPLORATEUR ===== */







/* ===== CHAPITRES (gestion) ===== */

/* ===== FLAGS / BADGES ===== */

/* ===== FORMULAIRES ===== */
.inline-form input:focus,
.inline-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.import-tex-form {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}

/* Étoiles.
   `.star.hover` a été retirée en même temps que sa jumelle de form.css :
   le JS pose `hovered` (exercise_meta.js), jamais `hover`. De même pour
   les rustines `.tag-container .tag` et `.separator`, qui ne
   tokenisaient que des composants sans aucun usage, supprimés depuis. */
.star.hovered { color: #ffd97a; }   /* ambre clair — distinct du filled */

/* Drag & drop */

/* Édition inline des métadonnées d'exercice */
.difficulty[data-editable] { cursor: pointer; }
.difficulty[data-editable] .star { transition: color 0.1s; }

.meta-chip { display: inline-flex; align-items: baseline; gap: 6px; }

.inline-edit {
    cursor: text;
    border-radius: 4px;
    padding: 1px 5px;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
}
.inline-edit:hover { background: var(--surface-2); border-color: var(--border); }
.inline-edit.empty { color: var(--text-faint); font-style: italic; }
.title-edit { font-style: normal; cursor: text; }

.inline-edit-input {
    min-width: 120px;
    padding: 1px 5px;
    background: var(--inset);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: 4px;;
}
.inline-edit-input:focus { outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }

/* Tags inline */
/* font-size 0.7rem et non 1rem : la croix est passée de × (U+00D7) à ✕
   (U+2715), un glyphe nettement plus lourd. Mesuré, × à 16px occupe 9x7px
   et ✕ à 11px occupe 9x8px — c'est la taille qui rend le même poids
   optique sur une puce. Régler le poids d'une croix par sa TAILLE, jamais
   en changeant de glyphe : ✕ est le seul glyphe d'action du site. */
.tag-remove:hover { color: var(--danger); }
.tag-add-input:focus { outline: none; border-color: var(--accent); }

/* Édition inline du contenu */
.content-editable { cursor: text; border-radius: 4px; transition: background 0.15s; min-height: 24px; }
.content-editable:hover { background: var(--surface-3); }
.content-editable[data-empty]:not(:has(textarea))::before {
    content: "Cliquer pour rédiger…";
    display: block;
    color: var(--text-faint);
    font-style: italic;
    font-size: 0.85rem;
    padding: 4px 0;
}

/* Génération IA en cours (création d'exercice/variante, cf.
   ai_create_exercise + polling dans sheets.js) : édition bloquée
   (pointer-events: none — un simple clic/double-clic ne peut alors pas
   atteindre l'élément, pas besoin de garde JS dédiée), libellé qui respire
   via 3 points clignotants décalés. */
.content-editable[data-generating] {
    display: block;
    color: var(--text-faint);
    font-style: italic;
    font-size: 0.85rem;
    padding: 4px 0;
    cursor: default;
    pointer-events: none;
}
.exo-generating-dots { display: inline-block; margin-left: 2px; }
.exo-generating-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    margin-left: 2px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.25;
    animation: exo-generating-blink 1.2s infinite ease-in-out;
}
.exo-generating-dots span:nth-child(2) { animation-delay: 0.2s; }
.exo-generating-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes exo-generating-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}
.content-edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    background: var(--inset);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-family: 'Fira Mono', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}
.content-edit-textarea:focus { outline: none; }

/* Éléments à compléter — onglets Exercices / Environnements */
.orphan-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.orphan-type-tab {
    padding: 8px 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.orphan-type-tab:hover { color: var(--text); }
.orphan-type-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.orphan-missing-labels { color: var(--text-muted); font-size: 0.82rem; margin: 0.6rem 0 0.2rem; }

/* Exercices orphelins — chips de filtre (cases combinables, plusieurs actives à la fois) */
.orphan-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.4rem;
}
.orphan-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.orphan-chip:hover { background: var(--surface-2); color: var(--text); }
.orphan-chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.orphan-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    padding: 0 5px;
    background: var(--inset);
    color: var(--text);
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}
.orphan-chip.active .orphan-count { background: rgba(255,255,255,0.22); color: #fff; }
.orphan-check { font-size: 0.8em; }
.orphan-empty { color: var(--text-muted); font-style: italic; padding: 2rem 0; }


/* =========================================================
   LAYOUT DEUX COLONNES + PANNEAU LATÉRAL
   ========================================================= */

/* ===== EXPLORER — sélecteur de filière en page ===== */
.filiere-selector {
    display: flex;
    gap: 6px;
    align-items: center;
}
.filiere-btn {
    display: inline-block;
    box-sizing: border-box;
    min-width: 0;
    padding: 5px 14px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.filiere-btn:hover { background: var(--surface-2); color: var(--text); }
.filiere-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.filter-group { margin-bottom: 14px; }
.filter-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 6px;
}
.filter-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    color: var(--text-muted);
    cursor: pointer;
}
.filter-option:hover { color: var(--text); }
.filter-option input[type="radio"] { accent-color: var(--accent); }
/* ===== FILTRES TOGGLE (type feuille, correction) ===== */
.filter-toggle-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.filter-toggle-vertical { flex-direction: column; gap: 3px; }
.filter-toggle-btn {
    padding: 5px 12px;
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    min-width: 0;
    width: fit-content;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    text-align: left;
    text-decoration: none;
    display: inline-block;
}
.filter-toggle-btn:hover { background: var(--surface-2); color: var(--text); }
.filter-toggle-btn.active {
    background: var(--accent-soft);
    color: var(--text);
    border-color: var(--accent);
}
.filter-toggle-all {
    font-size: 0.78rem;
    color: var(--text-faint);
    padding: 4px 0 0 2px;
    font-style: italic;
}

/* ===== TAGS FILTRE ===== */
.filter-tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.filter-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px 2px 8px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--text);
    border-radius: 12px;
    font-size: 0.78rem;
}
/* Même taille que .tag-remove ci-dessus, et pour la même raison (passage
   de × à ✕) : les deux puces sont le même composant conceptuel. */
.filter-tag-remove {
    min-width: 0;
    padding: 0 4px;
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
}
.filter-tag-remove:hover { color: var(--danger); }
.filter-tag-input {
    min-width: 70px;
    width: 100%;
    padding: 3px 8px;
    background: var(--inset);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.8rem;
}
.filter-tag-input:focus { outline: none; border-color: var(--accent); }

/* Lien réinitialiser filtres */
.filter-reset-link {
    display: inline-block;
    font-size: 0.78rem;
    color: var(--text-faint);
    text-decoration: underline;
    cursor: pointer;
}
.filter-reset-link:hover { color: var(--danger); }

.filter-family-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}
.filter-family-close {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.7;
}
.filter-family-close:hover { opacity: 1; }

/* ===== ÉTOILES DE DIFFICULTÉ (range) — identiques aux .star des cartes ===== */
.diff-star-row {
    display: flex;
    gap: 0;
    cursor: pointer;
    user-select: none;
}
.diff-star {
    font-size: 1.1rem;
    color: var(--star-off);
    transition: color 0.1s;
}
.diff-star.filled  { color: var(--star); }
.diff-star.hovered { color: #ffd97a; }

/* --- Listes LaTeX (enumerate / itemize) --- */

/* enumerate : compteur unique par niveau, réinitialisé à chaque <ol> */
ol.latex-list {
    list-style: none;
    counter-reset: latex-item;
    padding-left: 2em;
    margin: 0.4em 0;
}
ol.latex-list > li {
    counter-increment: latex-item;
    margin: 0.2em 0;
}
/* Priorité par défaut (tout ce qui n'est PAS l'énoncé/indication/corrigé
   d'un exercice : environnements, démonstrations, texte libre...) :
   (i) -> a) -> 1), quel que soit le type de feuille — jamais touchée par le
   style spécifique aux exercices ci-dessous. */
ol.latex-list > li::before {
    content: "(" counter(latex-item, lower-roman) ")";
    display: inline-block;
    min-width: 1.4em;
    margin-left: -1.8em;
    margin-right: 0.4em;
    text-align: right;
}
ol.latex-list ol.latex-list > li::before {
    content: counter(latex-item, lower-alpha) ")";
}
ol.latex-list ol.latex-list ol.latex-list > li::before {
    content: counter(latex-item) ")";
}

/* Un exercice (énoncé/indication/corrigé, `.exercise-card`) sur une feuille
   qui n'est pas un cours : 1) -> a) -> i), pour matcher \doctype=exos
   (prepa.sty). Sur une feuille de cours (\doctype=cours), un exercice
   éventuellement inséré garde le style par défaut ci-dessus, comme en
   LaTeX. Cf. [[enumcols-page-break-bug-2026-08-30]] pour l'historique du
   style exos côté LaTeX — cette règle est la contrepartie HTML, séparée
   pour ne jamais affecter les environnements/démonstrations voisins. */
.doc-page:not([data-sheet-kind="cours"]) .exercise-card ol.latex-list > li::before {
    content: counter(latex-item) ")";
}
.doc-page:not([data-sheet-kind="cours"]) .exercise-card ol.latex-list ol.latex-list > li::before {
    content: counter(latex-item, lower-alpha) ")";
}
.doc-page:not([data-sheet-kind="cours"]) .exercise-card ol.latex-list ol.latex-list ol.latex-list > li::before {
    content: "(" counter(latex-item, lower-roman) ")";
}

/* itemize niveau 1 : point rempli • */
ul.latex-list {
    list-style: disc;
    padding-left: 2em;
    margin: 0.4em 0;
}
ul.latex-list > li { margin: 0.2em 0; }

/* itemize niveau 2 : triangle ▶ */
ul.latex-list ul.latex-list {
    list-style: none;
    padding-left: 1.4em;
}
ul.latex-list ul.latex-list > li::before {
    content: "▶";
    display: inline-block;
    margin-left: -1.2em;
    margin-right: 0.4em;
    font-size: 0.65em;
    vertical-align: middle;
}

/* itemize niveau 3 : tiret – */
ul.latex-list ul.latex-list ul.latex-list {
    list-style: none;
    padding-left: 1.2em;
}
ul.latex-list ul.latex-list ul.latex-list > li::before {
    content: "–";
    display: inline-block;
    margin-left: -1em;
    margin-right: 0.3em;
}


/* ===== ESPACEMENT DANS LA FEUILLE ===== */
/* L'espacement entre blocs est géré par .doc-body { gap: 16px } (doc.css) ;
   ces anciennes règles margin-top faisaient doublon (ex. avec .doc-section,
   qui a son propre margin-top calculé pour le collage sticky) et créaient
   un écart en trop entre section et sous-section épinglées. */
/* Retiré : le bandeau d'en-tête (.doc-header-tall) a déjà 20px de
   padding-bottom, cette marge doublait l'écart avant la première section. */

/* ===== Mode compact = mode normal (l'ancien mode compact était l'unique mode) ===== */
.notes-block    { display: none !important; }

/* ===== MODE AJOUT — déjà dans la feuille ===== */
.exercise-card.already-in-sheet {
    outline: 2px solid var(--success);
    outline-offset: -2px;
    /* Le liseré gauche (--kind-border, exercise_card.css) reste bleu par
       défaut et dépasse l'outline (offset -2px, ne couvre que 2px) : sans
       ça le bord gauche restait bleu alors que le reste du cadre est vert. */
    border-left-color: var(--success);
}

/* ===== SÉLECTION / COUPER / COPIER ===== */
/* Même mécanisme que .sheet-block.selected (doc.css) : recolore la vraie
   bordure (le liseré gauche déjà là, cf. exercise_card.css --kind-border)
   plutôt que d'ajouter un anneau/box-shadow distinct — la sélection est la
   continuité du liseré existant, pas un cadre séparé. */
/* Génériques : posées par core/card_nav.js sur n'importe quel type d'item
   (carte d'exercice, bloc de feuille...), pas seulement .exercise-card. */
.selected {
    border-color: var(--kind-border, var(--accent));
}
/* Plage Ctrl/Cmd+Shift+clic (core/card_nav.js) sur une liste de cartes
   d'exercices (Exercices, À compléter...) — équivalent générique de
   .sheet-block.multi-selected (doc.css), qui ne couvre que les blocs d'une
   feuille. Sans cette règle le mécanisme fonctionnait déjà (classe posée
   en JS) mais restait invisible : seule l'ancre du clic portait .selected. */
.exercise-card.multi-selected {
    border-color: var(--kind-border, var(--accent));
    background: var(--accent-soft);
}
.cut-pending  { opacity: 0.4; }
.copy-pending { outline: 2px dashed var(--accent); outline-offset: -2px; opacity: 0.75; }

/* ===== DRAG & DROP ===== */
.exercise-card.dragging { opacity: 0.4; outline: none; }
.exercise-card:not([data-sheet-exercise-id]) .editable-header { user-select: none; }

/* ===== SHEET CARDS ===== */
.sheet-card { cursor: pointer; }
.sheet-detail-info.sheet-card { cursor: default; }
.sheet-card .editable-header { user-select: none; }

.sheet-kind-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--on-accent);
    vertical-align: middle;
    margin-right: 4px;
    letter-spacing: .04em;
    cursor: pointer;
}
.sheet-kind-badge:hover {
    filter: brightness(1.15);
}

.sheet-meta-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0 2px;
    flex-wrap: wrap;
}
.sheet-chapter-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}
.sheet-footer {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sheet-timestamps {
    font-size: 0.78rem;
    color: var(--text-muted);
}
/* notes-block-title est stylé dans editable.css via .notes-block-title */
.sheet-notes-icon.active { color: var(--accent); }
.sheet-card.cut-pending { opacity: 0.4; }

/* Zone de dépose en pointillés : la hauteur réelle est fixée en JS
   (drag_reorder.js) pour occuper exactement la place de l'item flottant. */
.drag-placeholder {
    background: var(--accent-dim, rgba(109,123,255,0.14));
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm, 8px);
    box-sizing: border-box;
}

/* ===== DÉTAIL FEUILLE — en-tête inline ===== */
.sheet-detail-header {
    margin-bottom: 10px;
}
.sheet-detail-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0;
    font-size: 1.4rem;
}
.sheet-detail-kind-badge {
    flex-shrink: 0;
    font-size: 0.8rem;
    cursor: pointer;
}
.sheet-detail-chapter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.9rem;
    flex-wrap: wrap;
}
.sheet-chapter-label-text {
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    flex-shrink: 0;
}
.sheet-detail-chapter-row .sheet-detail-flags {
    margin-left: auto;
}
.sheet-detail-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    font-size: 0.85rem;
}
.sheet-detail-timestamps {
    color: var(--text-faint);
    font-size: 0.78rem;
}
.sheet-detail-count {
    flex: 1;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.sheet-detail-icons {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.sheet-icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 6px;
    text-decoration: none;
    line-height: 1.4;
}
.sheet-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.sheet-icon-emoji {
    border: none;
    padding: 1px 2px;
    font-size: 1rem;
    line-height: 1;
}
.sheet-notes-content { min-height: 40px; }
.sheet-chapter-inline {
    color: var(--text-muted);
    font-style: italic;
    cursor: pointer;
    border-radius: 3px;
    padding: 1px 4px;
}
.sheet-chapter-inline:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sheet-chapter-empty {
    color: var(--accent-soft);
    font-style: normal;
}
.sheet-detail-flags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.flag-toggle-btn {
    font-size: 0.75rem;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.flag-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.flag-toggle-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}
.sheet-detail-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
}

/* ===== DÉTAIL FEUILLE — boutons right panel ===== */
.sheet-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
}
.sheet-action-btn {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

/* ===== DÉTAIL FEUILLE — état vide ===== */
.sheet-empty-hint {;
    margin-top: 6px;
    opacity: 0.7;
}

.empty-hint {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 3rem 0;
}

/* ===== MENUS CONTEXTUELS ===== */
.ctx-menu {
    position: fixed;
    z-index: 9000;
    min-width: 190px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    padding: 4px 0;
    display: flex;
    flex-direction: column;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    padding: 8px 16px;
    text-align: left;
    cursor: pointer;
    width: 100%;
}
.ctx-menu button:hover { background: var(--surface-3); }
.ctx-menu button:disabled { opacity: 0.4; cursor: default; }
.ctx-menu button:disabled:hover { background: transparent; }
.ctx-menu button svg { vertical-align: -3px; margin-right: 7px; }
.ctx-menu button .tex-logo { font-size: 12px; vertical-align: -1px; }
.ctx-menu button.ctx-amber { color: var(--star); }
.ctx-menu button.ctx-amber:hover { background: rgba(245, 179, 1, 0.1); color: var(--star); }
.ctx-menu button.ctx-danger { color: var(--danger-soft); }
.ctx-menu button.ctx-danger:hover { background: rgba(229, 103, 95, 0.12); color: var(--danger-soft); }
/* "Vider la feuille" : même jaune que "Retirer de la feuille" (action_remove
   sur les cartes exercice) — les deux sont des actions de retrait, pas de
   suppression définitive (rouge, réservé à ctx-danger). */
.ctx-menu button.ctx-orange { color: var(--hint); }
.ctx-menu button.ctx-orange:hover { background: var(--hint-bg); color: var(--hint); }
.ctx-menu hr { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }
/* Icône seule violette (actions liées aux variantes), texte neutre */
.ctx-icon-violet svg { color: var(--violet); vertical-align: -3px; }
/* Icônes de type de contenu : mêmes couleurs que les blocs réels (doc.css
   .doc-env-*), source unique = tokens.css. Icône seule colorée, texte neutre. */
.ctx-color-definition svg  { color: var(--content-definition); }
.ctx-color-proposition svg { color: var(--content-proposition); }
.ctx-color-hint svg        { color: var(--hint); }
.ctx-color-muted svg       { color: var(--text-muted); }
.ctx-color-danger svg      { color: var(--danger); }
.ctx-color-proof svg       { color: var(--content-proof); }
.ctx-color-exercise svg    { color: var(--content-exercise-doc); }

/* ===== PICKER DE TYPE DE FEUILLE ===== */
#sheet-kind-picker {
    position: fixed;
    z-index: 1100;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    padding: 4px 0;
    min-width: 170px;
}
#sheet-kind-picker[hidden] { display: none; }
#sheet-kind-picker button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    text-align: left; padding: 6px 14px;
    background: none; border: none;
    font-size: 13px; color: var(--text);
    cursor: pointer;
}
#sheet-kind-picker button img { width: 16px; height: 16px; flex: 0 0 auto; }
#sheet-kind-picker button:hover { background: var(--surface-3); }
/* Groupes thématiques (SHEET_KIND_GROUPS), même regroupement que le picker
   de création — juste un séparateur horizontal entre groupes ici, cette
   liste étant verticale (contrairement aux pills en ligne du picker de
   création, séparées par un trait vertical). */
#sheet-kind-picker hr { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }

/* sous-menu contextuel */
.ctx-submenu-wrap { position: relative; }
.ctx-submenu-trigger { display: flex; justify-content: flex-start; align-items: center; width: 100%; }
.ctx-submenu-arrow { font-size: 0.8em; color: var(--text-muted); margin-left: auto; padding-left: 8px; }
.ctx-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 160px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    padding: 4px 0;
    z-index: 1001;
}
.ctx-submenu-wrap.ctx-submenu-open .ctx-submenu { display: block; }
/* Retournement si le sous-menu déborderait de l'écran (cf. sheets.js,
   mesuré au survol) — même logique de repositionnement que le menu parent
   (positionMenuAt), appliquée ici au sous-menu en CSS. */
.ctx-submenu-wrap.ctx-submenu-flip-x .ctx-submenu { left: auto; right: 100%; }
.ctx-submenu-wrap.ctx-submenu-flip-y .ctx-submenu { top: auto; bottom: 0; }
.ctx-submenu button { width: 100%; text-align: left; padding: 6px 14px; background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text); }
.ctx-submenu button:hover:not(:disabled) { background: var(--surface-3); }
.ctx-submenu button:disabled { color: var(--text-faint); cursor: default; }

/* ===== MODALE TEX FEUILLE ===== */
.sheet-tex-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sheet-tex-modal-overlay[hidden] { display: none; }
.sheet-tex-modal-box {
    width: min(900px, 92vw);
    height: min(680px, 88vh);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.sheet-tex-modal-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    flex-shrink: 0;
}
.sheet-tex-modal-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sheet-tex-modal-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.sheet-tex-modal-actions button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 3px 10px;
    transition: background .15s, color .15s;
}
.sheet-tex-modal-actions button:hover { background: var(--surface-3); color: var(--text); }
#sheet-tex-close-btn { border-color: transparent; font-size: 0.9rem; padding: 3px 6px; }
.sheet-tex-modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}
.sheet-tex-modal-body .CodeMirror {
    height: 100%;
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9100;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay[hidden] { display: none; }
/* Modale fusion .tex (page feuille) : même largeur que la modale "Ajouter
   depuis LaTeX" de la liste d'exercices, pour cohérence — elle a en plus le
   champ de fichier upload que l'autre n'a pas. */
#sheet-merge-modal .modal-box { width: 980px; max-width: 95vw; }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: min(560px, 92vw);
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border-soft);
}
.modal-title { font-weight: 700; font-size: 1rem; }
/* Bouton icône compact (X, ⋮, ✕…) : les boutons "classiques" ont un
   min-width de 120px (form.css) hérité par tout <button>, ce qui élargit
   à tort les boutons qui ne portent qu'une icône. Réutiliser cette classe
   plutôt que de resurcharger min-width au cas par cas à chaque nouvelle
   modale/carte. */
.btn-icon-sm,
.modal-close-btn {
    min-width: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 6px;
}
.btn-icon-sm:hover,
.modal-close-btn:hover { background: var(--surface-3); color: var(--text); }
.modal-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-body textarea {
    resize: vertical;
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: monospace;
    font-size: 0.82rem;
    padding: 8px 10px;
}
.modal-body textarea:focus { outline: none; border-color: var(--accent); }
.modal-or {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.file-input { font-size: 0.85rem; color: var(--text); }
.modal-body input[type="text"],
.modal-body input[type="date"],
.modal-body select {
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    padding: 8px 10px;
    transition: border-color 0.15s, background 0.15s;
}
.modal-body input[type="text"]::placeholder { color: var(--text-faint); }
.modal-body input[type="text"]:focus,
.modal-body input[type="date"]:focus,
.modal-body select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}
.modal-body input[type="date"] { color-scheme: dark; }
/* Heures de début/fin côte à côte (modale de session de colle). */
.colle-session-time-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.colle-session-time-row[hidden] { display: none; }
.colle-session-time-row input[type="time"] {
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    padding: 8px 10px;
    color-scheme: dark;
}
.colle-session-time-row input[type="time"]:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.modal-body label.form-label { display: block; margin: 12px 0 6px; }
.modal-body label.form-label:first-child { margin-top: 0; }

/* ---------- Sélecteur de type de feuille (pills) ---------- */
/* Groupes thématiques (cf. SHEET_KIND_GROUPS) : chaque .kind-picker est un
   bloc visuellement séparé des autres, un seul choix possible au global. */
.kind-picker-groups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.kind-picker-groups .kind-picker:not(:last-child) {
    padding-right: 12px;
    border-right: 1px solid var(--border-soft);
}
.kind-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.kind-pill {
    --kind-color: var(--accent);
    min-width: 0;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.kind-pill:hover { border-color: var(--kind-color); color: var(--text); }
.kind-pill.active {
    background: color-mix(in srgb, var(--kind-color) 18%, var(--surface-2));
    border-color: var(--kind-color);
    color: var(--text);
}
.kind-pill-cours    { --kind-color: var(--kind-cours); }
.kind-pill-td       { --kind-color: var(--kind-td); }
.kind-pill-resume   { --kind-color: var(--kind-resume); }
.kind-pill-colle    { --kind-color: var(--kind-colle); }
.kind-pill-dm       { --kind-color: var(--content-exercise); }
.kind-pill-ds       { --kind-color: var(--danger); }
.kind-pill-banque   { --kind-color: var(--kind-banque); }
.kind-pill-probleme { --kind-color: var(--kind-probleme); }
.kind-pill-oral     { --kind-color: var(--kind-oral); }

/* Variante icône seule (menu de création de feuille) : label textuel retiré
   au profit du logo associé au type, le nom reste accessible via tooltip. */
.kind-pill-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 14px;
}
.kind-pill-icon-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}
.modal-footer {
    padding: 12px 18px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border-soft);
}
