/*
 * MyGoal — personnalisations au-dessus d'AdminLTE 4 (chargé avant ce fichier, voir assets/app.js).
 * On s'appuie sur les classes et variables CSS d'AdminLTE/Bootstrap ; les fichiers des bibliothèques ne sont jamais modifiés.
 */

:root {
    --mg-sidebar-bg: #14284b;
    --mg-sidebar-border: rgb(255 255 255 / 0.08);
    --mg-radius: 0.75rem;
}

/* --- Menu latéral bleu foncé ---------------------------------------------- */

.app-sidebar.mg-sidebar {
    --lte-sidebar-color: #c9d5ea;
    --lte-sidebar-hover-color: #fff;
    --lte-sidebar-hover-bg: rgb(255 255 255 / 0.08);
    --lte-sidebar-active-color: #fff;
    --lte-sidebar-menu-active-color: #fff;
    --lte-sidebar-menu-active-bg: rgba(var(--bs-primary-rgb), 0.85);
    --lte-sidebar-header-color: #8fa3c4;

    background-color: var(--mg-sidebar-bg);
}

.mg-sidebar .sidebar-brand {
    border-bottom-color: var(--mg-sidebar-border);
}

.mg-sidebar .brand-link {
    color: #fff;
    text-decoration: none;
}

.mg-sidebar .brand-text {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Logo textuel : pastille « M » (dans le menu, à la place de l'image habituelle d'AdminLTE .brand-image, prévue pour un <img>). */
.mg-brand-mark,
.sidebar-brand .brand-link .mg-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    max-height: none;
    border-radius: 0.5rem;
    background: var(--bs-primary);
    color: #fff;
    font-weight: 700;
    line-height: 1;
}

.mg-sidebar .sidebar-menu .nav-link {
    border-radius: 0.5rem;
}

.mg-sidebar .nav-header {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Icônes SVG (ux_icon) à la place des icônes-polices : alignement dans le menu replié et déplié. */
.sidebar-menu .nav-icon {
    flex-shrink: 0;
    width: 1.1rem;
    height: 1.1rem;
}

/* --- Barre supérieure sobre --------------------------------------------- */

.app-header {
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.app-header .btn-link.nav-link {
    text-decoration: none;
}

/* --- Zone principale aérée ------------------------------------------- */

.app-content-header {
    padding-top: 1.5rem;
}

.mg-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.mg-page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.mg-page-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
    max-width: 24rem;
}

@media (min-width: 768px) {
    .mg-page-title {
        font-size: 1.75rem;
    }

    .mg-page-actions {
        align-items: flex-end;
        text-align: right;
    }
}

.app-content {
    padding-bottom: 2rem;
}

/* Cartes lisibles : bordure discrète, ombre légère, coins arrondis. */
.app-content .card {
    --bs-card-border-color: var(--bs-border-color-translucent);
    --bs-card-border-radius: var(--mg-radius);
    --bs-card-inner-border-radius: calc(var(--mg-radius) - 1px);
    --bs-card-spacer-y: 1.5rem;
    --bs-card-spacer-x: 1.5rem;

    box-shadow: 0 1px 2px rgb(16 24 40 / 0.05);
}

/* --- État vide -------------------------------------------------------------- */

.mg-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 32rem;
    margin: 0 auto;
    padding: 2rem 0.5rem;
    text-align: center;
}

.mg-empty-state-icon {
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 1rem;
    color: var(--bs-primary);
    opacity: 0.7;
}

/* --- Avatar ------------------------------------------------------------------ */

.mg-avatar {
    flex-shrink: 0;
    background-color: var(--bs-secondary-bg);
}

/* --- Pages publiques : logo (accueil public, pages d'authentification « Élan », voir auth.css) --- */

.mg-auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--bs-body-color);
    font-weight: 600;
    text-decoration: none;
}

.mg-auth-brand .mg-brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.4rem;
}

/* --- Formulaires ------------------------------------------------------------ */

/* Champs obligatoires : le thème Bootstrap de Symfony ajoute la classe « required » au libellé. */
.form-label.required::after {
    content: " *";
    color: var(--bs-danger);
}

/* Champ en lecture seule (email du profil) : visiblement non modifiable. */
.form-control[readonly] {
    background-color: var(--bs-tertiary-bg);
}

/* --- Accueil public ---------------------------------------------------------- */

.mg-landing-header {
    border-bottom: 1px solid var(--bs-border-color-translucent);
    background-color: var(--bs-body-bg);
}

.mg-landing-hero {
    padding: 3rem 0 2.5rem;
    text-align: center;
}

.mg-landing-title {
    max-width: 40rem;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    font-weight: 700;
}

.mg-landing-lead {
    max-width: 36rem;
    margin: 0 auto 2rem;
    color: var(--bs-secondary-color);
    font-size: 1.1rem;
}

@media (min-width: 768px) {
    .mg-landing-hero {
        padding: 5rem 0 3.5rem;
    }

    .mg-landing-title {
        font-size: 2.5rem;
    }
}

.mg-landing-feature {
    --bs-card-border-color: var(--bs-border-color-translucent);
    --bs-card-border-radius: var(--mg-radius);

    box-shadow: 0 1px 2px rgb(16 24 40 / 0.05);
}

.mg-landing-feature-icon {
    width: 1.75rem;
    height: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--bs-primary);
}

/* --- Profil ------------------------------------------------------------------ */

.mg-profile-card {
    max-width: 48rem;
}

/* --- Logo du site (components/_brand.html.twig, page Paramètres du site) ------------------------ */

/*
 * Logo personnalisé : proportions conservées, jamais recadré (object-fit: contain), dimensions maximales par emplacement.
 * Fond blanc arrondi : un logo prévu pour un fond clair reste lisible sur le menu bleu foncé et en thème sombre.
 */
.mg-site-logo {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
    padding: 0.125rem 0.375rem;
    border-radius: 0.375rem;
    background-color: #fff;
}

.mg-site-logo-public {
    max-width: 12.5rem;
    max-height: 2.5rem;
}

.mg-site-logo-sidebar {
    max-width: 10rem;
    max-height: 2.125rem;
}

.mg-site-logo-preview {
    max-width: 100%;
    max-height: 7.5rem;
}

/* Menu : avec un logo personnalisé, la pastille « M » ne sert qu'au menu replié (le logo complet n'est pas recadré). */
.mg-sidebar .brand-link.mg-has-logo .mg-brand-mark {
    display: none;
}

.sidebar-mini.sidebar-collapse .app-sidebar:not(:hover) .brand-link.mg-has-logo .mg-brand-mark {
    display: inline-flex;
}

.mg-sidebar .brand-link.mg-has-logo .brand-text {
    margin-left: 0;
}

.mg-settings-card {
    max-width: 60rem;
}

.mg-logo-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 8.5rem;
    padding: 1rem;
    border: 1px dashed var(--bs-border-color);
    border-radius: var(--mg-radius);
    background-color: var(--bs-tertiary-bg);
}

/* --- Domaines et projets ----------------------------------------------------------------------- */

/* Pastille de couleur d'un domaine : toujours suivie du nom ; liseré pour rester visible sur fond clair comme sombre. */
.mg-domain {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.mg-domain-dot {
    flex-shrink: 0;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background-color: var(--mg-domain-color);
    box-shadow: 0 0 0 1px var(--bs-border-color), inset 0 0 0 1px rgb(0 0 0 / 0.15);
}

.mg-domain-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.mg-domain-cell {
    min-width: 12rem;
}

.mg-project-link {
    color: inherit;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.mg-project-link:hover,
.mg-project-link:focus-visible {
    text-decoration: underline;
}

.mg-project-facts dt {
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    font-weight: 600;
}

.mg-project-facts dd {
    margin-bottom: 0.75rem;
}

.mg-form-card {
    max-width: 48rem;
}

.mg-details {
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

.mg-details > summary {
    font-weight: 600;
    cursor: pointer;
}

.mg-details[open] > summary {
    margin-bottom: 0.25rem;
}

/* --- Texte enrichi (éditeur Trix, RichTextType ; affichage .mg-rich-text) ----------------------- */

/* Outils non proposés (titre, code, pièces jointes) : le serveur retirerait ces éléments. */
trix-toolbar [data-trix-attribute="heading1"],
trix-toolbar [data-trix-attribute="code"],
trix-toolbar .trix-button-group--file-tools {
    display: none;
}

trix-toolbar .trix-button-row {
    flex-wrap: wrap;
    gap: 0.25rem 0;
}

trix-toolbar .trix-button-group {
    margin-bottom: 0.375rem;
    border-color: var(--bs-border-color);
    border-radius: 0.375rem;
}

trix-toolbar .trix-button {
    border-bottom-color: var(--bs-border-color);
}

trix-toolbar .trix-button:not(:first-child) {
    border-left-color: var(--bs-border-color);
}

/* Boutons lisibles en thème sombre (Trix ne prévoit que le clair). */
[data-bs-theme="dark"] trix-toolbar .trix-button {
    background-color: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] trix-toolbar .trix-button::before {
    filter: invert(1);
}

[data-bs-theme="dark"] trix-toolbar .trix-button.trix-active {
    background-color: var(--bs-secondary-bg);
}

trix-toolbar .trix-dialog {
    border-color: var(--bs-border-color);
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Zone de saisie : aspect d'un champ Bootstrap, hauteur qui suit le contenu. */
trix-editor.mg-rich-text-editor {
    min-height: 6.5rem;
    height: auto;
    overflow-wrap: anywhere;
}

trix-editor.mg-rich-text-editor:focus {
    border-color: var(--bs-primary-border-subtle, #86b7fe);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Texte enrichi affiché (et contenu de l'éditeur). */
.mg-rich-text,
trix-editor.mg-rich-text-editor {
    overflow-wrap: anywhere;
}

.mg-rich-text ul,
.mg-rich-text ol,
trix-editor.mg-rich-text-editor ul,
trix-editor.mg-rich-text-editor ol {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.mg-rich-text blockquote,
trix-editor.mg-rich-text-editor blockquote {
    margin: 0 0 0.5rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--bs-border-color);
    color: var(--bs-secondary-color);
}

.mg-rich-text > :last-child {
    margin-bottom: 0;
}

/* --- Sélecteur de date (contrôleur date-picker, vanilla-calendar-pro) -------------------------- */

.mg-date-field {
    position: relative;
}

/* Sans JavaScript, les boutons sont masqués : le champ natif garde ses coins arrondis. */
.mg-date-field:not(.is-enhanced) .input-group > .form-control {
    border-radius: var(--bs-border-radius);
}

.mg-date-button {
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-border-color: var(--bs-border-color);
    --bs-btn-hover-color: var(--bs-body-color);
    --bs-btn-hover-bg: var(--bs-tertiary-bg);
    --bs-btn-hover-border-color: var(--bs-border-color);
    --bs-btn-active-color: var(--bs-body-color);
    --bs-btn-active-bg: var(--bs-secondary-bg);
    --bs-btn-active-border-color: var(--bs-border-color);

    background-color: var(--bs-body-bg);
}

/* Panneau du calendrier : sous le champ, au-dessus d'une modale Bootstrap (z-index 1055). */
.mg-date-popover {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 1070;
}

/* Manque de place sous le champ : panneau au-dessus (classe posée par le contrôleur). */
.mg-date-popover--above {
    top: auto;
    bottom: calc(100% + 0.25rem);
}

/* Petits écrans : panneau centré en bas de l'écran, jamais hors de la largeur visible. */
@media (max-width: 575.98px) {
    .mg-date-popover {
        position: fixed;
        top: auto;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: min(100vw - 2rem, 20rem);
    }

    .mg-date-popover [data-vc="calendar"] {
        min-width: 0;
        width: 100%;
    }
}

/* Couleurs MyGoal sur le calendrier (variables de vanilla-calendar-pro), thèmes clair et sombre. */
.mg-date-popover [data-vc="calendar"] {
    --vc-date-selected-bg: var(--bs-primary);
    --vc-date-selected-color: #fff;
    --vc-date-today-color: var(--bs-primary);

    border: 1px solid var(--bs-border-color-translucent);
    box-shadow: 0 0.5rem 1.5rem rgb(16 24 40 / 0.18);
}

.mg-date-popover [data-vc-theme="dark"][data-vc="calendar"] {
    --vc-date-today-color: #8fb3ee;

    background-color: var(--bs-tertiary-bg);
}

.mg-date-popover [data-vc-date-btn]:focus-visible,
.mg-date-popover [data-vc-months-month]:focus-visible,
.mg-date-popover [data-vc-years-year]:focus-visible,
.mg-date-popover [data-vc-arrow]:focus-visible,
.mg-date-popover [data-vc="month"]:focus-visible,
.mg-date-popover [data-vc="year"]:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 1px;
}

/* --- Objectifs ----------------------------------------------------------------------------- */

.mg-criteria-list {
    padding-left: 1.25rem;
}

.mg-criteria-list li + li {
    margin-top: 0.375rem;
}

.mg-criterion + .mg-criterion {
    margin-top: 0.75rem;
}

/* Bouton « Retirer » aligné sur le champ (sous le libellé). */
.mg-criterion-remove {
    margin-top: 1.625rem;
    flex-shrink: 0;
}

/* Critères de réussite détaillés (définition, évaluation). */
.mg-criterion-card dt {
    color: var(--bs-secondary-color);
    font-weight: 600;
}

.mg-criterion-card dd,
.mg-criterion-card h3 {
    overflow-wrap: anywhere;
}

.mg-criteria-fields .mg-criterion {
    --bs-card-border-color: var(--bs-border-color-translucent);
}

/* --- Plans de match ------------------------------------------------------------------------- */

.mg-step-list .mg-step-card + .mg-step-card {
    margin-top: 0.75rem;
}

.mg-step-card.is-selected {
    --bs-card-border-color: var(--bs-primary);

    box-shadow: 0 0 0 1px var(--bs-primary);
}

/* Numéro de l'étape : rang actuel dans le parcours. */
.mg-step-number {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 700;
}

.mg-step-move {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.mg-step-move .form-control {
    flex: 1 1 12rem;
}

/* Panneau du détail : collé en haut sur ordinateur, après la liste sur mobile (empilement naturel). */
@media (min-width: 992px) {
    .mg-step-panel {
        position: sticky;
        top: 4.5rem;
    }
}

.mg-step-panel article:focus {
    outline: none;
}

/* --- Notes d'étude (docs/study-notes.md) -------------------------------------------------------- */

.mg-form-narrow {
    max-width: 40rem;
}

/* Trois zones sur ordinateur : navigation, liste, note. Empilées sur mobile (voir plus bas). */
.mg-notes {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

@media (min-width: 992px) {
    .mg-notes {
        grid-template-columns: 13rem 18rem minmax(0, 1fr);
        align-items: start;
    }

    .mg-notes-nav,
    .mg-notes-list {
        position: sticky;
        top: 4.25rem;
        max-height: calc(100vh - 5.5rem);
        overflow-y: auto;
    }

    .mg-notes.is-focus {
        grid-template-columns: minmax(0, 1fr);
    }

    .mg-notes.is-focus .mg-notes-nav,
    .mg-notes.is-focus .mg-notes-list {
        display: none;
    }

    .mg-notes.is-focus .mg-note-card {
        max-width: 60rem;
        margin-inline: auto;
    }
}

/* Mobile : une note ouverte occupe tout l'écran ; sans note, filtres repliables puis liste. */
@media (max-width: 991.98px) {
    .mg-notes.has-main .mg-notes-nav,
    .mg-notes.has-main .mg-notes-list,
    .mg-notes:not(.has-main) .mg-notes-placeholder {
        display: none;
    }
}

.mg-notes-back {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.mg-notes-filters .nav-link {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: var(--bs-border-radius);
    color: var(--bs-body-color);
}

.mg-notes-filters .nav-link.active {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
}

.mg-note-list li + li {
    margin-top: 0.25rem;
}

.mg-note-item {
    display: block;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    text-decoration: none;
}

.mg-note-item:hover,
.mg-note-item:focus-visible {
    border-color: var(--bs-primary);
}

.mg-note-item.is-current {
    border-color: var(--bs-primary);
    box-shadow: inset 3px 0 0 var(--bs-primary);
}

.mg-note-item-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.mg-note-item-excerpt {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
}

.mg-note-item-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

/* En-tête de l'éditeur */
.mg-note-head {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.mg-note-title-input {
    font-weight: 600;
}

.mg-note-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.mg-note-meta form {
    margin: 0;
}

.mg-save-status {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
}

.mg-save-status[data-state="dirty"],
.mg-save-status[data-state="saving"] {
    color: var(--bs-warning-text-emphasis);
}

.mg-save-status[data-state="error"],
.mg-save-status[data-state="conflict"] {
    color: var(--bs-danger-text-emphasis);
    font-weight: 600;
}

/* Barre d'outils : collée en haut pendant l'écriture ; une seule ligne défilante sur mobile. */
.mg-note-toolbar {
    position: sticky;
    top: 3.5rem;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    padding: 0.35rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-tertiary-bg);
}

@media (max-width: 991.98px) {
    .mg-note-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}

.mg-tool-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.125rem;
    align-items: center;
}

.mg-tool-group-table {
    flex-wrap: wrap;
}

.mg-tool {
    min-width: 2rem;
    border: 1px solid transparent;
    color: var(--bs-body-color);
}

.mg-tool:hover {
    border-color: var(--bs-border-color);
}

.mg-tool[aria-pressed="true"] {
    background-color: var(--bs-primary-bg-subtle);
    border-color: var(--bs-primary);
    color: var(--bs-primary-text-emphasis);
}

.mg-tool-text {
    white-space: nowrap;
    font-size: 0.8rem;
}

.mg-tool-select {
    width: auto;
    max-width: 11rem;
}

.mg-tool-icon {
    color: var(--bs-secondary-color);
}

.mg-dialog {
    width: min(28rem, calc(100vw - 2rem));
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.mg-dialog::backdrop {
    background: rgb(0 0 0 / 40%);
}

/* Contenu (écriture et lecture) : rendu par Tiptap à partir du JSON validé. */
.mg-note-content .mg-prosemirror {
    outline: none;
    font-size: 1.0625rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

/* Hauteur minimale en écriture seulement (zone cliquable) ; la lecture et l'impression suivent le contenu. */
.mg-note-content-editable .mg-prosemirror {
    min-height: 50vh;
    padding: 0.25rem 0.125rem 4rem;
}

.mg-note-content .mg-prosemirror:focus-visible {
    box-shadow: 0 0 0 2px var(--bs-primary-bg-subtle);
}

.mg-prosemirror > * + * {
    margin-top: 0.6em;
}

.mg-prosemirror p {
    margin-bottom: 0;
}

/*
 * Espacement : seul l'écart entre blocs voisins (« * + * ») compte. Les marges basses de Bootstrap (listes,
 * citations, blocs de code, titres) s'y ajoutaient et creusaient de grands vides. Les paragraphes vides saisis restent
 * visibles (une ligne chacun), et rien n'est retiré du contenu.
 */
.mg-prosemirror ul,
.mg-prosemirror ol,
.mg-prosemirror blockquote,
.mg-prosemirror pre,
.mg-prosemirror table,
.mg-prosemirror h1,
.mg-prosemirror h2,
.mg-prosemirror h3 {
    margin-bottom: 0;
}

.mg-prosemirror li > * + * {
    margin-top: 0.25em;
}

.mg-prosemirror > :first-child {
    margin-top: 0;
}

/* Titre ciblé par le sommaire : visible sous la barre d'outils collée en haut. */
.mg-prosemirror h1,
.mg-prosemirror h2,
.mg-prosemirror h3 {
    scroll-margin-top: 7.5rem;
}

.mg-prosemirror h1,
.mg-prosemirror h2,
.mg-prosemirror h3 {
    margin-top: 1.2em;
    font-weight: 700;
}

.mg-prosemirror h1 { font-size: 1.75rem; }
.mg-prosemirror h2 { font-size: 1.4rem; }
.mg-prosemirror h3 { font-size: 1.2rem; }

.mg-prosemirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    height: 0;
    color: var(--bs-secondary-color);
    pointer-events: none;
}

.mg-prosemirror blockquote {
    padding-left: 1rem;
    border-left: 4px solid var(--bs-border-color);
    color: var(--bs-secondary-color);
}

.mg-prosemirror hr {
    margin: 1.5rem 0;
}

.mg-prosemirror hr.ProseMirror-selectednode {
    outline: 2px solid var(--bs-primary);
}

.mg-prosemirror code {
    padding: 0.1em 0.3em;
    border-radius: 0.25rem;
    background-color: var(--bs-secondary-bg);
    color: var(--bs-code-color);
    font-size: 0.9em;
}

/* Texte surligné toujours foncé (fond pastel), y compris en thème sombre : Tiptap pose « color: inherit » en ligne. */
.mg-prosemirror mark {
    padding: 0 0.1em;
    border-radius: 0.15rem;
    color: #1f2328 !important;
}

/* Texte coloré et surligné : la couleur choisie, portée par le span parent, reste visible. */
.mg-prosemirror span[style*="color"] mark {
    color: inherit !important;
}

.mg-prosemirror a {
    text-decoration: underline;
}

.mg-prosemirror img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--bs-border-radius);
}

.mg-prosemirror img.ProseMirror-selectednode {
    outline: 3px solid var(--bs-primary);
}

/* Pièces jointes (PDF, Word, Excel…) : bloc téléchargeable, badge coloré selon la famille du fichier. */
.mg-prosemirror .mg-file-attachment {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 32rem;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-tertiary-bg);
}

.mg-prosemirror .mg-file-attachment.ProseMirror-selectednode {
    outline: 3px solid var(--bs-primary);
}

.mg-prosemirror .mg-file-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1 1 auto;
    color: var(--bs-body-color);
    text-decoration: none;
}

.mg-prosemirror .mg-file-link:hover .mg-file-name,
.mg-prosemirror .mg-file-link:focus-visible .mg-file-name {
    text-decoration: underline;
}

.mg-prosemirror .mg-file-ext {
    flex: 0 0 auto;
    min-width: 2.75rem;
    padding: 0.35rem 0.4rem;
    border-radius: 0.25rem;
    background: #6c757d;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.03em;
}

.mg-prosemirror .mg-file-ext-pdf { background: #b42318; }
.mg-prosemirror .mg-file-ext-text { background: #1f5fbf; }
.mg-prosemirror .mg-file-ext-sheet { background: #17753d; }
.mg-prosemirror .mg-file-ext-slides { background: #b54708; }

.mg-prosemirror .mg-file-name {
    overflow: hidden;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mg-prosemirror .mg-file-size {
    flex: 0 0 auto;
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
}

/* Listes de tâches */
.mg-prosemirror ul[data-type="taskList"] {
    padding-left: 0.25rem;
    list-style: none;
}

.mg-prosemirror ul[data-type="taskList"] li {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.mg-prosemirror ul[data-type="taskList"] li > label {
    flex: 0 0 auto;
    margin-top: 0.3em;
}

.mg-prosemirror ul[data-type="taskList"] li > div {
    flex: 1 1 auto;
    min-width: 0;
}

.mg-prosemirror ul[data-type="taskList"] li[data-checked="true"] > div {
    color: var(--bs-secondary-color);
    text-decoration: line-through;
}

/* Tableaux : défilement horizontal (mobile) sans élargir la page. */
.mg-prosemirror table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.mg-prosemirror td,
.mg-prosemirror th {
    min-width: 6rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--bs-border-color);
    vertical-align: top;
}

.mg-prosemirror th {
    background-color: var(--bs-secondary-bg);
    font-weight: 600;
    text-align: left;
}

.mg-prosemirror td > * + *,
.mg-prosemirror th > * + * {
    margin-top: 0.4em;
}

.mg-prosemirror .selectedCell {
    background-color: var(--bs-primary-bg-subtle);
}

/* Blocs de code et coloration syntaxique (classes highlight.js, couleurs propres au thème clair / sombre). */
.mg-prosemirror pre {
    padding: 0.75rem 1rem;
    overflow-x: auto;
    border-radius: var(--bs-border-radius);
    background-color: #1f2430;
    color: #e6e6e6;
    font-size: 0.875rem;
    line-height: 1.5;
}

.mg-prosemirror pre code {
    padding: 0;
    background: none;
    color: inherit;
    font-size: inherit;
}

.mg-prosemirror .hljs-comment,
.mg-prosemirror .hljs-quote { color: #8a93a6; font-style: italic; }
.mg-prosemirror .hljs-keyword,
.mg-prosemirror .hljs-selector-tag,
.mg-prosemirror .hljs-built_in { color: #c792ea; }
.mg-prosemirror .hljs-string,
.mg-prosemirror .hljs-attr,
.mg-prosemirror .hljs-template-variable { color: #c3e88d; }
.mg-prosemirror .hljs-number,
.mg-prosemirror .hljs-literal,
.mg-prosemirror .hljs-symbol { color: #f78c6c; }
.mg-prosemirror .hljs-title,
.mg-prosemirror .hljs-section,
.mg-prosemirror .hljs-name { color: #82aaff; }
.mg-prosemirror .hljs-type,
.mg-prosemirror .hljs-class,
.mg-prosemirror .hljs-variable { color: #ffcb6b; }
.mg-prosemirror .hljs-meta,
.mg-prosemirror .hljs-tag { color: #89ddff; }
.mg-prosemirror .hljs-deletion { color: #ff5370; }
.mg-prosemirror .hljs-addition { color: #c3e88d; }
.mg-prosemirror .hljs-emphasis { font-style: italic; }
.mg-prosemirror .hljs-strong { font-weight: 700; }

/* Blocs pédagogiques : couleur discrète, toujours accompagnée d'une icône et d'un libellé. */
.mg-callout {
    --mg-callout-color: var(--bs-primary);
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid var(--mg-callout-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-tertiary-bg);
}

.mg-callout[data-kind="example"] { --mg-callout-color: var(--bs-info); }
.mg-callout[data-kind="remember"] { --mg-callout-color: var(--bs-success); }
.mg-callout[data-kind="warning"] { --mg-callout-color: var(--bs-warning); }

.mg-callout-head,
.mg-faq-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    user-select: none;
}

.mg-callout-icon {
    color: var(--mg-callout-color);
}

.mg-callout-title {
    font-weight: 600;
}

.mg-callout-label::after {
    content: " ·";
    color: var(--bs-secondary-color);
}

.mg-callout-label:has(+ .mg-callout-title[hidden])::after {
    content: none;
}

.mg-callout-kind {
    width: auto;
}

.mg-callout-title-input {
    flex: 1 1 10rem;
    min-width: 8rem;
    font-weight: 600;
}

.mg-block-remove {
    margin-left: auto;
    border: 1px solid transparent;
    color: var(--bs-danger-text-emphasis);
    font-size: 0.8rem;
}

.mg-block-remove:hover {
    border-color: var(--bs-danger);
}

.mg-callout-body > * + *,
.mg-faq-answer > * + * {
    margin-top: 0.5em;
}

.mg-faq {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.mg-faq-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background-color: var(--bs-secondary-bg);
    font-size: 0.8rem;
}

.mg-faq-question {
    font-weight: 600;
}

/* Question vide en écriture : invite (aucun texte ajouté au document). */
.mg-note-content-editable .mg-faq-question:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Question…";
    float: left;
    height: 0;
    color: var(--bs-secondary-color);
    font-weight: 400;
    pointer-events: none;
}

.mg-faq-answer {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--bs-border-color);
}

.mg-faq-controls {
    margin-top: 0.35rem;
    font-weight: 400;
}

/* Lecture : réponse masquée tant qu'elle n'est pas ouverte ; écriture : aperçu replié à la demande. */
.mg-note-content:not(.mg-note-content-editable) .mg-faq:not(.is-open) .mg-faq-answer,
.mg-faq.is-preview-collapsed .mg-faq-answer {
    display: none;
}

.mg-faq-preview {
    margin-left: auto;
    border: 1px solid var(--bs-border-color);
    font-size: 0.8rem;
}

.mg-faq-preview[aria-pressed="true"] {
    background-color: var(--bs-primary-bg-subtle);
    border-color: var(--bs-primary);
}

.mg-faq-preview + .mg-block-remove {
    margin-left: 0;
}

/* Sommaire : à côté du texte sur grand écran, replié au-dessus sur mobile. */
.mg-note-body {
    display: grid;
    gap: 0.75rem;
}

.mg-note-toc {
    font-size: 0.875rem;
}

.mg-note-toc > summary {
    color: var(--bs-secondary-color);
    font-weight: 600;
    cursor: pointer;
}

.mg-note-toc nav {
    margin-top: 0.35rem;
}

.mg-note-toc-empty {
    margin: 0;
    color: var(--bs-secondary-color);
    font-style: italic;
}

.mg-note-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.mg-note-toc-level-2 { padding-left: 0.85rem; }
.mg-note-toc-level-3 { padding-left: 1.7rem; }

.mg-note-toc-link {
    display: block;
    width: 100%;
    padding: 0.15rem 0.25rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background: none;
    color: var(--bs-link-color);
    text-align: left;
    overflow-wrap: anywhere;
}

.mg-note-toc-link:hover,
.mg-note-toc-link:focus-visible {
    background-color: var(--bs-secondary-bg);
}

@media (min-width: 1200px) {
    .mg-note-body {
        grid-template-columns: minmax(0, 1fr) 13rem;
        align-items: start;
    }

    .mg-note-toc {
        position: sticky;
        top: 7.5rem;
        grid-column: 2;
        grid-row: 1;
        max-height: calc(100vh - 9rem);
        overflow-y: auto;
    }

    .mg-note-body > .mg-note-content {
        grid-column: 1;
        grid-row: 1;
    }
}

.mg-note-read-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

/* Barre d'outils : menus et barres contextuelles. */
.mg-note-toolbar .dropdown-item[aria-pressed="true"] {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
}

.mg-tool-context {
    flex-basis: 100%;
    padding-top: 0.25rem;
    border-top: 1px solid var(--bs-border-color);
}

.mg-tool-context-label {
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
}

@media (max-width: 991.98px) {
    .mg-tool-context {
        flex-basis: auto;
        border-top: 0;
    }
}

/* Historique des versions */
.mg-revision-item {
    padding: 0.5rem 0;
    border-top: 1px solid var(--bs-border-color-translucent);
}

.mg-revision-item:first-child {
    border-top: 0;
}

/* Mobile : zone d'écriture aussi large que possible (marges de la carte réduites). */
@media (max-width: 991.98px) {
    .mg-notes .mg-note-card > .card-body {
        padding: 0.75rem 0.5rem;
    }

    .mg-note-content-editable .mg-prosemirror {
        padding-inline: 0;
    }
}

/* --- Notes d'étude : version imprimable (note/print.html.twig) ---------------------------------- */

.mg-print-body {
    background-color: #fff;
}

.mg-print {
    color: #212529;
    background-color: #fff;
}

.mg-print-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    max-width: 48rem;
    margin: 0 auto;
    padding: 1rem 1rem 0;
}

.mg-print-page {
    max-width: 48rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.mg-print-page:focus {
    outline: none;
}

.mg-print-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #ced4da;
}

.mg-print-title {
    margin-bottom: 0.25rem;
    font-size: 1.9rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.mg-print-meta {
    margin: 0;
    font-size: 0.875rem;
    color: #6c757d;
}

.mg-print .mg-prosemirror {
    min-height: 0;
}

/* Version imprimable : réponses toujours affichées, sans bouton (aperçu à l'écran comme sur papier). */
.mg-print .mg-faq-controls {
    display: none;
}

/* Cellules : les mots ne sont coupés que s'ils ne tiennent pas sur une ligne. */
.mg-print .mg-prosemirror td,
.mg-print .mg-prosemirror th {
    overflow-wrap: break-word;
}

/* Blocs de code sur fond clair (lisibles à l'écran comme sur papier) : couleurs proches de « GitHub ». */
.mg-print .mg-prosemirror pre {
    border: 1px solid #d0d7de;
    background-color: #f6f8fa;
    color: #1f2328;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.mg-print .mg-prosemirror .hljs-comment,
.mg-print .mg-prosemirror .hljs-quote { color: #6e7781; }
.mg-print .mg-prosemirror .hljs-keyword,
.mg-print .mg-prosemirror .hljs-selector-tag,
.mg-print .mg-prosemirror .hljs-built_in { color: #cf222e; }
.mg-print .mg-prosemirror .hljs-string,
.mg-print .mg-prosemirror .hljs-attr,
.mg-print .mg-prosemirror .hljs-template-variable,
.mg-print .mg-prosemirror .hljs-addition { color: #0a3069; }
.mg-print .mg-prosemirror .hljs-number,
.mg-print .mg-prosemirror .hljs-literal,
.mg-print .mg-prosemirror .hljs-symbol { color: #0550ae; }
.mg-print .mg-prosemirror .hljs-title,
.mg-print .mg-prosemirror .hljs-section,
.mg-print .mg-prosemirror .hljs-name { color: #8250df; }
.mg-print .mg-prosemirror .hljs-type,
.mg-print .mg-prosemirror .hljs-class,
.mg-print .mg-prosemirror .hljs-variable,
.mg-print .mg-prosemirror .hljs-meta,
.mg-print .mg-prosemirror .hljs-tag { color: #953800; }
.mg-print .mg-prosemirror .hljs-deletion { color: #82071e; }

@media print {
    @page {
        margin: 16mm 15mm;
    }

    .mg-print-body .skip-links,
    .mg-print-actions {
        display: none !important;
    }

    .mg-print-page {
        max-width: none;
        padding: 0;
    }

    .mg-print .mg-prosemirror {
        font-size: 11pt;
        line-height: 1.5;
    }

    /* Tableaux en pleine largeur (pas de défilement horizontal sur papier ; à l'écran, défilement conservé). */
    .mg-print .mg-prosemirror table {
        display: table;
        width: 100%;
        table-layout: auto;
    }

    .mg-print .mg-prosemirror td,
    .mg-print .mg-prosemirror th {
        min-width: 0;
    }

    /* Couleurs du texte, surlignages, en-têtes de tableau et blocs de code conservés à l'impression. */
    .mg-print .mg-prosemirror,
    .mg-print .mg-prosemirror * {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .mg-print .mg-prosemirror h1,
    .mg-print .mg-prosemirror h2,
    .mg-print .mg-prosemirror h3 {
        break-after: avoid;
    }

    .mg-print .mg-prosemirror p {
        orphans: 3;
        widows: 3;
    }

    .mg-print .mg-prosemirror tr,
    .mg-print .mg-prosemirror img,
    .mg-print .mg-prosemirror .mg-file-attachment,
    .mg-print .mg-prosemirror blockquote,
    .mg-print .mg-prosemirror li {
        break-inside: avoid;
    }

    .mg-print .mg-prosemirror img {
        max-height: 85vh;
        object-fit: contain;
    }

    /* Blocs pédagogiques : jamais coupés, toutes les réponses imprimées, boutons masqués. */
    .mg-print .mg-callout,
    .mg-print .mg-faq {
        break-inside: avoid;
    }

    .mg-print .mg-faq-answer {
        display: block !important;
    }

    .mg-print .mg-faq-controls,
    .mg-note-toc,
    .mg-note-read-tools {
        display: none !important;
    }

    /* Adresse des liens web imprimée après le texte (le lien n'est pas cliquable sur papier). */
    .mg-print .mg-prosemirror a[href^="http"]::after,
    .mg-print .mg-prosemirror a[href^="mailto:"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #555;
        overflow-wrap: anywhere;
    }
}

/* Disponibilité d'une étape « À faire » (plan de match) : texte explicite, couleur en complément. */
.mg-availability.is-ready {
    color: var(--bs-success-text-emphasis);
    font-weight: 600;
}

.mg-availability.is-waiting {
    color: var(--bs-secondary-color);
}

/* --- Actions des étapes (docs/actions.md) ------------------------------------------------------- */

.mg-action-list .mg-action-item {
    padding: 0.5rem 0;
    border-top: 1px solid var(--bs-border-color-translucent);
}

.mg-action-list .mg-action-item:first-child {
    border-top: 0;
    padding-top: 0;
}

.mg-duration .form-control {
    width: 6rem;
}

/* --- Actions récurrentes (docs/actions.md) ------------------------------------------------------ */

.mg-recurrence-number .form-control {
    width: 7rem;
}

/* Jours de la semaine et options : sur une ligne quand la place le permet. */
[data-recurrence-form-target="daily"] .form-check,
[data-recurrence-form-target="weekly"] .form-check {
    display: inline-block;
    margin-right: 1rem;
}

.mg-recurrence-preview {
    background: var(--bs-tertiary-bg);
}
