/* Polices et couleurs de Carnet (src/styles/settings.css du dépôt cours-ada), étendues aux états du quiz */
@font-face {
  font-family: "Inclusive Sans";
  src: url("/fonts/InclusiveSans.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Roboto Mono";
  src: url("/fonts/RobotoMono.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}

:root {
  --font-sans: "Inclusive Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, monospace;
  --bg-desk: #f2eee6;
  --bg-page: #fdfbf7;
  --bg-surface: #fffefc;
  --bg-sunken: #f5f1e9;
  --border: #e7e2d8;
  --border-strong: #c6beb1;
  --text: #1e2530;
  --text-muted: #56637a;
  --heading: #202637;
  --accent: #9475c6;
  --accent-text: #51357e;
  --accent-bg: #f2ecfa;
  --on-accent: #ffffff;
  --code-bg: #efebe3;
  --shadow: #e0dace;
  --ok: #2f7a4f;
  --ok-bg: #e6f2ea;
  --half: #8a5300;
  --half-bg: #fbf0da;
  --ko: #b3261e;
  --ko-bg: #fbeae8;
  --radius: 6px;
  --column: 42rem;
  --sheet-pad: 40px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-desk: #0f1117;
    --bg-page: #14171f;
    --bg-surface: #1b1f2a;
    --bg-sunken: #181c25;
    --border: #2c3242;
    --border-strong: #4a5268;
    --text: #e6e8ee;
    --text-muted: #a3abbd;
    --heading: #f2f4f8;
    --accent: #c4a6ee;
    --accent-text: #dcc8fa;
    --accent-bg: #272238;
    --on-accent: #14171f;
    --code-bg: #262c3a;
    --shadow: #0b0d12;
    --ok: #6fcf97;
    --ok-bg: #15291d;
    --half: #e8b866;
    --half-bg: #2e2615;
    --ko: #f2847c;
    --ko-bg: #341b1a;
  }
}

/* Base */

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

html {
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-desk);
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 1.0625rem;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  color: var(--heading);
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 1.35rem + 1.8vw, 2.25rem);
  font-weight: 700;
}

h2 {
  margin: 48px 0 16px;
  font-size: 1.3125rem;
  font-weight: 650;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 650;
}

p {
  margin: 0 0 12px;
}

a {
  color: var(--accent-text);
  text-underline-offset: 3px;
}

strong {
  font-weight: 650;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 1px 5px;
  background: var(--code-bg);
  border-radius: 4px;
}

pre {
  margin: 12px 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 0.9375rem;
  background: var(--code-bg);
  border-radius: var(--radius);
}

pre code {
  padding: 0;
  background: none;
}

kbd {
  font: 500 0.75rem var(--font-sans);
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.75;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  flex: none;
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mise en page */

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  max-width: calc(var(--column) + 2 * var(--sheet-pad));
  margin: 0 auto;
  padding: 14px var(--sheet-pad);
  font-size: 0.9375rem;
}

.brand {
  font-weight: 700;
  color: var(--heading);
  text-decoration: none;
}

.topbar-title {
  min-width: 0;
  color: var(--text-muted);
}

.topbar-title::before {
  content: "/";
  margin-right: 8px;
  color: var(--border-strong);
}

.topbar-who {
  margin-left: auto;
  color: var(--text-muted);
}

/* Feuille du carnet posée sur le bureau, comme les pages de cours */
.page {
  max-width: calc(var(--column) + 2 * var(--sheet-pad));
  margin: 0 auto 32px;
  padding: 40px var(--sheet-pad) 64px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.wide {
  max-width: 72rem;
}

.loading {
  color: var(--text-muted);
}

.kicker {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
}

.lead {
  font-size: 1.125rem;
  color: var(--text);
}

.help {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.alert {
  margin: 16px 0 0;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--ko);
  background: var(--ko-bg);
  border-radius: var(--radius);
}

.alert-info {
  color: var(--text);
  background: var(--bg-sunken);
}

/* Boutons et champs */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 18px;
  font: 600 1rem var(--font-sans);
  color: var(--heading);
  text-decoration: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--shadow);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--text-muted);
}

.btn-primary {
  color: var(--on-accent);
  background: var(--accent-text);
  border-color: var(--accent-text);
  box-shadow: none;
}

.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent-text) 86%, var(--heading));
  border-color: transparent;
}

.btn-quiet {
  padding: 0 4px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border-color: transparent;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-quiet:hover:not(:disabled) {
  color: var(--heading);
  border-color: transparent;
}

.btn-danger {
  color: var(--ko);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
}

.field,
.input {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.field:focus-visible,
.input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent-text);
}

.field:disabled {
  color: var(--text);
  background: var(--bg-sunken);
  cursor: default;
}

.field.is-right {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.field.is-wrong {
  border-color: var(--ko);
  background: var(--ko-bg);
}

textarea.field {
  min-height: 11rem;
  line-height: 1.5;
  resize: vertical;
}

.field::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.field-note {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Accueil du quiz */

/* Un trait avant chaque chiffre. La liste déborde de 15px à gauche et coupe ce débord :
   le trait du premier élément de chaque ligne disparaît quand la ligne passe à la suivante */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  margin: 20px 0 0 -15px;
  padding: 0;
  list-style: none;
  font-weight: 600;
  color: var(--heading);
  clip-path: inset(0 0 0 15px);
}

.facts li {
  padding: 0 14px;
  border-left: 1px solid var(--border-strong);
}

.start {
  display: grid;
  gap: 8px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

/* Règles repliées : on peut commencer sans les lire, elles restent sous la main */
.rules {
  margin-top: 32px;
  font-size: 0.9375rem;
}

.rules summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-weight: 600;
  color: var(--heading);
  cursor: pointer;
  list-style: none;
}

.rules summary::-webkit-details-marker {
  display: none;
}

.rules summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.rules[open] summary::before {
  transform: rotate(45deg);
}

.rules summary:hover {
  color: var(--accent-text);
}

.rules-body {
  margin: 12px 0 0 4px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.rules ul {
  margin: 0;
  padding-left: 18px;
}

.rules li {
  margin-bottom: 6px;
}

.rules li::marker {
  color: var(--accent);
}

.start label {
  font-weight: 650;
  color: var(--heading);
}

.start .field {
  max-width: 26rem;
}

.start .help {
  margin: 0;
}

.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 12px;
}

.waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.pulse {
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--half);
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* Question */

.play-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 32px;
}

.counter,
.play-meta {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.play-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-weight: 650;
  color: var(--heading);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.timer.is-short {
  color: var(--ko);
  background: var(--ko-bg);
  border-color: var(--ko);
}

.track {
  display: grid;
  grid-template-columns: repeat(var(--n, 10), minmax(0, 1fr));
  gap: 3px;
  margin: 10px 0 40px;
  padding: 0;
  list-style: none;
}

.track li {
  height: 6px;
  background: var(--border);
  border-radius: 2px;
}

.track .is-ok {
  background: var(--ok);
}

.track .is-half {
  background: var(--half);
}

.track .is-ko {
  background: var(--ko);
}

.track .is-pending {
  background: var(--accent);
}

.track .is-current:not(.is-ok, .is-half, .is-ko, .is-pending) {
  background: var(--heading);
}

.kind {
  margin: 0 0 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-text);
}

.prompt {
  margin: 0 0 28px;
  font-size: clamp(1.3rem, 1.1rem + 0.9vw, 1.5rem);
  font-weight: 650;
  line-height: 1.35;
  text-wrap: pretty;
}

/* Titres qui reçoivent le focus au changement d'écran, pour les lecteurs d'écran : pas de cadre */
.lookup {
  display: flex;
  gap: 10px;
  margin: -12px 0 24px;
  padding: 12px 14px;
  background: var(--accent-bg);
  border-radius: var(--radius);
}

.lookup .icon {
  margin-top: 0.2em;
  color: var(--accent-text);
}

.prompt:focus,
#end-title:focus {
  outline: none;
}

.choices {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 11px 14px;
  line-height: 1.4;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.choice:hover:not(.is-locked) {
  border-color: var(--accent-text);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice:has(input:checked) {
  background: var(--accent-bg);
  border-color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-text);
}

.key {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--text-muted);
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}

/* Carré pour cocher plusieurs réponses, rond pour une seule : la convention des formulaires */
.is-multiple .key {
  border-radius: 5px;
}

.choice:has(input:checked) .key {
  color: var(--on-accent);
  background: var(--accent-text);
  border-color: var(--accent-text);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  font-weight: 650;
  white-space: nowrap;
}

.choice.is-locked {
  cursor: default;
}

.choice.is-locked:not(.is-right, .is-wrong, .is-missed) {
  color: var(--text-muted);
  border-color: var(--border);
}

.choice.is-right {
  background: var(--ok-bg);
  border-color: var(--ok);
  box-shadow: inset 0 0 0 1px var(--ok);
}

.choice.is-right .key {
  color: var(--bg-surface);
  background: var(--ok);
  border-color: var(--ok);
}

.choice.is-right .tag,
.choice.is-missed .tag {
  color: var(--ok);
}

.choice.is-missed {
  border: 1.5px dashed var(--ok);
}

.choice.is-wrong {
  background: var(--ko-bg);
  border-color: var(--ko);
}

.choice.is-wrong .key {
  color: var(--ko);
  border-color: var(--ko);
}

.choice.is-wrong .tag {
  color: var(--ko);
}

.feedback {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.feedback:empty {
  display: none;
}

.feedback p {
  margin: 8px 0 0;
}

.feedback .feedback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 650;
}

.feedback.is-ok {
  background: var(--ok-bg);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.feedback.is-ok .feedback-title {
  color: var(--ok);
}

/* Un essai reste : orange. Question perdue : rouge. */
.feedback.is-half,
.feedback.is-retry {
  background: var(--half-bg);
  border-color: color-mix(in srgb, var(--half) 40%, transparent);
}

.feedback.is-half .feedback-title,
.feedback.is-retry .feedback-title {
  color: var(--half);
}

.feedback.is-ko {
  background: var(--ko-bg);
  border-color: color-mix(in srgb, var(--ko) 40%, transparent);
}

.feedback.is-ko .feedback-title {
  color: var(--ko);
}

.feedback.is-info {
  background: var(--accent-bg);
  border-color: color-mix(in srgb, var(--accent-text) 30%, transparent);
}

.feedback.is-info .feedback-title {
  color: var(--accent-text);
}

.feedback .hint {
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-top: 28px;
}

.actions .btn-quiet {
  margin-left: auto;
}

.keys {
  margin: 40px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Résultat */

.score {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 24px 0 12px;
}

.score-value {
  font-size: clamp(3rem, 2.4rem + 3vw, 4rem);
  font-weight: 700;
  line-height: 1;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.score-max {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-muted);
}

.meter {
  height: 10px;
  overflow: hidden;
  background: var(--border);
  border-radius: 3px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent-text);
}

.verdict {
  margin: 16px 0 0;
  font-size: 1.125rem;
}

.tally {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 16px;
  margin: 28px 0 0;
  padding: 20px 0;
  border-block: 1px solid var(--border);
}

.tally div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
}

.tally dt {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.tally dd {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.tally-ok dd {
  color: var(--ok);
}

.tally-half dd {
  color: var(--half);
}

.tally-ko dd {
  color: var(--ko);
}

.tally-pending dd {
  color: var(--accent-text);
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.review-title {
  margin-top: 56px;
}

.review {
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-item {
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.review-q {
  font-weight: 650;
  color: var(--heading);
}

.review-answers {
  display: grid;
  gap: 6px;
  margin: 0;
}

.review-answers div {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 12px;
}

.review-answers dt {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.review-answers dd {
  margin: 0;
}

.review-expl {
  margin: 10px 0 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.pre {
  white-space: pre-wrap;
}

.badge {
  flex: none;
  padding: 2px 8px;
  font-size: 0.8125rem;
  font-weight: 650;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--text-muted);
}

.badge-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.badge-half {
  color: var(--half);
  background: var(--half-bg);
}

.badge-ko {
  color: var(--ko);
  background: var(--ko-bg);
}

.badge-pending {
  color: var(--accent-text);
  background: var(--accent-bg);
}

/* Téléphone : la feuille occupe tout l'écran */
@media (max-width: 760px) {
  :root {
    --sheet-pad: 16px;
  }

  html {
    background: var(--bg-page);
  }

  .topbar {
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
  }

  .page {
    margin: 0;
    padding-top: 28px;
    border: 0;
    border-radius: 0;
  }
}

@media (max-width: 34rem) {

  .choice {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .choice .tag {
    grid-column: 2;
  }

  .choice .tag:empty {
    display: none;
  }

  .review-answers div {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .actions .btn-primary {
    flex: 1 1 100%;
  }

  .actions .btn-quiet {
    margin: 0 auto;
  }
}

/* Pages du formateur */

.notice {
  padding: 10px 14px;
  color: var(--ok);
  font-weight: 500;
  background: var(--ok-bg);
  border-radius: var(--radius);
}

.back {
  margin-bottom: 20px;
  font-size: 0.9375rem;
}

.back a::before {
  content: "← ";
}

.section {
  margin-top: 48px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 16px;
}

.field-group {
  display: grid;
  gap: 6px;
  min-width: min(100%, 16rem);
}

.field-group .input {
  height: 46px;
}

.data code {
  white-space: nowrap;
}

.data .sub {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.field-group label {
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--heading);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.table-scroll {
  overflow-x: auto;
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.data th,
.data td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.data thead th {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.data tbody th {
  font-weight: 600;
}

.data .num {
  text-align: right;
  white-space: nowrap;
}

.data tfoot th,
.data tfoot td {
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-bottom: 0;
}

/* Une colonne étroite et centrée par question, pour lire le tableau en colonnes */
.grid {
  width: auto;
}

.grid th,
.grid td {
  padding: 8px 10px;
}

.grid thead th.q,
.grid tfoot td.q {
  width: 2.75rem;
  padding-inline: 2px;
  text-align: center;
}

.grid tfoot td.q {
  white-space: nowrap;
}

.grid thead th.q a {
  color: inherit;
}

.cell {
  display: inline-block;
  min-width: 2.25rem;
  text-align: center;
  font-weight: 650;
}

.data td.cell {
  text-align: center;
}

td.cell {
  display: table-cell;
  padding: 8px 2px;
  border-left: 2px solid var(--bg-page);
}

.s-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.s-half {
  color: var(--half);
  background: var(--half-bg);
}

.s-ko {
  color: var(--ko);
  background: var(--ko-bg);
}

.s-pending {
  color: var(--accent-text);
  background: var(--accent-bg);
}

.s-pending a {
  color: inherit;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 16px 0 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  list-style: none;
}

.legend .cell {
  min-height: 1.6em;
  margin-right: 6px;
  padding: 1px 0;
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.attempt {
  margin-left: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  white-space: nowrap;
}

.state::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--half);
}

.state-open::before {
  background: var(--ok);
}

.state-closed::before {
  background: var(--text-muted);
}

.control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 28px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.control-state {
  margin: 0;
}

.control-state .state {
  margin-right: 8px;
  color: var(--heading);
}

.control form {
  margin: 0;
}

.share {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.share label {
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--heading);
}

.copy {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy .input {
  flex: 1 1 22rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.updated {
  margin: 40px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 16px 24px;
  margin: 12px 0 0;
  padding: 20px 0;
  border-block: 1px solid var(--border);
}

.stats div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
}

.stats dt {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.stats dd {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.stats small {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.empty {
  color: var(--text-muted);
}

.qnum {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  margin-right: 6px;
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--heading);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  vertical-align: 1px;
}

.grade-block {
  margin-top: 32px;
}

.grade-block h3 {
  line-height: 1.4;
}

.expected {
  max-width: 48rem;
  margin: 8px 0 4px;
  padding: 10px 14px;
  font-size: 0.9375rem;
  background: var(--bg-sunken);
  border-radius: var(--radius);
}

.grade-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.grade-item {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 8px 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.grade-item > * {
  margin: 0;
}

.grade-who {
  font-weight: 650;
}

.is-todo .grade-who::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 2px;
}

.answer-text,
.answer-tries {
  max-width: 48rem;
  white-space: pre-wrap;
}

.try {
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--ko-bg);
  border-radius: 4px;
}

.try.is-ok {
  background: var(--ok-bg);
}

.grade {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  grid-column: 2;
}

.grade-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.grade-btn {
  min-width: 48px;
  height: 36px;
  font: 650 0.9375rem var(--font-sans);
  color: var(--heading);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.grade-btn:hover {
  border-color: var(--accent-text);
}

.grade-btn[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent-text);
  border-color: var(--accent-text);
}

.grade .help {
  margin: 0 0 0 8px;
}

.qstats {
  margin: 0;
  padding: 0;
  list-style: none;
}

.qstats > li {
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.qstats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.qstats-head .qnum {
  margin: 0;
}

.qstats-head .rate {
  margin-left: auto;
  font-weight: 650;
  color: var(--heading);
}

.qtext {
  max-width: 48rem;
  font-weight: 600;
}

.dist {
  display: grid;
  gap: 6px;
  max-width: 48rem;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
}

.dist li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6rem, 30%) 2rem;
  align-items: center;
  gap: 12px;
}

.dist-bar {
  height: 8px;
  overflow: hidden;
  background: var(--border);
  border-radius: 2px;
}

.dist-bar span {
  display: block;
  height: 100%;
  background: var(--text-muted);
}

.dist-n {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dist .is-right {
  font-weight: 650;
  color: var(--ok);
}

.dist .is-right .dist-bar span {
  background: var(--ok);
}

.import {
  margin-top: 28px;
  padding: 20px;
  background: var(--bg-sunken);
  border-radius: var(--radius);
}

.import p {
  max-width: 48rem;
}

.file-btn {
  position: relative;
}

.file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-btn:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#import-result:empty {
  display: none;
}

#import-result {
  margin-top: 16px;
}

#import-result ul {
  margin: 8px 0 0;
  padding-left: 1.25rem;
}

.tools form {
  margin: 0;
}

@media (max-width: 40rem) {
  .grade-item {
    grid-template-columns: 1fr;
  }

  .grade {
    grid-column: 1;
  }
}

/* Écran tactile sans clavier : les raccourcis ne servent à rien */
@media (hover: none) and (pointer: coarse) {
  .keys,
  .btn kbd {
    display: none;
  }
}

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