:root {
  --color-bg: #f4f5fb;
  --color-bg-image: radial-gradient(circle at 15% 0%, #eef0fd 0%, transparent 45%),
    radial-gradient(circle at 85% 8%, #eef7f2 0%, transparent 40%);
  --color-surface: #ffffff;
  --color-surface-alt: #f8f9fd;
  --color-text: #14161f;
  --color-muted: #5c6270;
  --color-border: #e3e5ee;
  --color-primary: #4f46e5;
  --color-primary-dark: #3f37c9;
  --color-primary-light: #eef0ff;
  --color-on-primary: #ffffff;
  --color-danger: #d92d20;
  --color-danger-bg: #fef2f1;
  --color-danger-border: #f5a29a;
  --color-success: #17803d;
  --color-success-bg: #edf9f0;
  --color-success-border: #a6e0b6;
  --color-warning: #b7690a;
  --color-warning-bg: #fef6e7;
  --color-warning-border: #f3d59a;
  --color-info: #2563eb;
  --color-info-bg: #eef4ff;
  --color-info-border: #bcd2fb;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-xs: 0 1px 2px rgba(20, 22, 40, 0.05);
  --shadow-sm: 0 2px 6px rgba(20, 22, 40, 0.07);
  --shadow-md: 0 8px 24px rgba(20, 22, 40, 0.10);
  --shadow-lg: 0 20px 45px rgba(20, 22, 40, 0.16);
  --max-width: 920px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0d0f16;
    --color-bg-image: radial-gradient(circle at 10% 0%, rgba(79, 70, 229, 0.16) 0%, transparent 45%),
      radial-gradient(circle at 90% 5%, rgba(23, 128, 61, 0.10) 0%, transparent 40%);
    --color-surface: #171a24;
    --color-surface-alt: #1d212c;
    --color-text: #e8e9f1;
    --color-muted: #9aa1b3;
    --color-border: #2a2e3c;
    --color-primary: #818cf8;
    --color-primary-dark: #a5b0fb;
    --color-primary-light: #1e2140;
    --color-on-primary: #0d0f16;
    --color-danger: #f47469;
    --color-danger-bg: #2c1817;
    --color-danger-border: #6b2f2a;
    --color-success: #4ade80;
    --color-success-bg: #122a1c;
    --color-success-border: #245239;
    --color-warning: #fbbf62;
    --color-warning-bg: #2c2210;
    --color-warning-border: #5c4620;
    --color-info: #7bb0ff;
    --color-info-bg: #131d31;
    --color-info-border: #29416b;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: var(--color-bg-image);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: 0.6rem 1.1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus {
  left: 0;
  top: 0;
}

a {
  color: var(--color-primary-dark);
}

:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* En-tête */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.site-title {
  font-weight: 800;
  text-decoration: none;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.site-title::before {
  content: "";
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--color-primary), #22c55e);
}
.nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.nav a {
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}
.nav a[aria-current="page"] {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-xs);
}
.nav a[aria-current="page"]:hover {
  background: var(--color-primary);
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 4.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 0;
  margin-bottom: 0.5rem;
}
h2 {
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin-top: 2.25rem;
  margin-bottom: 0.9rem;
}
h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 1.25rem 2rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Boutons */
.btn {
  font: inherit;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 650;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
  box-shadow: var(--shadow-xs);
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn--primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: var(--color-on-primary);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-primary) 40%, transparent);
}
.btn--primary:hover {
  box-shadow: 0 8px 20px color-mix(in srgb, var(--color-primary) 45%, transparent);
}
.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn--secondary:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-muted);
}
.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--stop {
  background: var(--color-surface);
  border-color: var(--color-danger-border);
  color: var(--color-danger);
}
.btn--stop:hover {
  background: var(--color-danger-bg);
}
.btn--link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--color-primary-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0.2rem 0.4rem;
  font-weight: 500;
}
.btn--link:hover {
  transform: none;
  color: var(--color-primary);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

/* Notices */
.notice {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
}
.notice p:last-child,
.notice > *:last-child {
  margin-bottom: 0;
}
.notice--error {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  border-left-color: var(--color-danger);
}
.notice--warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  border-left-color: var(--color-warning);
}
.notice--info {
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
  border-left-color: var(--color-info);
}
.notice--pending {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  border-left-color: var(--color-warning);
}

.stat-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  display: grid;
  gap: 0.6rem;
}
.stat-list li {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 0.75rem 2.1rem;
  box-shadow: var(--shadow-xs);
  font-size: 0.95rem;
}
.stat-list li::before {
  content: "";
  position: absolute;
  left: 0.9rem;
  top: 1.1rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-primary);
}
.muted {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Formulaire de série */
.setup-form fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.1rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
}
.setup-form legend {
  font-weight: 700;
  padding: 0 0.4rem;
  color: var(--color-primary-dark);
}
.theme-option,
.mode-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease;
  cursor: pointer;
}
.theme-option:hover,
.mode-option:hover {
  background: var(--color-surface-alt);
}
.theme-option input,
.mode-option input {
  accent-color: var(--color-primary);
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}
.theme-option--all {
  font-weight: 700;
  border-bottom: 1px dashed var(--color-border);
  border-radius: 0;
  margin-bottom: 0.35rem;
  padding-bottom: 0.75rem;
}
.field {
  display: block;
  margin-bottom: 1.1rem;
  font-weight: 650;
}
.field input {
  display: block;
  font: inherit;
  padding: 0.6rem 0.7rem;
  margin-top: 0.4rem;
  width: 100%;
  max-width: 12rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
.field input:focus-visible {
  border-color: var(--color-primary);
}

/* Quiz */
.quiz-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.quiz-meta {
  font-weight: 650;
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}
.progress-bar {
  flex: 1 1 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #22c55e);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.question {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.5rem 1.25rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-md);
}
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.85rem;
}
.block-text {
  white-space: pre-wrap;
}
.block-image img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s ease;
}
.block-image img:hover {
  box-shadow: var(--shadow-sm);
}
.context {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.1rem;
  background: var(--color-surface-alt);
}
.context summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--color-primary-dark);
}
.context[open] summary {
  margin-bottom: 0.6rem;
}

.choices {
  border: none;
  padding: 0;
  margin: 0;
}
.choices legend {
  font-weight: 650;
  padding: 0;
  margin-bottom: 0.6rem;
}
.choice {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: start;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.55rem;
  cursor: pointer;
  background: var(--color-surface);
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.choice:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}
.choice input {
  accent-color: var(--color-primary);
  margin-top: 0.15rem;
}
.choice__badge {
  font-weight: 750;
  color: var(--color-muted);
}
.choice__content {
  min-width: 0;
}
.choice__mark {
  font-weight: 750;
}
.choice--correct-selected {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
}
.choice--correct-missed {
  border-style: dashed;
  border-color: var(--color-success-border);
}
.choice--wrong-selected {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.interaction-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.1rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.interaction-table th,
.interaction-table td {
  border: 1px solid var(--color-border);
  padding: 0.6rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.interaction-table th {
  background: var(--color-surface-alt);
  font-weight: 700;
}
.interaction-table tbody tr:hover {
  background: var(--color-surface-alt);
}
.inline-choice {
  margin-right: 1rem;
  cursor: pointer;
  accent-color: var(--color-primary);
}
.row--correct {
  background: var(--color-success-bg);
}
.row--incorrect {
  background: var(--color-danger-bg);
}
.row__mark {
  font-weight: 750;
  margin-left: 0.3rem;
}

.order-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.order-list__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  background: var(--color-surface);
  transition: border-color 0.12s ease;
}
.order-list__item:hover {
  border-color: var(--color-primary);
}
.order-list__pos {
  font-weight: 750;
  color: var(--color-primary-dark);
  width: 1.6rem;
}
.order-list__label {
  flex: 1;
}
.order-list__item .btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}
.order-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  margin-bottom: 1.1rem;
}
.order-columns__col {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.order-columns__col h4 {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}
.order-list__item {
  flex-wrap: wrap;
}
.order-list--pool .order-list__item {
  justify-content: space-between;
}
@media (max-width: 640px) {
  .order-columns {
    grid-template-columns: 1fr;
  }
}
.order-list.row--correct {
  outline: 2px solid var(--color-success-border);
  border-radius: var(--radius-sm);
}
.order-list.row--incorrect {
  outline: 2px solid var(--color-danger-border);
  border-radius: var(--radius-sm);
}

.question__feedback {
  min-height: 1.2rem;
  font-weight: 650;
  color: var(--color-danger);
}
.question__correction {
  margin-top: 1.1rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
}
.question__correction h2,
.question__correction h3 {
  margin-top: 0;
}
.question__actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
}
.correction-note {
  font-style: italic;
  color: var(--color-muted);
}

/* Résultats / progression */
.results-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1.25rem 0;
  box-shadow: var(--shadow-xs);
}
.results-summary .score-line {
  margin-top: 0;
}
.results-summary .stat-list {
  margin-bottom: 0;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
}
.status-badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.status-badge--completed {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success);
}
.status-badge--stopped {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}
.score-line {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.75rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.data-table th,
.data-table td {
  border: 1px solid var(--color-border);
  padding: 0.6rem 0.75rem;
  text-align: left;
}
.data-table thead th {
  background: var(--color-surface-alt);
  font-weight: 700;
}
.data-table tbody tr:hover {
  background: var(--color-surface-alt);
}
.review-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.review-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
}
.review-item h3 {
  margin-top: 0;
}

/* Dialogs */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: min(90vw, 700px);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background: rgba(10, 12, 20, 0.6);
  backdrop-filter: blur(2px);
}
.zoom-dialog {
  background: var(--color-surface);
}
.zoom-dialog img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  margin-top: 0.6rem;
  border-radius: var(--radius-sm);
}
.zoom-dialog__close {
  font: inherit;
  cursor: pointer;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.toast-region {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  max-width: 320px;
}
.toast {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease;
  border-left: 4px solid var(--color-primary);
}
.toast--error {
  border-left-color: var(--color-danger);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .choice {
    grid-template-columns: auto auto 1fr;
  }
  .data-table {
    display: block;
    overflow-x: auto;
  }
  .question {
    padding: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --color-border: #000;
  }
}
