:root {
  --brand: #7c3aed;
  --brand-2: #6d28d9;
  --brand-soft: #ede9fe;
  --accent: #f59e0b;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --ok: #059669;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: transform .1s, box-shadow .2s, background .2s;
  text-decoration: none;
}
.btn:hover { background: var(--brand-2); box-shadow: 0 6px 18px rgba(124, 58, 237, .3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); box-shadow: none; }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; color: var(--ink); background: #fff; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 90px; }

/* ---------- Cartes ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }

/* ---------- Grille ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand);
}
.badge.ok { background: #d1fae5; color: var(--ok); }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.gray { background: #e2e8f0; color: var(--muted); }

/* ---------- Layout application ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #fff; border-right: 1px solid var(--line);
  padding: 20px 14px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar .brand { font-size: 20px; font-weight: 800; color: var(--brand); margin-bottom: 20px; padding: 0 8px; }
.sidebar .brand span { color: var(--ink); }
.nav-item { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 10px; border: none; background: none; color: var(--ink); font-size: 15px; font-weight: 500; cursor: pointer; margin-bottom: 4px; }
.nav-item:hover { background: #f1f5f9; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.content { flex: 1; padding: 28px; max-width: 1000px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 12px; }
.topbar h1 { font-size: 22px; margin: 0; }

.mobile-nav { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-nav {
    display: flex; background: #fff; border-bottom: 1px solid var(--line);
    padding: 10px 14px; gap: 6px; overflow-x: auto; position: sticky; top: 0; z-index: 20;
  }
  .mobile-nav button { white-space: nowrap; }
  .content { padding: 18px 14px; }
}

/* ---------- Landing ---------- */
.landing-body { background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%); min-height: 100vh; }
.landing { max-width: 520px; margin: 0 auto; padding: 48px 20px; }
.landing-hero { text-align: center; color: #fff; margin-bottom: 28px; }
.landing-hero h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 8px; }
.landing-hero h1 span { color: #fbbf24; }
.landing-hero p { font-size: 17px; opacity: .92; margin: 0 auto; max-width: 420px; }
.landing .card { border-radius: 18px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tabs button { flex: 1; padding: 11px; border: none; background: #f1f5f9; color: var(--muted); border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--brand); color: #fff; }

.mini-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.mini-badges span { background: rgba(255,255,255,.16); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; backdrop-filter: blur(4px); }

/* ---------- Cours ---------- */
.course-card { cursor: pointer; transition: transform .15s, box-shadow .2s; position: relative; }
.course-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(15,23,42,.1); }
.course-cover { height: 130px; background: linear-gradient(135deg, var(--brand), #4f46e5); border-radius: 10px; margin: -20px -20px 14px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 40px; }
.course-meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ---------- Leçons / progression ---------- */
.lesson-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.lesson-item .ico { width: 34px; height: 34px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lesson-item.done .ico { background: #d1fae5; color: var(--ok); }
.progress-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }

/* ---------- Statistiques ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 28px; font-weight: 800; color: var(--brand); }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }

/* ---------- Divers ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt-2 { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.error-banner { background: #fee2e2; color: var(--danger); padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.success-banner { background: #d1fae5; color: var(--ok); padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.spinner { border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; width: 24px; height: 24px; animation: spin .7s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.code-display {
  font-size: 30px; letter-spacing: 6px; font-weight: 800; text-align: center;
  color: var(--brand); background: var(--brand-soft); padding: 18px; border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Ecole (vitrine publique) ---------- */
.ecole-body { background: #f5f3ff; }
.ecole-hero { background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; padding: 42px 20px; text-align: center; }
.ecole-hero h1 { font-size: 2rem; margin-bottom: 6px; }
.ecole-wrap { max-width: 900px; margin: -24px auto 40px; padding: 0 18px; }

@media (max-width: 600px) {
  .landing-hero h1 { font-size: 1.9rem; }
  .topbar h1 { font-size: 19px; }
}
