:root {
  --red: #c40018;
  --red-dark: #950013;
  --ink: #1e1e1e;
  --muted: #6f7176;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e5e7eb;
  --success: #237a4b;
  --danger: #b91c1c;
  --shadow: 0 12px 30px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--line);
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}

.logo { width: 160px; height: auto; display: block; }
.brand { display: flex; align-items: center; gap: 14px; }
.admin-badge {
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px;
}

.container { max-width: 900px; margin: 32px auto; padding: 0 18px 60px; }
.container.wide { max-width: 1200px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.hero { padding: 28px; }
.hero h1, .card h1, .card h2 { margin-top: 0; }
.eyebrow { color: var(--red); font-weight: 800; letter-spacing: .1em; font-size: 12px; margin-bottom: 8px; }
.intro { font-size: 18px; color: #4b4d52; line-height: 1.55; }

.question-card { padding: 22px 24px; }
.question-title { font-size: 19px; font-weight: 750; margin-bottom: 16px; line-height: 1.35; }
.question-number { color: var(--red); margin-right: 7px; }

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; cursor: pointer; transition: .15s ease;
}
.option:hover { border-color: #c9cbd0; background: #fafafa; }
.option input { transform: scale(1.15); }

.scale-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(38px, 1fr));
  gap: 7px;
}
.scale-item input { display: none; }
.scale-item span {
  display: flex; justify-content: center; align-items: center;
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  font-weight: 700; cursor: pointer;
}
.scale-item input:checked + span {
  background: var(--red); color: #fff; border-color: var(--red);
}

textarea, input[type="text"], input[type="email"], input[type="password"], input[type="url"], select {
  width: 100%;
  border: 1px solid #d8dbe0;
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 100px; resize: vertical; }

label { display: grid; gap: 7px; font-weight: 650; font-size: 14px; }
.stack { display: grid; gap: 16px; }

.btn {
  appearance: none; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 750; font-size: 14px;
  cursor: pointer; transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: #eceef1; color: var(--ink); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-large { padding: 14px 20px; font-size: 16px; }
.btn-small { padding: 8px 11px; font-size: 12px; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.submit-zone { text-align: center; }
.consent-line {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-bottom: 18px; font-weight: 500;
}

.progress-wrap { margin-top: 22px; }
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 7px; }
.progress { height: 9px; border-radius: 999px; background: #eee; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--red); transition: width .2s ease; }

.center { text-align: center; padding: 50px 25px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.form-message { min-height: 20px; margin: 12px 0 0; font-size: 14px; }
.error { color: var(--danger); }
.status-icon {
  width: 58px; height: 58px; border-radius: 50%;
  background: #e8f5ee; color: var(--success);
  display: grid; place-items: center; margin: 0 auto 18px; font-size: 28px; font-weight: 900;
}
.spinner {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border: 4px solid #eee; border-top-color: var(--red);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.admin-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.stats-row { display: flex; gap: 18px; margin-top: 18px; }
.metric {
  flex: 1; border: 1px solid var(--line); background: #fafafa;
  border-radius: 14px; padding: 18px;
}
.metric-value { display: block; font-size: 30px; font-weight: 850; }
.metric-label { color: var(--muted); font-size: 13px; }

.status-pill { border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; background: #eee; }
.status-open { background: #e8f5ee; color: #166534; }
.status-closed { background: #fee2e2; color: #991b1b; }

.qrbox {
  min-height: 220px; display: grid; place-items: center; margin-top: 18px;
  border: 1px dashed #cfd2d7; border-radius: 14px; background: #fff;
}
.qrbox img, .qrbox canvas { max-width: 200px; max-height: 200px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }

.editor-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin: 12px 0;
  background: #fcfcfd;
}
.editor-row { display: grid; grid-template-columns: 1fr 200px auto; gap: 10px; align-items: end; }
.editor-actions { display: flex; gap: 7px; }

.choice-list { display: grid; gap: 8px; margin-top: 12px; }
.choice-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.result-block { border-top: 1px solid var(--line); padding: 20px 0; }
.result-block:first-child { border-top: 0; }
.result-question { font-weight: 800; margin-bottom: 14px; }
.result-row { margin: 10px 0; }
.result-label { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 6px; font-size: 14px; }
.result-bar-wrap { height: 11px; background: #eee; border-radius: 999px; overflow: hidden; }
.result-bar { height: 100%; background: var(--red); border-radius: 999px; }
.result-average { font-size: 34px; font-weight: 850; color: var(--red); }
.text-answer {
  background: #fafafa; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin: 8px 0; white-space: pre-wrap;
}

.login-card { max-width: 460px; margin: 60px auto; }
.footer { text-align: center; color: #9a9ca1; font-size: 12px; padding: 10px 20px 35px; }

@media (max-width: 780px) {
  .topbar { min-height: 62px; padding: 10px 14px; }
  .logo { width: 135px; }
  .container { margin-top: 18px; padding-left: 12px; padding-right: 12px; }
  .card { border-radius: 14px; padding: 18px; }
  .admin-grid, .settings-grid { grid-template-columns: 1fr; }
  .scale-grid { grid-template-columns: repeat(5, 1fr); }
  .editor-row { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; }
}

/* --- Bonnes réponses (admin uniquement) --------------------------------- */

/* Menu « bonne réponse » dans l'éditeur de questions */
.answer-key-row { margin-top: 14px; }
.answer-key {
  border-top: 1px dashed var(--line);
  padding-top: 13px;
  gap: 7px;
}
.answer-key select { max-width: 100%; }

/* Marquage de la bonne réponse dans les résultats */
.result-row.is-correct .result-label { color: var(--success); }
.result-bar.bar-correct { background: var(--success); }
.badge-correct {
  display: inline-block;
  margin-left: 8px;
  background: #e8f5ee;
  color: #166534;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  vertical-align: 1px;
}
.success-rate {
  margin: 12px 0 0;
  font-size: 14px;
  color: #4b4d52;
  background: #f6f8f7;
  border-left: 3px solid var(--success);
  border-radius: 0 8px 8px 0;
  padding: 9px 12px;
}

/* Bandeau de score global, en tête des résultats */
.score-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 6px;
}
.score-main { font-size: 40px; font-weight: 850; color: var(--success); line-height: 1; }
.score-total { font-size: 18px; color: #777; font-weight: 700; }
.score-summary p { margin: 4px 0 0; }

@media (max-width: 780px) {
  .score-summary { flex-direction: column; align-items: flex-start; gap: 10px; }
}
