:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #677189;
  --line: #e2e6ef;
  --primary: #3b5bdb;
  --primary-soft: #e8edff;
  --ok: #2f9e44;
  --ok-soft: #e6f6ea;
  --warn: #e67700;
  --warn-soft: #fff3e0;
  --bad: #e03131;
  --bad-soft: #ffeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 14px rgba(20, 30, 60, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 20px 16px 60px; }
.wrap.wide { max-width: 1280px; }

.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 10px 12px; border: 1px solid #cdd3e0; border-radius: 8px; background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  background: var(--primary); color: #fff; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.07); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, .btn.secondary { background: #fff; color: var(--ink); border-color: #cdd3e0; }
button.ghost { background: transparent; color: var(--primary); padding: 6px 10px; }
button.danger { background: var(--bad); }
button.danger.secondary { background: #fff; color: var(--bad); border-color: #f3b4b4; }
button.ok { background: var(--ok); }
button.big { font-size: 1.1rem; padding: 13px 24px; }
button.sm { padding: 5px 10px; font-size: .85rem; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #eef0f5; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b5bccb; display: inline-block; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--primary-soft); color: #22378f; }
.notice.ok { background: var(--ok-soft); color: #1f6e30; }
.notice.warn { background: var(--warn-soft); color: #8a4a00; }
.notice.bad { background: var(--bad-soft); color: #9b1c1c; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); }

/* ---------- Élève ---------- */
.hero { text-align: center; padding: 30px 10px 10px; }
.hero h1 { font-size: 1.9rem; }
.login { max-width: 520px; margin: 0 auto; }
.partner-box { border: 1px dashed #b9c2d8; border-radius: 10px; padding: 14px; margin-bottom: 14px; background: #fafbff; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; margin-bottom: 14px; }
.check input { width: 20px; height: 20px; }

.waiting { text-align: center; padding: 50px 20px; }
.pulse { width: 74px; height: 74px; border-radius: 50%; background: var(--primary-soft); margin: 0 auto 18px; display: grid; place-items: center; position: relative; font-size: 30px; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--primary); animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .8; } to { transform: scale(1.6); opacity: 0; } }

.exam-head { position: sticky; top: 53px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); margin-bottom: 16px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; padding: 4px 12px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.question { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.question:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.qtitle { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.qtext { white-space: pre-wrap; font-weight: 600; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.option:hover { background: #fafbff; }
.option input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.good { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.instructions { white-space: pre-wrap; background: #fafbff; border-left: 4px solid var(--primary); padding: 12px 14px; border-radius: 6px; margin-bottom: 14px; }
.attachments { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.attachments img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.attachments iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.grade-big { font-size: 2rem; font-weight: 800; color: var(--primary); }

/* ---------- Professeur ---------- */
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; color: var(--muted); border-radius: 8px; }
.tabs button.active { background: var(--primary-soft); color: var(--primary); }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.stu { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.stu.off { opacity: .6; }
.stu .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.stu .partner { font-size: .85rem; color: var(--muted); padding-left: 17px; }
.stu .progress { height: 6px; border-radius: 99px; background: #eef0f5; overflow: hidden; }
.stu .progress > div { height: 100%; background: var(--primary); }
.stu.done .progress > div { background: var(--ok); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 120px; }
.stat b { font-size: 1.5rem; display: block; }
.live-eval { border: 2px solid var(--primary); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover, tr.selected { background: var(--primary-soft); }
.qedit { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fcfcfe; }
.qedit .opt { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.qedit .opt input[type=radio] { width: 18px; height: 18px; flex: none; }
.split { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.answer { white-space: pre-wrap; background: #fafbff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.score-input { width: 90px !important; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 28, 45, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 480px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
