/* =========================================================
   DataGrade — interface app (sidebar + pages)
   Réutilise les variables/typo de landing.css
   ========================================================= */

body.app {
    background: var(--bg);
    overflow: visible;
}

/* Cache la décor de la landing sur les pages app */
body.app .bg-decor { display: none; }

.app {
    display: flex;
    min-height: 100vh;
}

/* ======================== Sidebar ======================== */

.sidebar {
    position: sticky;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-elev);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.sidebar__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
}

.sidebar__nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__group {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    padding: 16px 12px 6px;
}

.sidebar__link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 500;
    color: var(--ink-soft);
    transition: all .15s var(--ease-out);
}
.sidebar__link:hover {
    background: var(--violet-50);
    color: var(--violet-700);
}
.sidebar__link.is-active {
    background: var(--ink);
    color: white;
}
.sidebar__link svg { flex-shrink: 0; }
.sidebar__link--admin { color: var(--coral-500); }
.sidebar__link--admin:hover { background: var(--rose-50); color: var(--coral-500); }

/* Bouton "Faire une suggestion" : style discret en bas de nav */
.sidebar__link--ghost {
    margin-top: auto;
    background: transparent;
    border: 1px dashed var(--line);
    color: var(--ink-muted);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 13.5px;
}
.sidebar__link--ghost:hover {
    background: var(--violet-50);
    color: var(--violet-700);
    border-color: var(--violet-500);
}

.sidebar__badge {
    margin-left: auto;
    background: var(--coral-500);
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

/* Dialog (modale native HTML5) */
.dialog {
    border: none;
    border-radius: 16px;
    padding: 0;
    max-width: 540px;
    width: calc(100% - 32px);
    background: var(--bg-elev);
    color: var(--ink);
    box-shadow: 0 25px 60px -20px rgba(0, 0, 0, 0.3);
}
.dialog::backdrop {
    background: rgba(15, 15, 30, 0.45);
    backdrop-filter: blur(2px);
}
.dialog__panel {
    padding: 28px;
}
.dialog__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.4rem;
    margin: 0 0 8px;
    color: var(--ink);
}
.dialog__lead {
    color: var(--ink-soft);
    font-size: 14.5px;
    margin: 0 0 18px;
}
.dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.sidebar__footer {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.user__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--violet-500), var(--coral-500));
    color: white;
    font-family: var(--font-display);
    font-weight: 700;
    display: grid;
    place-items: center;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}
.user__avatar--img {
    object-fit: cover;
}
.user--link {
    text-decoration: none;
    border-radius: 10px;
    padding: 4px;
    margin: -4px;
    transition: background .15s;
}
.user--link:hover {
    background: var(--violet-50);
}
.user__info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.user__name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user__role {
    font-size: 12px;
    color: var(--ink-muted);
}
.sidebar__logout {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--ink-muted);
    transition: all .15s;
}
.sidebar__logout:hover {
    background: var(--rose-50);
    color: var(--coral-500);
}

/* ======================== Main ======================== */

.app__main {
    flex: 1;
    padding: 32px 40px;
    max-width: 1100px;
}

.page-head {
    margin-bottom: 32px;
}
.page-head__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.page-head__subtitle {
    color: var(--ink-soft);
    margin-top: 4px;
}

.page-section {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 28px;
    margin-bottom: 24px;
}
.page-section__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 8px;
}
.page-section__lead {
    color: var(--ink-soft);
    font-size: 14.5px;
    margin-bottom: 18px;
}
/* Variante "minimal" : pas de fond ni de bordure (le contenu se suffit à
   lui-même), padding réduit. Utilisée par exemple pour la section
   "Derniers modifiés" sur Mes quiz, qui sert juste de raccourci. */
.page-section--minimal {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 24px;
}
.page-section__title--small {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    font-weight: 600;
    margin-bottom: 12px;
}

/* ======================== Quiz filter bar ======================== */
/* Barre de filtres horizontale au-dessus de la grille des quiz. Search
   prend le plus de place, les selects sont compacts, le toggle "partagés"
   reste à droite, "Réinitialiser" en bouton ghost. Sur mobile, tout passe
   en colonne avec gap réduit. */
.quiz-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.quiz-filter-bar input[type="search"] {
    flex: 1 1 220px;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-elev);
    color: var(--ink);
}
.quiz-filter-bar input[type="search"]:focus {
    outline: none;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--violet-50);
}
.quiz-filter-bar select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13.5px;
    background: var(--bg-elev);
    color: var(--ink);
    cursor: pointer;
    max-width: 200px;
}
.quiz-filter-bar__chk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
    padding: 0 6px;
}
.quiz-filter-bar__chk input { cursor: pointer; }
@media (max-width: 720px) {
    .quiz-filter-bar { padding: 10px; gap: 8px; }
    .quiz-filter-bar select { max-width: 100%; flex: 1 1 140px; }
}

/* ======================== Forms ======================== */

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.form-row label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row textarea,
.form-row select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 14.5px;
    color: var(--ink);
    background: var(--bg-elev);
    transition: border-color .15s, box-shadow .15s;
}
.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--violet-100);
}
.form-row textarea {
    min-height: 220px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    line-height: 1.55;
    resize: vertical;
}
.form-row__hint {
    font-size: 12.5px;
    color: var(--ink-muted);
}

/* ======================== Tables ======================== */

/* ======================== Tabs ======================== */

.tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--line-soft);
    border-radius: 12px;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-muted);
    transition: all .15s var(--ease-out);
}
.tab:hover { color: var(--ink); }
.tab--active {
    background: var(--bg-elev);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.tab__count {
    font-size: 12px;
    font-weight: 700;
    background: var(--ink-muted);
    color: white;
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}
.tab--active .tab__count {
    background: var(--violet-500);
}

/* ======================== Suggestion cards ======================== */

.suggestion-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.suggestion-card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    transition: border-color .15s, box-shadow .15s;
}
.suggestion-card:hover {
    border-color: var(--violet-500);
    box-shadow: 0 4px 14px -8px rgba(99, 102, 241, 0.25);
}
.suggestion-card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.suggestion-card__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.suggestion-card__avatar--initial {
    background: linear-gradient(135deg, var(--violet-500), var(--coral-500));
    color: white;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 15px;
}
.suggestion-card__meta {
    min-width: 0;
    flex: 1;
}
.suggestion-card__author {
    font-weight: 600;
    color: var(--ink);
    font-size: 15px;
}
.suggestion-card__sub {
    font-size: 12.5px;
    color: var(--ink-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.suggestion-card__dot {
    color: var(--line);
}
.suggestion-card__body {
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 4px 0 14px;
    border-bottom: 1px dashed var(--line);
}
.suggestion-card__treated {
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--emerald-500, #10b981);
    background: rgba(16, 185, 129, 0.08);
    padding: 8px 12px;
    border-radius: 8px;
}
.suggestion-card__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    font-weight: 700;
    background: var(--line-soft);
}
.table tr:hover td { background: var(--violet-50); }
.table .code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    color: var(--violet-700);
    background: var(--violet-50);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 13px;
    letter-spacing: 0.02em;
}

/* Variante click-to-copy : ressemble au badge .code mais réagit au survol/click */
.code--copy {
    border: 1px dashed transparent;
    cursor: pointer;
    transition: all .15s var(--ease-out);
}
.code--copy:hover {
    border-color: var(--violet-300, var(--violet-200));
    background: white;
}
.code--copy:focus-visible {
    outline: none;
    border-style: solid;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--violet-100);
}
.code--copied {
    background: var(--emerald-50) !important;
    color: var(--emerald-500) !important;
    border-color: var(--emerald-500) !important;
}

.gender {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11.5px;
    font-weight: 700;
    font-family: var(--font-display);
}
.gender--m { background: #DBEAFE; color: #1E40AF; }
.gender--f { background: #FCE7F3; color: #9D174D; }
.gender--x { background: var(--line-soft); color: var(--ink-muted); }

/* ======================== Inline gender edit (table cell) ======================== */
/* Apparence "pastille" sur le <select> pour rester proche du badge .gender, tout en
   restant éditable. Pas de chevron natif → on dessine notre propre flèche au hover. */
.gender-select {
    appearance: none;
    -webkit-appearance: none;
    border: 1.5px dashed transparent;
    border-radius: 999px;
    width: 36px;
    height: 28px;
    padding: 0;
    text-align: center;
    text-align-last: center;
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s var(--ease-out);
}
.gender-select:hover {
    border-color: var(--violet-200);
    width: 48px;
}
.gender-select:focus {
    outline: none;
    border-style: solid;
    border-color: var(--violet-500);
    background: white !important;
    color: var(--ink) !important;
    box-shadow: 0 0 0 3px var(--violet-100);
    width: 48px;
}
.gender-select--m     { background: #DBEAFE; color: #1E40AF; }
.gender-select--f     { background: #FCE7F3; color: #9D174D; }
.gender-select--x     { background: var(--line-soft); color: var(--ink-muted); }
.gender-select--empty { background: transparent; color: var(--ink-muted); font-weight: 400; }
/* Les options du dropdown système : on remet une couleur lisible (le fond coloré du select bave sinon). */
.gender-select option { background: white; color: var(--ink); font-weight: 500; }

/* ======================== Inline subgroup edit (table cell) ======================== */

.subgroup-input {
    background: transparent;
    border: 1.5px dashed transparent;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--violet-700);
    width: 110px;
    font-family: inherit;
    transition: all .15s var(--ease-out);
}
.subgroup-input::placeholder {
    color: var(--ink-muted);
    font-weight: 400;
}
.subgroup-input:hover {
    border-color: var(--violet-200);
    background: var(--bg);
}
.subgroup-input:focus {
    outline: none;
    border-style: solid;
    border-color: var(--violet-500);
    background: white;
    box-shadow: 0 0 0 3px var(--violet-100);
}
/* Quand l'input contient une valeur (sous-groupe défini) → fond violet light */
.subgroup-input:not(:placeholder-shown):not(:focus) {
    background: var(--violet-50);
    border-color: var(--violet-100);
}

/* ======================== Chips d'exclusion (lancement quiz) ======================== */

.exclude-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-elev);
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    transition: all .15s;
}
.exclude-chip:hover {
    border-color: var(--coral-500);
}
.exclude-chip input { margin: 0; accent-color: var(--coral-500); }
.exclude-chip:has(input:checked) {
    background: var(--rose-50);
    border-color: var(--coral-500);
    color: #9F1239;
    text-decoration: line-through;
}

/* ======================== Role picker (radios as cards) ======================== */

.role-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 700px) {
    .role-picker { grid-template-columns: 1fr; }
}
.role-option {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    transition: all .15s var(--ease-out);
    align-items: flex-start;
    background: var(--bg-elev);
}
.role-option:hover {
    border-color: var(--violet-200);
    background: var(--violet-50);
}
.role-option input[type="radio"] {
    margin-top: 4px;
    accent-color: var(--violet-500);
    flex-shrink: 0;
}
.role-option:has(input:checked) {
    border-color: var(--violet-500);
    background: var(--violet-50);
    box-shadow: 0 0 0 3px var(--violet-100);
}
.role-option__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.4;
}
.role-option__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
}
.role-option__desc {
    font-size: 12.5px;
    color: var(--ink-soft);
}

/* ======================== Invite card ======================== */

.invite-card {
    border: 2px solid var(--violet-200);
    background: linear-gradient(135deg, var(--violet-50), white);
}
.invite-link {
    display: flex;
    gap: 8px;
    align-items: center;
}
.invite-link input {
    flex: 1;
    padding: 12px 14px;
    border: 1.5px solid var(--violet-200);
    border-radius: 10px;
    background: white;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    color: var(--violet-700);
    cursor: pointer;
}
.invite-link input:focus {
    outline: none;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--violet-100);
}

/* ======================== Tags ======================== */

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
/* Pastille neutre "+N tags" qui condense les tags secondaires (chapitres,
   thèmes…) sur les cartes pour éviter le sapin de Noël coloré. */
.tag-chip--more {
    background: var(--line-soft);
    color: var(--ink-muted);
    cursor: help;
    border: 1px dashed var(--line);
}

.tag-picker-group {
    margin-bottom: 14px;
}
.tag-picker-group:last-child { margin-bottom: 0; }
.tag-picker-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    margin-bottom: 8px;
}
.tag-picker-sublabel {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
    margin-top: 4px;
    cursor: pointer;
    user-select: none;
    list-style: none;        /* Chrome/Safari : retire le marqueur natif */
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    transition: color .12s ease;
}
.tag-picker-sublabel::-webkit-details-marker { display: none; }  /* Safari */
.tag-picker-sublabel::before {
    content: '▸';
    font-size: 10px;
    color: var(--ink-muted);
    transition: transform .15s ease;
    display: inline-block;
}
details[open] > .tag-picker-sublabel::before { transform: rotate(90deg); }
.tag-picker-sublabel:hover { color: var(--violet-700); }
.tag-picker-sublabel small {
    color: var(--ink-muted);
    font-weight: 500;
    font-size: 11px;
    margin-left: 2px;
}
/* Petit point coloré quand au moins une chip du groupe est sélectionnée */
.tag-picker-sublabel__sel {
    color: var(--violet-500);
    font-size: 8px;
    margin-left: auto;
}
.tag-picker-group--sub {
    padding-left: 12px;
    border-left: 2px solid var(--line-soft);
    margin-bottom: 10px;
}
/* Le tag-picker à l'intérieur du <details> garde un peu d'air entre le summary et les chips */
details.tag-picker-group--sub > .tag-picker { margin-top: 6px; }
.tag-picker-hint {
    font-size: 13px;
    color: var(--ink-muted);
    font-style: italic;
}
.tag-picker-search {
    margin: 8px 0;
}
.tag-picker-search input {
    width: 100%;
    max-width: 360px;
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 13.5px;
    background: var(--bg);
    color: var(--ink);
    transition: all .15s;
}
.tag-picker-search input:focus {
    outline: none;
    border-color: var(--violet-500);
    background: var(--bg-elev);
    box-shadow: 0 0 0 3px var(--violet-100);
}
.tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tag-chip-pick {
    --tag-color: var(--violet-500);
    cursor: pointer;
    user-select: none;
    display: inline-flex;
}
.tag-chip-pick input {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    pointer-events: none !important;
    margin: 0 !important;
}
.tag-chip-pick > span {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    background: var(--bg-elev);
    border: 1.5px solid var(--line);
    transition: all 0.15s var(--ease-out);
    line-height: 1;
}
.tag-chip-pick:hover > span {
    color: var(--tag-color);
    border-color: var(--tag-color);
    transform: translateY(-1px);
}
.tag-chip-pick input:checked ~ span {
    background: var(--tag-color);
    color: white;
    border-color: var(--tag-color);
    box-shadow: 0 2px 8px rgba(21, 16, 31, 0.12);
}
/* Focus visible pour l'accessibilité clavier */
.tag-chip-pick input:focus-visible ~ span {
    outline: 2px solid var(--violet-500);
    outline-offset: 2px;
}

/* ======================== Question list (in editor) ======================== */

.q-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.q-item {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 14px;
    padding: 16px 12px;
    border-bottom: 1px solid var(--line);
    align-items: flex-start;
}
.q-item:last-child { border-bottom: none; }
.q-item__num {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    background: var(--violet-50);
    color: var(--violet-700);
    border-radius: 50%;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
}

/* Question bonus : couleur ambrée distinctive */
.q-item--bonus {
    background: linear-gradient(to right, #FFFBEB 0%, transparent 80%);
    border-left: 3px solid #F59E0B;
    padding-left: 14px;
    margin-left: -14px;
}
.q-item--bonus .q-item__num {
    background: #FEF3C7;
    color: #92400E;
}
.q-item__type {
    margin-bottom: 6px;
}
.q-item__statement {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
    line-height: 1.4;
}
.q-item__choices {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13.5px;
    color: var(--ink-soft);
}
.q-item__choices li {
    padding: 2px 0;
}
.q-item__choices li.is-correct {
    color: var(--emerald-500);
    font-weight: 600;
}
.q-item__explanation {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--violet-50);
    border-radius: 8px;
    font-size: 13px;
    color: var(--ink-soft);
    line-height: 1.5;
}
.q-item__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ======================== Choice rows in editor ======================== */

.choice-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.choice-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.choice-row input[type="text"] {
    flex: 1;
}
.choice-row__correct {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-muted);
    background: var(--bg);
    border: 1.5px solid var(--line);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.choice-row__correct:hover {
    border-color: var(--emerald-500);
    color: var(--emerald-500);
}
.choice-row__correct:has(input:checked) {
    background: var(--emerald-50);
    border-color: var(--emerald-500);
    color: #065F46;
}

/* ======================== Markdown / LaTeX editor ======================== */

.dg-editor {
    border: 1.5px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-elev);
}
.dg-editor__toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--line-soft);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.dg-editor__toolbar button {
    height: 30px;
    min-width: 32px;
    padding: 0 8px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.dg-editor__toolbar button:hover:not(:disabled) {
    background: white;
    color: var(--ink);
}
.dg-editor__toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.dg-editor__toolbar code {
    font-family: ui-monospace, monospace;
    font-size: 12px;
}
.dg-editor__sep {
    width: 1px;
    height: 18px;
    background: var(--line);
    margin: 0 4px;
}
.dg-editor__preview-toggle {
    margin-left: auto;
    font-size: 12px !important;
}
.dg-editor__preview-toggle.is-active {
    background: var(--violet-100) !important;
    color: var(--violet-700) !important;
}

.dg-editor__split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 200px;
}
.dg-editor__split:has(.dg-editor__pane--preview.is-hidden) {
    grid-template-columns: 1fr;
}
@media (max-width: 720px) {
    .dg-editor__split { grid-template-columns: 1fr; }
}

.dg-editor__pane {
    overflow: auto;
}
.dg-editor__pane--edit {
    border-right: 1px solid var(--line);
    position: relative;
}
.dg-editor__pane--edit textarea {
    width: 100%;
    height: 100%;
    min-height: 200px;
    padding: 14px 16px;
    border: none !important;
    outline: none;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important;
    font-size: 13.5px !important;
    line-height: 1.6;
    background: var(--bg-elev);
    color: var(--ink);
    border-radius: 0 !important;
}
.dg-editor__pane--edit textarea:focus {
    box-shadow: none !important;
}
.dg-editor__pane--edit.is-drop {
    background: var(--violet-50);
}
.dg-editor__pane--edit.is-drop::after {
    content: "Dépose ton image ici";
    position: absolute;
    inset: 8px;
    border: 2px dashed var(--violet-500);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--violet-700);
    font-weight: 600;
    pointer-events: none;
    background: rgba(245, 241, 250, 0.8);
}

.dg-editor__pane--preview {
    padding: 14px 18px;
    background: var(--bg);
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--ink);
}
.dg-editor__pane--preview.is-hidden {
    display: none;
}
.dg-editor__pane--preview p { margin: 0 0 12px; }
.dg-editor__pane--preview p:last-child { margin-bottom: 0; }
.dg-editor__pane--preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}
.dg-editor__pane--preview code {
    background: var(--violet-50);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    font-family: ui-monospace, monospace;
    color: var(--violet-700);
}
.dg-editor__pane--preview pre {
    background: var(--ink);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.dg-editor__pane--preview pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 13px;
}
.dg-editor__pane--preview blockquote {
    border-left: 3px solid var(--violet-500);
    padding: 4px 14px;
    margin: 8px 0;
    color: var(--ink-soft);
    background: var(--violet-50);
}
.dg-editor__preview-empty {
    color: var(--ink-muted);
    font-style: italic;
    font-size: 13px;
}

/* Question rendering in lists (q-item__statement) — same pretty look */
.q-item__statement img,
.q-item__choices img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 4px 0;
}
.q-item__statement code {
    background: var(--violet-50);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    font-family: ui-monospace, monospace;
    color: var(--violet-700);
}
.q-item__statement pre {
    background: var(--ink);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 13px;
}
.q-item__statement pre code { background: transparent; color: inherit; padding: 0; }

/* ======================== Citation du jour ======================== */
/* Carte sobre, lecture aérée. Variante --eleve = même style mais centrée et
   posée plus modestement en bas de page sans cadre marqué. */

.dg-quote {
    position: relative;
    margin: 24px 0 28px;
    padding: 22px 28px 22px 56px;
    background: linear-gradient(135deg, var(--violet-50), #FFF6F4);
    border: 1px solid var(--violet-100);
    border-radius: 14px;
    box-shadow: 0 1px 0 rgba(20,14,50,.02);
}
.dg-quote__mark {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 26px;
    height: 26px;
    fill: var(--violet-500);
    opacity: .35;
}
.dg-quote__text {
    margin: 0;
    padding: 0;
    border: none;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 17px;
    line-height: 1.45;
    color: var(--ink);
    letter-spacing: -0.005em;
}
.dg-quote__author {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--violet-700);
    text-align: right;
    font-style: normal;
}

/* Variante côté élève : plus discrète, centrée, sans fond */
.dg-quote--eleve {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 24px 24px 12px;
    text-align: center;
    max-width: 720px;
    margin: 36px auto 8px;
}
.dg-quote--eleve .dg-quote__mark {
    position: static;
    display: block;
    margin: 0 auto 8px;
    width: 22px;
    height: 22px;
    opacity: .25;
}
.dg-quote--eleve .dg-quote__text {
    font-size: 15.5px;
    color: var(--ink-soft);
}
.dg-quote--eleve .dg-quote__author {
    text-align: center;
    color: var(--ink-muted);
}

/* ======================== Bandeau "Cognitive Engine en calibrage" ======================== */
/* Avertissement amber/orange clair, à afficher sur les pages prof où la
   correction automatique par LLM peut intervenir. Volontairement non-fermable
   pendant la phase de beta : le but est que la mention reste visible. */
.cognitive-notice {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #FEF3C7, #FFFBEB);
    border: 1px solid #FCD34D;
    border-left: 4px solid #F59E0B;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    color: #78350F;
}
.cognitive-notice strong { color: #78350F; font-weight: 700; }
.cognitive-notice__icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}
@media (max-width: 720px) {
    .cognitive-notice { padding: 12px 14px; font-size: 13px; }
    .cognitive-notice__icon { font-size: 18px; }
}

/* ======================== Toggle + tooltip explicatif ======================== */
/* Petit ⓘ à côté d'une case à cocher qui révèle un panneau d'explication
   au survol ou au focus clavier. Utilisé pour la notation strict/partial. */
.toggle-with-tip { position: relative; }
.toggle-tip {
    display: inline-grid;
    place-items: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--violet-50);
    color: var(--violet-700);
    font-size: 11px;
    font-weight: 700;
    cursor: help;
    border: 1px solid var(--violet-100);
    user-select: none;
    transition: background .15s, color .15s;
}
.toggle-tip:hover, .toggle-tip:focus {
    background: var(--violet-500);
    color: white;
    outline: none;
}
.toggle-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 360px;
    max-width: 90vw;
    background: var(--ink);
    color: white;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    text-transform: none;
    white-space: pre-line;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s, visibility .15s;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    pointer-events: none;
}
.toggle-tip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--ink);
    opacity: 0;
    transition: opacity .15s;
    z-index: 100;
}
.toggle-tip:hover::after, .toggle-tip:focus::after,
.toggle-tip:hover::before, .toggle-tip:focus::before {
    opacity: 1;
    visibility: visible;
}
@media (max-width: 720px) {
    .toggle-tip::after {
        width: 280px;
        left: auto;
        right: -10px;
        transform: none;
    }
    .toggle-tip::before { display: none; }
}

/* ======================== Modale de correction d'une question ouverte ======================== */
.correct-modal {
    border: none;
    border-radius: 16px;
    padding: 0;
    max-width: 720px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    background: var(--bg-elev);
    overflow: hidden;
}
.correct-modal::backdrop { background: rgba(20,14,50,.45); }

.correct-modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--line);
}
.correct-modal__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    margin: 0;
    color: var(--ink);
}
.correct-modal__close {
    background: transparent; border: none; font-size: 18px;
    cursor: pointer; color: var(--ink-muted); padding: 4px 10px;
    border-radius: 8px; transition: all .12s;
}
.correct-modal__close:hover { background: var(--line-soft); color: var(--ink); }

.correct-modal__body {
    padding: 18px 24px;
    max-height: 65vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 18px;
}
.correct-modal__statement {
    font-weight: 600; font-size: 15px; line-height: 1.45;
    color: var(--ink);
    padding: 12px 16px;
    background: var(--violet-50);
    border-radius: 10px;
    border-left: 3px solid var(--violet-500);
}
.correct-modal__llm-notice {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(244,63,94,0.06));
    border: 1px solid rgba(124,58,237,0.25);
    border-left: 4px solid #7C3AED;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #4C1D95;
}
.correct-modal__group { display: flex; flex-direction: column; gap: 8px; }
.correct-modal__label {
    font-size: 12px; font-weight: 700; color: var(--ink-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.correct-modal__answer {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink);
    white-space: pre-wrap;
    max-height: 280px;
    overflow-y: auto;
}
.correct-modal__expected {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0;
}
.correct-modal__expected summary {
    cursor: pointer;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--violet-700);
    list-style: none;
}
.correct-modal__expected summary::-webkit-details-marker { display: none; }
.correct-modal__expected[open] summary { border-bottom: 1px solid var(--line); }
.correct-modal__expected-body {
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-soft);
    white-space: pre-wrap;
}

.correct-modal__score-row {
    display: flex; align-items: center; gap: 14px;
}
.correct-modal__score-row input[type="range"] {
    flex: 1; min-width: 0;
    accent-color: var(--violet-500);
    cursor: pointer;
}
.correct-modal__score-row input[type="number"] {
    width: 90px;
    padding: 8px 12px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    color: var(--violet-700);
    background: var(--violet-50);
}
.correct-modal__score-row input[type="number"]:focus {
    outline: none;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--violet-100);
}
.correct-modal__score-unit {
    font-size: 13px; font-weight: 600; color: var(--ink-muted);
    white-space: nowrap;
}
.correct-modal__score-marks {
    position: relative; height: 14px;
    margin: 0 8px;
}
.correct-modal__score-marks span {
    position: absolute;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.correct-modal textarea {
    width: 100%;
    min-height: 90px;
    padding: 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg-elev);
    resize: vertical;
}
.correct-modal textarea:focus {
    outline: none;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--violet-100);
}

.correct-modal__actions {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: var(--bg);
}

@media (max-width: 720px) {
    .correct-modal { max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
    .correct-modal__body { max-height: calc(100vh - 180px); }
}

/* ======================== Anneau de note (prof attempt.php) ======================== */
/* Jauge émeraude qui se remplit selon le pourcentage. Variante côté prof
   (toujours verte) — le côté élève (quiz-done.php) a sa propre version qui
   change de couleur selon le palier (parfait/bravo/satisfaisant/...). */
.score-ring-wrap {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto;
}
.score-ring {
    width: 160px;
    height: 160px;
    transform: rotate(-90deg);
    display: block;
}
.score-ring__track {
    fill: none;
    stroke: var(--line-soft);
    stroke-width: 14;
}
.score-ring__fill {
    fill: none;
    stroke: url(#score-ring-grad);
    stroke-width: 14;
    stroke-linecap: round;
    /* circonférence d'un cercle de rayon 96 */
    stroke-dasharray: 603.19;
    animation: scoreRingIn 1.2s cubic-bezier(.2,.8,.2,1) .15s both;
}
@keyframes scoreRingIn { from { stroke-dashoffset: 603.19; } }
.score-ring__content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.score-ring__num {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 36px;
    line-height: 1;
    background: linear-gradient(135deg, #34D399, #10B981);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -.02em;
}
.score-ring__unit {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    color: var(--ink-muted);
    margin-top: 2px;
}
.score-ring__pct {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 4px;
}
.score-ring-wrap--empty {
    background: var(--line-soft);
    color: var(--ink-muted);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 600;
}

/* ======================== Vote widget (qv = question vote) ======================== */
.qv {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    user-select: none;
    line-height: 1;
}
.qv__btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 11px;
    color: var(--ink-muted);
    cursor: pointer;
    line-height: 1;
    transition: all .12s ease;
}
.qv__btn:hover { background: var(--violet-50); color: var(--violet-700); }
.qv__btn:disabled { cursor: wait; opacity: 0.5; }
.qv__btn--active-up { background: var(--emerald-50); color: var(--emerald-500); border-color: var(--emerald-500); }
.qv__btn--active-up:hover { background: var(--emerald-50); }
.qv__btn--active-down { background: var(--rose-50, #FEE2E2); color: var(--coral-500); border-color: var(--coral-500); }
.qv__btn--active-down:hover { background: var(--rose-50, #FEE2E2); }
.qv__score {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--ink-muted);
    min-width: 16px; text-align: center;
}
.qv__score--pos { color: var(--emerald-500); }
.qv__score--neg { color: var(--coral-500); }
.qv--readonly { opacity: 0.7; cursor: default; }

/* ======================== Coloration syntaxique (highlight.js) ======================== */
/* On laisse les couleurs des tokens du thème github-dark (mots-clés, chaînes…), mais on
   neutralise le fond + padding qu'il applique à .hljs : sinon on double le fond/padding
   du <pre> qui est déjà stylé par notre design system. */
.hljs {
    background: transparent !important;
    padding: 0 !important;
    color: inherit;
}
/* Quand on a une langue détectée (fenced ```python), le thème colore les comments/keywords ; rien à faire de plus. */

/* ======================== Cards / Empty ======================== */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.card {
    display: block;
    padding: 22px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    transition: all .2s var(--ease-out);
    position: relative;
    overflow: hidden;
}
.card:hover {
    border-color: var(--violet-200);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.card__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card__meta {
    font-size: 13px;
    color: var(--ink-muted);
}

/* ===== Card colorée (classes avec couleur choisie par le prof) ===== */
/* Une fine barre de la couleur en haut de la card + un dot à côté du titre.
   Au hover, la bordure prend la couleur. Si pas de couleur (.card sans
   .card--colored), comportement standard. */
.card--colored {
    --card-color: var(--violet-500); /* fallback, override en inline style */
}
.card--colored:hover {
    border-color: var(--card-color);
    box-shadow: 0 6px 20px -10px var(--card-color);
}
.card__color-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--card-color);
}
.card__color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px rgba(0,0,0,0.04);
}
.card__color-dot--small {
    width: 8px;
    height: 8px;
    box-shadow: none;
}
.card__legend {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: 12px;
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    font-style: italic;
}

/* ===== Color picker (formulaire de création de classe) ===== */
.class-color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.class-color-picker__chip,
.class-color-picker__none {
    cursor: pointer;
    user-select: none;
}
.class-color-picker__chip input,
.class-color-picker__none input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.class-color-picker__chip span {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--line);
    transition: transform .12s ease, box-shadow .12s ease;
}
.class-color-picker__chip:hover span {
    transform: scale(1.08);
}
.class-color-picker__chip input:checked + span {
    box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ink);
    transform: scale(1.12);
}
.class-color-picker__none-dot {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--line-soft);
    color: var(--ink-muted);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--line);
    transition: box-shadow .12s ease;
}
.class-color-picker__none input:checked + .class-color-picker__none-dot {
    box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ink);
}

.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--ink-muted);
}
.empty h3 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 6px;
}

/* ======================== Card placeholder "À venir" ====================== */
/* Carte non-cliquable, fond pâle, bordure pointillée, opacité un peu réduite —
   visuellement présent mais clairement passif. Sert à montrer au prof qu'on a
   des choses dans les tuyaux sans encombrer l'UX. */
.card--soon {
    background: transparent;
    border: 2px dashed var(--violet-200);
    color: var(--ink-muted);
    cursor: default;
    box-shadow: none;
}
.card--soon:hover {
    transform: none;
    border-color: var(--violet-500);
    background: var(--violet-50);
    box-shadow: none;
}
.card--soon .card__title {
    color: var(--violet-700);
    font-weight: 700;
}
.card--soon .card__title::before {
    content: "⏳ ";
    margin-right: 4px;
}

/* ======================== Panneau Cognitive Engine ======================
   Affiché sur le tableau de bord. Deux colonnes :
     - main : pensée du jour + tagline rattachant le module à Tesseract
     - aside : status badge style monitoring (TESSERACT / ACTIF / L2 Rapide)
   Sur mobile, le badge passe en dessous (display: block).
   Le ton typo reste sobre : pas de point médian dans le titre, pas de hex,
   pas de bilingue — l'identité Tesseract se signale par le badge à droite. */
.dg-engine {
    position: relative;
    margin: 8px 0 28px;
    padding: 22px 28px;
    background: linear-gradient(135deg, #1E1B4B, #312E81 55%, #4338CA);
    border: 1px solid #312E81;
    border-radius: 14px;
    color: #E0E7FF;
    overflow: hidden;
    box-shadow: 0 4px 16px -8px rgba(49, 46, 129, 0.4);
    display: flex;
    align-items: stretch;
    gap: 24px;
}
.dg-engine::before {
    content: "";
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(167,139,250,0.25), transparent 65%);
    pointer-events: none;
}
.dg-engine__main { flex: 1; min-width: 0; }
.dg-engine__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #C7D2FE;
}
.dg-engine__icon { font-size: 16px; }
.dg-engine__text {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: 18px;
    line-height: 1.5;
    color: #F5F3FF;
    letter-spacing: -0.005em;
}
.dg-engine__tagline {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: #C7D2FE;
}
.dg-engine__tagline strong { color: #FFFFFF; font-weight: 600; }
.dg-engine__stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 14px;
    padding: 5px 12px;
    background: rgba(167, 139, 250, 0.12);
    border: 1px solid rgba(167, 139, 250, 0.28);
    border-radius: 999px;
    font-size: 12px;
    color: #DDD6FE;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: 0.02em;
}
.dg-engine__stat strong { color: #FFFFFF; font-weight: 700; }

/* Status badge à droite — style "carte monitoring" type widget Tesseract */
.dg-engine-badge {
    flex-shrink: 0;
    width: 200px;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(94, 234, 212, 0.18);
    border-radius: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    color: #E0E7FF;
    backdrop-filter: blur(4px);
    z-index: 1;  /* passe au-dessus du halo ::before */
}
.dg-engine-badge__row {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.3;
}
.dg-engine-badge__row--brand {
    color: #5EEAD4;
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 11.5px;
}
.dg-engine-badge__sub {
    margin: 4px 0 8px 16px;
    font-size: 12px;
    color: #C7D2FE;
    font-family: var(--font-body);
    letter-spacing: 0;
}
.dg-engine-badge__row--state {
    color: #6EE7B7;
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 11.5px;
}
.dg-engine-badge__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}
.dg-engine-badge__dot--teal  { background: #5EEAD4; color: #5EEAD4; }
.dg-engine-badge__dot--green { background: #6EE7B7; color: #6EE7B7; }
.dg-engine-badge__sep {
    height: 1px;
    margin: 10px 0;
    background: linear-gradient(90deg, transparent, rgba(199, 210, 254, 0.18), transparent);
}
.dg-engine-badge__tier {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.dg-engine-badge__tier strong { color: #5EEAD4; font-weight: 700; letter-spacing: 0.04em; }
.dg-engine-badge__tier-label {
    color: #C7D2FE;
    opacity: 0.75;
    font-family: var(--font-body);
}
.dg-engine-badge__bars {
    width: 14px;
    height: 12px;
    fill: #5EEAD4;
}

@media (max-width: 720px) {
    .dg-engine {
        flex-direction: column;
        padding: 18px 20px;
        gap: 16px;
    }
    .dg-engine__text { font-size: 16px; }
    .dg-engine-badge { width: 100%; }
}

/* ======================== Flash messages ======================== */

.flashes {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.flash {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid;
}
.flash--success {
    background: var(--emerald-50);
    color: #065F46;
    border-color: #A7F3D0;
}
.flash--error {
    background: var(--rose-50);
    color: #9F1239;
    border-color: #FECDD3;
}
.flash--info {
    background: var(--violet-50);
    color: var(--violet-700);
    border-color: var(--violet-100);
}

/* ======================== Auth pages ======================== */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
}
.auth-card__brand {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}
.auth-card h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 26px;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.auth-card__lead {
    text-align: center;
    color: var(--ink-soft);
    font-size: 14.5px;
    margin-bottom: 24px;
}
.auth-card .btn--primary {
    width: 100%;
    justify-content: center;
}
.auth-card__alt {
    text-align: center;
    margin-top: 18px;
    font-size: 13.5px;
    color: var(--ink-muted);
}
.auth-card__alt a { color: var(--violet-700); font-weight: 500; }

/* ======================== Responsive ======================== */

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 10px 12px;
        position: sticky; /* reste visible au scroll */
        top: 0; z-index: 50;
        gap: 12px;
    }
    .sidebar__brand { padding: 0; border: none; margin: 0; flex-shrink: 0; }
    .sidebar__nav {
        flex-direction: row;
        gap: 2px;
        overflow-x: auto;
        flex: 1;
        scrollbar-width: thin; /* discret sur Firefox */
    }
    .sidebar__nav::-webkit-scrollbar { height: 4px; }
    .sidebar__group { display: none; }
    /* Cibles tactiles plus larges, pas de label texte */
    .sidebar__link {
        padding: 10px 12px;
        flex-shrink: 0;
    }
    .sidebar__link > svg + * { display: none; }
    .sidebar__link svg { width: 22px; height: 22px; }
    .sidebar__footer {
        border: none;
        padding: 0;
        flex-shrink: 0;
    }
    .user__info { display: none; }
    .app__main { padding: 20px 16px; }
}

/* ======================== Mobile (≤ 720px) ======================== */
/* Surcouche dédiée petits écrans : tables scrollables, grilles à 1 col,
   page-head empilé, filtres pleine largeur. */
@media (max-width: 720px) {
    /* Page header : nom + actions empilés */
    .page-head {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    .page-head__title { font-size: 24px; }

    /* Tables : scroll horizontal pour conserver la lecture des données.
       white-space: nowrap empêche les cellules de wrapper, sinon le scroll
       n'a pas de raison d'apparaître. */
    .table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
        font-size: 13px;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .table th, .table td { padding: 10px 12px; }

    /* Filtres : empilés, pleine largeur */
    .filters-row { flex-direction: column; gap: 8px; }
    .filter-field { width: 100%; }
    .filter-select { min-width: 0; width: 100%; }

    /* Grilles inline qui ne se reflowent pas spontanément */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr !important;
    }
    /* Sauf l'histogramme des notes qui doit rester en 11 col mais réduit */
    [style*="grid-template-columns: repeat(11"] {
        grid-template-columns: repeat(11, 1fr) !important;
        font-size: 9px;
    }

    /* Cards : 1 par ligne */
    .cards { grid-template-columns: 1fr !important; gap: 12px; }
    .card__title { font-size: 18px; }

    /* Sections un peu moins de padding pour gagner de la place */
    .page-section { padding: 18px 16px; }

    /* Tag picker : moins de padding sur les chips pour packing */
    .tag-chip-pick { padding: 4px 10px; font-size: 12px; }

    /* Boutons full-width plus accessibles au pouce */
    .btn--lg { padding: 14px 20px; font-size: 15px; }

    /* Form rows à grille */
    .form-row input, .form-row select, .form-row textarea { font-size: 16px; }
    /* 16px sur les inputs évite le zoom auto iOS */
}

/* ======================== Très petits écrans (≤ 380px) ======================== */
@media (max-width: 380px) {
    .app__main { padding: 16px 12px; }
    .page-section { padding: 14px 12px; }
    .page-head__title { font-size: 22px; }
    .sidebar__brand .brand__text { display: none; }
}

/* ======================== Tutos ======================== */

.back-link {
    display: inline-block;
    color: var(--ink-muted);
    font-size: 14px;
    margin-bottom: 16px;
    transition: color .15s var(--ease-out);
}
.back-link:hover { color: var(--violet-700); }

.tuto-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.tuto-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    transition: all .2s var(--ease-out);
}
.tuto-card:hover {
    border-color: var(--violet-200);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.tuto-card__icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--violet-50), var(--rose-50));
    display: grid;
    place-items: center;
    font-size: 26px;
    flex-shrink: 0;
}
.tuto-card__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
    margin-bottom: 4px;
}
.tuto-card__lead {
    color: var(--ink-soft);
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.45;
}
.tuto-card__meta {
    color: var(--ink-muted);
    font-size: 12.5px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.tuto-hero {
    display: flex;
    align-items: center;
    gap: 28px;
    background: linear-gradient(135deg, var(--violet-50), var(--rose-50));
    border-radius: var(--r-lg);
    padding: 28px;
    margin-bottom: 28px;
}
.tuto-hero__art {
    flex-shrink: 0;
}
.tuto-hero__art img {
    width: 150px;
    height: auto;
    display: block;
}
.tuto-hero__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.7rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 6px;
    line-height: 1.15;
}
.tuto-hero__lead {
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.5;
}

.tuto-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.tuto-step {
    display: flex;
    gap: 18px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px;
}
.tuto-step__num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ink);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-family: var(--font-display);
    font-size: 15px;
    flex-shrink: 0;
}
.tuto-step__body {
    flex: 1;
    min-width: 0;
}
.tuto-step__caption {
    font-size: 15.5px;
    color: var(--ink);
    font-weight: 500;
    margin-bottom: 12px;
    line-height: 1.45;
}
.tuto-step__shot {
    background: var(--line-soft);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    overflow: hidden;
}
.tuto-step__shot img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0 auto;
}
.tuto-step__shot.is-missing {
    padding: 28px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 13px;
    font-style: italic;
}
.tuto-step__shot.is-missing::before {
    content: "🖼️  Capture à venir";
}
.tuto-step__cta {
    margin-top: 14px;
}

.tuto-end {
    text-align: center;
    padding: 36px 28px;
    margin-top: 28px;
    background: linear-gradient(135deg, var(--emerald-50), var(--violet-50));
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
}
.tuto-end__art {
    width: 130px;
    height: auto;
    margin: 0 auto 14px;
    display: block;
}
.tuto-end__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--ink);
    margin-bottom: 6px;
}
.tuto-end__lead {
    color: var(--ink-soft);
    margin-bottom: 18px;
}
.tuto-end__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 720px) {
    .tuto-hero { flex-direction: column; text-align: center; gap: 16px; }
    .tuto-hero__art img { margin: 0 auto; width: 120px; }
    .tuto-step { flex-direction: column; gap: 12px; }
}
