/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: "Inter", sans-serif;
    background: #f8fafc;
    color: #1e293b;
    min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
    --green: #16a34a;
    --green-light: #22c55e;
    --green-bg: #f0fdf4;
    --blue: #3b82f6;
    --gold: #f59e0b;
    --radius: 14px;
    --shadow: 0 2px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --header-h: 64px;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
    position: sticky; top: 0; z-index: 100;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    height: var(--header-h);
}
.header-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    height: 100%;
}
.logo {
    display: flex; align-items: center; gap: 8px;
    font-size: 1.2rem; font-weight: 800; color: var(--green);
}
.logo-icon { font-size: 1.4rem; }
.nav { display: flex; gap: 4px; }
.nav-link {
    padding: 7px 14px; border-radius: 8px;
    font-size: 0.9rem; font-weight: 500; color: #64748b;
    transition: all 0.18s;
}
.nav-link:hover { background: #f1f5f9; color: #1e293b; }
.nav-link.active { background: var(--green-bg); color: var(--green); font-weight: 600; }

.burger {
    display: none;
    flex-direction: column; gap: 5px;
    background: none; border: none; padding: 4px;
}
.burger span {
    display: block; width: 24px; height: 2px;
    background: #1e293b; border-radius: 2px;
    transition: all 0.25s;
}
.burger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   VIEWS
   ============================================================ */
#app { max-width: 1200px; margin: 0 auto; padding: 0 20px 60px; }
.view { display: none; }
.view.active { display: block; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
    background: var(--green); color: white;
    border: none; border-radius: 10px;
    padding: 11px 22px; font-size: 0.95rem; font-weight: 600;
    transition: background 0.18s, transform 0.12s;
}
.btn-primary:hover { background: #15803d; transform: translateY(-1px); }
.btn-secondary {
    background: white; color: var(--green);
    border: 2px solid var(--green); border-radius: 10px;
    padding: 9px 22px; font-size: 0.95rem; font-weight: 600;
    transition: all 0.18s;
}
.btn-secondary:hover { background: var(--green-bg); }
.btn-sm {
    background: var(--green-bg); color: var(--green);
    border: none; border-radius: 8px;
    padding: 7px 14px; font-size: 0.85rem; font-weight: 600;
    white-space: nowrap; transition: all 0.18s;
}
.btn-sm:hover { background: var(--green); color: white; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
    display: grid; grid-template-columns: 1fr 1fr; gap: 48px;
    align-items: center;
    padding: 60px 0 48px;
}
.hero-badge {
    display: inline-block;
    background: var(--green-bg); color: var(--green);
    font-size: 0.85rem; font-weight: 600;
    padding: 5px 12px; border-radius: 20px;
    margin-bottom: 16px;
}
.hero h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800; line-height: 1.15;
    margin-bottom: 16px;
}
.gradient-text {
    background: linear-gradient(135deg, var(--green), #059669);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 1.05rem; color: #64748b; line-height: 1.6; margin-bottom: 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-visual { display: flex; justify-content: flex-end; }
.hero-card {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px; width: 260px;
    display: flex; flex-direction: column; gap: 12px;
}
.hc-row {
    display: flex; align-items: center; gap: 10px;
    font-size: 0.95rem; font-weight: 500;
}
.hc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.hc-dot.green { background: #22c55e; }
.hc-dot.blue  { background: #3b82f6; }
.hc-dot.orange{ background: #f59e0b; }
.hc-dot.purple{ background: #8b5cf6; }
.hc-stat {
    margin-top: 8px; padding-top: 12px;
    border-top: 1px solid #f1f5f9;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.9rem; color: #64748b;
}
.hc-stat strong { font-size: 1.4rem; color: var(--green); font-weight: 800; }

/* ============================================================
   SECTIONS
   ============================================================ */
.section { padding: 40px 0; }
.section-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.section-sub { color: #64748b; margin-bottom: 28px; }

/* Subjects grid */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.subject-card {
    background: white; border-radius: var(--radius);
    padding: 24px 20px; cursor: pointer;
    border: 2px solid transparent;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}
.subject-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--green-light);
}
.sc-icon { font-size: 2rem; margin-bottom: 12px; }
.subject-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.subject-card p { font-size: 0.85rem; color: #64748b; line-height: 1.5; margin-bottom: 12px; }
.sc-badge {
    background: var(--green-bg); color: var(--green);
    font-size: 0.78rem; font-weight: 600;
    padding: 3px 9px; border-radius: 12px;
}

/* Stats section */
.stats-section {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    background: linear-gradient(135deg, #166534, #15803d);
    border-radius: var(--radius); padding: 32px;
}
.stat-box { text-align: center; color: white; }
.stat-num { display: block; font-size: 2.2rem; font-weight: 800; }
.stat-label { font-size: 0.85rem; opacity: 0.85; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header { padding: 36px 0 28px; }
.page-header h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 6px; }
.page-header p { color: #64748b; }

/* ============================================================
   COURS
   ============================================================ */
.cours-layout { display: grid; grid-template-columns: 200px 1fr; gap: 24px; }
.cours-sidebar {
    background: white; border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow);
    height: fit-content; position: sticky; top: 80px;
}
.sidebar-title { font-size: 0.75rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; padding: 0 8px; }
.sidebar-item {
    display: block; width: 100%; text-align: left;
    background: none; border: none; border-radius: 8px;
    padding: 9px 10px; font-size: 0.88rem; font-weight: 500; color: #475569;
    transition: all 0.15s;
}
.sidebar-item:hover { background: #f8fafc; color: #1e293b; }
.sidebar-item.active { background: var(--green-bg); color: var(--green); font-weight: 600; }

.lesson-card {
    background: white; border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: var(--shadow); cursor: pointer;
    border-left: 4px solid transparent;
    transition: all 0.18s;
}
.lesson-card:hover { transform: translateX(4px); border-left-color: var(--green); }
.lesson-card.read { border-left-color: var(--green-light); }
.lc-left { display: flex; align-items: flex-start; gap: 14px; flex: 1; }
.lc-icon { font-size: 1.5rem; flex-shrink: 0; }
.lc-left h4 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.lc-left p { font-size: 0.85rem; color: #64748b; margin-bottom: 8px; }
.lc-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
    background: #f1f5f9; color: #64748b;
    font-size: 0.75rem; font-weight: 500;
    padding: 2px 8px; border-radius: 8px;
}
.tag-done { background: #dcfce7; color: var(--green); }

/* Lesson detail */
.lesson-detail { padding-bottom: 40px; }
.back-btn {
    background: none; border: none;
    color: var(--green); font-weight: 600; font-size: 0.95rem;
    padding: 0 0 16px; cursor: pointer;
}
.back-btn:hover { text-decoration: underline; }

/* Lesson content styles */
#lesson-content h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
#lesson-content h3 { font-size: 1.1rem; font-weight: 700; margin: 20px 0 10px; color: #1e293b; }
#lesson-content p, #lesson-content li { font-size: 0.95rem; line-height: 1.7; color: #334155; }
#lesson-content ul, #lesson-content ol { padding-left: 20px; margin-bottom: 12px; }
#lesson-content li { margin-bottom: 4px; }
.lesson-meta { display: flex; gap: 8px; margin-bottom: 20px; }
.lesson-meta span { background: #f1f5f9; padding: 3px 10px; border-radius: 8px; font-size: 0.8rem; font-weight: 500; color: #64748b; }
.formula {
    background: #1e293b; color: #a7f3d0;
    font-family: "Courier New", monospace; font-size: 1rem;
    padding: 12px 18px; border-radius: 10px;
    margin: 12px 0; display: inline-block;
}
.lesson-tip {
    background: #fffbeb; border-left: 4px solid var(--gold);
    padding: 12px 16px; border-radius: 0 10px 10px 0;
    font-size: 0.9rem; line-height: 1.6; margin-top: 20px;
}
.lesson-table {
    width: 100%; border-collapse: collapse;
    margin: 12px 0; font-size: 0.9rem;
}
.lesson-table th, .lesson-table td {
    border: 1px solid #e2e8f0; padding: 8px 12px; text-align: left;
}
.lesson-table th { background: #f8fafc; font-weight: 600; }
blockquote {
    border-left: 3px solid var(--green); padding: 10px 16px;
    margin: 12px 0; font-style: italic; color: #475569;
    background: var(--green-bg); border-radius: 0 8px 8px 0;
}

/* ============================================================
   QUIZ
   ============================================================ */
.quiz-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.quiz-item-card {
    background: white; border-radius: var(--radius);
    padding: 22px 20px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 8px;
}
.qic-top { display: flex; align-items: center; gap: 8px; }
.qic-icon { font-size: 1.4rem; }
.qic-subject { font-size: 0.8rem; font-weight: 600; color: #64748b; }
.quiz-item-card h4 { font-size: 1rem; font-weight: 700; }
.quiz-item-card p { font-size: 0.85rem; color: #64748b; flex: 1; }
.qic-score { font-size: 0.85rem; font-weight: 600; padding: 4px 0; }
.qic-new { color: #94a3b8; }
.quiz-item-card .btn-primary { margin-top: 4px; }

.quiz-card {
    max-width: 640px; margin: 0 auto;
    background: white; border-radius: var(--radius);
    padding: 32px; box-shadow: var(--shadow-lg);
}
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.quiz-subject-label { font-size: 0.9rem; font-weight: 600; color: var(--green); }
.quiz-counter { font-size: 0.85rem; color: #94a3b8; }
.quiz-progress-bar {
    height: 6px; background: #e2e8f0; border-radius: 3px;
    margin-bottom: 24px; overflow: hidden;
}
.quiz-progress-bar > div {
    height: 100%; background: var(--green);
    border-radius: 3px; transition: width 0.35s;
}
.quiz-question { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.quiz-opt {
    background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 10px;
    padding: 12px 16px; text-align: left; font-size: 0.95rem; font-weight: 500;
    transition: all 0.15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--green); background: var(--green-bg); }
.quiz-opt.correct { background: #dcfce7; border-color: var(--green); color: #15803d; }
.quiz-opt.wrong   { background: #fef2f2; border-color: #ef4444; color: #dc2626; }
.quiz-opt:disabled { cursor: default; }
.quiz-feedback {
    padding: 12px 16px; border-radius: 10px; font-size: 0.9rem;
    line-height: 1.6; margin-bottom: 16px;
}
.fb-correct { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.fb-wrong   { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.quiz-card .btn-primary { width: 100%; }

.result-card {
    max-width: 520px; margin: 0 auto;
    background: white; border-radius: var(--radius);
    padding: 40px 32px; box-shadow: var(--shadow-lg);
    text-align: center;
}
.result-emoji { font-size: 3.5rem; margin-bottom: 12px; }
.result-card h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.result-card > p { font-size: 1.1rem; color: #475569; margin-bottom: 20px; }
.result-details { text-align: left; margin-bottom: 24px; display: flex; flex-direction: column; gap: 6px; }
.rd-item { font-size: 0.9rem; padding: 6px 10px; border-radius: 8px; }
.rd-ok { background: #f0fdf4; color: #15803d; }
.rd-ko { background: #fef2f2; color: #dc2626; }
.result-actions { display: flex; gap: 12px; justify-content: center; }

/* ============================================================
   PROGRESSION
   ============================================================ */
.progress-dashboard { padding: 8px 0; }
.prog-overview {
    display: flex; align-items: center; gap: 40px;
    background: white; border-radius: var(--radius);
    padding: 32px; box-shadow: var(--shadow);
    margin-bottom: 32px; flex-wrap: wrap;
}
.prog-circle-wrap { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.prog-circle { width: 140px; height: 140px; }
.prog-circle-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.prog-circle-text span { font-size: 1.5rem; font-weight: 800; display: block; }
.prog-circle-text small { font-size: 0.75rem; color: #94a3b8; }
.prog-stats { display: flex; flex-wrap: wrap; gap: 24px; flex: 1; }
.ps-item { display: flex; align-items: center; gap: 12px; }
.ps-icon { font-size: 1.8rem; }
.ps-item strong { font-size: 1.3rem; font-weight: 700; display: block; }
.ps-item small { font-size: 0.8rem; color: #94a3b8; }

.prog-section-title { font-size: 1.1rem; font-weight: 700; margin: 24px 0 14px; }
.subject-bars { background: white; border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); margin-bottom: 28px; display: flex; flex-direction: column; gap: 14px; }
.sub-bar-row { display: flex; align-items: center; gap: 12px; }
.sb-label { width: 160px; font-size: 0.9rem; font-weight: 500; flex-shrink: 0; }
.sb-bar-wrap { flex: 1; height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.sb-bar { height: 100%; border-radius: 5px; transition: width 0.8s ease; }
.sb-pct { width: 42px; text-align: right; font-size: 0.85rem; font-weight: 600; color: #64748b; }

.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge-card {
    background: white; border-radius: var(--radius);
    padding: 20px 16px; text-align: center; box-shadow: var(--shadow);
    transition: transform 0.18s;
}
.badge-card.unlocked { border: 2px solid var(--green-light); }
.badge-card.locked { opacity: 0.45; }
.badge-card.unlocked:hover { transform: translateY(-3px); }
.badge-icon { font-size: 2rem; margin-bottom: 8px; }
.badge-name { font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; }
.badge-desc { font-size: 0.75rem; color: #94a3b8; }

/* ============================================================
   FORUM
   ============================================================ */
.forum-layout { display: flex; flex-direction: column; gap: 16px; }
.forum-controls { display: flex; gap: 12px; flex-wrap: wrap; }
.forum-search {
    flex: 1; min-width: 200px;
    border: 2px solid #e2e8f0; border-radius: 10px;
    padding: 10px 14px; font-size: 0.95rem; outline: none;
    transition: border-color 0.18s;
}
.forum-search:focus { border-color: var(--green); }
.forum-categories { display: flex; gap: 8px; flex-wrap: wrap; }
.fc-btn {
    background: white; border: 2px solid #e2e8f0; border-radius: 20px;
    padding: 6px 14px; font-size: 0.85rem; font-weight: 500; color: #64748b;
    transition: all 0.15s;
}
.fc-btn:hover { border-color: var(--green); color: var(--green); }
.fc-btn.active { background: var(--green); border-color: var(--green); color: white; }

.forum-post {
    background: white; border-radius: var(--radius);
    padding: 20px 24px; box-shadow: var(--shadow);
    border-left: 4px solid transparent; transition: border-color 0.15s;
}
.forum-post:hover { border-left-color: var(--green-light); }
.fp-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.fp-cat { font-size: 0.8rem; font-weight: 600; background: var(--green-bg); color: var(--green); padding: 3px 10px; border-radius: 12px; }
.fp-date { font-size: 0.8rem; color: #94a3b8; }
.fp-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.fp-body { font-size: 0.9rem; color: #475569; line-height: 1.6; margin-bottom: 12px; }
.fp-footer { display: flex; align-items: center; gap: 16px; }
.fp-author { font-size: 0.85rem; color: #64748b; }
.fp-like {
    background: none; border: 1px solid #e2e8f0; border-radius: 20px;
    padding: 4px 10px; font-size: 0.85rem; cursor: pointer;
    transition: all 0.15s;
}
.fp-like:hover { border-color: #ef4444; background: #fef2f2; }
.fp-replies { font-size: 0.85rem; color: #94a3b8; }
.fp-replies-list { margin-top: 14px; padding-top: 14px; border-top: 1px solid #f1f5f9; display: flex; flex-direction: column; gap: 10px; }
.fp-reply { background: #f8fafc; border-radius: 8px; padding: 10px 14px; font-size: 0.88rem; }
.fp-reply strong { font-weight: 700; }
.reply-date { font-size: 0.78rem; color: #94a3b8; margin-left: 6px; }
.fp-reply p { margin-top: 4px; color: #475569; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.45); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
    background: white; border-radius: var(--radius);
    width: 100%; max-width: 480px;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid #f1f5f9;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; font-size: 1.1rem;
    color: #94a3b8; cursor: pointer; transition: color 0.15s;
}
.modal-close:hover { color: #1e293b; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: #475569; }
.form-group input, .form-group select, .form-group textarea {
    border: 2px solid #e2e8f0; border-radius: 8px;
    padding: 9px 12px; font-size: 0.9rem; outline: none;
    transition: border-color 0.18s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--green); }

/* Helpers */
.hidden { display: none !important; }
.empty-msg { text-align: center; color: #94a3b8; padding: 40px 0; font-size: 0.95rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; gap: 32px; padding: 40px 0 32px; }
    .hero-visual { justify-content: flex-start; }
    .stats-section { grid-template-columns: repeat(2, 1fr); }
    .cours-layout { grid-template-columns: 1fr; }
    .cours-sidebar { position: static; display: flex; flex-wrap: wrap; gap: 6px; background: transparent; box-shadow: none; padding: 0; }
    .sidebar-title { display: none; }
    .sidebar-item { background: white; box-shadow: var(--shadow); width: auto; }
}

@media (max-width: 600px) {
    .nav { display: none; flex-direction: column; gap: 4px; }
    .nav.open {
        display: flex; position: absolute;
        top: var(--header-h); left: 0; right: 0;
        background: white; padding: 12px 16px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.1);
        border-bottom: 1px solid #e2e8f0;
    }
    .nav.open .nav-link { padding: 10px 14px; }
    .burger { display: flex; }
    .hero h1 { font-size: 1.8rem; }
    .stats-section { grid-template-columns: repeat(2, 1fr); padding: 20px; }
    .subjects-grid { grid-template-columns: repeat(2, 1fr); }
    .prog-overview { flex-direction: column; align-items: flex-start; }
    .sb-label { width: 110px; font-size: 0.8rem; }
    .quiz-card, .result-card { padding: 20px 16px; }
}

/* ============================================================
   HEADER AUTH
   ============================================================ */
.header-inner { position: relative; }
.header-auth { display: flex; align-items: center; }

.btn-login {
    background: var(--green); color: white;
    border: none; border-radius: 8px;
    padding: 8px 16px; font-size: 0.88rem; font-weight: 600;
    cursor: pointer; transition: background 0.18s;
    white-space: nowrap;
}
.btn-login:hover { background: #15803d; }

.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 7px;
    background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 24px;
    padding: 6px 12px; cursor: pointer; font-size: 0.9rem;
    transition: all 0.18s;
}
.user-btn:hover { border-color: var(--green); background: var(--green-bg); }
.user-arrow { font-size: 0.7rem; color: #94a3b8; }

.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: white; border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: var(--shadow-lg); min-width: 190px; z-index: 200;
    overflow: hidden;
}
.ud-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 11px 16px;
    font-size: 0.9rem; color: #334155; font-weight: 500;
    background: none; border: none; cursor: pointer; text-align: left;
    transition: background 0.15s;
}
.ud-item:hover { background: #f8fafc; }
.ud-logout { color: #ef4444; }
.ud-logout:hover { background: #fef2f2; }
.ud-divider { height: 1px; background: #f1f5f9; margin: 2px 0; }

/* ============================================================
   ANIMATIONS VECTORIELLES
   ============================================================ */
.lesson-anim {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px 16px 12px;
    margin: 20px 0 24px;
    text-align: center;
}
.lesson-anim svg {
    width: 100%;
    max-width: 480px;
    height: auto;
    display: block;
    margin: 0 auto;
}
.anim-caption {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 10px;
    font-style: italic;
    line-height: 1.4;
}
.anim-caption strong { color: #64748b; font-style: normal; }

/* ============================================================
   QUIZ VISUALS INTERACTIFS
   ============================================================ */
#quiz-visual {
    margin: 0 0 16px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}
#quiz-visual svg {
    display: block;
    width: 100%;
    height: auto;
}
.qv-hint {
    text-align: center;
    font-size: 0.78rem;
    color: #94a3b8;
    padding: 6px 12px 10px;
    font-style: italic;
}
.qz { cursor: pointer; transition: opacity .15s; }
.qz-bg {
    fill: #e2e8f0;
    stroke: #cbd5e1;
    stroke-width: 1.5;
    rx: 8;
    transition: fill .15s, stroke .15s;
}
.qz:hover .qz-bg    { fill: #dbeafe; stroke: #3b82f6; }
.qz.vz-ok .qz-bg   { fill: #dcfce7; stroke: #22c55e; }
.qz.vz-ko .qz-bg   { fill: #fee2e2; stroke: #ef4444; }
.qz.vz-dim          { opacity: .4; }
.qz-badge {
    font-size: 11px;
    font-weight: 700;
    fill: #475569;
}
.qz.vz-ok .qz-badge { fill: #16a34a; }
.qz.vz-ko .qz-badge { fill: #dc2626; }
.qz-lbl {
    font-size: 10px;
    fill: #64748b;
}

/* ============================================================
   AUTH MODAL
   ============================================================ */
.auth-modal { max-width: 440px; }
.auth-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; border-bottom: 1px solid #f1f5f9;
}
.auth-tabs-header { display: flex; gap: 4px; }
.auth-tab-btn {
    background: none; border: none;
    padding: 7px 16px; border-radius: 8px;
    font-size: 0.9rem; font-weight: 600; color: #94a3b8; cursor: pointer;
    transition: all 0.15s;
}
.auth-tab-btn.active { background: var(--green-bg); color: var(--green); }

.auth-hint {
    background: #fffbeb; border: 1px solid #fde68a;
    border-radius: 10px; padding: 12px 14px;
    font-size: 0.85rem; line-height: 1.6;
}
.auth-hint code {
    background: white; border: 1px solid #e2e8f0;
    padding: 1px 6px; border-radius: 4px;
    font-size: 0.82rem; font-family: "Courier New", monospace;
}
.label-hint { font-weight: 400; color: #94a3b8; }
.auth-error  { color: #ef4444; font-size: 0.85rem; padding: 4px 0; }
.auth-success { color: var(--green); font-size: 0.88rem; padding: 4px 0; }

/* Avatar grid */
.avatar-grid {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0;
}
.avatar-opt {
    background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 8px;
    width: 40px; height: 40px; font-size: 1.3rem; cursor: pointer;
    transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.avatar-opt:hover   { border-color: var(--green); background: var(--green-bg); }
.avatar-opt.selected { border-color: var(--green); background: var(--green-bg); transform: scale(1.1); }

/* ============================================================
   PROFIL
   ============================================================ */
.profile-layout {
    display: grid; grid-template-columns: 280px 1fr; gap: 24px;
    padding-bottom: 48px;
}
.profile-card {
    background: white; border-radius: var(--radius);
    padding: 32px 24px; box-shadow: var(--shadow);
    text-align: center; height: fit-content;
}
.profile-avatar-big {
    font-size: 4rem; margin-bottom: 12px;
    width: 96px; height: 96px; background: #f1f5f9;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
}
.profile-card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.profile-username { font-size: 0.85rem; color: #94a3b8; margin-bottom: 10px; }
.profile-role-badge {
    display: inline-block; background: var(--green-bg); color: var(--green);
    font-size: 0.8rem; font-weight: 600; padding: 4px 12px; border-radius: 20px; margin-bottom: 20px;
}
.profile-role-badge.admin { background: #fef3c7; color: #d97706; }
.profile-mini-stats {
    display: flex; justify-content: space-around;
    border-top: 1px solid #f1f5f9; padding-top: 16px;
}
.pms-item { text-align: center; }
.pms-item strong { display: block; font-size: 1.3rem; font-weight: 800; }
.pms-item small  { font-size: 0.75rem; color: #94a3b8; }

.profile-edit-card {
    background: white; border-radius: var(--radius);
    padding: 28px; box-shadow: var(--shadow);
}
.profile-edit-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }

/* ============================================================
   ADMIN PANEL
   ============================================================ */
.admin-tabs-bar {
    display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.admin-tab {
    background: white; border: 2px solid #e2e8f0; border-radius: 10px;
    padding: 8px 18px; font-size: 0.9rem; font-weight: 600; color: #64748b; cursor: pointer;
    transition: all 0.15s;
}
.admin-tab:hover  { border-color: var(--green); color: var(--green); }
.admin-tab.active { background: var(--green); border-color: var(--green); color: white; }

.admin-panel { display: none; padding-bottom: 40px; }
.admin-panel.active { display: block; }

.admin-stats-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.admin-stat-card {
    background: white; border-radius: var(--radius);
    padding: 24px 20px; box-shadow: var(--shadow); text-align: center;
}
.asc-icon  { font-size: 2rem; margin-bottom: 8px; }
.asc-val   { font-size: 2rem; font-weight: 800; color: var(--green); }
.asc-label { font-size: 0.82rem; color: #64748b; margin-top: 4px; }

/* Admin users table */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%; border-collapse: collapse;
    background: white; border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow);
    font-size: 0.88rem;
}
.admin-table th {
    background: #f8fafc; padding: 12px 14px;
    text-align: left; font-weight: 600; color: #64748b;
    border-bottom: 2px solid #e2e8f0;
}
.admin-table td {
    padding: 12px 14px; border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr.me-row { background: #f0fdf4; }
.admin-table td:first-child { display: flex; align-items: center; gap: 10px; }
.admin-table td:first-child strong { display: block; }
.admin-table td:first-child small { color: #94a3b8; font-size: 0.78rem; }
.at-avatar { font-size: 1.4rem; }

.role-badge {
    background: var(--green-bg); color: var(--green);
    font-size: 0.78rem; font-weight: 600;
    padding: 3px 9px; border-radius: 12px;
}
.role-badge.admin { background: #fef3c7; color: #d97706; }

/* Admin forum list */
.admin-forum-list { display: flex; flex-direction: column; gap: 10px; }
.admin-post-row {
    background: white; border-radius: var(--radius);
    padding: 14px 18px; box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.apr-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; font-size: 0.88rem; }
.apr-info strong { font-weight: 600; }
.apr-info span   { color: #94a3b8; font-size: 0.8rem; }

/* fp-delete button in forum */
.fp-delete {
    background: none; border: none; cursor: pointer; font-size: 1rem;
    padding: 2px 6px; border-radius: 6px; transition: background 0.15s;
}
.fp-delete:hover { background: #fef2f2; }

/* ============================================================
   RESPONSIVE ADDITIONS
   ============================================================ */
@media (max-width: 900px) {
    .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .header-auth { order: -1; }
    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-table { font-size: 0.8rem; }
    .admin-table th, .admin-table td { padding: 8px 10px; }
}

/* ============================================================
   ANIMATIONS DYNAMIQUES
   ============================================================ */

/* --- Transition de vue --- */
@keyframes viewEnter {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.view.active {
    animation: viewEnter 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --- Stagger cartes --- */
@keyframes staggerFade {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.stagger-in {
    animation: staggerFade 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --- Toast --- */
.toast-container {
    position: fixed; bottom: 28px; right: 28px; z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: 10px;
    pointer-events: none; max-width: 340px;
}
.toast {
    background: #1e293b; color: white;
    padding: 13px 18px; border-radius: 12px;
    font-size: 0.9rem; font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.28);
    display: flex; align-items: center; gap: 10px;
    pointer-events: all;
    animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.toast-out { animation: toastOut 0.28s ease forwards; }
.toast-success { border-left: 4px solid #22c55e; }
.toast-error   { border-left: 4px solid #ef4444; }
.toast-info    { border-left: 4px solid #3b82f6; }
.toast-warn    { border-left: 4px solid #f59e0b; }
.toast-icon    { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg     { line-height: 1.4; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(60px) scale(0.94); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateX(60px); }
}

/* --- Ripple sur boutons --- */
.ripple-circle {
    position: absolute; border-radius: 50%;
    background: rgba(255,255,255,0.28);
    transform: scale(0); pointer-events: none;
    animation: rippleAnim 0.55s linear;
}
@keyframes rippleAnim {
    to { transform: scale(4); opacity: 0; }
}
.btn-primary, .btn-secondary, .quiz-opt, .sidebar-item, .fc-btn {
    position: relative; overflow: hidden;
}

/* --- Hero orbes --- */
.hero { position: relative; overflow: hidden; }
.hero-content, .hero-visual { position: relative; z-index: 1; }
.hero-bg-orb {
    position: absolute; border-radius: 50%;
    background: radial-gradient(circle, rgba(34,197,94,0.13) 0%, transparent 68%);
    pointer-events: none; z-index: 0;
    animation: orbFloat 7s ease-in-out infinite;
}
@keyframes orbFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50%       { transform: translateY(-26px) scale(1.07); }
}

/* --- Hero card flottante --- */
.hero-card {
    animation: heroFloat 4.5s ease-in-out infinite;
}
@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

/* --- Slide question quiz --- */
@keyframes qSlideIn {
    from { opacity: 0; transform: translateX(32px); }
    to   { opacity: 1; transform: translateX(0); }
}
.quiz-q-enter {
    animation: qSlideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --- Pop feedback quiz --- */
@keyframes fbPop {
    from { opacity: 0; transform: translateY(-10px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.quiz-feedback:not(.hidden) {
    animation: fbPop 0.28s ease both;
}

/* --- Pop option correcte --- */
@keyframes correctBounce {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}
.quiz-opt.correct { animation: correctBounce 0.35s ease; }

/* --- Résultat quiz --- */
@keyframes resultPop {
    from { opacity: 0; transform: scale(0.86) translateY(24px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.result-card-anim {
    animation: resultPop 0.48s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* --- Transition arc progression --- */
#prog-arc {
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Scroll reveal --- */
.reveal {
    opacity: 0; transform: translateY(26px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* --- Soulignement page-header --- */
.page-header h1 { position: relative; display: inline-block; }
.page-header h1::after {
    content: ""; position: absolute;
    bottom: -5px; left: 0; width: 0; height: 3px;
    background: linear-gradient(90deg, var(--green), var(--green-light));
    border-radius: 2px;
    animation: headLine 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards;
}
@keyframes headLine { to { width: 100%; } }

/* --- Badge pulse au déverrouillage --- */
@keyframes badgePulse {
    0%   { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(34,197,94,0.45); }
    60%  { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(34,197,94,0); }
    100% { transform: scale(1); }
}
.badge-card.unlocked {
    animation: badgePulse 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* --- Icône subject au survol --- */
.subject-card:hover .sc-icon {
    display: inline-block;
    animation: iconWiggle 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes iconWiggle {
    0%   { transform: rotate(-8deg) scale(0.9); }
    50%  { transform: rotate(6deg)  scale(1.2); }
    100% { transform: rotate(0deg)  scale(1); }
}

/* --- Icône leçon au survol --- */
.lesson-card:hover .lc-icon {
    display: inline-block;
    animation: iconBounce 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes iconBounce {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3) rotate(-5deg); }
    100% { transform: scale(1) rotate(0); }
}

/* --- Soulignement nav actif --- */
.nav-link.active { position: relative; }
.nav-link.active::after {
    content: ""; position: absolute;
    bottom: 2px; left: 50%; right: 50%;
    height: 2px; background: var(--green); border-radius: 1px;
    animation: navLine 0.3s ease forwards;
}
@keyframes navLine { to { left: 14px; right: 14px; } }

/* --- Confetti canvas --- */
#confetti-canvas { position: fixed; inset: 0; z-index: 9998; pointer-events: none; }

/* --- Glow sur stat mise à jour --- */
@keyframes statGlow {
    0%   { color: #22c55e; transform: scale(1.18); }
    100% { color: inherit; transform: scale(1); }
}
.stat-glow { animation: statGlow 0.55s ease both; }

/* ============================================================
   REFONTE DESIGN — STYLE ÉDUCATION NATIONALE
   ============================================================ */

/* Variables couleurs par matière */
:root {
    --c-maths:    #2563eb; --bg-maths:    #eff6ff; --lt-maths:    #dbeafe;
    --c-francais: #7c3aed; --bg-francais: #f5f3ff; --lt-francais: #ede9fe;
    --c-histgeo:  #ea580c; --bg-histgeo:  #fff7ed; --lt-histgeo:  #ffedd5;
    --c-svt:      #16a34a; --bg-svt:      #f0fdf4; --lt-svt:      #dcfce7;
    --c-physchim: #0891b2; --bg-physchim: #ecfeff; --lt-physchim: #cffafe;
    --c-anglais:  #dc2626; --bg-anglais:  #fef2f2; --lt-anglais:  #fee2e2;
    --c-ses:      #0d9488; --bg-ses:      #f0fdfa; --lt-ses:      #ccfbf1;
    --c-philo:    #4f46e5; --bg-philo:    #eef2ff; --lt-philo:    #e0e7ff;
}

/* ---- CARTES MATIÈRES REDESIGNÉES ---- */
.subjects-grid { gap: 20px; }

.subject-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 18px;
    box-shadow: 0 2px 14px rgba(0,0,0,0.07);
    transition: transform 0.22s, box-shadow 0.22s;
}
.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 36px rgba(0,0,0,0.13);
    border-color: transparent;
}

.sc-icon {
    font-size: 2.8rem;
    padding: 30px 20px 22px;
    text-align: center;
    display: block;
    margin: 0;
    line-height: 1;
    transition: transform 0.22s;
}
.subject-card:hover .sc-icon { transform: scale(1.12) rotate(-3deg); }
.subject-card h3 { padding: 0 20px 6px; font-size: 1.05rem; font-weight: 700; }
.subject-card p  { padding: 0 20px 14px; font-size: 0.84rem; color: #64748b; line-height: 1.5; flex: 1; }
.sc-badge        { margin: 0 20px 22px; align-self: flex-start; font-size: 0.78rem; font-weight: 700; padding: 4px 12px; border-radius: 20px; }

/* Couleurs icon bg par matière */
.subject-card[data-subject="maths"]    .sc-icon { background: var(--bg-maths);    }
.subject-card[data-subject="francais"] .sc-icon { background: var(--bg-francais); }
.subject-card[data-subject="histgeo"]  .sc-icon { background: var(--bg-histgeo);  }
.subject-card[data-subject="svt"]      .sc-icon { background: var(--bg-svt);      }
.subject-card[data-subject="physchim"] .sc-icon { background: var(--bg-physchim); }
.subject-card[data-subject="anglais"]  .sc-icon { background: var(--bg-anglais);  }
.subject-card[data-subject="ses"]      .sc-icon { background: var(--bg-ses);      }
.subject-card[data-subject="philo"]    .sc-icon { background: var(--bg-philo);    }

/* Badges colorés par matière */
.subject-card[data-subject="maths"]    .sc-badge { background: var(--lt-maths);    color: var(--c-maths);    }
.subject-card[data-subject="francais"] .sc-badge { background: var(--lt-francais); color: var(--c-francais); }
.subject-card[data-subject="histgeo"]  .sc-badge { background: var(--lt-histgeo);  color: var(--c-histgeo);  }
.subject-card[data-subject="svt"]      .sc-badge { background: var(--lt-svt);      color: var(--c-svt);      }
.subject-card[data-subject="physchim"] .sc-badge { background: var(--lt-physchim); color: var(--c-physchim); }
.subject-card[data-subject="anglais"]  .sc-badge { background: var(--lt-anglais);  color: var(--c-anglais);  }
.subject-card[data-subject="ses"]      .sc-badge { background: var(--lt-ses);      color: var(--c-ses);      }
.subject-card[data-subject="philo"]    .sc-badge { background: var(--lt-philo);    color: var(--c-philo);    }

/* Bordure haute colorée */
.subject-card[data-subject="maths"]    { border-top: 4px solid var(--c-maths);    }
.subject-card[data-subject="francais"] { border-top: 4px solid var(--c-francais); }
.subject-card[data-subject="histgeo"]  { border-top: 4px solid var(--c-histgeo);  }
.subject-card[data-subject="svt"]      { border-top: 4px solid var(--c-svt);      }
.subject-card[data-subject="physchim"] { border-top: 4px solid var(--c-physchim); }
.subject-card[data-subject="anglais"]  { border-top: 4px solid var(--c-anglais);  }
.subject-card[data-subject="ses"]      { border-top: 4px solid var(--c-ses);      }
.subject-card[data-subject="philo"]    { border-top: 4px solid var(--c-philo);    }

/* ---- PAGE HEADER AMÉLIORÉ ---- */
.page-header {
    padding: 40px 0 32px;
    border-bottom: 2px solid #f1f5f9;
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.page-header p { font-size: 1rem; color: #64748b; }

/* ---- HERO AMÉLIORÉ ---- */
.hero-badge {
    font-size: 0.88rem;
    padding: 6px 16px;
    border-radius: 24px;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.hero h1 { letter-spacing: -0.03em; }

/* ---- STATS SECTION AMÉLIORÉE ---- */
.stats-section {
    background: linear-gradient(135deg, #0f4c2a 0%, #166534 50%, #15803d 100%);
    border-radius: 20px;
    padding: 36px;
    position: relative;
    overflow: hidden;
}
.stats-section::before {
    content: "";
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}
.stat-num { font-size: 2.6rem; font-weight: 900; text-shadow: 0 2px 8px rgba(0,0,0,0.2); }

/* ---- LEÇONS AMÉLIORÉES ---- */
.lesson-card {
    border-radius: 16px;
    border-left: 5px solid transparent;
    padding: 20px 22px;
}
.lesson-card:hover { transform: translateX(5px); }

/* ---- QUIZ CARDS AMÉLIORÉES ---- */
.quiz-item-card {
    border-radius: 18px;
    border-top: 4px solid #e2e8f0;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.quiz-item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    border-top-color: var(--green);
}

/* ---- EXERCICES GRID REDESIGNÉE ---- */
.exo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    padding: 4px 0 32px;
}
.exo-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 14px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    transition: transform 0.22s, box-shadow 0.22s;
    border: none;
    cursor: pointer;
}
.exo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.13);
}

/* Bandeau illustration en haut de la carte exercice */
.exo-card-banner {
    width: 100%;
    background: #f8fafc;
    display: block;
    overflow: hidden;
    border-radius: 0;
}
.exo-card-banner svg { display: block; width: 100%; height: 120px; }

.exo-card-body {
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
}
.exo-card-icon { font-size: 1.5rem; }
.exo-card-subject {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.exo-card h3 { font-size: 1rem; font-weight: 700; color: #1e293b; }
.exo-card-sub { font-size: 0.83rem; color: #64748b; flex: 1; }
.exo-diff {
    display: inline-block;
    font-size: 0.75rem; font-weight: 700;
    padding: 3px 10px; border-radius: 20px;
    align-self: flex-start; margin-top: 4px;
}
.diff-facile { background: #dcfce7; color: #16a34a; }
.diff-moyen  { background: #fef3c7; color: #d97706; }
.diff-hard   { background: #fee2e2; color: #dc2626; }
.exo-card .btn-primary { margin-top: 12px; width: 100%; }

/* Couleurs par matière sur l'entête des cartes exercice */
.exo-card[data-subj="maths"]    .exo-card-banner { background: var(--bg-maths);    }
.exo-card[data-subj="maths"]    .exo-card-subject { color: var(--c-maths);          }
.exo-card[data-subj="francais"] .exo-card-banner { background: var(--bg-francais); }
.exo-card[data-subj="francais"] .exo-card-subject { color: var(--c-francais);       }
.exo-card[data-subj="histgeo"]  .exo-card-banner { background: var(--bg-histgeo);  }
.exo-card[data-subj="histgeo"]  .exo-card-subject { color: var(--c-histgeo);        }
.exo-card[data-subj="svt"]      .exo-card-banner { background: var(--bg-svt);      }
.exo-card[data-subj="svt"]      .exo-card-subject { color: var(--c-svt);            }
.exo-card[data-subj="physchim"] .exo-card-banner { background: var(--bg-physchim); }
.exo-card[data-subj="physchim"] .exo-card-subject { color: var(--c-physchim);       }
.exo-card[data-subj="anglais"]  .exo-card-banner { background: var(--bg-anglais);  }
.exo-card[data-subj="anglais"]  .exo-card-subject { color: var(--c-anglais);        }

/* ---- BANDEAU ANIMATION EXERCICE (LECTEUR) ---- */
.exo-anim-banner {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.exo-anim-banner svg {
    display: block;
    width: 100%;
    height: 150px;
}

/* ---- HEADER EXERCICE LECTEUR AMÉLIORÉ ---- */
.sudoku-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 0 20px;
    border-bottom: 2px solid #f1f5f9;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.su-title-block {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}
.su-title-block h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }

.exo-intro {
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.65;
    padding: 14px 18px;
    background: #f8fafc;
    border-left: 4px solid var(--green);
    border-radius: 0 12px 12px 0;
    margin-bottom: 22px;
}

/* Feedback succès/erreur amélioré */
.su-success {
    display: block;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #15803d;
    border: 1.5px solid #86efac;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 12px;
}
.su-error {
    display: block;
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #fca5a5;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* ---- SIDEBAR COURS AMÉLIORÉE ---- */
.sidebar-item.active {
    font-weight: 700;
    border-left: 3px solid var(--green);
    padding-left: 9px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
    .exo-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .exo-card-body { padding: 12px 14px 16px; }
    .exo-anim-banner svg { height: 100px; }
}
@media (max-width: 400px) {
    .exo-grid { grid-template-columns: 1fr; }
}

/* --- Gradient animé hero h1 --- */
.gradient-text {
    background: linear-gradient(135deg, #16a34a, #22c55e, #059669, #16a34a);
    background-size: 300% 300%;
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    animation: gradientShift 4s ease infinite;
}
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Quiz progress bar shine --- */
.quiz-progress-bar > div {
    position: relative; overflow: hidden;
}
.quiz-progress-bar > div::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.35) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: barShine 1.8s linear infinite;
}
@keyframes barShine {
    from { background-position: -200% 0; }
    to   { background-position: 200% 0; }
}

/* --- Pulsation bouton primary au survol --- */
.btn-primary:active { transform: scale(0.97); }
.btn-full { width: 100%; }
#quiz-next.btn-quiz-next { display: none; }

/* --- Stats section compteurs --- */
.stat-num { transition: all 0.2s; }

/* ============================================================
   EXERCICES — Sélection
   ============================================================ */
.exo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    padding: 8px 0 32px;
}
.exo-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 28px 24px;
    display: flex; flex-direction: column; align-items: center;
    gap: 10px; text-align: center;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}
.exo-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.exo-card-icon { font-size: 2.6rem; line-height: 1; }
.exo-card h3   { font-size: 1.1rem; font-weight: 700; }
.exo-desc      { font-size: 0.82rem; color: #64748b; line-height: 1.5; }
.exo-diff {
    font-size: 0.75rem; font-weight: 700; padding: 3px 10px;
    border-radius: 20px; letter-spacing: .03em;
}
.diff-facile   { background: #dcfce7; color: #15803d; }
.diff-moyen    { background: #fef9c3; color: #a16207; }
.diff-difficile{ background: #fee2e2; color: #b91c1c; }

/* ============================================================
   EXERCICES — Jeu interactif
   ============================================================ */
.exo-card-subject { font-size: 0.72rem; font-weight: 700; color: #64748b; letter-spacing:.06em; text-transform:uppercase; }
.exo-card-sub     { font-size: 0.82rem; color: #64748b; font-style: italic; }

/* En-tête exercice */
.sudoku-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.su-title-block { display: flex; align-items: center; gap: 10px; flex: 1; }
.su-title-block h2 { font-size: 1.05rem; font-weight: 700; }

/* Intro */
.exo-intro {
    font-size: 0.88rem; color: #475569; background: #f0fdf4;
    border-left: 3px solid var(--green); border-radius: 6px;
    padding: 10px 14px; margin-bottom: 18px; line-height: 1.5;
}

/* Layout principal */
.exo-layout {
    display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;
}

/* SVG wraps */
.exo-svg-wrap {
    flex: 1 1 auto; overflow-x: auto; max-width: 100%;
}
.exo-table-svg, .exo-diagram-svg {
    width: 100%; height: auto; display: block;
    border-radius: 8px; box-shadow: 0 3px 18px rgba(0,0,0,0.08);
    -webkit-user-select: none; user-select: none; cursor: default;
    transition: opacity .12s;
}
.exo-cell { transition: fill .15s; }
.exo-zone { transition: fill .15s; }

/* Palette de réponses */
.exo-controls {
    display: flex; flex-direction: column; gap: 10px;
    min-width: 170px; max-width: 240px;
}
.su-tip { font-size: 0.78rem; color: #94a3b8; }
.exo-palette {
    display: flex; flex-direction: column; gap: 7px;
}
.exo-pal-btn {
    background: white; border: 2px solid #e2e8f0;
    border-radius: 10px; padding: 9px 12px;
    font-size: 0.9rem; font-weight: 600; color: #1e293b;
    cursor: pointer; text-align: left;
    transition: background .14s, border-color .14s, transform .1s;
}
.exo-pal-btn:hover  { background: #f0fdf4; border-color: var(--green); color: var(--green); }
.exo-pal-btn:active { transform: scale(0.96); }

/* Feedback */
.su-hint    { min-height: 30px; font-size: 0.87rem; text-align: center; padding-top: 4px; }
.su-success { color: #16a34a; font-weight: 700; }
.su-error   { color: #dc2626; font-weight: 600; }

@media (max-width: 680px) {
    .exo-layout   { flex-direction: column; }
    .exo-controls { max-width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .exo-palette  { flex-direction: row; flex-wrap: wrap; }
    .exo-pal-btn  { padding: 7px 10px; font-size: 0.82rem; }
}

/* ============================================================
   ADMIN — COURS
   ============================================================ */
.course-modal { max-width: 680px; }
.course-modal-body { max-height: 70vh; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.cm-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .cm-row2 { grid-template-columns: 1fr; } }
.cm-section-block { background: #f8fafc; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; border: 1px solid #e2e8f0; }
.label-hint { font-size: 0.75rem; color: #94a3b8; font-weight: 400; }
/* ---- Modal éditeur exercice ---- */
.exo-modal-box  { max-width: 700px; }
.exo-modal-body { max-height: 72vh; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.em-row-block   { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.em-row-inner   { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.em-del-row {
    flex-shrink: 0; margin-top: 26px;
    background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
    color: #ef4444; font-size: 0.85rem; padding: 6px 10px; cursor: pointer;
    transition: background .15s;
}
.em-del-row:hover { background: #fee2e2; }

.lesson-formula { background: #f0fdf4; border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 8px; font-family: monospace; font-size: 1rem; margin: 8px 0; color: #15803d; }
.lesson-tip { background: #fefce8; border-left: 4px solid #f59e0b; padding: 10px 14px; border-radius: 8px; font-size: 0.93rem; margin: 8px 0; color: #78350f; }

.btn-add-course {
    display: block; width: 100%; margin-top: 14px;
    padding: 10px 14px; border-radius: 10px;
    background: var(--green); color: white;
    font-weight: 700; font-size: 0.9rem;
    border: none; cursor: pointer;
    transition: background 0.18s, transform 0.12s;
}
.btn-add-course:hover { background: #15803d; transform: translateY(-1px); }
.btn-add-course:active { transform: scale(0.97); }

.admin-courses-list { display: flex; flex-direction: column; gap: 8px; }
.admin-course-row { display: flex; align-items: center; justify-content: space-between; background: white; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 16px; gap: 12px; }
.acr-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.acr-info .lc-icon { font-size: 1.4rem; flex-shrink: 0; }
.acr-info strong { display: block; font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acr-info small { color: #64748b; font-size: 0.78rem; }
.acr-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ============================================================
   PROFESSEUR IA — Widget flottant
   ============================================================ */
.ai-tutor-btn {
    position: fixed; bottom: 28px; right: 28px;
    width: 58px; height: 58px; border-radius: 50%;
    background: var(--green); color: white; border: none;
    font-size: 1.65rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(22,163,74,0.45);
    z-index: 500;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.ai-tutor-btn:hover { background: #15803d; transform: scale(1.08); box-shadow: 0 6px 28px rgba(22,163,74,0.55); }
.ai-tutor-btn.ai-btn-active { background: #15803d; transform: scale(1.06); }

.ai-tutor-panel {
    position: fixed; bottom: 100px; right: 28px;
    width: 360px; max-height: 530px;
    background: white; border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    display: flex; flex-direction: column;
    z-index: 500; overflow: hidden;
    border: 1px solid #e2e8f0;
    animation: aiPanelIn 0.22s cubic-bezier(.22,.68,0,1.2);
}
@keyframes aiPanelIn {
    from { opacity: 0; transform: scale(0.88) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ai-panel-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--green) 0%, #15803d 100%);
    color: white;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.ai-panel-title { display: flex; align-items: center; gap: 10px; }
.ai-avatar {
    font-size: 1.5rem; background: rgba(255,255,255,0.2); border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
}
.ai-panel-title strong { font-size: 0.95rem; font-weight: 700; display: block; }
.ai-panel-title small  { font-size: 0.75rem; opacity: 0.85; }
.ai-panel-hdr-btns { display: flex; gap: 5px; }
.ai-icon-btn {
    background: rgba(255,255,255,0.15); border: none; color: white;
    width: 30px; height: 30px; border-radius: 8px; font-size: 0.82rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.ai-icon-btn:hover { background: rgba(255,255,255,0.3); }

.ai-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 140px;
}
.ai-welcome { text-align: center; padding: 18px 10px; color: #64748b; }
.ai-welcome-icon { font-size: 2.4rem; margin-bottom: 10px; }
.ai-welcome p { font-size: 0.875rem; line-height: 1.55; }

.ai-msg { display: flex; gap: 7px; align-items: flex-end; }
.ai-msg-user { flex-direction: row-reverse; }
.ai-msg-icon { font-size: 1.15rem; flex-shrink: 0; margin-bottom: 2px; }
.ai-msg-bubble {
    max-width: 80%; padding: 9px 13px;
    border-radius: 14px; font-size: 0.865rem; line-height: 1.5;
}
.ai-msg-bot  .ai-msg-bubble { background: #f1f5f9; color: #1e293b; border-bottom-left-radius: 4px; }
.ai-msg-user .ai-msg-bubble { background: var(--green); color: white; border-bottom-right-radius: 4px; }

.ai-typing { display: flex; gap: 4px; align-items: center; padding: 11px 14px !important; }
.ai-typing span {
    width: 7px; height: 7px; background: #94a3b8; border-radius: 50%;
    animation: aiDot 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.ai-config {
    padding: 13px 15px; background: #f8fafc;
    border-top: 1px solid #e2e8f0; flex-shrink: 0;
}
.ai-config > p { font-size: 0.84rem; color: #475569; margin-bottom: 8px; }
.ai-config input {
    width: 100%; padding: 8px 11px;
    border: 1px solid #e2e8f0; border-radius: 9px;
    font-size: 0.85rem; background: white;
}
.ai-config input:focus { outline: none; border-color: var(--green); }
.ai-config-btns { display: flex; gap: 8px; margin-top: 8px; }
.ai-config-btns .btn-primary,
.ai-config-btns .btn-secondary { flex: 1; padding: 9px 12px; font-size: 0.88rem; }
.ai-key-hint { margin-top: 8px !important; font-size: 0.75rem !important; color: #94a3b8 !important; }

.ai-input-area {
    display: flex; gap: 8px; align-items: flex-end;
    padding: 10px 12px; border-top: 1px solid #e2e8f0;
    flex-shrink: 0; background: white;
}
.ai-input-area textarea {
    flex: 1; border: 1px solid #e2e8f0; border-radius: 11px;
    padding: 8px 11px; font-size: 0.87rem; resize: none;
    font-family: inherit; line-height: 1.45; max-height: 100px;
    transition: border-color 0.15s;
}
.ai-input-area textarea:focus { outline: none; border-color: var(--green); }
.ai-send-btn {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--green); color: white; border: none;
    font-size: 1.1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background 0.15s, transform 0.12s;
}
.ai-send-btn:hover { background: #15803d; transform: translateY(-1px); }
.ai-send-btn:active { transform: scale(0.95); }

/* Bouton aide rapide après vérification exercice */
.ai-help-inline-btn {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 8px; padding: 7px 14px;
    background: var(--green-bg); color: var(--green);
    border: 1px solid var(--green); border-radius: 8px;
    font-size: 0.82rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s;
}
.ai-help-inline-btn:hover { background: #dcfce7; }

@media (max-width: 500px) {
    .ai-tutor-panel { width: calc(100vw - 24px); right: 12px; bottom: 88px; max-height: 58vh; }
    .ai-tutor-btn { bottom: 20px; right: 12px; width: 52px; height: 52px; font-size: 1.45rem; }
}

/* ============================================================
   MATIÈRES — Hero, grille, cartes
   ============================================================ */
#view-matieres, #view-matiere-detail, #view-espaces {
    padding-bottom: 60px;
}

/* Hero */
.mat-hero {
    position: relative; overflow: hidden;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    color: white; padding: 60px 24px 50px; text-align: center;
}
.mat-hero-bg {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 70% 40%, rgba(255,255,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.mat-hero-content { position: relative; z-index: 1; max-width: 700px; margin: 0 auto; }
.mat-hero-badge {
    display: inline-block; background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25); border-radius: 20px;
    padding: 4px 14px; font-size: 0.82rem; font-weight: 600;
    margin-bottom: 18px; letter-spacing: 0.3px;
}
.mat-hero-content h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800; margin-bottom: 12px; line-height: 1.2; }
.mat-hero-content p { font-size: 1rem; opacity: 0.88; margin-bottom: 28px; line-height: 1.55; }
.mat-gradient-text {
    background: linear-gradient(90deg, #93c5fd, #c4b5fd);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.mat-hero-stats { display: flex; justify-content: center; gap: 32px; flex-wrap: wrap; }
.mat-hs { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mat-hs strong { font-size: 1.6rem; font-weight: 800; }
.mat-hs span { font-size: 0.78rem; opacity: 0.75; }

/* Search */
.mat-search-wrap { max-width: 600px; margin: -24px auto 0; padding: 0 20px; position: relative; z-index: 2; }
.mat-search-box {
    display: flex; align-items: center; gap: 8px;
    background: white; border-radius: 14px;
    padding: 10px 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    border: 1px solid #e2e8f0;
}
.mat-search-box input {
    flex: 1; border: none; outline: none; font-size: 0.95rem;
    color: #1e293b; background: transparent;
}
.mat-search-icon { font-size: 1rem; color: #94a3b8; }
.mat-search-clear {
    background: none; border: none; color: #94a3b8; font-size: 0.9rem;
    padding: 2px 6px; border-radius: 6px; cursor: pointer;
}
.mat-search-clear:hover { color: #64748b; background: #f1f5f9; }
.mat-count { text-align: center; margin-top: 10px; font-size: 0.82rem; color: #64748b; }

/* Category filter */
.mat-cats {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
    padding: 28px 20px 0;
}
.mat-cat-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 24px; border: 1.5px solid #e2e8f0;
    background: white; color: #475569; font-size: 0.85rem; font-weight: 500;
    transition: all 0.18s;
}
.mat-cat-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.mat-cat-btn.active { background: #2563eb; color: white; border-color: #2563eb; }

/* Grid */
.mat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 20px; padding: 28px 20px;
    max-width: 1200px; margin: 0 auto;
}
.mat-empty { grid-column: 1/-1; text-align: center; color: #94a3b8; font-size: 1rem; padding: 48px; }

/* Card */
.mat-card {
    background: white; border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); transition: transform 0.18s, box-shadow 0.18s;
    display: flex; flex-direction: column;
    opacity: 0; transform: translateY(18px);
}
.mat-card.visible { opacity: 1; transform: none; transition: opacity 0.4s ease, transform 0.4s ease; }
.mat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.mat-card-header {
    padding: 24px 20px 16px; display: flex; align-items: flex-start;
    justify-content: space-between; cursor: pointer;
}
.mat-icon { font-size: 2.2rem; }
.mat-cat-tag {
    font-size: 0.72rem; font-weight: 600; color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.2); border-radius: 10px; padding: 3px 9px;
}
.mat-card-body { padding: 16px 20px; flex: 1; }
.mat-card-body h3 { font-size: 1.1rem; font-weight: 700; color: #1e293b; margin-bottom: 6px; }
.mat-card-body p { font-size: 0.84rem; color: #64748b; line-height: 1.5; margin-bottom: 10px; }
.mat-niveaux { display: flex; gap: 6px; flex-wrap: wrap; }
.mat-niv {
    font-size: 0.72rem; font-weight: 600; padding: 3px 9px;
    border-radius: 10px; background: #f1f5f9; color: #475569;
}
.mat-niv-white { background: rgba(255,255,255,0.25); color: white; }
.mat-card-footer {
    padding: 12px 20px 16px; display: flex; gap: 8px;
    border-top: 1px solid #f1f5f9;
}
.mat-btn-prog {
    flex: 1; padding: 8px; border-radius: 9px; border: 1.5px solid #e2e8f0;
    background: white; color: #475569; font-size: 0.82rem; font-weight: 500;
    transition: all 0.15s;
}
.mat-btn-prog:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.mat-btn-cours { flex: 1; font-size: 0.82rem; }

/* Scroll reveal */
.reveal { opacity: 0; transform: translateY(16px); }
.reveal.visible { opacity: 1; transform: none; transition: opacity 0.45s ease, transform 0.45s ease; }

/* ============================================================
   MATIÈRE — Détail (onglets)
   ============================================================ */
.mat-detail-hero {
    padding: 40px 24px 32px; color: white;
}
.mat-back-btn {
    display: inline-block; background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3); color: white;
    padding: 6px 14px; border-radius: 8px; font-size: 0.84rem;
    margin-bottom: 20px; transition: background 0.15s;
}
.mat-back-btn:hover { background: rgba(255,255,255,0.28); }
.mat-detail-header { display: flex; align-items: flex-start; gap: 20px; }
.mat-detail-icon { font-size: 3rem; flex-shrink: 0; }
.mat-detail-cat { font-size: 0.78rem; font-weight: 600; opacity: 0.8; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.mat-detail-hero h1 { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; margin-bottom: 6px; }
.mat-detail-hero p { font-size: 0.9rem; opacity: 0.85; line-height: 1.5; }

.mat-detail-tabs {
    display: flex; gap: 0; overflow-x: auto; border-bottom: 2px solid #e2e8f0;
    background: white; position: sticky; top: var(--header-h); z-index: 10;
    padding: 0 16px;
}
.mat-detail-tab {
    padding: 14px 16px; font-size: 0.84rem; font-weight: 500; white-space: nowrap;
    border: none; background: none; color: #64748b;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.mat-detail-tab:hover { color: #2563eb; }
.mat-detail-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.mat-detail-content { max-width: 900px; margin: 0 auto; padding: 28px 20px; }

/* Programme tab */
.mat-prog-niveaux { display: flex; gap: 8px; margin-bottom: 20px; }
.mat-prog-niv-btn {
    padding: 7px 16px; border-radius: 20px; border: 1.5px solid #e2e8f0;
    background: white; color: #475569; font-size: 0.84rem; font-weight: 500;
    transition: all 0.15s;
}
.mat-prog-niv-btn.active { background: #2563eb; color: white; border-color: #2563eb; }
.mat-prog-item {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 16px; background: white; border-radius: 10px;
    border: 1px solid #e2e8f0; margin-bottom: 10px;
}
.mat-prog-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: #eff6ff; color: #2563eb;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
}

/* Ressources tab */
.mat-ressources h3, .mat-videos h3, .mat-devoirs h3,
.mat-quiz-section h3, .mat-dl-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.mat-res-grid { display: flex; flex-direction: column; gap: 10px; }
.mat-res-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; background: white; border-radius: 10px;
    border: 1px solid #e2e8f0;
}
.mat-res-icon { font-size: 1.6rem; }
.mat-res-info { flex: 1; }
.mat-res-info strong { display: block; font-size: 0.9rem; font-weight: 600; color: #1e293b; }
.mat-res-info span { font-size: 0.78rem; color: #94a3b8; }
.mat-res-dl {
    background: #eff6ff; border: none; border-radius: 8px;
    width: 36px; height: 36px; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.mat-res-dl:hover { background: #dbeafe; }
.mat-empty-small { color: #94a3b8; font-size: 0.88rem; text-align: center; padding: 24px; }

/* Vidéos tab */
.mat-vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mat-vid-card { background: white; border-radius: 10px; overflow: hidden; border: 1px solid #e2e8f0; }
.mat-vid-thumb {
    height: 120px; display: flex; align-items: center; justify-content: center;
    position: relative;
}
.mat-vid-play { font-size: 2rem; color: white; }
.mat-vid-dur {
    position: absolute; bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.65); color: white;
    font-size: 0.72rem; padding: 2px 7px; border-radius: 5px;
}
.mat-vid-info { padding: 10px 12px; }
.mat-vid-info strong { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.mat-vid-notice { margin-top: 16px; padding: 12px 16px; background: #fffbeb; border-radius: 9px; font-size: 0.83rem; color: #92400e; }

/* Devoirs tab */
.mat-login-prompt { text-align: center; padding: 40px; color: #64748b; font-size: 0.9rem; }
.mat-login-prompt a { color: #2563eb; font-weight: 600; }
.mat-devoir-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; background: white; border-radius: 10px;
    border: 1px solid #e2e8f0; margin-bottom: 10px;
}
.mat-devoir-item.rendu { opacity: 0.6; }
.mat-dv-status { font-size: 1.2rem; }
.mat-dv-info { flex: 1; }
.mat-dv-info strong { display: block; font-size: 0.88rem; font-weight: 600; }
.mat-dv-info span { font-size: 0.78rem; color: #94a3b8; }
.mat-dv-badge { font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 10px; }
.badge-ok { background: #dcfce7; color: #16a34a; }
.badge-todo { background: #fff7ed; color: #ea580c; }

/* Quiz tab */
.mat-quiz-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.mat-quiz-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: white; border-radius: 10px; border: 1px solid #e2e8f0;
    font-size: 0.9rem;
}
.mat-quiz-cta { margin-top: 16px; text-align: center; }

/* Téléchargement tab */
.mat-dl-grid { display: flex; flex-direction: column; gap: 12px; }
.mat-dl-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; background: white; border-radius: 10px; border: 1px solid #e2e8f0;
}
.mat-dl-icon { font-size: 1.8rem; }
.mat-dl-card div { flex: 1; }
.mat-dl-card strong { display: block; font-size: 0.9rem; font-weight: 600; }
.mat-dl-card span { font-size: 0.78rem; color: #94a3b8; }
.mat-dl-btn {
    padding: 7px 14px; border-radius: 8px; border: 1.5px solid #e2e8f0;
    background: white; color: #475569; font-size: 0.83rem; transition: all 0.15s;
}
.mat-dl-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.mat-dl-notice { margin-top: 16px; padding: 12px 16px; background: #eff6ff; border-radius: 9px; font-size: 0.83rem; color: #1e40af; }

/* ============================================================
   ESPACES UTILISATEURS
   ============================================================ */
.esp-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white; padding: 48px 24px 36px; text-align: center;
}
.esp-hero-content h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; margin-bottom: 8px; }
.esp-hero-content p { opacity: 0.75; font-size: 0.95rem; }

.esp-tabs-bar {
    display: flex; gap: 0; border-bottom: 2px solid #e2e8f0;
    background: white; position: sticky; top: var(--header-h); z-index: 10;
    padding: 0 20px; overflow-x: auto;
}
.esp-tab {
    padding: 14px 20px; font-size: 0.88rem; font-weight: 500;
    border: none; background: none; color: #64748b; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.esp-tab:hover { color: #1e293b; }
.esp-tab.active { color: #1e293b; border-bottom-color: #1e293b; font-weight: 700; }

#esp-content { max-width: 960px; margin: 0 auto; padding: 28px 20px; }

.esp-login-prompt { display: flex; justify-content: center; align-items: center; min-height: 260px; }
.esp-login-card {
    text-align: center; background: white; border-radius: var(--radius);
    padding: 40px; box-shadow: var(--shadow); max-width: 400px; width: 100%;
}
.esp-login-card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.esp-login-card p { color: #64748b; font-size: 0.88rem; }

.esp-dashboard { display: flex; flex-direction: column; gap: 20px; }
.esp-welcome {
    display: flex; align-items: center; gap: 16px;
    background: white; border-radius: var(--radius); padding: 20px 24px;
    box-shadow: var(--shadow);
}
.esp-welcome h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.esp-welcome p { color: #64748b; font-size: 0.85rem; }

.esp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.esp-kpi {
    background: white; border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow); text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.esp-kpi-icon { font-size: 1.4rem; margin-bottom: 4px; }
.esp-kpi strong { font-size: 1.5rem; font-weight: 800; color: #1e293b; }
.esp-kpi small { font-size: 0.75rem; color: #64748b; }

.esp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .esp-cols { grid-template-columns: 1fr; } }

.esp-card {
    background: white; border-radius: var(--radius);
    padding: 20px 22px; box-shadow: var(--shadow);
}
.esp-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: #1e293b; }

.esp-notes-list { display: flex; flex-direction: column; gap: 10px; }
.esp-note-row { display: flex; align-items: center; gap: 10px; }
.esp-note-mat { width: 120px; font-size: 0.8rem; color: #475569; flex-shrink: 0; }
.esp-note-bar-wrap { flex: 1; height: 7px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.esp-note-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.esp-note-val { font-size: 0.8rem; font-weight: 700; width: 42px; text-align: right; flex-shrink: 0; }

.esp-edt { display: flex; flex-direction: column; gap: 10px; }
.esp-edt-jour { }
.esp-edt-day { font-size: 0.78rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.esp-edt-cours { display: flex; flex-direction: column; gap: 4px; }
.esp-cours-item {
    display: flex; gap: 8px; align-items: center;
    background: #f8fafc; border-radius: 7px; padding: 6px 10px; font-size: 0.78rem;
}
.esp-cours-h { color: #94a3b8; width: 72px; flex-shrink: 0; }
.esp-cours-mat { flex: 1; font-weight: 600; color: #1e293b; }
.esp-cours-salle { color: #94a3b8; font-size: 0.72rem; }

.esp-msgs { }
.esp-msg-list { display: flex; flex-direction: column; gap: 0; }
.esp-msg-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid #f1f5f9;
}
.esp-msg-item:last-child { border-bottom: none; }
.esp-msg-dot { width: 8px; height: 8px; border-radius: 50%; background: #2563eb; flex-shrink: 0; }
.esp-msg-dot.lu { background: #e2e8f0; }
.esp-msg-content { flex: 1; }
.esp-msg-content strong { display: block; font-size: 0.85rem; font-weight: 600; color: #1e293b; }
.esp-msg-content span { font-size: 0.78rem; color: #64748b; }
.esp-msg-date { font-size: 0.72rem; color: #94a3b8; white-space: nowrap; }
.esp-msg-item.non-lu .esp-msg-content strong { color: #1e40af; }

.esp-prof-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.esp-action-btn {
    padding: 14px; border-radius: 10px; border: 1.5px solid #e2e8f0;
    background: white; color: #475569; font-size: 0.88rem; font-weight: 500;
    box-shadow: var(--shadow); transition: all 0.15s; text-align: left;
}
.esp-action-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }

/* ============================================================
   RESPONSIVE MATIÈRES
   ============================================================ */
@media (max-width: 640px) {
    .mat-hero { padding: 48px 16px 36px; }
    .mat-detail-header { flex-direction: column; gap: 10px; }
    .mat-detail-tabs { padding: 0 8px; }
    .mat-detail-tab { padding: 12px 10px; font-size: 0.78rem; }
    .mat-grid { grid-template-columns: 1fr 1fr; gap: 12px; padding: 20px 12px; }
    .mat-vid-grid { grid-template-columns: 1fr; }
    .esp-kpis { grid-template-columns: 1fr 1fr; }
    .esp-note-mat { width: 90px; }
}
@media (max-width: 400px) {
    .mat-grid { grid-template-columns: 1fr; }
}

