:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --border: #e2e2e0;
  --accent: #4a5bd4;
  --accent-text: #ffffff;
  --accent-soft: #eceefc;
  --danger: #c0392b;
  /* Palette du diagramme (validée daltonisme, clair et sombre) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-other: #a3a29c;
  --radius: 14px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --surface: #1c1c1f;
    --text: #ececef;
    --muted: #9a9aa2;
    --border: #2e2e33;
    --accent: #8391f0;
    --accent-text: #0f1030;
    --accent-soft: #23264a;
    --danger: #ef7a6c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-other: #6b6a65;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 16px 64px;
}

/* Barre de progression */
.progress {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 4px;
  background: var(--border);
}
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .3s ease;
}

/* Typographie */
h1, h2 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h1:focus, h2:focus { outline: none; }
p { margin: 0 0 14px; }
.eyebrow {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.lead { color: var(--muted); }
.small { font-size: .9rem; color: var(--muted); }

/* Carte */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
}

/* Blocs de question */
fieldset {
  border: 0;
  margin: 0 0 28px;
  padding: 0;
  min-width: 0;
}
legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 12px;
}
label.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.field { margin-bottom: 22px; }
.optional { font-weight: 400; color: var(--muted); }

input[type="text"], input[type="number"] {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .15s;
}
input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
input[type="number"] { max-width: 140px; }

/* Options (radios / cases) présentées comme des boutons */
.options { display: grid; gap: 10px; }
.options--inline { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.option__mark {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: border-color .15s, background .15s;
}
.option input[type="checkbox"] + .option__mark { border-radius: 6px; }
.option__mark::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: inherit;
  background: var(--accent-text);
  transform: scale(0);
  transition: transform .15s;
}
.option input:checked + .option__mark {
  border-color: var(--accent);
  background: var(--accent);
}
.option input:checked + .option__mark::after { transform: scale(1); }
.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option:has(input:focus-visible) { box-shadow: var(--focus); }
.option__body { display: block; }
.option__label { display: block; font-weight: 500; }
.option__hint { display: block; font-size: .88rem; color: var(--muted); margin-top: 2px; }

.option--none { margin-top: 6px; }

/* Échelle 0–10 */
.scale__grid {
  display: grid;
  grid-template-columns: repeat(var(--points, 11), 1fr);
  gap: 4px;
}
.scale__point { position: relative; }
.scale__point input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.scale__point span {
  display: grid;
  place-items: center;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
}
.scale__point span:hover { border-color: var(--accent); }
.scale__point input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.scale__point input:focus-visible + span { box-shadow: var(--focus); }
.scale__anchors {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.3;
}
.scale__anchors span:nth-child(2) { text-align: center; }
.scale__anchors span:nth-child(3) { text-align: right; }
.scale__value {
  min-height: 1.5em;
  margin-top: 10px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--accent);
}

@media (max-width: 420px) {
  .scale__grid { gap: 3px; }
  .scale__point span { height: 40px; font-size: .9rem; border-radius: 8px; }
}

/* Croyances personnalisées */
.custom-row { display: flex; gap: 8px; }
.custom-row input { flex: 1; }

/* Boutons */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
}
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 13px 24px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn--primary { background: var(--accent); color: var(--accent-text); margin-left: auto; }
.btn--primary:disabled { opacity: .4; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--muted); padding-left: 4px; padding-right: 4px; }
.btn--ghost:hover { color: var(--text); }
.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text); }

.error {
  color: var(--danger);
  font-size: .92rem;
  margin-top: 12px;
  min-height: 1.4em;
}

/* Informations de consentement */
details {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}
summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
details ul { padding-left: 20px; margin: 12px 0 0; font-size: .92rem; color: var(--muted); }
details li { margin-bottom: 6px; }

/* Champ piège invisible pour les humains */
.hp {
  position: absolute !important;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Consigne de la question 1 : texte normal (pas grisé) pour qu'elle soit lue */
.intro-text { color: var(--text); margin-bottom: 22px; }

/* Croyances ajoutées, à l'intérieur du bloc « Une autre croyance ? » */
.custom-list { list-style: none; margin: 0; padding: 0; }
.custom-list:not(:empty) { margin-top: 14px; border-top: 1px solid var(--border); }
.custom-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.custom-item:last-child { border-bottom: 0; padding-bottom: 0; }
.custom-item__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.custom-item__label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.custom-item__remove {
  flex: none;
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.custom-item__remove:hover { color: var(--danger); }
.custom-item__remove:focus-visible { outline: none; box-shadow: var(--focus); }

.other-input { margin-top: 10px; }
.other-input[hidden] { display: none; }

.field-help { font-size: .9rem; color: var(--muted); margin: -6px 0 12px; }

textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  resize: vertical;
  min-height: 220px;
  line-height: 1.5;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.counter { text-align: right; font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* Diagramme des résultats */
.results { margin-top: 32px; }
.end-note { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); }
.end-note p + p { margin-top: 12px; }
.chart__title { font-size: .9rem; font-weight: 600; color: var(--muted); margin-bottom: 16px; }
.chart__body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: center;
}
.donut { width: 100%; height: auto; display: block; }
.donut__total { font-size: 34px; font-weight: 700; fill: var(--text); font-variant-numeric: tabular-nums; }
.donut__caption { font-size: 12px; fill: var(--muted); }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: .92rem; line-height: 1.3; }
.legend__swatch { flex: none; width: 12px; height: 12px; border-radius: 4px; }
.legend__label { flex: 1; min-width: 0; }
.legend__detail { color: var(--muted); font-size: .85rem; }
.legend__value { font-weight: 600; font-variant-numeric: tabular-nums; }

.series-1 { stroke: var(--series-1); background: var(--series-1); }
.series-2 { stroke: var(--series-2); background: var(--series-2); }
.series-3 { stroke: var(--series-3); background: var(--series-3); }
.series-4 { stroke: var(--series-4); background: var(--series-4); }
.series-5 { stroke: var(--series-5); background: var(--series-5); }
.series-6 { stroke: var(--series-6); background: var(--series-6); }
.series-other { stroke: var(--series-other); background: var(--series-other); }

@media (max-width: 480px) {
  .chart__body { grid-template-columns: 1fr; }
  .donut { max-width: 200px; margin: 0 auto; }
}

.card .error:empty { display: none; }

/* Jauge de conviction (une seule croyance) */
.meter__head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; margin-bottom: 10px; }
.meter__value { font-variant-numeric: tabular-nums; }
.meter { height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 999px; background: var(--series-1); }
