:root {
    --bg: #f5f6fb;
    --card: #ffffff;
    --ink: #1c2033;
    --muted: #666d85;
    --line: #e2e5f0;
    --brand: #4f46e5;
    --brand-dark: #3730a3;
    --accent: #f59e0b;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 8px 24px rgba(20, 24, 50, .06);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 60px; min-height: 70vh; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.4rem; margin: 1.4em 0 .5em; }
h3 { font-size: 1.1rem; margin: 1.2em 0 .4em; }
.muted { color: var(--muted); }

/* En-tête */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { font-weight: 800; font-size: 1.1rem; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.logo { background: var(--brand); color: #fff; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: .8rem; }
.topbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: var(--ink); font-weight: 500; }
.topbar nav a.btn { color: #fff; }
.topbar nav a.btn.ghost { color: var(--ink); }
.who { color: var(--muted); font-size: .9rem; }
.foot { border-top: 1px solid var(--line); padding: 22px 0; color: var(--muted); font-size: .9rem; background: #fff; }

/* Boutons */
.btn {
    display: inline-block; border: 0; cursor: pointer; font: inherit; font-weight: 600;
    background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 10px; text-decoration: none;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 6px 12px; font-size: .88rem; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #7f1d1d; }
.btn.ok { background: var(--ok); }
.btn.block { display: block; width: 100%; text-align: center; }
form.inline { display: inline; }

/* Alertes */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-weight: 500; }
.alert.info { background: #e0e7ff; color: #312e81; }
.alert.success { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--bad-bg); color: var(--bad); }

/* Cartes */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.course-card { display: flex; flex-direction: column; gap: 10px; padding: 0; overflow: hidden; }
.course-card .cover { height: 120px; background: linear-gradient(135deg, var(--brand), #7c3aed 60%, var(--accent)); display: grid; place-items: center; font-size: 2.6rem; }
.course-card .body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.course-card h3 { margin: 0; font-size: 1.15rem; }
.course-card p { margin: 0; color: var(--muted); font-size: .94rem; flex: 1; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: #eef0ff; color: var(--brand-dark); padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }

.hero { background: linear-gradient(135deg, #1e1b4b, var(--brand) 70%); color: #fff; border-radius: 22px; padding: 44px 36px; margin-bottom: 30px; }
.hero h1 { color: #fff; font-size: 2.2rem; }
.hero p { max-width: 640px; color: #dfe2ff; margin: 0 0 18px; }
.search { display: flex; gap: 10px; max-width: 520px; }
.search input { flex: 1; }

/* Formulaires */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 120px; resize: vertical; }
textarea.big { min-height: 320px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92rem; }
.hint { color: var(--muted); font-size: .86rem; margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.form-narrow { max-width: 440px; margin: 20px auto; }
.actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; align-items: center; }

/* Barres de progression */
.bar-track { background: #e6e8f5; height: 9px; border-radius: 99px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--brand), #7c3aed); height: 100%; border-radius: 99px; transition: width .4s; }

/* Page formation */
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.outline details { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fff; }
.outline summary { cursor: pointer; padding: 14px 18px; font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.outline ul { list-style: none; margin: 0; padding: 0 18px 12px; }
.outline li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.outline li .t { flex: 1; }
.outline li .dur { color: var(--muted); font-size: .85rem; }
.done-mark { color: var(--ok); font-weight: 700; }
.goals { padding-left: 20px; }

/* Leçon */
.lesson-layout { display: grid; grid-template-columns: 300px 1fr; gap: 26px; align-items: start; }
.side { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.side h4 { margin: 14px 0 6px; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.side a { display: flex; gap: 8px; padding: 6px 8px; border-radius: 8px; color: var(--ink); font-size: .93rem; }
.side a:hover { background: var(--bg); text-decoration: none; }
.side a.current { background: #eef0ff; color: var(--brand-dark); font-weight: 700; }
.lesson-body { font-size: 1.04rem; }
.lesson-body h2:first-child { margin-top: 0; }
.lesson-body code { background: #eef0ff; padding: 1px 6px; border-radius: 5px; font-size: .92em; }
pre.code { position: relative; background: #12142b; color: #e6e8ff; padding: 18px 20px; border-radius: 12px; overflow: auto; font-size: .9rem; line-height: 1.55; }
pre.code[data-lang]::before { content: attr(data-lang); position: absolute; top: 6px; right: 12px; color: #8b90c4; font-size: .72rem; text-transform: uppercase; }
pre.code code { background: none; padding: 0; color: inherit; }
.media { margin: 0 0 22px; }
.media img, .media video { max-width: 100%; border-radius: 12px; display: block; }
.media audio { width: 100%; }
.media.ratio { position: relative; padding-top: 56.25%; }
.media.ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 12px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; flex-wrap: wrap; align-items: center; }

/* Quiz */
.q { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; background: #fff; }
.q h3 { margin-top: 0; }
.opt { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); margin: 8px 0; cursor: pointer; font-weight: 500; }
.opt:hover { border-color: var(--brand); }
.opt input { width: auto; }
.opt.right { background: var(--ok-bg); border-color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.score { font-size: 2.2rem; font-weight: 800; }
.expl { font-size: .93rem; color: var(--muted); margin-top: 8px; }

/* Tableaux & admin */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f0f2fb; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.9rem; }
.subnav { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.subnav a.on { color: var(--brand-dark); border-color: var(--brand); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.num { width: 80px !important; }

/* Certificat */
.cert { max-width: 860px; margin: 20px auto; background: #fff; border: 10px double var(--brand); padding: 60px 40px; text-align: center; border-radius: 6px; }
.cert h1 { font-size: 2.6rem; color: var(--brand-dark); letter-spacing: .06em; text-transform: uppercase; }
.cert .name { font-size: 2.2rem; font-weight: 800; margin: 18px 0; border-bottom: 2px solid var(--accent); display: inline-block; padding: 0 30px 6px; }

@media (max-width: 860px) {
    .two-col, .lesson-layout { grid-template-columns: 1fr; }
    .side { position: static; max-height: none; }
    .row { grid-template-columns: 1fr; }
    .hero { padding: 30px 22px; }
    .bar { height: auto; padding: 10px 20px; flex-wrap: wrap; }
}
@media print {
    .topbar, .foot, .no-print { display: none !important; }
    body { background: #fff; }
    .cert { border-width: 8px; margin: 0; }
}
