:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --accent: #6ee7b7;
  --accent2: #f472b6;
  --text: #eef1fb;
  --muted: #9aa1c2;
  --danger: #f87171;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
header {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2a2f4a;
}
header a { color: var(--muted); text-decoration: none; font-size: .9rem; }
main { max-width: 780px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.subtitle { color: var(--muted); margin-top: 0; }
.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 1.5rem;
  margin: 1rem 0;
  border: 1px solid #262b47;
}
.candidates { display: grid; gap: .75rem; }
.candidate-btn {
  padding: 1rem;
  font-size: 1.1rem;
  border-radius: 12px;
  border: 2px solid #2a2f4a;
  background: #1c2140;
  color: var(--text);
  cursor: pointer;
}
.candidate-btn:active, .candidate-btn.selected { border-color: var(--accent); background: #1e2b26; }

/* Vue "Carte" (BMD) — vue par défaut : UN SEUL grand candidat affiché à la fois (grande photo,
   gros numéro, nom en gros caractères), avec Précédent/Suivant (+ flèches clavier) pour naviguer.
   Le choix fait doit être visuellement sans ambiguïté — c'est la vue la plus lisible des trois,
   et le candidat courant ne peut jamais être confondu avec un voisin comme dans une liste dense. */
.candidate-card-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  padding: .5rem .25rem;
}
.card-nav-btn { width: 100%; max-width: 320px; }
.card-nav-progress { margin: 0; }
.candidate-big-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  width: 100%;
  max-width: 320px;
  padding: 1.5rem 1.2rem;
  border-radius: 16px;
  border: 2px solid #2a2f4a;
  background: #1c2140;
  color: var(--text);
  text-align: center;
}
.candidate-big-card img { width: 120px; height: 120px; border-radius: 16px; }
.candidate-big-card .cand-number { font-family: ui-monospace, monospace; font-size: 1.4rem; color: var(--muted); }
.candidate-big-card .cand-name { font-size: 1.6rem; font-weight: 700; }
.candidate-big-card-empty { color: var(--muted); font-style: italic; padding: 2.5rem 1.2rem; border-style: dashed; }

/* Vue "Grille" — repliable, optionnelle : cartes compactes mais gardées assez grandes pour
   rester lisibles (photo + numéro + nom visibles sans zoomer). */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem;
  max-height: 480px;
  overflow-y: auto;
  padding: .25rem;
}
.candidate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .7rem .5rem;
  border-radius: 12px;
  border: 2px solid #2a2f4a;
  background: #1c2140;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.candidate-card:active, .candidate-card.selected { border-color: var(--accent); background: #1e2b26; }
.candidate-card img { width: 56px; height: 56px; border-radius: 8px; }
.candidate-card .cand-number { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--muted); }
.candidate-card .cand-name { font-size: .95rem; line-height: 1.15; }


/* Bulletin papier V1 : une case par ligne (photo/numéro/nom), défilable une fois longue. */
.sheet-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .4rem .5rem;
  border-bottom: 1px solid #262b47;
}
.sheet-row img { width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0; }
.sheet-row .cand-number { font-family: ui-monospace, monospace; color: var(--muted); width: 2.4rem; flex-shrink: 0; }
.sheet-row .cand-name { flex: 1; }

/* Clavier numérique (accessibilité façon urne électronique brésilienne) — saisie du numéro
   plutôt que sélection tactile de la photo, gardé volontairement simple pour la démo. */
.keypad-wrap { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .75rem; }
.keypad-input { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .1em; padding: .5rem .8rem; border-radius: 8px; border: 1px solid #2a2f4a; background: #1c2140; color: var(--text); width: 100%; }
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; max-width: 220px; }
.keypad-grid button { padding: .7rem; font-size: 1.1rem; border-radius: 8px; border: 1px solid #2a2f4a; background: #1c2140; color: var(--text); cursor: pointer; }

/* Étape "choix du candidat" (V2/V3) : le bouton d'action (Confirmer / Imprimer) en tête de la
   section, puis clavier numérique et Carte côte à côte sur une même rangée (l'un tape le numéro,
   l'autre confirme visuellement le même candidat), puis l'aperçu du bulletin en dessous.
   #candidates passe en display:contents pour que ses enfants (déjà générés par
   setupCandidateChooser) rejoignent directement la grille de #vote-panel. */
#vote-panel {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  grid-template-areas: "confirm confirm" "keypad card" "preview preview";
  gap: 1rem;
  align-items: start;
}
#vote-panel #candidates { display: contents; }
#vote-panel #keypad-panel { grid-area: keypad; }
#vote-panel #candidates-cards { grid-area: card; }
#vote-panel #draft-preview { grid-area: preview; margin: 0; }
#vote-panel #draft-preview img { margin: 0 auto; }
#vote-panel #confirm-vote-btn, #vote-panel #print-ballot-btn { grid-area: confirm; justify-self: center; width: 100%; max-width: 320px; }
@media (max-width: 640px) {
  #vote-panel {
    grid-template-columns: 1fr;
    grid-template-areas: "confirm" "keypad" "card" "preview";
  }
}
.btn {
  padding: .8rem 1.4rem;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #04120b;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}
.btn.secondary { background: #2a2f4a; color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; }
.badge.ok { background: #14432c; color: var(--accent); }
.badge.warn { background: #4a2b1c; color: #fbbf24; }
.badge.err { background: #4a1c2b; color: var(--danger); }
.mono { font-family: ui-monospace, monospace; word-break: break-all; }
.qr-wrap { text-align: center; }
.qr-wrap img { background: white; padding: 8px; border-radius: 12px; }
#ballot-wall { position: relative; height: 380px; background: #f5f0e6; border-radius: 12px; overflow: hidden; }
.paper-ballot { position: absolute; width: 90px; height: 60px; background: white; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.paper-ballot.ambiguous { outline: 2px solid var(--danger); }
.paper-ballot svg { width: 100%; height: 100%; display: block; }
.cross { position: absolute; font-weight: 900; color: #1a1a1a; }
.version-nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.version-nav a { flex: 1; text-align: center; padding: .7rem; border-radius: 10px; background: var(--panel); color: var(--text); text-decoration: none; border: 1px solid #262b47; }
.version-nav a.active { border-color: var(--accent); color: var(--accent); }
.stepper-indicator { display: inline-block; font-size: .85rem; font-weight: 600; color: var(--accent); background: var(--panel); border: 1px solid #262b47; border-radius: 999px; padding: .35rem .9rem; margin-bottom: 1rem; }
.tally-row { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid #262b47; }
video { width: 100%; border-radius: 12px; }
.small { font-size: .85rem; color: var(--muted); }

/* Arbre JSON dépliable (renderJsonTree, shared.js) — données brutes de verify.html et board.html. */
.json-tree { font-family: ui-monospace, monospace; font-size: .78rem; line-height: 1.55; max-height: 440px; overflow: auto; background: var(--bg); border: 1px solid #2a2f4a; border-radius: 8px; padding: .5rem .75rem; margin-top: .6rem; }
.json-tree details > :not(summary) { margin-left: 1.2rem; }
.json-tree summary { cursor: pointer; }
.json-key { color: var(--muted); }
.json-meta { color: var(--accent2); }
.json-string { color: var(--accent); word-break: break-all; }
.json-value { color: #facc15; }

/* V1/V2 (comparaison) masqués par défaut, affichés à la demande (setupLegacyToggle, shared.js). */
body:not(.show-legacy) .legacy { display: none !important; }
