/*
 * Contrôle de maths — thème « Freelancer revisité »
 *
 * Reprend l'identité de l'ancien site : turquoise #1abc9c, bleu nuit #2c3e50, Montserrat (titres) + Lato (texte).
 * Bootstrap 5.3 sert de base (les énoncés des exercices convertis utilisent ses classes),
 * personnalisé par les variables ci-dessous. Clair / sombre automatique (data-bs-theme).
 *
 * Le turquoise d'origine (#1abc9c) est trop clair pour du texte blanc : il sert aux aplats (bandeau d'accueil),
 * avec du texte bleu nuit. Boutons et liens utilisent un turquoise foncé (--cdm-primary) qui passe le contraste AA.
 */

:root,
[data-bs-theme="light"] {
    --cdm-brand: #1abc9c;
    --cdm-navy: #2c3e50;
    --cdm-ink: #13212d;
    --cdm-primary: #13806b;
    --cdm-primary-rgb: 19, 128, 107;
    --cdm-primary-hover: #2c3e50;
    --cdm-primary-soft: #dff5ef;
    --cdm-accent: #1abc9c;
    --cdm-ruby: #e0245e;
    --cdm-ruby-soft: #ffe4ea;
    --cdm-emerald: #0f9d58;
    --cdm-emerald-soft: #d6f5e4;
    --cdm-badge: #f39c12;
    --cdm-badge-soft: #fdefd3;
    --cdm-surface: #ffffff;
    --cdm-surface-2: #f4f7f6;
    --cdm-border: #dbe4e2;
    --cdm-text: #1f2d3a;
    --cdm-muted: #55636f;
    --cdm-shadow: 0 2px 0 #dbe4e2;
    --cdm-shadow-lg: 0 10px 24px rgba(31, 45, 58, .12);
    --cdm-radius: 18px;
    --cdm-radius-sm: 12px;
    --cdm-font-title: "Montserrat", "Segoe UI", system-ui, sans-serif;

    --bs-primary: var(--cdm-primary);
    --bs-primary-rgb: var(--cdm-primary-rgb);
    --bs-link-color: var(--cdm-primary);
    --bs-link-color-rgb: var(--cdm-primary-rgb);
    --bs-link-hover-color: #0c5a4b;
    --bs-link-hover-color-rgb: 12, 90, 75;
    --bs-body-bg: var(--cdm-surface-2);
    --bs-body-color: var(--cdm-text);
    --bs-border-color: var(--cdm-border);
    --bs-border-radius: var(--cdm-radius-sm);
    --bs-border-radius-lg: var(--cdm-radius);
    --bs-body-font-family: "Lato", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: 1.0625rem;
}

[data-bs-theme="dark"] {
    --cdm-primary: #45d6b6;
    --cdm-primary-rgb: 69, 214, 182;
    --cdm-primary-hover: #8af0d9;
    --cdm-primary-soft: #0f2f2a;
    --cdm-ruby-soft: #4a0f22;
    --cdm-emerald-soft: #0b3122;
    --cdm-badge-soft: #46300a;
    --cdm-surface: #1b2733;
    --cdm-surface-2: #121b24;
    --cdm-border: #2b3a48;
    --cdm-text: #e6edf2;
    --cdm-muted: #a3b1bd;
    --cdm-shadow: 0 2px 0 #0b1118;
    --cdm-shadow-lg: 0 10px 24px rgba(0, 0, 0, .5);

    --bs-primary: var(--cdm-primary);
    --bs-primary-rgb: var(--cdm-primary-rgb);
    --bs-link-color: var(--cdm-primary);
    --bs-link-color-rgb: var(--cdm-primary-rgb);
    --bs-link-hover-color: #8af0d9;
    --bs-link-hover-color-rgb: 138, 240, 217;
    --bs-body-bg: var(--cdm-surface-2);
    --bs-body-color: var(--cdm-text);
    --bs-border-color: var(--cdm-border);
}

/* Contrastes suffisants (WCAG AA, 4,5:1) pour les textes colorés sur fond pâle */
:root, [data-bs-theme="light"] { --cdm-ruby-text: #b3123f; --cdm-emerald-text: #0b6b3a; --cdm-badge-text: #8a4b00; --cdm-on-primary: #ffffff; }
[data-bs-theme="dark"] { --cdm-ruby-text: #ff9db5; --cdm-emerald-text: #7ee2ad; --cdm-badge-text: #fcd38a; --cdm-on-primary: #0b1a16; }

/* ---------- Accessibilité ---------- */

.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 2000; padding: .6rem 1rem; border-radius: var(--cdm-radius-sm); background: var(--cdm-primary); color: var(--cdm-on-primary); font-weight: 700; }
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid rgba(var(--cdm-primary-rgb), .6); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Base ---------- */

html { scroll-padding-top: 80px; }
body { min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
main { flex: 1; }
h1, h2, h3, h4, .h1, .h2, .h3, .h4 { font-family: var(--cdm-font-title); font-weight: 800; letter-spacing: -.02em; }
h1, .h1 { font-weight: 900; }
.text-muted, .text-secondary { color: var(--cdm-muted) !important; }
a { text-underline-offset: 3px; }
.btn { border-radius: var(--cdm-radius-sm); font-family: var(--cdm-font-title); font-weight: 700; padding-inline: 1.1rem; }
.btn-lg { font-weight: 800; padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-primary { --bs-btn-color: var(--cdm-on-primary); --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-disabled-color: var(--cdm-on-primary); --bs-btn-bg: var(--cdm-primary); --bs-btn-border-color: var(--cdm-primary); --bs-btn-hover-bg: var(--cdm-navy); --bs-btn-hover-border-color: var(--cdm-navy); --bs-btn-active-bg: var(--cdm-ink); --bs-btn-active-border-color: var(--cdm-ink); --bs-btn-disabled-bg: var(--cdm-primary); --bs-btn-disabled-border-color: var(--cdm-primary); }
.btn-soft { background: var(--cdm-primary-soft); color: var(--cdm-primary); border: 0; }
.btn-soft:hover, .btn-soft:focus { background: var(--cdm-primary); color: var(--cdm-on-primary); }
.btn-navy { background: var(--cdm-navy); color: #fff; border: 0; }
.btn-navy:hover, .btn-navy:focus { background: var(--cdm-ink); color: #fff; }
.btn-white { background: #fff; color: var(--cdm-navy); border: 0; }
.btn-white:hover, .btn-white:focus { background: var(--cdm-navy); color: #fff; }
.form-control, .form-select { border-radius: var(--cdm-radius-sm); padding: .65rem .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--cdm-primary); box-shadow: 0 0 0 .2rem rgba(var(--cdm-primary-rgb), .2); }
.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; vertical-align: -.25em; }

.cdm-card { background: var(--cdm-surface); border: 1px solid var(--cdm-border); border-radius: var(--cdm-radius); box-shadow: var(--cdm-shadow); }
.cdm-card-link { display: block; color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.cdm-card-link:hover { transform: translateY(-2px); box-shadow: var(--cdm-shadow-lg); border-color: rgba(var(--cdm-primary-rgb), .4); color: inherit; }
.section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--cdm-muted); }

/* ---------- En-tête ---------- */

/* Bandeau bleu nuit dans les deux thèmes, comme l'ancien site */
.cdm-header { position: sticky; top: 0; z-index: 1030; background: var(--cdm-navy); color: #fff; }
[data-bs-theme="dark"] .cdm-header { background: #0e1720; border-bottom: 1px solid var(--cdm-border); }
.cdm-header .navbar { min-height: 68px; }
.cdm-logo { display: flex; align-items: center; gap: .6rem; font-family: var(--cdm-font-title); font-weight: 800; font-size: 1.2rem; color: #fff; text-decoration: none; letter-spacing: -.01em; }
.cdm-logo:hover { color: #fff; }
.cdm-logo-mark { width: 48px; height: 48px; flex-shrink: 0; }
.cdm-nav-link { color: #fff; text-decoration: none; font-family: var(--cdm-font-title); font-weight: 700; font-size: .95rem; padding: .55rem .8rem; border-radius: 10px; white-space: nowrap; }
.cdm-nav-link:hover, .cdm-nav-link:focus, .cdm-nav-link.show { color: #fff; background: rgba(255, 255, 255, .12); }
.cdm-nav-link.active { color: var(--cdm-ink); background: var(--cdm-brand); }
.cdm-header .btn-primary { --bs-btn-color: var(--cdm-ink); --bs-btn-bg: var(--cdm-brand); --bs-btn-border-color: var(--cdm-brand); --bs-btn-hover-color: var(--cdm-ink); --bs-btn-hover-bg: #fff; --bs-btn-hover-border-color: #fff; }
.cdm-header :focus-visible { outline-color: #fff; }
.cdm-search { position: relative; max-width: 360px; width: 100%; }
.cdm-search input { padding-left: 2.4rem; border-radius: 999px; background: var(--cdm-surface); }
.cdm-search > .icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--cdm-muted); }
.cdm-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1050; max-height: 60vh; overflow: auto; padding: .4rem; }
.cdm-search-results a { display: block; padding: .55rem .75rem; border-radius: var(--cdm-radius-sm); color: inherit; text-decoration: none; }
.cdm-search-results a:hover, .cdm-search-results a.active { background: var(--cdm-primary-soft); }

.cdm-counter { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem; border-radius: 999px; font-weight: 700; font-size: .9rem; text-decoration: none; }
.cdm-counter.ruby { background: var(--cdm-ruby-soft); color: var(--cdm-ruby-text); }
.cdm-counter.emerald { background: var(--cdm-emerald-soft); color: var(--cdm-emerald-text); }
.cdm-counter.badge-c { background: var(--cdm-badge-soft); color: var(--cdm-badge-text); }
.cdm-header .cdm-counter { background: rgba(255, 255, 255, .12); color: #fff; padding: .3rem .75rem .3rem .5rem; }
.cdm-header .cdm-counter:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.cdm-header .cdm-counter .gem { width: 1.45em; height: 1.45em; }
.cdm-header .cdm-avatar { box-shadow: 0 0 0 2px var(--cdm-brand); }

.cdm-avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--cdm-primary-soft); color: var(--cdm-primary); font-weight: 800; flex-shrink: 0; }
.cdm-avatar img, .cdm-avatar svg { width: 100%; height: 100%; object-fit: cover; }
.cdm-avatar-lg { width: 120px; height: 120px; font-size: 2.5rem; }
.cdm-avatar-wrap { position: relative; display: inline-block; }
.cdm-dot { position: absolute; top: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--cdm-ruby); border: 2px solid var(--cdm-surface); }

/* Barre de navigation mobile en bas d'écran */
.cdm-tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; display: flex; background: var(--cdm-surface); border-top: 1px solid var(--cdm-border); padding-bottom: env(safe-area-inset-bottom); }
.cdm-tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .45rem; font-size: .72rem; font-weight: 600; color: var(--cdm-muted); text-decoration: none; }
.cdm-tabbar a.active { color: var(--cdm-primary); }
.cdm-tabbar .icon { width: 1.5rem; height: 1.5rem; }
@media (max-width: 767.98px) { body { padding-bottom: 72px; } }
@media (min-width: 768px) { .cdm-tabbar { display: none; } }

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

/* Bandeau turquoise semé de symboles mathématiques, texte bleu nuit (contraste AA) */
.cdm-hero { position: relative; background-color: var(--cdm-brand); color: var(--cdm-ink); overflow: hidden; }
[data-bs-theme="dark"] .cdm-hero { background-color: #17a589; }
.cdm-hero::before { content: ""; position: absolute; inset: 0; opacity: .2; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cg fill='%23fff' font-family='Arial' font-weight='700'%3E%3Ctext x='10' y='44' font-size='38'%3E%CF%80%3C/text%3E%3Ctext x='82' y='104' font-size='34'%3E%C3%B7%3C/text%3E%3Ctext x='78' y='38' font-size='24'%3Ex%C2%B2%3C/text%3E%3Ctext x='16' y='122' font-size='32'%3E%E2%88%9A%3C/text%3E%3C/g%3E%3C/svg%3E"); }
.cdm-hero > * { position: relative; }
.cdm-hero h1 { font-size: clamp(2.1rem, 3.5vw + 1rem, 3.3rem); line-height: 1.05; text-wrap: balance; }
.cdm-hero .lead { font-size: 1.2rem; }
.cdm-hero .section-title, .cdm-hero .text-muted { color: var(--cdm-ink) !important; }
.cdm-hero .btn-soft { background: #fff; color: var(--cdm-navy); }
.cdm-hero .btn-soft:hover, .cdm-hero .btn-soft:focus { background: var(--cdm-navy); color: #fff; }
.cdm-hero .btn-primary { --bs-btn-color: #fff; --bs-btn-bg: var(--cdm-navy); --bs-btn-border-color: var(--cdm-navy); --bs-btn-hover-bg: var(--cdm-ink); --bs-btn-hover-border-color: var(--cdm-ink); }
.cdm-hero :focus-visible { outline-color: var(--cdm-ink); }
.cdm-gradient-text { color: var(--cdm-primary); }
.cdm-hero .cdm-gradient-text { color: var(--cdm-navy); background: #fff; padding: 0 .25em; border-radius: 10px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* Carte « Ça, c'est toi ! » à bord pointillé, signature de l'ancien site */
.me-card { display: flex; align-items: center; gap: 1.1rem; padding: 1rem 1.25rem; background: var(--cdm-surface); color: var(--cdm-text); border: 3px dashed var(--cdm-navy); border-radius: 22px; }
[data-bs-theme="dark"] .me-card { border-color: var(--cdm-muted); }
.me-card .cdm-avatar { width: 132px; height: 132px; font-size: 2.6rem; background: var(--cdm-primary-soft); }
.me-card-title { font-family: var(--cdm-font-title); font-weight: 800; font-size: 1.2rem; }

/* Tuiles de classe : gros chiffre dans un rond blanc sur aplat de couleur (comme les anciennes images) */
.level-tile { display: flex; flex-direction: column; height: 100%; background: var(--cdm-surface); color: var(--cdm-text); border-radius: var(--cdm-radius); overflow: hidden; box-shadow: var(--cdm-shadow); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.level-tile:hover { color: var(--cdm-text); transform: translateY(-3px); box-shadow: var(--cdm-shadow-lg); }
.level-tile-art { aspect-ratio: 1.15; display: grid; place-items: center; background: var(--tile, var(--cdm-brand)); }
.level-tile-burst { width: 70%; aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle, #fff 58%, rgba(255, 255, 255, .55) 66%, rgba(255, 255, 255, 0) 72%); color: #141b22; transition: transform .2s ease; }
.level-tile:hover .level-tile-burst { transform: scale(1.06) rotate(-4deg); }
.level-num { font-family: var(--cdm-font-title); font-weight: 900; font-size: clamp(3rem, 5vw, 4.4rem); line-height: 1; }
.level-sup { align-self: flex-start; margin-top: 30%; font-style: italic; font-size: clamp(1rem, 1.6vw, 1.45rem); }
.level-tile-body { display: flex; flex-direction: column; gap: .4rem; padding: .85rem 1rem 1rem; }
.level-tile-name { font-family: var(--cdm-font-title); font-weight: 800; font-size: 1.1rem; }
.level-tile .cdm-progress > span { background: var(--tile, var(--cdm-brand)); }

.stat { padding: 1rem 1.25rem; }
.stat-value { font-family: var(--cdm-font-title); font-size: 1.9rem; font-weight: 900; letter-spacing: -.03em; }
.stat-label { color: var(--cdm-muted); font-size: .9rem; font-weight: 700; }
.podium-row { display: flex; align-items: center; gap: .75rem; padding: .45rem 0; }
.podium-rank { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-family: var(--cdm-font-title); font-weight: 800; font-size: .9rem; color: #fff; background: #8a9aa6; flex-shrink: 0; }
.podium-rank.r1 { background: #b8860b; }
.podium-rank.r2 { background: #6b7b88; }
.podium-rank.r3 { background: #a0592a; }

/* Grandes cartes d'action (course aux nombres, enseignants) */
.cdm-card-navy { background: var(--cdm-navy); color: #fff; border-color: transparent; }
.cdm-card-navy:hover { color: #fff; }
.cdm-card-navy p { color: #dbe4ea; }
.action-art { width: 88px; height: auto; flex-shrink: 0; }

/* ---------- Progression ---------- */

.cdm-progress { height: 8px; border-radius: 999px; background: var(--cdm-border); overflow: hidden; }
.cdm-progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cdm-primary), var(--cdm-accent)); transition: width .6s ease; }
.cdm-progress.done > span { background: var(--cdm-emerald); }

.chapter-card { padding: 1.1rem 1.25rem; }
.skill-row { display: flex; align-items: center; gap: .9rem; padding: .65rem .75rem; border-radius: var(--cdm-radius-sm); color: inherit; text-decoration: none; }
.skill-row:hover { background: var(--cdm-surface-2); color: inherit; }
.skill-row .skill-state { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--cdm-surface-2); color: var(--cdm-muted); font-size: .75rem; font-weight: 700; }
.skill-row.has-ruby .skill-state { background: var(--cdm-ruby-soft); color: var(--cdm-ruby-text); }
.skill-row.in-progress .skill-state { background: var(--cdm-primary-soft); color: var(--cdm-primary); }
.gem { width: 1.1em; height: 1.1em; vertical-align: -.15em; }
.gem-ruby { color: var(--cdm-ruby); }
.gem-emerald { color: var(--cdm-emerald); }
.gem-badge { color: var(--cdm-badge); }

/* ---------- Page compétence / exercices ---------- */

.page-header { padding: 1.5rem 0 1rem; }
.breadcrumb { font-size: .85rem; margin-bottom: .5rem; }
.breadcrumb a { color: var(--cdm-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--cdm-primary); }
.lesson { padding: 1.25rem 1.5rem; font-size: 1.02rem; line-height: 1.65; }
.lesson img { max-width: 100%; height: auto; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--cdm-radius-sm); overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.exercise { padding: 0; overflow: hidden; scroll-margin-top: 90px; }
.exercise-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--cdm-border); }
.exercise-num { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--cdm-primary-soft); color: var(--cdm-primary); }
.exercise.is-done .exercise-num { background: var(--cdm-emerald-soft); color: var(--cdm-emerald); }
.exercise-body { padding: 1.25rem; font-size: 1.05rem; line-height: 1.7; overflow-x: auto; }
.exercise-body img { max-width: 100%; height: auto; }
.exercise-body input[name='user_answer[]'] { display: inline-block; border: 2px solid var(--cdm-border); border-radius: 10px; padding: .3rem .6rem; min-width: 90px; max-width: 100%; background: var(--cdm-surface); color: var(--cdm-text); font-weight: 600; }
.exercise-body input[name='user_answer[]']:focus { outline: none; border-color: var(--cdm-primary); box-shadow: 0 0 0 .2rem rgba(var(--cdm-primary-rgb), .2); }
.exercise-body math-field { display: inline-block; min-width: 120px; border: 2px solid var(--cdm-border); border-radius: 10px; padding: .15rem .5rem; font-size: 1.2rem; vertical-align: middle; background: var(--cdm-surface); color: var(--cdm-text); }
.exercise-body math-field:focus-within { border-color: var(--cdm-primary); }
.exercise-body math-field.mf_medium { min-width: 220px; }
.exercise-body math-field::part(menu-toggle) { display: none; }
.exercise-body .btn-check + .btn { margin: .15rem; }
.exercise-foot { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: 1rem 1.25rem; background: var(--cdm-surface-2); border-top: 1px solid var(--cdm-border); }

/* États de correction */
.answer-ok { border-color: var(--cdm-emerald) !important; color: var(--cdm-emerald) !important; }
.answer-ko { border-color: var(--cdm-ruby) !important; color: var(--cdm-ruby) !important; }
.expected { display: inline-flex; align-items: center; gap: .35rem; margin: .2rem .4rem; padding: .1rem .7rem; border-radius: 999px; font-size: .95rem; font-weight: 600; animation: pop .35s ease both; vertical-align: middle; }
.expected.ok { background: var(--cdm-emerald-soft); color: var(--cdm-emerald-text); }
.expected.ko { background: var(--cdm-ruby-soft); color: var(--cdm-ruby-text); }
.expected math-field { border: 0 !important; background: transparent !important; min-width: 0 !important; padding: 0 !important; font-size: 1.05rem; }
.correction-banner { display: flex; gap: .75rem; align-items: center; padding: .9rem 1.25rem; font-weight: 700; animation: pop .35s ease both; }
.correction-banner.ok { background: var(--cdm-emerald-soft); color: var(--cdm-emerald-text); }
.correction-banner.ko { background: var(--cdm-ruby-soft); color: var(--cdm-ruby-text); }

@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
.shake { animation: shake .5s both; }

/* Récompense */
.reward-toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 1080; display: flex; align-items: center; gap: .9rem; padding: .9rem 1.3rem; border-radius: 999px; background: var(--cdm-surface); box-shadow: var(--cdm-shadow-lg); border: 1px solid var(--cdm-border); font-weight: 700; animation: rise .5s cubic-bezier(.2, 1.4, .4, 1) both; max-width: calc(100vw - 2rem); }
.reward-toast .gem { width: 2rem; height: 2rem; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 30px) scale(.8); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (min-width: 768px) { .reward-toast { bottom: 32px; } }

/* Clavier MathLive au-dessus de la barre mobile */
body > .ML__keyboard { z-index: 1090; }

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

.avatar-item { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .5rem .25rem; border: 2px solid var(--cdm-border); border-radius: var(--cdm-radius-sm); background: var(--cdm-surface); color: var(--cdm-text); transition: border-color .15s, transform .15s; }
.avatar-item:hover { border-color: rgba(var(--cdm-primary-rgb), .5); transform: translateY(-1px); }
.avatar-item.selected { border-color: var(--cdm-primary); box-shadow: 0 0 0 3px rgba(var(--cdm-primary-rgb), .2); }
.avatar-item[data-owned="0"] img, .avatar-item[data-owned="0"] .swatch { opacity: .55; }
.avatar-item img { width: 100%; max-width: 84px; aspect-ratio: 1; border-radius: 50%; background: var(--cdm-primary-soft); }
.avatar-item .swatch { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--cdm-border); margin: 14px 0; }
.avatar-item-label { font-size: .75rem; font-weight: 600; line-height: 1.2; text-align: center; min-height: 1.8em; display: flex; align-items: center; gap: .15rem; }

/* ---------- Divers ---------- */

.cdm-footer { border-top: 1px solid var(--cdm-border); background: var(--cdm-surface); color: var(--cdm-muted); font-size: .9rem; }
.cdm-footer a { color: var(--cdm-muted); text-decoration: none; }
.cdm-footer a:hover { color: var(--cdm-primary); }
.toast-container { z-index: 1090; }
.auth-card { max-width: 440px; margin: 0 auto; padding: 2rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--cdm-muted); }

/* Mode sombre : rouge et vert de Bootstrap trop foncés sur fond sombre (contraste < 4,5:1) */
[data-bs-theme="dark"] .text-danger { color: #fca5a5 !important; }
[data-bs-theme="dark"] .text-success { color: #86efac !important; }
