/* =============================================================================
   Révision DSCG — feuille de style unique (refonte du lot C).

   - Mobile d'abord (320 à 430 px), polices système, aucune dépendance.
   - Thème : automatique (prefers-color-scheme) ou choisi (<html data-theme>,
     écrit par PHP d'après le cookie du thème) ; jetons de couleur sur :root.
   - Une couleur d'accent par UE (classes ue-0 à ue-3, ordre du catalogue),
     palette validée pour le daltonisme ; toujours accompagnée d'un libellé.
   - Les états ne reposent jamais sur la seule couleur (✓ / ✗, textes).
   - Zones tactiles d'au moins 44 px ; aucun effet réservé au survol.
   - Transitions courtes, désactivées si prefers-reduced-motion.
   ============================================================================= */

/* --- Jetons : thème clair ------------------------------------------------------ */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --surface-3: #e3e6ec;
    --text: #15181d;
    --muted: #535b67;
    --border: #dce0e6;
    --primary: #1f5fbf;
    --primary-text: #ffffff;
    --primary-hover: #194f9f;
    --primary-soft: #e6eefb;
    --ok: #17703a;
    --ok-bg: #e6f4ea;
    --ok-border: #8fcca5;
    --ko: #a3222a;
    --ko-bg: #fbe9ea;
    --ko-border: #eba3a8;
    --warn: #8a5a00;
    --warn-bg: #fff4dc;
    --warn-border: #f0cf80;
    --danger-bg: #fdecec;
    --danger-text: #8a1c1c;
    --danger-border: #f2b8b8;
    --focus: #f0a400;
    --radius: 16px;
    --radius-s: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 14px rgba(16, 24, 40, 0.05);
    --shadow-strong: 0 6px 24px rgba(16, 24, 40, 0.12);
    --appbar-bg: rgba(255, 255, 255, 0.86);
    /* Accents des UE (ordre du catalogue) : palette catégorielle validée (daltonisme). */
    --ue-0: #2a78d6;
    --ue-1: #eb6834;
    --ue-2: #1baf7a;
    --ue-3: #eda100;
    /* Graphiques : série principale, son pas clair, grille. */
    --chart-1: #2a78d6;
    --chart-1-soft: #a9c8ef;
    --chart-grid: #e6e8ec;
    /* Couleurs des paires (association), associées à un numéro. */
    --pair-1: #1f5fbf;
    --pair-2: #b8570b;
    --pair-3: #7a3db8;
    --pair-4: #0f7d73;
    --pair-5: #b3245f;
    --pair-6: #5c6b10;
    --bottom-nav-h: 64px;
    color-scheme: light;
}

/* --- Jetons : thème sombre (réglage du système, sauf thème clair choisi) ------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111316;
        --surface: #1b1e23;
        --surface-2: #252930;
        --surface-3: #2f343c;
        --text: #e9ebee;
        --muted: #a7afba;
        --border: #333941;
        --primary: #5b9bff;
        --primary-text: #0d1117;
        --primary-hover: #7eb0ff;
        --primary-soft: #1c2a40;
        --ok: #6fd394;
        --ok-bg: #15301f;
        --ok-border: #2f6b44;
        --ko: #ff9aa0;
        --ko-bg: #3a1a1c;
        --ko-border: #7a3238;
        --warn: #ffd27a;
        --warn-bg: #352a10;
        --warn-border: #6e5420;
        --danger-bg: #3a1a1a;
        --danger-text: #ffc4c4;
        --danger-border: #6b2a2a;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-strong: 0 6px 24px rgba(0, 0, 0, 0.5);
        --appbar-bg: rgba(27, 30, 35, 0.86);
        --ue-0: #3987e5;
        --ue-1: #d95926;
        --ue-2: #199e70;
        --ue-3: #c98500;
        --chart-1: #3987e5;
        --chart-1-soft: #2c4a70;
        --chart-grid: #2c3138;
        --pair-1: #6aa7ff;
        --pair-2: #ffa25c;
        --pair-3: #c49bff;
        --pair-4: #4fd1c5;
        --pair-5: #ff7eb3;
        --pair-6: #c6d65a;
        color-scheme: dark;
    }
}

/* Thème sombre choisi avec le bouton (mêmes valeurs). */
:root[data-theme="dark"] {
    --bg: #111316;
    --surface: #1b1e23;
    --surface-2: #252930;
    --surface-3: #2f343c;
    --text: #e9ebee;
    --muted: #a7afba;
    --border: #333941;
    --primary: #5b9bff;
    --primary-text: #0d1117;
    --primary-hover: #7eb0ff;
    --primary-soft: #1c2a40;
    --ok: #6fd394;
    --ok-bg: #15301f;
    --ok-border: #2f6b44;
    --ko: #ff9aa0;
    --ko-bg: #3a1a1c;
    --ko-border: #7a3238;
    --warn: #ffd27a;
    --warn-bg: #352a10;
    --warn-border: #6e5420;
    --danger-bg: #3a1a1a;
    --danger-text: #ffc4c4;
    --danger-border: #6b2a2a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 6px 24px rgba(0, 0, 0, 0.5);
    --appbar-bg: rgba(27, 30, 35, 0.86);
    --ue-0: #3987e5;
    --ue-1: #d95926;
    --ue-2: #199e70;
    --ue-3: #c98500;
    --chart-1: #3987e5;
    --chart-1-soft: #2c4a70;
    --chart-grid: #2c3138;
    --pair-1: #6aa7ff;
    --pair-2: #ffa25c;
    --pair-3: #c49bff;
    --pair-4: #4fd1c5;
    --pair-5: #ff7eb3;
    --pair-6: #c6d65a;
    color-scheme: dark;
}

/* Accent courant : celui de l'UE (classe ue-N), sinon la couleur principale. */
.ue-0 { --accent: var(--ue-0); }
.ue-1 { --accent: var(--ue-1); }
.ue-2 { --accent: var(--ue-2); }
.ue-3 { --accent: var(--ue-3); }

/* --- Base ------------------------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Pas de délai ni de zoom au double appui. */
    touch-action: manipulation;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.0625rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.25;
}

h1 {
    font-size: 1.375rem;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.125rem;
}

h3 {
    font-size: 1rem;
}

p {
    margin: 0 0 0.75rem;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--primary);
    text-underline-offset: 2px;
}

img,
svg {
    max-width: 100%;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.icon {
    flex: none;
    width: 22px;
    height: 22px;
}

.muted {
    color: var(--muted);
}

.break {
    overflow-wrap: anywhere;
}

.small {
    font-size: 0.875rem;
}

.center {
    text-align: center;
}

/* Texte saisi dans les banques : les retours à la ligne sont conservés. */
.text {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Masqué visuellement mais lu par les lecteurs d'écran. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

/* Focus toujours visible au clavier. */
:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

#main:focus,
[tabindex="-1"]:focus {
    outline: none;
}

/* Lien d'évitement : visible seulement au clavier. */
.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-strong);
}

.skip-link:focus {
    top: calc(8px + env(safe-area-inset-top));
}

/* --- Mise en page ---------------------------------------------------------- */
.page {
    flex: 1 0 auto;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.stack > * + * {
    margin-top: 14px;
}

.section {
    margin-top: 22px;
}

.section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 10px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.row-between {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

/* --- Barre d'application ---------------------------------------------------- */
.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--appbar-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.appbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
}

.appbar-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    white-space: nowrap;
    font-weight: 750;
    font-size: 1.0625rem;
    color: var(--text);
    text-decoration: none;
    margin-right: auto;
}

.brand-mark {
    display: inline-flex;
    color: var(--primary);
}

.brand-mark .icon {
    width: 26px;
    height: 26px;
}

.appbar-logout {
    margin: 0;
}

/* Navigation principale en haut : ordinateur et tablette seulement. */
.appbar-nav {
    display: none;
    align-items: center;
    gap: 2px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 6px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
}

.nav-link .icon {
    width: 20px;
    height: 20px;
}

.nav-link[aria-current="page"] {
    color: var(--primary);
    background: var(--primary-soft);
}

.appbar-tools {
    display: flex;
    align-items: center;
    gap: 2px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.icon-btn[aria-current="page"] {
    color: var(--primary);
    background: var(--primary-soft);
}

/* Libellés des boutons d'icône : masqués visuellement sur téléphone (lus par les lecteurs d'écran). */
.icon-btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.sync-status {
    white-space: nowrap;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--warn);
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (min-width: 768px) {
    .appbar-nav {
        display: flex;
    }
}

@media (min-width: 1024px) {
    .icon-btn-label {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
    }
}

/* Petits écrans : le titre se réduit au logo s'il manque de place. */
@media (max-width: 359px) {
    .appbar-title span:last-child {
        font-size: 0.9375rem;
    }
}

/* --- Navigation basse (téléphone) ------------------------------------------ */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    background: var(--appbar-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
}

.bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 4px 2px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.bottom-link .icon {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.bottom-link[aria-current="page"] {
    color: var(--primary);
}

.bottom-link[aria-current="page"] .icon {
    background: var(--primary-soft);
    box-shadow: 0 0 0 6px var(--primary-soft);
}

/* Place réservée sous le contenu pour la barre du bas. */
body:has(.bottom-nav) {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }

    body:has(.bottom-nav) {
        padding-bottom: 0;
    }
}

/* Pendant une série : écran dédié, sans navigation ni pied de page. */
body.is-running .bottom-nav,
body.is-running .site-footer {
    display: none;
}

body.is-running {
    padding-bottom: 0;
}

@media (max-width: 767px) {
    body.is-running .appbar {
        display: none;
    }
}

/* --- Pied de page ------------------------------------------------------------ */
.site-footer {
    flex: none;
    padding: 18px 16px 22px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--muted);
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: var(--muted);
}

/* --- Page de connexion ------------------------------------------------------ */
.login-card {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    padding: 28px 22px;
}

.login-head {
    text-align: center;
    margin-bottom: 18px;
}

.login-logo {
    display: inline-flex;
    padding: 12px;
    border-radius: 18px;
    background: var(--primary);
    color: #fff;
    margin-bottom: 10px;
}

.login-logo .icon {
    width: 34px;
    height: 34px;
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

/* --- Messages --------------------------------------------------------------- */
.alert,
.success,
.notice {
    border-radius: var(--radius-s);
    padding: 10px 14px;
    font-size: 0.9375rem;
}

.alert {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
    margin-bottom: 16px;
}

.success {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid var(--ok-border);
    margin-bottom: 16px;
}

.notice {
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid var(--warn-border);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 24px 8px;
}

/* --- Champs ---------------------------------------------------------------- */
.field-label {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 6px;
}

.field {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    /* 16 px minimum : évite le zoom automatique sur iPhone. */
    font-size: max(1rem, 16px);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.field:focus-visible {
    border-color: var(--primary);
    background: var(--surface);
}

.field.is-correct {
    border-color: var(--ok);
    background: var(--ok-bg);
}

.field.is-wrong {
    border-color: var(--ko);
    background: var(--ko-bg);
}

.field-inline {
    margin-bottom: 0;
}

.answer-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.answer-line .field {
    flex: 1;
    margin-bottom: 0;
}

.unit {
    font-weight: 600;
    color: var(--muted);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
}

.checkbox input {
    flex: none;
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
}

/* --- Boutons --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-s);
    font: inherit;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active:not(:disabled) {
    transform: scale(0.985);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
    margin-top: 4px;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    min-height: 44px;
    padding: 8px 14px;
    font-size: 0.9375rem;
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.btn-danger {
    background: transparent;
    color: var(--ko);
    border-color: var(--ko-border);
}

.btn-small {
    min-height: 40px;
    padding: 4px 12px;
    font-size: 0.875rem;
}

.btn-large {
    min-height: 56px;
    font-size: 1.0625rem;
}

/* Survol : seulement avec une souris (aucun effet collant sur écran tactile). */
@media (hover: hover) {
    .btn-primary:hover:not(:disabled) {
        background: var(--primary-hover);
    }

    .btn-secondary:hover:not(:disabled),
    .chip:hover:not(:disabled),
    .method:hover:not([aria-pressed="true"]),
    .option:hover:not(:disabled):not([aria-pressed="true"]) {
        border-color: var(--muted);
    }

    .btn-ghost:hover:not(:disabled),
    .icon-btn:hover,
    .nav-link:hover {
        color: var(--text);
        background: var(--surface-2);
    }
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* --- Onglets ---------------------------------------------------------------- */
.tabs {
    display: grid;
    /* Autant de colonnes égales que d'onglets. */
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
    background: var(--surface-3);
    border-radius: 14px;
    margin-bottom: 16px;
}

.tab {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* Onglets de l'administration (cinq) : passent sur deux lignes sur un petit écran. */
.tabs-wrap {
    display: flex;
    flex-wrap: wrap;
}

.tabs-wrap .tab {
    flex: 1 1 auto;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
}

/* Onglets en liens (administration). */
a.tab {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
}

/* Trois onglets sur 320 px : texte un peu plus petit pour que « Sauvegardes » tienne. */
@media (max-width: 380px) {
    a.tab {
        font-size: 0.8125rem;
        padding: 4px 2px;
    }
}

.tab[aria-selected="true"],
.tab[aria-current="page"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* Bascule à deux ou trois choix (14 / 30 jours). */
.seg {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 2px;
    padding: 3px;
    background: var(--surface-3);
    border-radius: 12px;
}

.seg button {
    min-height: 36px;
    min-width: 64px;
    padding: 4px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.seg button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* --- Puces de choix (périmètre, nombre, méthode) ------------------------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9375rem;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
}

.chip[aria-pressed="true"] {
    background: var(--primary-soft);
    border-color: var(--primary);
    font-weight: 600;
}

.chip[aria-pressed="true"]::before {
    content: "✓";
    color: var(--primary);
}

.chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Puce d'UE : pastille de l'accent de l'UE devant le libellé. */
.chip .dot,
.dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent, var(--primary));
}

.chip-count {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.8125rem;
}

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 650;
    background: var(--surface-2);
    color: var(--muted);
    vertical-align: middle;
}

.badge-warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-ko {
    background: var(--ko-bg);
    color: var(--ko);
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

/* Badge d'UE : pastille colorée + code en texte (jamais la couleur seule). */
.badge-ue {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    color: var(--text);
}

.badge-ue::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent, var(--primary));
}

/* Méthodes : liste de grandes cases avec description. */
.methods {
    display: grid;
    gap: 8px;
}

@media (min-width: 560px) {
    .methods {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.method {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    min-height: 60px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}

.method[aria-pressed="true"] {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.method-title {
    font-weight: 700;
}

.method[aria-pressed="true"] .method-title::before {
    content: "✓ ";
    color: var(--primary);
}

.method-desc {
    font-size: 0.875rem;
    color: var(--muted);
}

.custom-count {
    width: 110px;
    margin-bottom: 0;
}

.availability {
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--muted);
}

.quick {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}

/* --- Accueil (tableau de bord visuel) ------------------------------------------ */
.hello {
    margin-bottom: 14px;
}

.hello h1 {
    font-size: 1.5rem;
}

.hero {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.kpi {
    padding: 14px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.kpi-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.1;
}

.kpi-label {
    display: block;
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.3;
}

.kpi-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}

.kpi-primary .kpi-label {
    color: inherit;
    opacity: 0.88;
}

@media (max-width: 359px) {
    .kpi-value {
        font-size: 1.4rem;
    }
}

.cta-list {
    display: grid;
    gap: 10px;
}

.cta {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 64px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}

.cta-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}

.cta-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
}

.cta-primary .cta-icon {
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
}

.cta-body {
    flex: 1;
    min-width: 0;
}

.cta-title {
    display: block;
    font-weight: 700;
}

.cta-desc {
    display: block;
    font-size: 0.875rem;
    opacity: 0.85;
    overflow-wrap: anywhere;
}

.cta-arrow {
    flex: none;
    font-size: 1.25rem;
    opacity: 0.7;
}

/* Cartes d'UE avec anneau de progression. */
.ue-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 680px) {
    .ue-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.ue-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px 12px;
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent, var(--primary));
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    font: inherit;
    text-align: center;
    cursor: pointer;
    touch-action: manipulation;
}

.ring {
    width: 88px;
    height: 88px;
}

.ring-track {
    stroke: var(--surface-3);
}

.ring-value {
    stroke: var(--accent, var(--primary));
    transition: stroke-dashoffset 0.6s ease;
}

.ring-text {
    fill: var(--text);
    font-size: 19px;
    font-weight: 800;
}

.ring-sub {
    fill: var(--muted);
    font-size: 10px;
}

.ue-tile-code {
    font-weight: 800;
}

.ue-tile-title {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.ue-tile-stats {
    font-size: 0.8125rem;
    color: var(--muted);
}

/* --- Écran de question ------------------------------------------------------ */
.runner-head {
    position: sticky;
    top: 0;
    z-index: 15;
    margin: -16px calc(-1 * max(16px, env(safe-area-inset-right))) 0 calc(-1 * max(16px, env(safe-area-inset-left)));
    padding: calc(6px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
    background: var(--appbar-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
    .runner-head {
        top: calc(57px + env(safe-area-inset-top));
        border-radius: 0 0 var(--radius) var(--radius);
    }
}

.runner-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.runner-count {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.runner-method {
    color: var(--muted);
    font-size: 0.875rem;
    margin-right: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--muted);
}

.progress {
    height: 6px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.question-card {
    margin-top: 14px;
    border-top: 4px solid var(--accent, var(--primary));
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 10px;
}

/* Pas de césure automatique : elle couperait le mot étudié (vocabulaire espagnol). */
.question-text {
    font-size: 1.125rem;
    font-weight: 650;
    line-height: 1.45;
    margin-bottom: 6px;
}

.question-text:focus {
    outline: none;
}

/* Mention bien visible : plusieurs réponses attendues. */
.question-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 700;
    margin: 4px 0;
}

.answers {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

/* Proposition de QCM / vrai-faux : carte pleine largeur, toute cliquable. */
.option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1.0625rem;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.option[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.option:disabled {
    cursor: default;
    color: var(--text);
}

.option-key {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.9375rem;
    font-weight: 800;
}

.option[aria-pressed="true"] .option-key {
    background: var(--primary);
    color: var(--primary-text);
}

.option-text {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.option-mark {
    flex: none;
    font-weight: 800;
    font-size: 1.125rem;
    line-height: 1.4;
}

.option.is-correct {
    border-color: var(--ok);
    background: var(--ok-bg);
}

.option.is-correct .option-key {
    background: var(--ok);
    color: var(--surface);
}

.option.is-correct .option-mark {
    color: var(--ok);
}

.option.is-wrong {
    border-color: var(--ko);
    background: var(--ko-bg);
}

.option.is-wrong .option-key {
    background: var(--ko);
    color: var(--surface);
}

.option.is-wrong .option-mark {
    color: var(--ko);
}

.option.is-missed {
    border-color: var(--ok);
    border-style: dashed;
}

.option.is-missed .option-mark {
    color: var(--ok);
}

.option.is-dimmed {
    opacity: 0.55;
}

/* Vrai / faux : deux grands boutons côte à côte. */
.answers-tf {
    grid-template-columns: 1fr 1fr;
}

.answers-tf .option {
    justify-content: center;
    align-items: center;
    min-height: 64px;
    font-weight: 700;
}

/* Clavier d'accents (espagnol) : dans la barre d'action, au-dessus du clavier du téléphone. */
.accent-keys {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.accent-key {
    flex: 1 0 40px;
    min-width: 40px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1.125rem;
    cursor: pointer;
    touch-action: manipulation;
}

.answer-expected {
    margin-top: 10px;
    font-size: 0.9375rem;
}

/* --- Association ------------------------------------------------------------ */
.assoc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.assoc-col {
    display: grid;
    gap: 8px;
    align-content: start;
}

.assoc-head {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.assoc-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
    min-height: 52px;
    padding: 8px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9375rem;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}

@media (max-width: 380px) {
    .assoc-item {
        font-size: 0.875rem;
        padding: 6px;
    }
}

.assoc-item[aria-pressed="true"] {
    border-color: var(--focus);
    border-style: dashed;
    background: var(--warn-bg);
}

.assoc-item:disabled {
    cursor: default;
}

.assoc-tag {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 700;
}

.assoc-text {
    flex: 1;
    min-width: 0;
    white-space: pre-line;
    overflow-wrap: anywhere;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.assoc-item.pair-1 { border-color: var(--pair-1); }
.assoc-item.pair-2 { border-color: var(--pair-2); }
.assoc-item.pair-3 { border-color: var(--pair-3); }
.assoc-item.pair-4 { border-color: var(--pair-4); }
.assoc-item.pair-5 { border-color: var(--pair-5); }
.assoc-item.pair-6 { border-color: var(--pair-6); }
.assoc-item.pair-1 .assoc-tag { background: var(--pair-1); color: var(--surface); }
.assoc-item.pair-2 .assoc-tag { background: var(--pair-2); color: var(--surface); }
.assoc-item.pair-3 .assoc-tag { background: var(--pair-3); color: var(--surface); }
.assoc-item.pair-4 .assoc-tag { background: var(--pair-4); color: var(--surface); }
.assoc-item.pair-5 .assoc-tag { background: var(--pair-5); color: var(--surface); }
.assoc-item.pair-6 .assoc-tag { background: var(--pair-6); color: var(--surface); }

.assoc-result {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.assoc-line {
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow-wrap: anywhere;
}

.assoc-line.is-correct {
    border-color: var(--ok);
    background: var(--ok-bg);
}

.assoc-line.is-wrong {
    border-color: var(--ko);
    background: var(--ko-bg);
}

.assoc-line-term {
    font-weight: 700;
}

.assoc-line-fix {
    font-size: 0.875rem;
    margin-top: 4px;
}

/* --- Cartes (flashcards) ---------------------------------------------------- */
.flashcard {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    margin-top: 14px;
    scroll-margin-bottom: calc(150px + env(safe-area-inset-bottom));
}

.flashcard.is-flipped {
    border-style: solid;
    border-color: var(--primary);
    background: var(--surface);
    animation: flip-in 0.25s ease;
}

.flashcard-side {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.flashcard-main {
    font-size: 1.125rem;
    font-weight: 650;
}

.flashcard-list {
    margin: 0;
    padding-left: 1.2em;
}

.flashcard-list li + li {
    margin-top: 4px;
}

.self-eval {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.self-eval .btn {
    flex-direction: column;
    gap: 2px;
    min-height: 56px;
    padding: 8px 6px;
    font-size: 0.875rem;
    line-height: 1.2;
}

.eval-ko {
    background: var(--ko-bg);
    color: var(--ko);
    border-color: var(--ko-border);
}

.eval-mid {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: var(--warn-border);
}

.eval-ok {
    background: var(--ok-bg);
    color: var(--ok);
    border-color: var(--ok-border);
}

.key-hint {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
}

/* --- Correction ------------------------------------------------------------- */
.feedback {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    animation: rise-in 0.22s ease;
    /* Défilement automatique : la correction n'est pas masquée par la barre d'action. */
    scroll-margin-bottom: calc(120px + env(safe-area-inset-bottom));
}

.feedback.is-ok {
    border-color: var(--ok-border);
    background: var(--ok-bg);
}

.feedback.is-ko {
    border-color: var(--ko-border);
    background: var(--ko-bg);
}

.feedback-verdict {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.0625rem;
    margin-bottom: 8px;
}

.verdict-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--surface);
    font-size: 1rem;
}

.feedback.is-ok .feedback-verdict {
    color: var(--ok);
}

.feedback.is-ok .verdict-icon {
    background: var(--ok);
    animation: pop 0.3s ease;
}

.feedback.is-ko .feedback-verdict {
    color: var(--ko);
}

.feedback.is-ko .verdict-icon {
    background: var(--ko);
    animation: nudge 0.3s ease;
}

.feedback-block + .feedback-block {
    margin-top: 8px;
}

.label {
    font-weight: 700;
}

.source {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--muted);
}

/*
 * Barre d'action de la série (Valider / Suivant, accents, auto-évaluation) :
 * fixée en bas, dans la zone du pouce, au-dessus de la barre d'accueil de
 * l'iPhone ; remontée au-dessus du clavier du téléphone par script.js
 * (variable --kb, d'après visualViewport).
 */
.action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--kb, 0px);
    z-index: 25;
    padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--appbar-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
}

.action-bar:empty {
    display: none;
}

.action-bar-inner {
    max-width: 728px;
    margin: 0 auto;
}

/* Clavier ouvert : la marge de la barre d'accueil n'est plus nécessaire. */
.action-bar.has-keyboard {
    padding-bottom: 10px;
}

/* Place réservée sous le contenu de la série pour la barre d'action. */
body.is-running .page {
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
}

/* --- Résultats -------------------------------------------------------------- */
.score {
    text-align: center;
    padding: 22px 16px;
}

.score-ring {
    width: 128px;
    height: 128px;
    margin: 8px auto 4px;
    display: block;
}

.score-value {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.1;
}

.score-detail {
    color: var(--muted);
}

.review-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.review-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left-width: 5px;
    border-radius: var(--radius-s);
    background: var(--surface);
}

.review-item.is-ok {
    border-left-color: var(--ok);
}

.review-item.is-ko {
    border-left-color: var(--ko);
}

.review-item.is-mid {
    border-left-color: var(--warn);
}

.review-q {
    font-weight: 650;
    margin-bottom: 6px;
}

.review-line {
    font-size: 0.9375rem;
}

.review-item details {
    margin-top: 6px;
    font-size: 0.9375rem;
}

summary {
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
}

details > summary {
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::after {
    content: "▸";
    margin-left: auto;
    padding-left: 8px;
    color: var(--muted);
}

details[open] > summary::after {
    content: "▾";
}

/* --- Page Progression ------------------------------------------------------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

@media (min-width: 560px) {
    .tiles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tile {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--surface);
}

.tile-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.tile-label {
    font-size: 0.8125rem;
    color: var(--muted);
}

.chart-card {
    margin: 0;
    padding: 16px;
}

.chart-card.section {
    margin-top: 12px;
}

.chart-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.chart-title {
    font-size: 1rem;
}

.chart-sub {
    font-size: 0.8125rem;
    color: var(--muted);
    margin: 0 0 8px;
}

.chart {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart text {
    fill: var(--muted);
    font-size: 11px;
    font-family: inherit;
}

.chart .chart-value {
    fill: var(--text);
    font-weight: 700;
}

.chart .grid-line {
    stroke: var(--chart-grid);
    stroke-width: 1;
}

.chart .bar-main {
    fill: var(--chart-1);
}

.chart .bar-soft {
    fill: var(--chart-1-soft);
}

.chart .bar-accent {
    fill: var(--accent, var(--chart-1));
}

.chart .line-main {
    fill: none;
    stroke: var(--chart-1);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart .dot-main {
    fill: var(--chart-1);
    stroke: var(--surface);
    stroke-width: 2;
}

.chart .area-main {
    fill: var(--chart-1);
    opacity: 0.1;
}

.chart .hit {
    fill: transparent;
}

@media (hover: hover) {
    .chart .hit:hover {
        fill: var(--surface-3);
        opacity: 0.5;
    }
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--muted);
}

.chart-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--chart-1);
}

.swatch-soft {
    background: var(--chart-1-soft);
}

.chart-data {
    margin-top: 6px;
    font-size: 0.875rem;
}

.chart-data summary {
    color: var(--muted);
    font-size: 0.8125rem;
    min-height: 40px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table td.num,
.data-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Couverture et réussite par thème : barres horizontales. */
.hbars {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hbar-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
    font-size: 0.875rem;
}

/* Intitulé sur toute la largeur, chiffres sur la ligne suivante (lisible dès 320 px). */
.hbar-name {
    flex: 1 1 100%;
    font-weight: 600;
    min-width: 0;
    overflow-wrap: anywhere;
}

.hbar-num {
    color: var(--muted);
    font-size: 0.8125rem;
}

.hbar-track {
    height: 10px;
    margin-top: 4px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}

.hbar-fill {
    height: 100%;
    width: 0;
    background: var(--accent, var(--chart-1));
    border-radius: 999px;
    transition: width 0.4s ease;
}

.hbar.is-weak .hbar-name::after {
    content: " ⚠ à retravailler";
    color: var(--ko);
    font-weight: 700;
    font-size: 0.8125rem;
}

.ue-card {
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent, var(--primary));
    border-radius: var(--radius-s);
    background: var(--surface);
    overflow: hidden;
}

.ue-card + .ue-card {
    margin-top: 10px;
}

.ue-card > summary {
    display: block;
    padding: 12px 14px;
}

.ue-card > summary::after {
    float: right;
    margin-top: -1.4em;
}

.ue-body {
    padding: 0 14px 14px;
}

.stat-line {
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 4px;
}

.bar {
    height: 6px;
    margin-top: 6px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0;
    background: var(--accent, var(--primary));
}

.theme-row {
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.theme-row.is-weak .theme-title::after {
    content: " · ⚠ à retravailler";
    color: var(--ko);
    font-weight: 600;
    font-size: 0.8125rem;
}

.theme-title {
    font-weight: 600;
}

.theme-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.weak-list {
    display: grid;
    gap: 8px;
}

.weak-item {
    padding: 10px 12px;
    border: 1px solid var(--ko-border);
    border-radius: var(--radius-s);
    background: var(--ko-bg);
}

/* Rappel des raccourcis clavier : inutile sur écran tactile. */
.kbd-hint {
    margin-top: 12px;
    text-align: center;
}

@media (hover: none) {
    .kbd-hint {
        display: none;
    }
}

/* --- Signaler une erreur (lot B) -------------------------------------------- */
/* Discret (bouton fantôme) mais atteignable au pouce : 44 px de haut. */
.report {
    margin-top: 12px;
}

.report-toggle {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--muted);
}

.report-form {
    margin-top: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.report-title {
    font-size: 1rem;
}

.report-form .field {
    margin-bottom: 4px;
}

.report-comment {
    min-height: 110px;
    resize: vertical;
    line-height: 1.4;
}

.report-form .actions {
    margin-top: 4px;
}

.field-help-top {
    margin: 0 0 6px;
}

.report-done {
    color: var(--ok);
    font-weight: 600;
    font-size: 0.9375rem;
    margin: 0;
}

/* --- Administration des questions (lot B) ----------------------------------- */
.filters {
    display: grid;
    gap: 8px;
}

@media (min-width: 560px) {
    .filters {
        grid-template-columns: 1fr 1fr;
    }
}

.filters .field {
    margin-bottom: 0;
}

.filters .filters-wide {
    grid-column: 1 / -1;
}

.q-list {
    display: grid;
    gap: 8px;
}

.q-item {
    display: block;
    padding: 12px 14px;
    color: var(--text);
    text-decoration: none;
}

.q-id {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875rem;
    font-weight: 700;
}

.q-item .q-text {
    margin: 4px 0 6px;
    overflow-wrap: anywhere;
}

.q-item.is-retired {
    border-style: dashed;
    opacity: 0.8;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 16px;
}

.q-options {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.q-options li {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-wrap: anywhere;
}

.q-options li.is-good {
    border-color: var(--ok-border);
    background: var(--ok-bg);
}

.report-card {
    padding: 14px 16px;
}

.report-card.is-open {
    border-color: var(--warn-border);
}

.report-card blockquote,
blockquote.small {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 3px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 10px 10px 0;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.report-card textarea.field {
    min-height: 80px;
}

/* --- Pages Compte, Administration, Mentions légales ---------------------------- */
.page-title {
    margin-bottom: 16px;
}

.form-fields {
    display: flex;
    flex-direction: column;
}

.field-help {
    margin: -10px 0 16px;
}

.fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 16px;
}

.fieldset legend {
    padding: 0;
}

/* Liste « terme : valeur » (identifiant, rôle, dates). */
.facts {
    margin-inline: 0;
    margin-block-end: 0;
    display: grid;
    gap: 6px;
}

.facts > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
}

.facts dt {
    color: var(--muted);
}

.facts dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.facts-compact {
    font-size: 0.875rem;
    margin-top: 10px;
}

/* Zone de danger : réinitialisation complète, suppression. */
.danger-zone {
    border-color: var(--ko-border);
}

.danger-zone h2 {
    color: var(--ko);
}

.step-label {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0;
}

.erase-list {
    margin: 0;
    padding-left: 1.25rem;
}

.erase-list li + li {
    margin-top: 4px;
}

/* Phrase à recopier : bien lisible, jamais coupée de façon ambiguë. */
.phrase {
    font-weight: 700;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    overflow-wrap: anywhere;
    user-select: none;
    -webkit-user-select: none;
}

/* Comptes et sauvegardes (cartes empilées, lisibles sur téléphone). */
.user-list {
    display: grid;
    gap: 10px;
}

.user-card {
    padding: 14px 16px;
}

.user-card.is-inactive {
    opacity: 0.75;
    border-style: dashed;
}

.user-name {
    font-size: 1.0625rem;
    overflow-wrap: anywhere;
}

.user-actions {
    margin-top: 12px;
}

.user-actions form,
.user-card form {
    margin: 0;
}

.user-card .stat-line + form {
    margin-top: 10px;
}

.secret-card {
    border-color: var(--ok-border);
    margin-bottom: 16px;
}

.secret {
    font-size: 1.375rem;
    text-align: center;
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-2);
    letter-spacing: 0.06em;
    overflow-wrap: anywhere;
    user-select: all;
    -webkit-user-select: all;
}

.secret code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Code de validation : QR code toujours noir sur blanc (lisible par l'appareil
   photo, y compris en mode sombre), clé et champ de code bien lisibles. */
.qr-box {
    display: flex;
    justify-content: center;
}

.qr {
    width: min(240px, 100%);
    height: auto;
    border-radius: 10px;
    background: #fff;
}

.otp-key {
    font-size: 1.0625rem;
}

.code-field {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: max(1.375rem, 16px);
    letter-spacing: 0.2em;
    text-align: center;
}

.legal h2 {
    font-size: 1.0625rem;
}

/* --- Écrire à l'administrateur (contact.php, admin.php > Messages) ------------- */
.contact-message {
    min-height: 160px;
    font-size: 1rem;
    line-height: 1.45;
    resize: vertical;
}

.message-text {
    margin: 6px 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

/* --- Assistant IA (lot D) ---------------------------------------------------- */
/* Explication courte sous un titre de section (ex. « Révision espacée »). */
.section-help {
    margin: -4px 0 12px;
    line-height: 1.45;
}

.ai {
    margin-top: 14px;
}

.ai-toggle {
    min-height: 44px;
    gap: 8px;
}

.ai-spark {
    color: var(--primary);
}

.ai-panel {
    padding: 14px 14px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    animation: rise-in 0.2s ease;
    scroll-margin-bottom: calc(120px + env(safe-area-inset-bottom));
}

.ai-head {
    flex-wrap: nowrap;
    margin-bottom: 6px;
}

.ai-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1rem;
}

.ai-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-log:empty {
    display: none;
}

.ai-msg {
    max-width: 92%;
    padding: 10px 12px;
    border-radius: var(--radius-s);
    line-height: 1.5;
    overflow-wrap: anywhere;
    animation: rise-in 0.18s ease;
    scroll-margin-bottom: calc(120px + env(safe-area-inset-bottom));
}

.ai-msg p {
    margin: 0 0 6px;
}

.ai-msg p:last-child {
    margin-bottom: 0;
}

/* Message de l'utilisateur : à droite, teinte de l'accent. */
.ai-user {
    align-self: flex-end;
    background: var(--primary-soft);
    border-bottom-right-radius: 4px;
}

/* Réponse de l'IA : à gauche, surface neutre et filet d'accent (pas la couleur seule : libellé du fournisseur). */
.ai-bot {
    align-self: flex-start;
    background: var(--surface-2);
    border-left: 3px solid var(--primary);
    border-bottom-left-radius: 4px;
}

.ai-list {
    margin: 0 0 6px;
    padding-left: 1.25em;
}

.ai-list li + li {
    margin-top: 3px;
}

.ai-msg-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 10px;
    margin-top: 6px;
}

.ai-report {
    min-height: 44px;
    padding: 6px 4px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.ai-status:not(:empty) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.ai-status p {
    margin: 0;
}

.ai-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.9375rem;
}

.ai-dots {
    display: inline-flex;
    gap: 4px;
}

.ai-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: ai-blink 1.2s infinite ease-in-out;
}

.ai-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-blink {
    0%,
    80%,
    100% {
        opacity: 0.25;
    }

    40% {
        opacity: 1;
    }
}

.ai-error {
    color: var(--ko);
    font-weight: 600;
    font-size: 0.9375rem;
}

.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.ai-chip {
    font-size: 0.875rem;
}

.ai-form {
    margin-top: 10px;
}

/* 16 px au moins : pas de zoom automatique de Safari iOS au focus. */
.ai-input {
    min-height: 64px;
    font-size: 1rem;
    line-height: 1.4;
    resize: vertical;
}

.ai-form-foot {
    flex-wrap: nowrap;
    margin-top: 6px;
}

.ai-counter.is-over {
    color: var(--ko);
    font-weight: 600;
}

.ai-send {
    min-height: 44px;
    min-width: 108px;
}

.ai-quota {
    margin: 8px 0 0;
}

.ai-notice {
    margin: 6px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

/* Saisie dans un formulaire de la série : la barre d'action fixe ne recouvre pas le champ. */
body.is-typing .action-bar {
    display: none;
}

/* --- Animations (courtes ; désactivées si mouvement réduit) -------------------- */
@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pop {
    0% {
        transform: scale(0.6);
    }

    70% {
        transform: scale(1.12);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes nudge {
    0%,
    100% {
        transform: translateX(0);
    }

    30% {
        transform: translateX(-3px);
    }

    60% {
        transform: translateX(3px);
    }
}

@keyframes flip-in {
    from {
        opacity: 0.4;
        transform: rotateX(12deg);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.view-enter {
    animation: rise-in 0.18s ease;
}

/* --- Mouvement réduit ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

/* --- Contraste forcé (Windows) : les états gardent un contour visible. ------- */
@media (forced-colors: active) {
    .option[aria-pressed="true"],
    .chip[aria-pressed="true"],
    .method[aria-pressed="true"] {
        outline: 2px solid Highlight;
    }
}
