:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ko: #dc2626;
  --ko-soft: #fee2e2;
  --wip: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 18px; color: var(--ink); letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.chip-pseudo { background: #f1f5f9; color: var(--muted); }

/* Layout */
.wrap { max-width: 820px; margin: 0 auto; padding: 28px 20px 56px; }
.page-title { font-size: 26px; margin: 6px 0 4px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.back { display: inline-block; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.kind-tag {
  display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 6px; font-weight: 700;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Cards & forms */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-narrow { max-width: 420px; margin: 8vh auto 0; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.code-input { text-align: center; font-family: ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.error { color: var(--ko); background: var(--ko-soft); padding: 8px 12px; border-radius: 8px; font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: #f1f5f9; color: var(--ink);
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-done { background: var(--ok-soft); color: var(--ok); }
.link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.inline { display: inline; }

/* Progress bar */
.bar { height: 8px; background: #eef0f5; border-radius: 999px; overflow: hidden; min-width: 90px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* Course grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.course {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); color: var(--ink);
}
.course:hover { text-decoration: none; border-color: #c7d2fe; transform: translateY(-1px); transition: .15s; }
.course-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.course-head h2 { font-size: 17px; margin: 0; }
.course-meta { font-size: 13px; color: var(--muted); }

/* Module list */
.modules { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.module {
  display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: var(--ink);
}
.module:hover { text-decoration: none; border-color: #c7d2fe; }
.module-badge {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: #f1f5f9; color: var(--muted);
}
.module-done .module-badge { background: var(--ok-soft); color: var(--ok); }
.module-wip .module-badge { background: #fef3c7; color: var(--wip); }
.module-main { display: flex; flex-direction: column; }
.module-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.module-title { font-weight: 600; }
.score { margin-left: auto; font-family: ui-monospace, monospace; font-size: 13px; color: var(--accent); font-weight: 700; }

/* Prose (lesson content) */
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.prose h3 { margin: 18px 0 6px; font-size: 16px; }
.prose ul { padding-left: 20px; }
.prose code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.callout { border-radius: 10px; padding: 12px 16px; margin: 16px 0; font-size: 15px; }
.callout-info { background: var(--accent-soft); border-left: 3px solid var(--accent); }

/* H5P slot + reveal */
.h5p-slot { border: 2px dashed #c7d2fe; border-radius: 12px; padding: 16px; margin: 16px 0; background: #fafaff; }
.h5p-slot-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.reveal-card { margin: 16px 0; }
.reveal-btn { background: #f1f5f9; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--ink); }
.reveal-body { margin-top: 10px; padding: 12px 16px; background: var(--ok-soft); border-radius: 10px; }

/* Actions / nav */
.actions { margin-top: 18px; }
.seance-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; }

/* Quiz */
.quiz { display: flex; flex-direction: column; gap: 14px; }
.q { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0; background: var(--surface); }
.q legend { font-weight: 600; padding: 0 6px; }
.q-ok { border-color: var(--ok); background: var(--ok-soft); }
.q-ko { border-color: var(--ko); background: var(--ko-soft); }
.choice { display: flex; align-items: center; gap: 10px; padding: 7px 4px; cursor: pointer; }
.choice-correct { font-weight: 700; color: var(--ok); }
.quiz-result { display: flex; align-items: center; gap: 16px; font-size: 18px; padding: 12px 0; }
.quiz-result.all-good strong { color: var(--ok); }

/* Dashboard */
.table-scroll { overflow-x: auto; }
.dash { width: 100%; border-collapse: collapse; font-size: 14px; }
.dash th, .dash td { border: 1px solid var(--line); padding: 8px 10px; text-align: center; }
.dash thead th { background: #f8fafc; font-weight: 700; }
.dash .row-h, .dash tbody .row-h { text-align: left; font-weight: 600; background: #fcfcfd; }
.cell-done { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.cell-wip { background: #fef3c7; color: var(--wip); }
.cell-todo { color: var(--muted); }

/* Footer */
.foot { max-width: 820px; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }

/* Activités interactives (subnet explorer, etc.) */
.activite { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.subnet-controls { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; margin: 14px 0 18px; }
.subnet-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.subnet-controls input[type="range"] { width: 220px; accent-color: var(--accent); }
.subnet-controls .input { max-width: 220px; font-family: ui-monospace, monospace; }
.subnet-bin { font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: .04em; background: #0f172a; padding: 14px 16px; border-radius: 10px; overflow-x: auto; white-space: nowrap; }
.subnet-bin .octet { display: inline-block; }
.subnet-bin .dot { color: #475569; padding: 0 4px; font-style: normal; }
.b-net { color: var(--accent); font-weight: 700; }
.b-host { color: #0284c7; }
.subnet-bin .b-net { color: #818cf8; }
.subnet-bin .b-host { color: #38bdf8; font-weight: 400; }
.subnet-legend { font-size: 13px; color: var(--muted); margin: 10px 2px 14px; }
.subnet-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.subnet-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line); width: 45%; }
.subnet-table td { font-family: ui-monospace, monospace; padding: 7px 10px; border-bottom: 1px solid var(--line); }

/* Espace prof — back-office */
.prof-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.prof-tabs { display: flex; gap: 4px; }
.prof-tab { padding: 10px 16px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.prof-tab:hover { text-decoration: none; color: var(--ink); }
.prof-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.dash-left th, .dash-left td { text-align: left; }
.link-danger { color: var(--ko); font-weight: 600; }
.acces-gen { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.acces-gen select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 18px 0; }
.code-card { border: 1px dashed #94a3b8; border-radius: 10px; padding: 14px; text-align: center; background: #fff; }
.code-cls { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.code-val { font-family: ui-monospace, monospace; font-size: 18px; font-weight: 700; margin: 8px 0; color: #1e1b4b; }
.code-url { font-size: 11px; color: var(--accent); }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .page-title { font-size: 22px; }
  .subnet-bin { font-size: 15px; }
}
@media print { .prof-bar, .callout, .actions, .topbar, .foot { display: none; } .code-card { break-inside: avoid; } }
