:root {
  --bg: #f5f6f8; --surface: #fff; --text: #16191f; --muted: #6b7280; --line: #e3e6eb;
  --accent: #3b5bdb; --accent-soft: #e7ecfd; --good: #1f7a4d; --good-soft: #def3e8; --bad: #b42318; --bad-soft: #fde7e5;
  --warn: #8a5a00; --warn-soft: #fbf0d4; --code: #f0f2f5;
  --t-it: #3b5bdb; --t-linux: #c2410c; --t-python: #0f766e; --t-scen: #7c3aed;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #1a1d23; --text: #e8eaee; --muted: #9aa1ad; --line: #2c3038;
    --accent: #7c95f5; --accent-soft: #232b45; --good: #5fd39a; --good-soft: #17301f; --bad: #f2877d; --bad-soft: #3a1f1d;
    --warn: #e9c46a; --warn-soft: #33291a; --code: #23272f;
    --t-it: #7c95f5; --t-linux: #f08a4b; --t-python: #4fd1c5; --t-scen: #b794f6;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; align-items: baseline; gap: 14px; max-width: 900px; margin: 0 auto; padding: 18px 16px 6px; }
.brand { font-weight: 800; font-size: 1.3rem; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.brand span { color: var(--accent); font-weight: 600; }
main { max-width: 900px; margin: 0 auto; padding: 8px 16px 80px; }
h1 { font-size: 1.5rem; margin: 12px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 18px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 14px; }
a { color: var(--accent); }

button, .btn { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 10px 16px; text-decoration: none; display: inline-block; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.danger { color: var(--bad); border-color: var(--bad); }
.ghost { background: none; border-color: transparent; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

/* Accueil */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.mode { text-align: left; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.mode:hover { border-color: var(--accent); }
.mode b { display: block; font-size: 1.25rem; margin-bottom: 4px; }
.mode .ico { font-size: 2rem; display: block; margin-bottom: 8px; }

/* Choix */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 8px 14px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip .n { color: var(--muted); font-weight: 400; font-size: .85em; margin-left: 4px; }
input[type=number], input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
input[type=number] { width: 90px; }
textarea { width: 100%; min-height: 260px; resize: vertical; line-height: 1.5; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }

/* Quiz */
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; color: #fff; }
.tag.it_and_security { background: var(--t-it); } .tag.linux { background: var(--t-linux); }
.tag.python { background: var(--t-python); } .tag.situational_scenarios { background: var(--t-scen); }
.tag.src { background: var(--muted); }
.question { font-size: 1.12rem; font-weight: 600; margin: 12px 0 16px; }
.question pre { font-weight: 400; }
.options { display: grid; gap: 10px; }
.opt { text-align: left; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; line-height: 1.4; }
.opt .k { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line); font-size: .85rem; font-weight: 700; color: var(--muted); }
.opt.good { background: var(--good-soft); border-color: var(--good); }
.opt.good .k { background: var(--good); color: #fff; border-color: var(--good); }
.opt.bad { background: var(--bad-soft); border-color: var(--bad); }
.opt.bad .k { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.dim { opacity: .55; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; }
.feedback.ok { background: var(--good-soft); } .feedback.ko { background: var(--bad-soft); }
.feedback b { display: block; margin-bottom: 4px; }
.kbd { font-size: .8rem; color: var(--muted); }
code { font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--code); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--code); padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: 10px 0; }
pre code { background: none; padding: 0; font-size: .92rem; line-height: 1.5; }

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.bars { display: grid; gap: 14px; }
.bar-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; margin-bottom: 5px; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; }
.lvl-good { color: var(--good); } .lvl-mid { color: var(--warn); } .lvl-bad { color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }

/* Onglets trainer */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; }
.tabs button { border: 0; background: none; color: var(--muted); padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
.tabs button.on { background: var(--text); color: var(--bg); }

.qitem { border-top: 1px solid var(--line); padding: 14px 0; }
.qitem:first-child { border-top: 0; }
.qitem ol { margin: 8px 0; padding-left: 22px; }
.qitem li.right { color: var(--good); font-weight: 600; }
.qitem .exp { color: var(--muted); font-size: .92rem; }
.qitem .meta { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.hide-ans .qitem li.right { color: inherit; font-weight: inherit; }
.hide-ans .qitem .exp { display: none; }

.sheet table { margin: 6px 0 12px; }
.sheet ul { padding-left: 20px; margin: 6px 0; }
.sheet li { margin: 3px 0; }
.callout { background: var(--warn-soft); border-radius: 12px; padding: 12px 16px; margin: 12px 0; }
.pill { font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }

@media print {
  header, .tabs, .noprint, button { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 0; padding: 0; }
  .qitem { break-inside: avoid; }
}
