:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --ink: #1d2430;
  --muted: #68727f;
  --line: #e4e8e2;
  --accent: #2fb457;
  --accent-ink: #ffffff;
  --accent-soft: #e3f5e9;
  --blue: #2f7dd1;
  --blue-soft: #e5effa;
  --danger: #e0483f;
  --danger-soft: #fbe9e7;
  --gold: #e8a13c;
  --gold-soft: #fdf3e3;
  --radius: 18px;
  --shadow: 0 1px 3px rgba(20, 30, 25, .07), 0 6px 18px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --card: #1c2229;
    --ink: #e8ecf1;
    --muted: #94a0ac;
    --line: #2a323b;
    --accent: #35c261;
    --accent-soft: #17301f;
    --blue: #4f97e0;
    --blue-soft: #16283a;
    --danger: #ef6a5f;
    --danger-soft: #3a201d;
    --gold: #f0b054;
    --gold-soft: #382b16;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 22px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 560px; margin: 0 auto; padding: 14px 16px 40px; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ---------- entête ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 14px; }
.brand { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.chips { display: flex; gap: 8px; }
.chip {
  font-size: .8rem; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); white-space: nowrap;
}
.chip.warn { color: var(--gold); }
.chip.fire { color: var(--danger); }

/* ---------- cartes ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 1rem; }
.card .sub { color: var(--muted); font-size: .84rem; margin: 0; }

/* préparation globale */
.hero { display: flex; align-items: center; gap: 18px; }
.ring { width: 92px; height: 92px; flex: none; }
.ring text { font-weight: 800; font-size: 22px; fill: var(--ink); }
.hero .stats { flex: 1; }
.hero .stats .big { font-size: 1.05rem; font-weight: 800; margin-bottom: 2px; }
.hero .meta { color: var(--muted); font-size: .82rem; }

/* boutons d'action */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.btn {
  border-radius: var(--radius); padding: 14px 12px; font-weight: 800; font-size: .95rem;
  text-align: center; box-shadow: var(--shadow); transition: transform .06s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.btn:active { transform: scale(.97); }
.btn .ico { font-size: 1.4rem; }
.btn .note { font-size: .72rem; font-weight: 600; opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-ink); grid-column: 1 / -1; }
.btn.blue { background: var(--blue-soft); color: var(--blue); }
.btn.red { background: var(--danger-soft); color: var(--danger); }
.btn.plain { background: var(--card); }
.btn.small { padding: 10px 14px; font-size: .85rem; flex-direction: row; }
.btn:disabled { opacity: .45; }

/* liste modules */
.modlist .mod {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 14px; margin-bottom: 10px;
}
.mod .emoji { font-size: 1.5rem; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 12px; flex: none; }
.mod .txt { flex: 1; min-width: 0; }
.mod .name { font-weight: 750; font-size: .92rem; }
.mod .info { color: var(--muted); font-size: .76rem; margin-top: 1px; }
.mod .pct { font-weight: 800; font-size: .9rem; color: var(--accent); }
.mod .due { color: var(--gold); font-size: .72rem; font-weight: 700; }

.bar { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s; }
.bar.thin { height: 5px; }

/* ---------- écran quiz ---------- */
.quizbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; }
.quizbar .close { font-size: 1.3rem; color: var(--muted); padding: 4px 8px; }
.quizbar .bar { flex: 1; margin: 0; height: 12px; }
.quizbar .count { font-size: .8rem; font-weight: 700; color: var(--muted); }

.qmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tag { font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.tag.gen { background: var(--gold-soft); color: var(--gold); }

.question { font-size: 1.02rem; font-weight: 700; margin: 0 0 16px; white-space: pre-wrap; }

.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  text-align: left; padding: 13px 14px; border-radius: 14px; background: var(--card);
  border: 2px solid var(--line); font-size: .92rem; font-weight: 550; line-height: 1.35;
}
.opt:not(:disabled):active { border-color: var(--blue); }
.opt.sel { border-color: var(--blue); background: var(--blue-soft); }
.opt.good { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.opt.bad { border-color: var(--danger); background: var(--danger-soft); }
.opt:disabled { cursor: default; }

.feedback { border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; animation: pop .18s ease-out; }
.feedback.good { background: var(--accent-soft); }
.feedback.bad { background: var(--danger-soft); }
.feedback .verdict { font-weight: 800; font-size: 1rem; margin-bottom: 6px; }
.feedback.good .verdict { color: var(--accent); }
.feedback.bad .verdict { color: var(--danger); }
.feedback .expl { font-size: .87rem; white-space: pre-wrap; }
.feedback .src { font-size: .74rem; color: var(--muted); margin-top: 8px; }
.feedback .report { font-size: .74rem; color: var(--muted); text-decoration: underline; margin-top: 8px; padding: 0; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.continuebar { position: sticky; bottom: 0; padding: 12px 0 6px; background: linear-gradient(transparent, var(--bg) 35%); }
.continuebar .btn { width: 100%; }

/* ---------- fin de session ---------- */
.endscore { text-align: center; padding: 26px 16px; }
.endscore .big { font-size: 2.6rem; font-weight: 800; }
.endscore .msg { font-size: 1.05rem; font-weight: 700; margin: 6px 0 2px; }
.endscore .xp { color: var(--gold); font-weight: 800; }
.review .rq { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .84rem; }
.review .rq:last-child { border-bottom: 0; }
.review .rq .st { font-weight: 800; margin-right: 6px; }
.review .rq .st.ok { color: var(--accent); }
.review .rq .st.ko { color: var(--danger); }

/* ---------- sujets / stats ---------- */
.sujet { margin-bottom: 12px; }
.sujet .row { display: flex; justify-content: space-between; font-size: .84rem; font-weight: 650; }
.sujet .row .p { color: var(--muted); font-weight: 700; }

/* ---------- validation ---------- */
.vitem { border-bottom: 1px solid var(--line); padding: 10px 0; }
.vitem:last-child { border-bottom: 0; }
.vitem .vhead { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font-size: .84rem; font-weight: 600; }
.vitem .vhead .st { flex: none; width: 22px; text-align: center; }
.vbody { padding: 8px 0 4px 30px; font-size: .82rem; }
.vbody .vopt { padding: 2px 0; color: var(--muted); }
.vbody .vopt.correct { color: var(--accent); font-weight: 700; }
.vbody .vsrc { color: var(--muted); font-size: .76rem; margin: 6px 0; }
.vbtns { display: flex; gap: 8px; margin-top: 8px; }
.vbtns .btn { padding: 8px 14px; font-size: .8rem; box-shadow: none; }

.link { color: var(--muted); font-size: .8rem; text-decoration: underline; padding: 6px; }
.center { text-align: center; }
.footer { text-align: center; color: var(--muted); font-size: .72rem; margin-top: 24px; }
.footer .link { display: inline-block; }

.back { color: var(--muted); font-weight: 700; font-size: .88rem; padding: 6px 0 14px; display: inline-flex; align-items: center; gap: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: .82rem; font-weight: 700;
  padding: 10px 18px; border-radius: 99px; box-shadow: var(--shadow); z-index: 50;
  animation: pop .2s ease-out;
}
